2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.xml.codec;
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;
22 // FIXME : CompositeNode is not avaliable anymore so fix the test to use NormalizedNodeContainer ASAP
23 public class XmlUtilsTest {
25 private static final DocumentBuilderFactory BUILDERFACTORY;
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;
36 private SchemaContext schema;
37 private RpcDefinition testRpc;
39 public static final String XML_CONTENT = "<add-flow xmlns=\"urn:opendaylight:controller:rpc:test\"><input xmlns=\"urn:opendaylight:controller:rpc:test\">" +
41 "<flow xmlns:ltha=\"urn:opendaylight:controller:rpc:test\">/ltha:node/ltha:node1[ltha:id='3@java.lang.Short']</flow>" +
42 "</input></add-flow>";
45 public void setUp() throws Exception {
46 final ByteSource byteSource = new ByteSource() {
48 public InputStream openStream() throws IOException {
49 return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.yang");
52 schema = new YangParserImpl().parseSources(Lists.newArrayList(byteSource));
53 final Module rpcTestModule = schema.getModules().iterator().next();
54 testRpc = rpcTestModule.getRpcs().iterator().next();