Search in sources :

Example 1 with NormalizedNodeWriter

use of org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter in project controller by opendaylight.

the class NormalizedNodePrunerTest method testReusePruner.

@Test(expected = IllegalStateException.class)
public void testReusePruner() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
    NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
    NormalizedNode<?, ?> expected = createTestContainer();
    normalizedNodeWriter.write(expected);
    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals(expected, actual);
    NormalizedNodeWriter.forStreamWriter(pruner).write(expected);
}
Also used : NormalizedNodeWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter) Test(org.junit.Test)

Example 2 with NormalizedNodeWriter

use of org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter in project controller by opendaylight.

the class NormalizedNodePrunerTest method testNodesPrunedWhenAugmentationSchemaMissing.

@Test
public void testNodesPrunedWhenAugmentationSchemaMissing() throws IOException {
    NormalizedNodePruner pruner = prunerNoAugSchema(TestModel.TEST_PATH);
    NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
    NormalizedNode<?, ?> expected = createTestContainer();
    normalizedNodeWriter.write(expected);
    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    Assert.assertNotEquals(expected, actual);
    // Asserting true here instead of checking actual value because I don't want this assertion to be fragile
    assertTrue(countNodes(expected, "store:aug") > 0);
    // All nodes from the augmentation module are gone from the resulting node
    assertEquals(0, countNodes(actual, "store:aug"));
}
Also used : NormalizedNodeWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter) Test(org.junit.Test)

Example 3 with NormalizedNodeWriter

use of org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter in project controller by opendaylight.

the class NormalizedNodeXMLOutput method toStream.

public static void toStream(OutputStream outStream, NormalizedNode<?, ?> node) throws XMLStreamException, IOException {
    XMLStreamWriter xmlWriter = XOF.createXMLStreamWriter(outStream);
    IndentingXMLStreamWriter indenting = new IndentingXMLStreamWriter(xmlWriter);
    try (NormalizedNodeStreamWriter streamWriter = XMLStreamNormalizedNodeStreamWriter.createSchemaless(indenting)) {
        NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(streamWriter);
        nodeWriter.write(node);
        nodeWriter.flush();
    }
}
Also used : IndentingXMLStreamWriter(javanet.staxutils.IndentingXMLStreamWriter) NormalizedNodeWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter) IndentingXMLStreamWriter(javanet.staxutils.IndentingXMLStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) XMLStreamNormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter) NormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)

Example 4 with NormalizedNodeWriter

use of org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter in project controller by opendaylight.

the class SampleNormalizedNodeSerializable method writeObject.

private void writeObject(final ObjectOutputStream stream) throws IOException {
    NormalizedNodeStreamWriter writer = new NormalizedNodeOutputStreamWriter(stream);
    NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(writer);
    normalizedNodeWriter.write(this.input);
}
Also used : NormalizedNodeWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter) NormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)

Example 5 with NormalizedNodeWriter

use of org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter in project controller by opendaylight.

the class NormalizedNodePrunerTest method testNodesNotPrunedWhenSchemaPresent.

@Test
public void testNodesNotPrunedWhenSchemaPresent() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
    NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
    NormalizedNode<?, ?> expected = createTestContainer();
    normalizedNodeWriter.write(expected);
    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals(expected, actual);
}
Also used : NormalizedNodeWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter) Test(org.junit.Test)

Aggregations

NormalizedNodeWriter (org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter)6 Test (org.junit.Test)4 NormalizedNodeStreamWriter (org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)2 IndentingXMLStreamWriter (javanet.staxutils.IndentingXMLStreamWriter)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 XMLStreamNormalizedNodeStreamWriter (org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter)1