hypervisorfdi commented on a change in pull request #887:
URL: https://github.com/apache/cxf/pull/887#discussion_r775216735



##########
File path: 
core/src/test/java/org/apache/cxf/staxutils/transform/InTransformReaderTest.java
##########
@@ -69,6 +69,116 @@ public void testReplaceSimpleElement() throws Exception {
         String value = bos.toString();
         assertEquals("<ns:test xmlns:ns=\"http://bar\";><ns:a>1 2 
3</ns:a></ns:test>", value);
     }
+    
+    @Test

Review comment:
       The namespace is not adding any additional benefit other than taking 
space, small refactor could help.
   here is a suggestion:
   
   ```
       @Test
       public void testDropComplexElement() throws Exception {
           String template = 
"<greetMe>%s<email>alex.just@nowhere</email></greetMe>";
           String expected = String.format(template, "<age>35</age>");
           String inXml = String.format(template, 
"<skippedElement><age>35</age></skippedElement>");
           verifyTransformation(expected, inXml, null, 
Collections.singletonList("skippedElement"));
       }
   
       @Test
       public void testDropComplexElementByReplacement() throws Exception {
           String template = 
"<greetMe><firstname>Alex</firstname>%s<email>alex.just@nowhere</email></greetMe>";
           String expected = String.format(template, "");
           String inXml = String.format(template, 
"<skippedElement><age>35</age></skippedElement>");
           verifyTransformation(expected, inXml, 
Collections.singletonMap("skippedElement", ""), null);
       }
   
       @Test
       public void testDropComplexElementLastByReplacement() throws Exception {
           String template = 
"<greetMe><firstname>Alex</firstname><lastname>Just</lastname>%s</greetMe>";
           String expected = String.format(template, "");
           String inXml = String.format(template, 
"<skippedElement><age>35</age></skippedElement>");
           verifyTransformation(expected, inXml, 
Collections.singletonMap("skippedElement", ""), null);
       }
   
       @Test
       public void testDropSimpleElementByReplacement() throws Exception {
           String template = 
"<greetMe><firstname>Alex</firstname><lastname>Just</lastname>%s</greetMe>";
           String expected = String.format(template, "<skippedElement/>");
           String inXml = String.format(template, 
"<skippedElement><age>35</age></skippedElement>");
           verifyTransformation(expected, inXml, 
Collections.singletonMap("age", ""), null);
       }
   
       private void verifyTransformation(String expected, 
                String inXml, 
                Map<String, String> inEMap, 
                List<String> dropESet) throws XMLStreamException {
   
           InputStream is = new ByteArrayInputStream(inXml.getBytes());
           XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
           reader = new InTransformReader(reader,
                                           inEMap,
                                           null,
                                           dropESet,
                                           null, false);
   
           ByteArrayOutputStream bos = new ByteArrayOutputStream();
           StaxUtils.copy(reader, bos);
           String value = bos.toString();
           assertEquals(expected, value);
       }
   ```




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to