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
8 package org.opendaylight.netconf.nettyutil.handler.exi;
10 import static org.junit.Assert.assertFalse;
12 import org.junit.Test;
13 import org.opendaylight.netconf.shaded.exificient.core.CodingMode;
14 import org.opendaylight.netconf.shaded.exificient.core.FidelityOptions;
15 import org.xmlunit.builder.DiffBuilder;
17 public class NetconfStartExiMessageTest {
19 public void testCreateEmpty() {
21 <rpc message-id="id" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
22 <start-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0">
23 <alignment>bit-packed</alignment>
25 </rpc>""", EXIParameters.empty());
29 public void testCreateFull() throws Exception {
30 final var fullOptions = FidelityOptions.createDefault();
31 fullOptions.setFidelity(FidelityOptions.FEATURE_LEXICAL_VALUE, true);
32 fullOptions.setFidelity(FidelityOptions.FEATURE_DTD, true);
33 fullOptions.setFidelity(FidelityOptions.FEATURE_COMMENT, true);
34 fullOptions.setFidelity(FidelityOptions.FEATURE_PREFIX, true);
35 fullOptions.setFidelity(FidelityOptions.FEATURE_PI, true);
38 <rpc message-id="id" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
39 <start-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0">
40 <alignment>byte-aligned</alignment>
49 </rpc>""", new EXIParameters(CodingMode.BYTE_PACKED, fullOptions));
52 private static void assertCreate(final String control, final EXIParameters exiOptions) {
53 final var startExiMessage = NetconfStartExiMessageProvider.create(exiOptions, "id");
55 final var diff = DiffBuilder.compare(control)
56 .withTest(startExiMessage.getDocument())
60 assertFalse(diff.toString(), diff.hasDifferences());