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);
}
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"));
}
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();
}
}
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);
}
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);
}
Aggregations