Bump exificient to 1.0.1
[netconf.git] / netconf / netconf-netty-util / src / test / java / org / opendaylight / netconf / nettyutil / handler / NetconfEXIHandlersTest.java
index b1b6e6d56ab3fea5a3554c7e3614cf034371c383..80be3858d9a5f3988d3f6c80bf4bb7d5149be58d 100644 (file)
@@ -11,24 +11,24 @@ package org.opendaylight.netconf.nettyutil.handler;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
-import com.google.common.collect.Lists;
+import com.siemens.ct.exi.core.exceptions.EXIException;
+import com.siemens.ct.exi.main.api.sax.SAXEncoder;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
-import org.openexi.proc.common.EXIOptions;
-import org.openexi.proc.common.EXIOptionsException;
-import org.openexi.sax.Transmogrifier;
-import org.openexi.sax.TransmogrifierException;
-import org.xml.sax.InputSource;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
 
 public class NetconfEXIHandlersTest {
 
@@ -40,20 +40,21 @@ public class NetconfEXIHandlersTest {
 
     @Before
     public void setUp() throws Exception {
-        final NetconfEXICodec codec = new NetconfEXICodec(new EXIOptions());
+        final NetconfEXICodec codec = NetconfEXICodec.forParameters(EXIParameters.empty());
         netconfMessageToEXIEncoder = NetconfMessageToEXIEncoder.create(codec);
         netconfEXIToMessageDecoder = NetconfEXIToMessageDecoder.create(codec);
 
         msg = new NetconfMessage(XmlUtil.readXmlToDocument(msgAsString));
-        this.msgAsExi = msgToExi(msgAsString, codec);
+        this.msgAsExi = msgToExi(msg, codec);
     }
 
-    private static byte[] msgToExi(final String msgAsString,final NetconfEXICodec codec)
-            throws EXIOptionsException, TransmogrifierException, IOException {
+    private static byte[] msgToExi(final NetconfMessage msg, final NetconfEXICodec codec)
+            throws IOException, EXIException, TransformerException {
         final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-        final Transmogrifier transmogrifier = codec.getTransmogrifier();
-        transmogrifier.setOutputStream(byteArrayOutputStream);
-        transmogrifier.encode(new InputSource(new ByteArrayInputStream(msgAsString.getBytes())));
+        final SAXEncoder encoder = codec.getWriter();
+        encoder.setOutputStream(byteArrayOutputStream);
+        ThreadLocalTransformers.getDefaultTransformer().transform(new DOMSource(msg.getDocument()),
+                new SAXResult(encoder));
         return byteArrayOutputStream.toByteArray();
     }
 
@@ -70,9 +71,9 @@ public class NetconfEXIHandlersTest {
             assertEquals((byte)0, buffer.array()[i]);
         }
 
-        final List<Object> out = Lists.newArrayList();
+        final List<Object> out = new ArrayList<>();
         netconfEXIToMessageDecoder.decode(null, buffer, out);
 
         XMLUnit.compareXML(msg.getDocument(), ((NetconfMessage) out.get(0)).getDocument());
     }
-}
\ No newline at end of file
+}