Search in sources :

Example 11 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class SvnMaterialMockitoTest method shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol.

@Test
public void shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol() throws IOException {
    Subversion subversion = mock(Subversion.class);
    when(subversion.getUserName()).thenReturn("");
    when(subversion.getPassword()).thenReturn("");
    when(subversion.isCheckExternals()).thenReturn(false);
    File workingCopy = createSvnWorkingCopy(true);
    when(subversion.workingRepositoryUrl(workingCopy)).thenReturn(workingCopy.getPath());
    String url = "file://" + workingCopy.getPath();
    when(subversion.getUrl()).thenReturn(new UrlArgument(url));
    SvnMaterial svnMaterial = SvnMaterial.createSvnMaterialWithMock(subversion);
    svnMaterial.setUrl(url);
    svnMaterial.updateTo(outputStreamConsumer, workingCopy, new RevisionContext(revision), new TestSubprocessExecutionContext());
    assertThat(workingCopy.exists(), is(true));
    verify(subversion).updateTo(outputStreamConsumer, workingCopy, revision);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) File(java.io.File) Test(org.junit.Test)

Example 12 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldUpdateModificationsForExternals.

@Test
public void shouldUpdateModificationsForExternals() throws Exception {
    updater.updateMaterial(material);
    testRepoWithExternal.checkInExternalFile("foo_bar", "foo bar quux");
    updater.updateMaterial(material);
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
    assertThat(materialRevisions.numberOfRevisions(), is(2));
    SvnMaterial externalMaterial = testRepoWithExternal.externalMaterial();
    MaterialRevision revisionForExternal = materialRevisions.findRevisionFor(externalMaterial);
    assertThat(revisionForExternal.getModification(0).getComment(), is("foo bar quux"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 13 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldNotTryToSaveModificationForAnExternalThathasAlreadyBeenSaved.

@Test
public void shouldNotTryToSaveModificationForAnExternalThathasAlreadyBeenSaved() throws Exception {
    updater.updateMaterial(material);
    SvnTestRepoWithExternal otherRepo = new SvnTestRepoWithExternal(testRepoWithExternal.externalRepositoryUrl());
    SvnMaterial otherMaterial = new SvnMaterial(otherRepo.projectRepositoryUrl(), null, null, true);
    updater.updateMaterial(otherMaterial);
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(otherMaterial);
    assertThat(materialRevisions.numberOfRevisions(), is(2));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnTestRepoWithExternal(com.thoughtworks.go.helper.SvnTestRepoWithExternal) Test(org.junit.Test)

Example 14 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class MaterialRevisionBuilder method svnInstance.

public Tuple svnInstance(String revision, Date modifiedTime) {
    String key = key("svn", revision, modifiedTime);
    insertIfNotPresent(new SvnMaterial("url", "username", "password", false), key, revision, modifiedTime);
    return new Tuple(null, instanceToRevision.get(key));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 15 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method findModificationsSince_shouldCacheResults.

@Test
public void findModificationsSince_shouldCacheResults() {
    SvnMaterial material = MaterialsMother.svnMaterial();
    MaterialRevision zero = saveOneScmModification(material, "user1", "file1");
    MaterialRevision first = saveOneScmModification(material, "user1", "file1");
    MaterialRevision second = saveOneScmModification(material, "user2", "file2");
    MaterialRevision third = saveOneScmModification(material, "user2", "file2");
    repo.findModificationsSince(material, first);
    HibernateTemplate mockTemplate = mock(HibernateTemplate.class);
    repo.setHibernateTemplate(mockTemplate);
    List<Modification> modifications = repo.findModificationsSince(material, first);
    assertThat(modifications.size(), is(2));
    assertEquals(third.getLatestModification(), modifications.get(0));
    assertEquals(second.getLatestModification(), modifications.get(1));
    verifyNoMoreInteractions(mockTemplate);
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate) Test(org.junit.Test)

Aggregations

SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)136 Test (org.junit.Test)113 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)44 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)37 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)21 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)17 Material (com.thoughtworks.go.domain.materials.Material)16 Modification (com.thoughtworks.go.domain.materials.Modification)16 Date (java.util.Date)14 Materials (com.thoughtworks.go.config.materials.Materials)13 Username (com.thoughtworks.go.server.domain.Username)9 File (java.io.File)9 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7