rfscholte commented on a change in pull request #286: [MNG-6656] Introduce base 
for build/consumer process
URL: https://github.com/apache/maven/pull/286#discussion_r330232022
 
 

 ##########
 File path: 
maven-xml/src/test/java/org/apache/maven/xml/filter/ConsumerPomXMLFilterTest.java
 ##########
 @@ -0,0 +1,168 @@
+package org.apache.maven.xml.filter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.xmlunit.assertj.XmlAssert.assertThat;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Optional;
+import java.util.function.Function;
+
+import javax.inject.Provider;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.junit.Test;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLFilter;
+
+public class ConsumerPomXMLFilterTest extends AbstractXMLFilterTests
+{
+    @Override
+    protected XMLFilter getFilter() throws SAXException, 
ParserConfigurationException
+    {
+        final BuildPomXMLFilterFactory buildPomXMLFilterFactory = new 
BuildPomXMLFilterFactory()
+        {
+            @Override
+            protected Optional<String> getSha1()
+            {
+                return Optional.empty();
+            }
+            
+            @Override
+            protected Optional<String> getRevision()
+            {
+                return Optional.empty();
+            }
+            
+            @Override
+            protected Optional<String> getChangelist()
+            {
+                return Optional.of( "CL" );
+            }
+            
+            @Override
+            protected Function<Path, Optional<RelativeProject>> 
getRelativePathMapper()
+            {
+                return null;
+            }
+            
+            @Override
+            protected Function<DependencyKey, String> 
getDependencyKeyToVersionMapper()
+            {
+                return null;
+            }
+        };
+        
+        Provider<BuildPomXMLFilterFactory> provider = new 
Provider<BuildPomXMLFilterFactory>()
+        {
+
+            @Override
+            public BuildPomXMLFilterFactory get()
+            {
+                return buildPomXMLFilterFactory;
+            }
+        };
+        
+        XMLFilter filter = new ConsumerPomXMLFilterFactory( provider )
+        {
+        }.get( Paths.get( "pom.xml" ) );
+        filter.setFeature( "http://xml.org/sax/features/namespaces";, true );
+        return filter;
+    }
+    
+    @Test
+    public void testAllFilters() throws Exception {
+        String input = "<project>\n"
+                     + "  <parent>\n"
+                     + "    <groupId>GROUPID</groupId>\n"
+                     + "    <artifactId>PARENT</artifactId>\n"
+                     + "    <version>VERSION</version>\n"
+                     + "    <relativePath>../pom.xml</relativePath>\n"
+                     + "  </parent>\n"
+                     + "  <artifactId>PROJECT</artifactId>\n"
+                     + "  <modules>\n"
+                     + "    <module>ab</module>\n"
+                     + "    <module>../cd</module>\n"
+                     + "  </modules>\n"
+                     + "</project>";
+        String expected = "<project>\n"
+                        + "  <parent>\n"
+                        + "    <groupId>GROUPID</groupId>\n"
+                        + "    <artifactId>PARENT</artifactId>\n"
+                        + "    <version>VERSION</version>\n"
+                        + "    <relativePath/>\n"
+                        + "  </parent>\n"
+                        + "  <artifactId>PROJECT</artifactId>\n"
+                        + "</project>";
+        String actual = transform( input );
+        assertThat( actual ).and( expected ).ignoreWhitespace().areIdentical();
+    }
+    
+    @Test
+    public void testMe() throws Exception {
+        String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + 
+            "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"; \r\n" + 
+            "         
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n"; + 
+            "         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 
\r\n" + 
+            "                             
http://maven.apache.org/maven-v4_0_0.xsd\";>\r\n" + 
 
 Review comment:
   A test, but it is fine to update

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to