From 1c2c16858e95db9ae90726fa0da69b88457c1807 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 5 Dec 2012 13:09:49 +0100 Subject: o More common XML parsing and HTTP client code. o Reimplemented the Nexus code to consume the timeline instead of calculating its own diff. --- .../esper/testing/nexus/TestXmlParsing.java | 19 +++++++++++++++++ .../resources/nexus/recentlyDeployedArtifacts.xml | 24 ++++++++++++++++++++++ src/test/resources/nexus/search-1.xml | 1 - 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 src/test/resources/nexus/recentlyDeployedArtifacts.xml (limited to 'src/test') diff --git a/src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java b/src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java index 6495d86..038de34 100755 --- a/src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java +++ b/src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java @@ -3,7 +3,9 @@ package io.trygvis.esper.testing.nexus; import static com.google.common.collect.Iterables.*; import static com.google.common.collect.Lists.*; import static io.trygvis.esper.testing.nexus.ArtifactXml.repositoryFilter; +import io.trygvis.esper.testing.util.*; import junit.framework.*; +import org.jdom2.*; import java.io.*; import java.util.*; @@ -44,4 +46,21 @@ public class TestXmlParsing extends TestCase { assertEquals(2, flatArtifact.files.size()); } } + + public void testTimelineParsing() throws Exception { + XmlParser parser = new XmlParser(); + + try (InputStream stream = getClass().getResourceAsStream("/nexus/recentlyDeployedArtifacts.xml")) { + Document document = parser.parseDocument(stream).some(); + + NexusEvent event = NexusFeedParser.parseEvent(document.getRootElement().getChild("channel").getChild("item")).some(); + + assertTrue(event instanceof NewSnapshotEvent); + NewSnapshotEvent nse = (NewSnapshotEvent) event; + assertEquals("org.example", nse.artifactId.groupId); + assertEquals("example", nse.artifactId.artifactId); + assertEquals("1.0-SNAPSHOT", nse.artifactId.version); + assertEquals("20121204.122640-536", nse.snapshotTimestamp); + } + } } diff --git a/src/test/resources/nexus/recentlyDeployedArtifacts.xml b/src/test/resources/nexus/recentlyDeployedArtifacts.xml new file mode 100755 index 0000000..1fe22d9 --- /dev/null +++ b/src/test/resources/nexus/recentlyDeployedArtifacts.xml @@ -0,0 +1,24 @@ + + + + New deployed artifacts + http://localhost:8081/repository/service/local/feeds/recentlyDeployedArtifacts + New deployed artifacts in all Nexus repositories (deployed). + Tue, 04 Dec 2012 12:26:41 GMT + Nexus 1.9.2.3 + 2012-12-04T12:26:41Z + + org.example:example:1.0-20121204.122640-536 + http://hostname/repository/content/repositories/snapshots/org/example/example/1.0-SNAPSHOT/example-1.0-20121204.122640-536.pom + + The artifact 'org.example:example:1.0-20121204.122640-536' in repository 'Snapshots' was + deployed.Action was initiated by user "developer". + Request originated from IP address 1.2.3.4. + + Tue, 04 Dec 2012 12:26:40 GMT + http://hostname/repository/content/repositories/snapshots/org/example/example/1.0-SNAPSHOT/example-1.0-20121204.122640-536.pom + developer + 2012-12-04T12:26:40Z + + + diff --git a/src/test/resources/nexus/search-1.xml b/src/test/resources/nexus/search-1.xml index b501491..75bfdc9 100755 --- a/src/test/resources/nexus/search-1.xml +++ b/src/test/resources/nexus/search-1.xml @@ -2674,4 +2674,3 @@ -- -- cgit v1.2.3