/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.store.serialization.xml.internal;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.dom4j.Element;
import org.junit.Assert;
import org.junit.Test;

/**
 * Tests to make sure AbstractXMLSerializer faithfuly parses and serializes content.
 *
 * @param <T> The class of object which the serializer can serialize.
 * @version $Id$
 * @since 3.0M2
 */
public class AbstractXMLSerializerTest extends AbstractXMLSerializer<Element, Element>
{
    private static final String TEST_CONTENT =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
      + "\n"
      + "<root>\n"
      + " <doc>\n"
      + "  <name>docName</name>\n"
      + "  <obj>\n"
      + "   <name>objName</name>\n"
      + "   <content>objContent</content>\n"
      + "  </obj>\n"
      + "  <content>docContent</content>\n"
      + " </doc>\n"
      + "</root>";

    public Element parse(final Element xmlElement)
    {
        return xmlElement;
    }

    public void serialize(final Element object, final XMLWriter writeTo) throws IOException
    {
        writeTo.write(object);
    }

    @Test
    public void testParseSerialize() throws Exception
    {
        final ByteArrayInputStream bais = new ByteArrayInputStream(TEST_CONTENT.getBytes("US-ASCII"));
        final Element element = this.parse(bais);
        bais.close();

        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOUtils.copy(this.serialize(element), baos);
        final String test = new String(baos.toByteArray(), "US-ASCII");
        Assert.assertEquals("Parsing and serializing yields a different output.", TEST_CONTENT, test);
    }
}

@@ -1129,23 +1129,41 @@
 nit.
-Asser
+jupiter.api.Tes
 t;%0A
+%0A
 import 
+static 
 org.
@@ -1168,20 +1168,51 @@
 g.junit.
-Test
+jupiter.api.Assertions.assertEquals
 ;%0A%0A/**%0A 
@@ -1302,78 +1302,8 @@
 %0A *%0A
- * @param %3CT%3E The class of object which the serializer can serialize.%0A
  * @
@@ -1335,23 +1335,16 @@
 0M2%0A */%0A
-public 
 class Ab
@@ -1370,56 +1370,8 @@
 Test
- extends AbstractXMLSerializer%3CElement, Element%3E
 %0A%7B%0A 
@@ -1763,24 +1763,221 @@
 oot%3E%22;%0A%0A    
+@Test%0A    void parseAndSerialize() throws Exception%0A    %7B%0A        AbstractXMLSerializer%3CElement, Element%3E serializer = new AbstractXMLSerializer%3CElement, Element%3E()%0A        %7B%0A            @Override 
 public Eleme
@@ -1985,22 +1985,16 @@
 t parse(
-final 
 Element 
@@ -2005,26 +2005,42 @@
 lement)%0A    
-%7B%0A
+        %7B%0A        
         retu
@@ -2058,22 +2058,48 @@
 nt;%0A    
-%7D%0A%0A
    
+     %7D%0A%0A            @Override
  public 
@@ -2113,22 +2113,16 @@
 rialize(
-final 
 Element 
@@ -2128,22 +2128,16 @@
  object,
- final
  XMLWrit
@@ -2171,26 +2171,40 @@
 ion%0A    
-%7B%0A
+        %7B%0A      
         
 writeTo.
@@ -2195,16 +2195,18 @@
         
+  
 writeTo.
@@ -2228,80 +2228,28 @@
     
-%7D%0A%0A
     
-@Test%0A    public void testParseSerialize() throws Exception%0A
+    %7D%0A    
     
-%7B
+%7D;
 %0A   
@@ -2380,20 +2380,26 @@
 ement = 
-this
+serializer
 .parse(b
@@ -2520,20 +2520,26 @@
 ls.copy(
-this
+serializer
 .seriali
@@ -2642,15 +2642,8 @@
     
-Assert.
 asse
@@ -2651,16 +2651,36 @@
 tEquals(
+TEST_CONTENT, test, 
 %22Parsing
@@ -2727,28 +2727,8 @@
 ut.%22
-, TEST_CONTENT, test
 );%0A 

Convert to JUnit5 test and apply best practices