output.writeInt(pathArguments.size());
for (PathArgument pathArgument : pathArguments) {
- writePathArgument(pathArgument);
+ writePathArgumentInternal(pathArgument);
}
}
- @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST",
- justification = "The casts in the switch clauses are indirectly confirmed via the determination of 'type'.")
@Override
public void writePathArgument(final PathArgument pathArgument) throws IOException {
+ ensureHeaderWritten();
+ writePathArgumentInternal(pathArgument);
+ }
+
+ @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST",
+ justification = "The casts in the switch clauses are indirectly confirmed via the determination of 'type'.")
+ final void writePathArgumentInternal(final PathArgument pathArgument) throws IOException {
byte type = PathArgumentTypes.getSerializablePathArgumentType(pathArgument);
}
@Test
- public void testSchemaPathSerialization() throws Exception {
+ public void testSchemaPathSerialization() throws IOException {
final SchemaPath expected = SchemaPath.create(true, TestModel.ANY_XML_QNAME);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos));
- nnout.writeSchemaPath(expected);
+ try (NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos))) {
+ nnout.writeSchemaPath(expected);
+ }
+
+ NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(
+ bos.toByteArray()));
+ assertEquals(expected, nnin.readSchemaPath());
+ }
+
+ @Test
+ public void testWritePathArgument() throws IOException {
+ final NodeIdentifier expected = new NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ try (NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos))) {
+ nnout.writePathArgument(expected);
+ }
NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(
bos.toByteArray()));
- SchemaPath actual = nnin.readSchemaPath();
- assertEquals(expected, actual);
+ assertEquals(expected, nnin.readPathArgument());
}
private static String largeString(final int pow) {