use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnCommandTest method shouldUseCorrectCredentialsPerSvnMaterialWhenQueryingForInfo.
@Test
public void shouldUseCorrectCredentialsPerSvnMaterialWhenQueryingForInfo() throws Exception {
final String svnMaterial1Url = "http://localhost/svn/project1";
final String svnMaterial1User = "svnMaterial1_user";
final String svnMaterial1Password = "svnMaterial1_password";
final SvnMaterial svnMaterial1 = buildMockSvnMaterial(svnMaterial1Url, svnMaterial1User, svnMaterial1Password);
String svnMaterial2Url = "http://localhost/svn/project2";
SvnMaterial svnMaterial2 = buildMockSvnMaterial(svnMaterial2Url, null, null);
HashSet<SvnMaterial> svnMaterials = new HashSet<>();
svnMaterials.add(svnMaterial1);
svnMaterials.add(svnMaterial2);
SvnCommand spy = spy(subversion);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
final ConsoleResult consoleResult = mock(ConsoleResult.class);
when(consoleResult.outputAsString()).thenReturn(svnInfoOutput);
verifyCommandLine((CommandLine) invocation.getArguments()[0]);
return consoleResult;
}
private void verifyCommandLine(CommandLine commandLine) {
String commandString = commandLine.toStringForDisplay();
if (commandString.contains(svnMaterial1User)) {
List<CommandArgument> arguments = commandLine.getArguments();
for (CommandArgument argument : arguments) {
if (argument instanceof PasswordArgument) {
assertThat(argument.forCommandline(), is(svnMaterial1Password));
}
}
} else {
assertThat(commandString, not(Matchers.containsString("--username")));
assertThat(commandString, not(Matchers.containsString("password")));
}
}
}).when(spy).executeCommand(any(CommandLine.class));
HashMap<String, String> result = spy.createUrlToRemoteUUIDMap(svnMaterials);
verify(svnMaterial1).getUserName();
verify(svnMaterial1).getPassword();
verify(svnMaterial2).getUserName();
verify(svnMaterial2).getPassword();
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnCommandTest method shouldRecogniseSvnAsTheSameIfURLContainsSpaces.
@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void shouldRecogniseSvnAsTheSameIfURLContainsSpaces() throws Exception {
File working = temporaryFolder.newFolder("shouldRecogniseSvnAsTheSameIfURLContainsSpaces");
SvnTestRepo repo = new SvnTestRepo(temporaryFolder, "a directory with spaces");
SvnMaterial material = repo.material();
assertThat(material.getUrl(), containsString("%20"));
InMemoryStreamConsumer output = new InMemoryStreamConsumer();
material.freshCheckout(output, new SubversionRevision("3"), working);
assertThat(output.getAllOutput(), containsString("Checked out revision 3"));
InMemoryStreamConsumer output2 = new InMemoryStreamConsumer();
material.updateTo(output2, working, new RevisionContext(new SubversionRevision("4")), new TestSubprocessExecutionContext());
assertThat(output2.getAllOutput(), containsString("Updated to revision 4"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnCommandTest method shouldRecogniseSvnAsTheSameIfURLUsesFileProtocol.
@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void shouldRecogniseSvnAsTheSameIfURLUsesFileProtocol() throws Exception {
SvnTestRepo repo = new SvnTestRepo(temporaryFolder);
File working = temporaryFolder.newFolder("someDir");
SvnMaterial material = repo.material();
InMemoryStreamConsumer output = new InMemoryStreamConsumer();
material.freshCheckout(output, new SubversionRevision("3"), working);
assertThat(output.getAllOutput(), containsString("Checked out revision 3"));
InMemoryStreamConsumer output2 = new InMemoryStreamConsumer();
updateMaterial(material, new SubversionRevision("4"), working, output2);
assertThat(output2.getAllOutput(), containsString("Updated to revision 4"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevisionFromExpandedSvnExternalRepository.
@Test
public void shouldGetLatestRevisionFromExpandedSvnExternalRepository() {
MaterialRevisions materialRevisions = new MaterialRevisions();
Material svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
List<Modification> modifications = ((SvnMaterial) svnExt).latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
materialRevisions.addRevision(svnExt, modifications);
assertThat(materialRevisions.numberOfRevisions(), is(1));
MaterialRevision materialRevision = materialRevisions.getRevisions().get(0);
assertThat(materialRevision.getMaterial(), is(svnExt));
assertThat(materialRevision.getRevision().getRevision(), is("4"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevision.
@Test
public void shouldGetLatestRevision() {
SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), null);
SvnMaterial svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
final Materials materials = new Materials(svn, svnExt);
final MaterialRevisions materialRevisions = materials.latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
assertThat(materialRevisions.numberOfRevisions(), is(2));
MaterialRevision main = materialRevisions.getRevisions().get(0);
assertThat(main.getMaterial(), is(svn));
assertThat(main.getModifications().size(), is(1));
assertThat(main.getRevision().getRevision(), is("5"));
MaterialRevision external = materialRevisions.getRevisions().get(1);
assertThat(external.getMaterial(), is(svnExt));
assertThat(external.getRevision().getRevision(), is("4"));
assertThat(external.getModifications().size(), is(1));
}
Aggregations