Github user eolivelli commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/726#discussion_r236977045
--- Diff:
zookeeper-jute/src/test/java/org/apache/jute/XmlInputArchiveTest.java ---
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jute;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+
+public class XmlInputArchiveTest {
+
+ void checkWriterAndReader(TestWriter writer, TestReader reader) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try {
+ XmlOutputArchive oa = XmlOutputArchive.getArchive(baos);
+ writer.write(oa);
+ } catch (IOException e) {
+ Assert.fail("Should not throw IOException");
+ }
+ InputStream is = new ByteArrayInputStream(baos.toByteArray());
+ try {
+ XmlInputArchive ia = XmlInputArchive.getArchive(is);
+ reader.read(ia);
+ } catch (ParserConfigurationException e) {
+ Assert.fail("Should not throw ParserConfigurationException
while reading back");
+ } catch (SAXException e) {
+ Assert.fail("Should not throw SAXException while reading
back");
+ } catch (IOException e) {
+ Assert.fail("Should not throw IOException while reading back");
+ }
+ }
+
+ @Test
+ public void testWriteInt() {
+ final int expected = 4;
+ final String tag = "tag1";
+ checkWriterAndReader(
+ (oa) -> oa.writeInt(expected, tag),
+ (ia) -> {
+ int actual = ia.readInt(tag);
+ Assert.assertEquals(expected, actual);
+ }
+ );
+ }
+
+ @Test
+ public void testWriteBool() {
+ final boolean expected = false;
+ final String tag = "tag1";
+ checkWriterAndReader(
+ (oa) -> oa.writeBool(expected, tag),
+ (ia) -> {
+ boolean actual = ia.readBool(tag);
+ Assert.assertEquals(expected, actual);
--- End diff --
Sorry, last nit: any reason for not using static imports?
---