From af92579129943acac73542f4e05e1c7faeda0994 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 19 Nov 2012 18:04:49 +0100 Subject: o Adding logic to stop fetching pages when Gitorious returns non-XML response. o Adding support for self-signed certificates with https. o Moving client code to GitoriousClient. o Adding Nexus client and an importer that fetches all artifacts. o A nexus client that actually fetches the entire set of artifacts. --- .../esper/testing/nexus/TestXmlParsing.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java (limited to 'src/test/java/io') diff --git a/src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java b/src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java new file mode 100755 index 0000000..c9aba8d --- /dev/null +++ b/src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java @@ -0,0 +1,47 @@ +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 junit.framework.*; + +import java.io.*; +import java.util.*; + +public class TestXmlParsing extends TestCase { + public void testProjectParsing() throws Exception { + try (InputStream stream = getClass().getResourceAsStream("/nexus/search-1.xml")) { + ArtifactSearchResult result = NexusParser.parseDocument(stream); + + List list = result.artifacts; + + assertNotNull(list); + assertEquals(132, list.size()); + + ArtifactXml artifact = list.get(0); + assertEquals("org.codehaus.mojo.hibernate3", artifact.groupId); + assertEquals("maven-hibernate3-jdk15", artifact.artifactId); + assertEquals("2.0-alpha-1", artifact.version); + + artifact = list.get(4); + assertEquals("org.codehaus.mojo.hibernate3", artifact.groupId); + assertEquals("maven-hibernate3", artifact.artifactId); + assertEquals("2.0-alpha-1", artifact.version); + assertEquals(2, artifact.hits.size()); + assertEquals("appfuse-releases", artifact.hits.get(0).repositoryId); + assertEquals(1, artifact.hits.get(0).files.size()); + assertTrue(artifact.hits.get(0).files.get(0).classifier.isNone()); + assertEquals("pom", artifact.hits.get(0).files.get(0).extension); + + assertEquals(2, artifact.hits.size()); + ArrayList filtered = newArrayList(filter(list, repositoryFilter("appfuse-releases"))); + assertEquals(5, filtered.size()); + + FlatArtifact flatArtifact = filtered.get(0).flatten("appfuse-releases"); + assertEquals("org.codehaus.mojo.hibernate3", flatArtifact.groupId); + assertEquals("maven-hibernate3-jdk15", flatArtifact.artifactId); + assertEquals("2.0-alpha-1", flatArtifact.version); + assertEquals(2, flatArtifact.files.size()); + } + } +} -- cgit v1.2.3