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 java.util.ArrayList;
16 import org.junit.Before;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
20 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
23 // FIXME : CompositeNode is not avaliable anymore so fix the test to use NormalizedNodeContainer ASAP
24 public class XmlUtilsTest {
25 public static final String XML_CONTENT = "<add-flow xmlns=\"urn:opendaylight:controller:rpc:test\">"
26 + "<input xmlns=\"urn:opendaylight:controller:rpc:test\"><id>flowid</id>"
27 + "<flow xmlns:ltha=\"urn:opendaylight:controller:rpc:test\">/ltha:node/ltha:node1"
28 + "[ltha:id='3@java.lang.Short']</flow></input></add-flow>";
30 private SchemaContext schemaContext;
33 public void setUp() throws Exception {
34 final ByteSource byteSource = new ByteSource() {
36 public InputStream openStream() throws IOException {
37 return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.yang");
41 final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
42 final ArrayList<ByteSource> sources = Lists.newArrayList(byteSource);
46 schemaContext = reactor.buildEffective(sources);
47 } catch (ReactorException e) {
48 throw new RuntimeException("Unable to build schema context from " + sources, e);
51 final Module rpcTestModule = schemaContext.getModules().iterator().next();
52 rpcTestModule.getRpcs().iterator().next();