Search in sources :

Example 51 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 52 with SvnMaterial

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

the class SvnMaterialTest method shouldSerializeAndDeserializeCorrectly.

@Test
public void shouldSerializeAndDeserializeCorrectly() throws Exception {
    final SvnMaterial material1 = MaterialsMother.svnMaterial("url1", "foo");
    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    ObjectOutputStream serialized = new ObjectOutputStream(buf);
    serialized.writeObject(material1);
    ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf.toByteArray()));
    assertThat(in.readObject(), is(material1));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 53 with SvnMaterial

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

the class SvnMaterialTest method shouldGeneratePipelineUniqueFingerprintBasedOnFingerprintAndDest.

@Test
public void shouldGeneratePipelineUniqueFingerprintBasedOnFingerprintAndDest() throws Exception {
    SvnMaterial one = new SvnMaterial("url", "username", "password", true, "folder1");
    SvnMaterial two = new SvnMaterial("url", "username", "password", true, "folder2");
    assertThat(one.getPipelineUniqueFingerprint(), is(Matchers.not(two.getFingerprint())));
    assertThat(one.getPipelineUniqueFingerprint(), is(DigestUtils.sha256Hex("type=SvnMaterial<|>url=url<|>username=username<|>checkExternals=true<|>dest=folder1")));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 54 with SvnMaterial

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

the class SvnMaterialTest method shouldGetAttributesWithSecureFields.

@Test
public void shouldGetAttributesWithSecureFields() {
    SvnMaterial material = new SvnMaterial("http://username:password@svnrepo.com", "user", "password", true);
    Map<String, Object> attributes = material.getAttributes(true);
    assertThat(attributes.get("type"), is("svn"));
    Map<String, Object> configuration = (Map<String, Object>) attributes.get("svn-configuration");
    assertThat(configuration.get("url"), is("http://username:password@svnrepo.com"));
    assertThat(configuration.get("username"), is("user"));
    assertThat(configuration.get("password"), is("password"));
    assertThat(configuration.get("check-externals"), is(true));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 55 with SvnMaterial

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

the class SvnMaterialTest method shouldGenerateFingerprintBasedOnSqlCriteria.

@Test
public void shouldGenerateFingerprintBasedOnSqlCriteria() throws Exception {
    SvnMaterial one = new SvnMaterial("url", "username", "password", true);
    SvnMaterial two = new SvnMaterial("url", "username", "password", false);
    assertThat(one.getFingerprint(), is(Matchers.not(two.getFingerprint())));
    assertThat(one.getFingerprint(), is(DigestUtils.sha256Hex("type=SvnMaterial<|>url=url<|>username=username<|>checkExternals=true")));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Aggregations

SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)140 Test (org.junit.Test)111 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)44 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)39 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)22 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)21 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)20 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)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 Materials (com.thoughtworks.go.config.materials.Materials)13 Date (java.util.Date)11 Username (com.thoughtworks.go.server.domain.Username)10 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)9 File (java.io.File)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7