Merge "BUG 2849 : Reduce sending of duplicate replication messages"
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / xml / codec / XmlUtilsTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.xml.codec;
10
11 import com.google.common.collect.Lists;
12 import com.google.common.io.ByteSource;
13 import java.io.IOException;
14 import java.io.InputStream;
15 import javax.xml.parsers.DocumentBuilderFactory;
16 import org.junit.Before;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
21
22 // FIXME : CompositeNode is not avaliable anymore so fix the test to use NormalizedNodeContainer ASAP
23 public class XmlUtilsTest {
24
25   private static final DocumentBuilderFactory BUILDERFACTORY;
26
27   static {
28     final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
29     factory.setNamespaceAware(true);
30     factory.setCoalescing(true);
31     factory.setIgnoringElementContentWhitespace(true);
32     factory.setIgnoringComments(true);
33     BUILDERFACTORY = factory;
34   }
35
36   private SchemaContext schema;
37   private RpcDefinition testRpc;
38
39   public static final String XML_CONTENT = "<add-flow xmlns=\"urn:opendaylight:controller:rpc:test\"><input xmlns=\"urn:opendaylight:controller:rpc:test\">" +
40       "<id>flowid</id>" +
41       "<flow xmlns:ltha=\"urn:opendaylight:controller:rpc:test\">/ltha:node/ltha:node1[ltha:id='3@java.lang.Short']</flow>" +
42       "</input></add-flow>";
43
44   @Before
45   public void setUp() throws Exception {
46     final ByteSource byteSource = new ByteSource() {
47       @Override
48       public InputStream openStream() throws IOException {
49         return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.yang");
50       }
51     };
52     schema = new YangParserImpl().parseSources(Lists.newArrayList(byteSource));
53     final Module rpcTestModule = schema.getModules().iterator().next();
54     testRpc = rpcTestModule.getRpcs().iterator().next();
55   }
56
57 }