X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fnb%2Frfc8040%2Fjersey%2Fproviders%2FXmlNormalizedNodeBodyWriterTest.java;fp=restconf%2Frestconf-nb%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fnb%2Frfc8040%2Fjersey%2Fproviders%2FXmlNormalizedNodeBodyWriterTest.java;h=0000000000000000000000000000000000000000;hb=4c54c44f4642490b2d0687f1ee2d6a7356e6b752;hp=c19e53c9c32d0f730d5a604e4e92dba9e3ea6042;hpb=afc2f00460f3866d8dffcf230ba08f549e835a0b;p=netconf.git diff --git a/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriterTest.java b/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriterTest.java deleted file mode 100644 index c19e53c9c3..0000000000 --- a/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriterTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.nb.rfc8040.jersey.providers; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import javax.ws.rs.core.MediaType; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; -import org.opendaylight.restconf.api.query.PrettyPrintParam; -import org.opendaylight.restconf.nb.rfc8040.AbstractInstanceIdentifierTest; -import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload; -import org.opendaylight.restconf.nb.rfc8040.legacy.WriterParameters; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference; - -@RunWith(MockitoJUnitRunner.StrictStubs.class) -public class XmlNormalizedNodeBodyWriterTest extends AbstractInstanceIdentifierTest { - @Test - public void testWriteEmptyRootContainer() throws IOException { - final EffectiveModelContext schemaContext = mock(EffectiveModelContext.class); - - final NormalizedNodePayload nodePayload = new NormalizedNodePayload(Inference.ofDataTreePath(schemaContext), - ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)).build(), - WriterParameters.EMPTY, PrettyPrintParam.FALSE); - - final ByteArrayOutputStream output = new ByteArrayOutputStream(); - final XmlNormalizedNodeBodyWriter xmlWriter = new XmlNormalizedNodeBodyWriter(); - xmlWriter.writeTo(nodePayload, null, null, null, MediaType.APPLICATION_XML_TYPE, null, output); - - // FIXME: NETCONF-855: this is wrong, the namespace should be 'urn:ietf:params:xml:ns:yang:ietf-restconf' - assertEquals("", - output.toString(StandardCharsets.UTF_8)); - } - - @Test - public void testRootContainerWrite() throws IOException { - final NormalizedNodePayload nodePayload = new NormalizedNodePayload( - Inference.ofDataTreePath(IID_SCHEMA), - ImmutableNodes.newContainerBuilder() - .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)) - .withChild(ImmutableNodes.newContainerBuilder() - .withNodeIdentifier(new NodeIdentifier( - QName.create("foo:module", "2016-09-29", "foo-bar-container"))) - .build()) - .withChild(ImmutableNodes.newContainerBuilder() - .withNodeIdentifier(new NodeIdentifier( - QName.create("bar:module", "2016-09-29", "foo-bar-container"))) - .build()) - .build(), WriterParameters.EMPTY, PrettyPrintParam.FALSE); - - final ByteArrayOutputStream output = new ByteArrayOutputStream(); - final XmlNormalizedNodeBodyWriter xmlWriter = new XmlNormalizedNodeBodyWriter(); - xmlWriter.writeTo(nodePayload, null, null, null, MediaType.APPLICATION_XML_TYPE, null, output); - - assertEquals(""" - \ - \ - \ - """, output.toString(StandardCharsets.UTF_8)); - } -} \ No newline at end of file