2 * Copyright (c) 2015 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.netconf.notifications.impl.ops;
11 import static org.junit.Assert.assertTrue;
13 import com.google.common.collect.Lists;
14 import java.io.IOException;
15 import org.custommonkey.xmlunit.Diff;
16 import org.custommonkey.xmlunit.XMLUnit;
17 import org.junit.Test;
18 import org.opendaylight.controller.netconf.notifications.impl.ops.Get;
19 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.StreamsBuilder;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamKey;
25 import org.w3c.dom.Document;
26 import org.xml.sax.SAXException;
28 public class GetTest {
31 public void testSerializeStreamsSubtree() throws Exception {
32 final StreamsBuilder streamsBuilder = new StreamsBuilder();
33 final StreamBuilder streamBuilder = new StreamBuilder();
34 final StreamNameType base = new StreamNameType("base");
35 streamBuilder.setName(base);
36 streamBuilder.setKey(new StreamKey(base));
37 streamBuilder.setDescription("description");
38 streamBuilder.setReplaySupport(false);
39 streamsBuilder.setStream(Lists.newArrayList(streamBuilder.build()));
40 final Streams streams = streamsBuilder.build();
42 final Document response = getBlankResponse();
43 Get.serializeStreamsSubtree(response, streams);
44 final Diff diff = XMLUnit.compareXML(XmlUtil.toString(response),
45 "<rpc-reply message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
47 "<netconf xmlns=\"urn:ietf:params:xml:ns:netmod:notification\">\n" +
50 "<name>base</name>\n" +
51 "<description>description</description>\n" +
52 "<replaySupport>false</replaySupport>\n" +
59 assertTrue(diff.toString(), diff.identical());
62 private Document getBlankResponse() throws IOException, SAXException {
64 return XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\"\n" +
65 "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +