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.netconf.notifications.impl.ops;
11 import com.google.common.collect.Lists;
12 import java.io.IOException;
13 import org.junit.Test;
14 import org.opendaylight.netconf.api.xml.XmlUtil;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.StreamsBuilder;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamKey;
20 import org.w3c.dom.Document;
21 import org.xml.sax.SAXException;
23 public class GetTest {
26 public void testSerializeStreamsSubtree() throws Exception {
27 final StreamsBuilder streamsBuilder = new StreamsBuilder();
28 final StreamBuilder streamBuilder = new StreamBuilder();
29 final StreamNameType base = new StreamNameType("base");
30 streamBuilder.setName(base);
31 streamBuilder.withKey(new StreamKey(base));
32 streamBuilder.setDescription("description");
33 streamBuilder.setReplaySupport(false);
34 streamsBuilder.setStream(Lists.newArrayList(streamBuilder.build()));
35 final Streams streams = streamsBuilder.build();
37 final Document response = getBlankResponse();
38 Get.serializeStreamsSubtree(response, streams);
39 NotificationsTransformUtilTest.compareXml(XmlUtil.toString(response),
40 "<rpc-reply message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
42 + "<netconf xmlns=\"urn:ietf:params:xml:ns:netmod:notification\">\n"
45 + "<name>base</name>\n"
46 + "<description>description</description>\n"
47 + "<replaySupport>false</replaySupport>\n"
55 private static Document getBlankResponse() throws IOException, SAXException {
57 return XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\"\n"
58 + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"