diff options
Diffstat (limited to 'src/test/java')
-rwxr-xr-x | src/test/java/io/trygvis/esper/testing/nexus/TestXmlParsing.java | 47 |
1 files changed, 47 insertions, 0 deletions
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<ArtifactXml> 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<ArtifactXml> 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()); + } + } +} |