use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class P4OutputParserTest method shouldParseChangesWithLotsOfFilesWithoutError.
/*
* This test reproduces a problem we saw at a customer's installation, where the changelist was really really large
* It caused a frequent StackOverflow in the java regex library.
*/
@Test
void shouldParseChangesWithLotsOfFilesWithoutError() throws IOException, P4OutputParseException {
final StringWriter writer = new StringWriter();
IOUtils.copy(new ClassPathResource("/BIG_P4_OUTPUT.txt").getInputStream(), writer, Charset.defaultCharset());
String output = writer.toString();
Modification modification = parser.modificationFromDescription(output, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
assertThat(modification.getModifiedFiles().size()).isEqualTo(1304);
assertThat(modification.getModifiedFiles().get(0).getFileName()).isEqualTo("Internal Projects/ABC/Customers3/ABC/RIP/SomeProject/data/main/config/lib/java/AdvJDBCColumnHandler.jar");
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class P4OutputParserTest method shouldRetrieveModificationFromDescription.
@Test
void shouldRetrieveModificationFromDescription() throws P4OutputParseException, ParseException {
String output = "Change 2 by cce123user@connect4_10.18.2.31 on 2008/08/19 15:04:43\n" + "\n" + "\tAdded config file\n" + "\n" + "Affected files ...\n" + "\n" + "... //depot/cruise-config.xml#1 add\n" + "... //depot/README.txt#2 edit\n" + "... //depot/cruise-output/log.xml#1 delete\n" + "";
Modification mod = parser.modificationFromDescription(output, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
assertThat(mod.getRevision()).isEqualTo("2");
assertThat(mod.getUserName()).isEqualTo("cce123user@connect4_10.18.2.31");
assertThat(mod.getModifiedTime()).isEqualTo(DESCRIPTION_FORMAT.parse("2008/08/19 15:04:43"));
assertThat(mod.getComment()).isEqualTo("Added config file");
List<ModifiedFile> files = mod.getModifiedFiles();
assertThat(files.size()).isEqualTo(3);
assertThat(files.get(0).getAction()).isEqualTo(ModifiedAction.added);
assertThat(files.get(0).getFileName()).isEqualTo("cruise-config.xml");
assertThat(files.get(1).getAction()).isEqualTo(ModifiedAction.modified);
assertThat(files.get(2).getAction()).isEqualTo(ModifiedAction.deleted);
assertThat(files.get(2).getFileName()).isEqualTo("cruise-output/log.xml");
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class P4OutputParserTest method shouldParseCorrectlyWhenCommentIsEmpty.
@Test
void shouldParseCorrectlyWhenCommentIsEmpty() throws P4OutputParseException {
String description = "Change 102 by godev@blrstdcrspair03 on 2013/06/04 12:00:35\n" + "\n" + "\n" + "Affected files ...\n" + "\n" + "... //another_depot/1.txt#6 edit";
Modification modification = parser.modificationFromDescription(description, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
assertThat(modification.getComment()).isEqualTo("");
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class HgModificationSplitterTest method shouldBeAbleToParseModifications.
@Test
public void shouldBeAbleToParseModifications() throws Exception {
ConsoleResult result = new ConsoleResult(0, Arrays.asList(("<changeset>\n" + "<node>ca3ebb67f527c0ad7ed26b789056823d8b9af23f</node>\n" + "<author>cruise</author>\n" + "<date>Tue, 09 Dec 2008 18:56:14 +0800</date>\n" + "<desc>test</desc>\n" + "<files>\n" + "<modified>\n" + "<file>end2end/file</file>\n" + "</modified>\n" + "<added>\n" + "<file>end2end/file</file>\n" + "</added>\n" + "<deleted>\n" + "</deleted>\n" + "</files>\n" + "</changeset>").split("\n")), new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
HgModificationSplitter splitter = new HgModificationSplitter(result);
List<Modification> list = splitter.modifications();
assertThat(list.size(), is(1));
assertThat(list.get(0).getModifiedTime(), is(new DateTime("2008-12-09T18:56:14+08:00").toDate()));
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class P4Fixture method stopP4d.
private void stopP4d(P4Client p4) {
try {
p4.admin("stop");
ConsoleResult consoleResult = p4.checkConnection();
while (!consoleResult.failed()) {
try {
// Wait for the server to shutdown
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
}
} catch (CommandLineException expected) {
// Stopping p4d on windows returns the following failure:
if (expected.getResult().errorAsString().contains("WSAECONNRESET") || expected.getResult().errorAsString().contains("WSAECONNREFUSED")) {
return;
}
if (expected.getResult().errorAsString().contains("Connection refused") || expected.getResult().errorAsString().contains("Connection reset")) {
return;
}
throw expected;
}
}
Aggregations