]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1136]
authorMaria Odea B. Ching <oching@apache.org>
Fri, 20 Mar 2009 16:05:05 +0000 (16:05 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Fri, 20 Mar 2009 16:05:05 +0000 (16:05 +0000)
o remove namespaces before getting child nodes of metadata
o added test case

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@756559 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java
archiva-modules/archiva-base/archiva-xml-tools/src/test/examples/maven-metadata-codehaus-snapshots.xml [new file with mode: 0644]
archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLReaderTest.java

index b1639aac1e0d4b00cdd633b75a762f7310de2d6b..a6fc50b82a77ec82bfadc2e41fd89398d7674136 100644 (file)
@@ -50,7 +50,9 @@ public class RepositoryMetadataReader
         try
         {
             XMLReader xml = new XMLReader( "metadata", metadataFile );
-
+            // invoke this to remove namespaces, see MRM-1136
+            xml.removeNamespaces();
+            
             ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
 
             metadata.setGroupId( xml.getElementText( "//metadata/groupId" ) );
diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/examples/maven-metadata-codehaus-snapshots.xml b/archiva-modules/archiva-base/archiva-xml-tools/src/test/examples/maven-metadata-codehaus-snapshots.xml
new file mode 100644 (file)
index 0000000..f101ae6
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata xsi:schemaLocation="http://maven.apache.org/METADATA/1.0.0 http://maven.apache.org/xsd/metadata-1.0.0.xsd" xmlns="http://maven.apache.org/METADATA/1.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <groupId>org.codehaus.mojo</groupId>
+  <artifactId>idlj-maven-plugin</artifactId>
+  <version>1.1-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <timestamp>20090312.163710</timestamp>
+      <buildNumber>16</buildNumber>
+    </snapshot>
+    <lastUpdated>20090312163712</lastUpdated>
+  </versioning>
+</metadata>
index 1fb12fba85b9a9ef35daa728f7bc703098945cbe..86a30530f3738cffb85e9ba666c8b23f4dd49df4 100644 (file)
@@ -89,5 +89,18 @@ public class XMLReaderTest
         List<Element> names = reader.getElementList( "//basic/names/name" );
         assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
     }
+    
+    // MRM-1136
+    public void testProxiedMetadataRead()
+        throws XMLException
+    {
+        File xmlFile = getExampleXml( "maven-metadata-codehaus-snapshots.xml" );
+        XMLReader reader = new XMLReader( "metadata", xmlFile );        
+        reader.removeNamespaces();
+        
+        Element groupId = reader.getElement( "//metadata/groupId" );        
+        assertNotNull( groupId );
+        assertEquals( "org.codehaus.mojo", groupId.getTextTrim() );   
+    }
 
 }