aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-12 17:46:33 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-12 17:46:33 +0100
commitc3730fc1cbad2f3747b14bab39beff90fbf66f72 (patch)
tree063092a45571f3dfede5e1727e120f0e02040cd3
parent17f6eaadeb91057cb37309271c0b6e79439f64aa (diff)
downloadesper-testing-c3730fc1cbad2f3747b14bab39beff90fbf66f72.tar.gz
esper-testing-c3730fc1cbad2f3747b14bab39beff90fbf66f72.tar.bz2
esper-testing-c3730fc1cbad2f3747b14bab39beff90fbf66f72.tar.xz
esper-testing-c3730fc1cbad2f3747b14bab39beff90fbf66f72.zip
o Parsing out data from svn as well.
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXml.java17
-rwxr-xr-xsrc/test/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXmlTest.java28
2 files changed, 40 insertions, 5 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXml.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXml.java
index e80097b..169a65c 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXml.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXml.java
@@ -8,6 +8,7 @@ import org.jdom2.Element;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,6 +21,7 @@ import static fj.data.Option.none;
import static fj.data.Option.some;
import static fj.data.Option.somes;
import static io.trygvis.esper.testing.Util.childText;
+import static io.trygvis.esper.testing.Util.parseInt;
import static io.trygvis.esper.testing.jenkins.JenkinsBuildXml.ChangeSetItemXml.parseChangeSetItem;
import static io.trygvis.esper.testing.jenkins.JenkinsBuildXml.RevisionXml.parseRevision;
@@ -120,13 +122,20 @@ public class JenkinsBuildXml {
}
private static final F<String, Option<DateTime>> parseDate = new F<String, Option<DateTime>>() {
+ // This variant is used by git
DateTimeFormatter parser = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss Z");
+ // and this by subversion
+ DateTimeFormatter parser2 = ISODateTimeFormat.dateTime();
public Option<DateTime> f(String s) {
try {
return some(parser.parseDateTime(s));
} catch (IllegalArgumentException e) {
- return none();
+ try {
+ return some(parser2.parseDateTime(s));
+ } catch (IllegalArgumentException e2) {
+ return none();
+ }
}
}
};
@@ -150,9 +159,9 @@ public class JenkinsBuildXml {
public static class RevisionXml {
public final String module;
- public final String revision;
+ public final int revision;
- public RevisionXml(String module, String revision) {
+ public RevisionXml(String module, int revision) {
this.module = module;
this.revision = revision;
}
@@ -160,7 +169,7 @@ public class JenkinsBuildXml {
public static final F<Element, Option<RevisionXml>> parseRevision = new F<Element, Option<RevisionXml>>() {
public Option<RevisionXml> f(Element e) {
Option<String> module = childText(e, "module");
- Option<String> revision = childText(e, "revision");
+ Option<Integer> revision = childText(e, "revision").bind(parseInt);
if (module.isNone() || revision.isNone()) {
return none();
diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXmlTest.java b/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXmlTest.java
index 75d7326..46f89a1 100755
--- a/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXmlTest.java
+++ b/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsBuildXmlTest.java
@@ -16,18 +16,20 @@ import junit.framework.TestCase;
import static org.joda.time.DateTimeZone.forOffsetHours;
import static org.joda.time.DateTimeZone.forOffsetHoursMinutes;
import static org.joda.time.chrono.ISOChronology.getInstance;
+import static org.joda.time.chrono.ISOChronology.getInstanceUTC;
public class JenkinsBuildXmlTest extends TestCase {
XmlParser parser = new XmlParser();
ISOChronology minus6 = getInstance(forOffsetHours(-6));
ISOChronology minus5 = getInstance(forOffsetHours(-5));
ISOChronology plus530 = getInstance(forOffsetHoursMinutes(5, 30));
+ ISOChronology utc = getInstanceUTC();
public Option<Document> f(InputStream inputStream) {
return parser.parseDocument(inputStream);
}
- public void testYo() throws IOException {
+ public void testGitCommitParsing() throws IOException {
try (InputStream is = getClass().getResourceAsStream("/jenkins/build/build-with-git-commits.xml")) {
Option<JenkinsBuildXml> option = JenkinsBuildXml.parse(parser.parseDocument(is).some().getRootElement());
@@ -54,6 +56,30 @@ public class JenkinsBuildXmlTest extends TestCase {
}
}
+ public void testSvnCommitParsing() throws IOException {
+ try (InputStream is = getClass().getResourceAsStream("/jenkins/build/build-with-subversion-commits.xml")) {
+ Option<JenkinsBuildXml> option = JenkinsBuildXml.parse(parser.parseDocument(is).some().getRootElement());
+
+ assertTrue(option.isSome());
+ JenkinsBuildXml build = option.some();
+
+ assertEquals(URI.create("https://builds.apache.org/job/Lucene-Solr-Tests-4.x-Java6/1102/"), build.url);
+ assertEquals(1102, build.number);
+ assertTrue(build.result.isSome());
+ assertEquals(1646526, build.duration);
+ assertTrue(build.changeSet.isSome());
+ JenkinsBuildXml.ChangeSetXml changeSet = build.changeSet.some();
+ assertTrue(changeSet.revision.isSome());
+ assertEquals("http://svn.apache.org/repos/asf/lucene/dev/branches/branch_4x", changeSet.revision.some().module);
+ assertEquals(1419960, changeSet.revision.some().revision);
+ assertEquals(3, changeSet.items.size());
+
+ assertItem(changeSet.items.get(0), "1419960", "SOLR-2986: Add MoreLikeThis to warning about features that require uniqueKey. Also, change the warning to warn log level.", new DateTime(2012, 12, 11, 1, 8, 10, 682, utc));
+ assertItem(changeSet.items.get(1), "1419953", "SOLR-4071: Validate that name is pass to Collections API create, and behave the same way as on startup when collection.configName is not explicitly passed.", new DateTime(2012, 12, 11, 0, 56, 19, 684, utc));
+ assertItem(changeSet.items.get(2), "1419940", "SOLR-3948: Calculate/display deleted documents in admin interface.", new DateTime(2012, 12, 11, 0, 10, 12, 700, utc));
+ }
+ }
+
private void assertItem(JenkinsBuildXml.ChangeSetItemXml item, String commitId, String msg, DateTime date) {
assertEquals(commitId, item.commitId);
assertEquals(msg, item.msg);