X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fimplementation%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnector%2Fremoterpc%2FSerilizationTest.java;fp=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fimplementation%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnector%2Fremoterpc%2FSerilizationTest.java;h=0000000000000000000000000000000000000000;hb=3b301f14027755f8924714c25d888132080f6b54;hp=41422fd680b00a33660f880f12462eb96197e51a;hpb=445deeb731eee757ec1b37d5a24301e99d97394b;p=controller.git diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/SerilizationTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/SerilizationTest.java deleted file mode 100644 index 41422fd680..0000000000 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/SerilizationTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.connector.remoterpc; - -import org.junit.Test; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; -import org.opendaylight.yangtools.yang.data.impl.NodeUtils; -import org.opendaylight.yangtools.yang.data.impl.XmlTreeBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; - -import javax.xml.stream.XMLStreamException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.StringWriter; - -public class SerilizationTest { - - private static final Logger _logger = LoggerFactory.getLogger(SerilizationTest.class); - - public void fromXml() { - } - - @Test - public void toXml() throws FileNotFoundException { - - //InputStream xmlStream = SerilizationTest.class.getResourceAsStream("/FourSimpleChildren.xml"); - InputStream xmlStream = SerilizationTest.class.getResourceAsStream("/AddFlow.xml"); - StringWriter writer = new StringWriter(); - - CompositeNode data = loadCompositeNode(xmlStream); - Document domTree = NodeUtils.buildShadowDomTree(data); - try { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - //transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - //transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - //transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - //transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - transformer.transform(new DOMSource(domTree), new StreamResult(writer)); - } catch (TransformerException e) { - _logger.error("Error during translation of Document to OutputStream", e); - } - - _logger.info("Parsed xml [{}]", writer.toString()); - } - - // Figure out how to include TestUtils through pom ...was getting errors - private CompositeNode loadCompositeNode(InputStream xmlInputStream) throws FileNotFoundException { - if (xmlInputStream == null) { - throw new IllegalArgumentException(); - } - Node dataTree; - try { - dataTree = XmlTreeBuilder.buildDataTree(xmlInputStream); - } catch (XMLStreamException e) { - _logger.error("Error during building data tree from XML", e); - return null; - } - if (dataTree == null) { - _logger.error("data tree is null"); - return null; - } - if (dataTree instanceof SimpleNode) { - _logger.error("RPC XML was resolved as SimpleNode"); - return null; - } - return (CompositeNode) dataTree; - } -}