You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ke...@apache.org on 2010/07/15 00:52:57 UTC
svn commit: r964240 - in
/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util: ./
Base64Test.java CacheMapTest.java EnterpriseEntityResolverTest.java
LDAPTest.java UtilityTest.java XMLTest.java
Author: kelly
Date: Wed Jul 14 22:52:57 2010
New Revision: 964240
URL: http://svn.apache.org/viewvc?rev=964240&view=rev
Log:
WIP OODT-15
Import additional unit tests for XML entity resolvers, LDAP, misc XML functions, the CacheMap class, misc utilities, etc.
Added:
incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/
incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/Base64Test.java
incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/CacheMapTest.java
incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/EnterpriseEntityResolverTest.java
incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/LDAPTest.java
incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/UtilityTest.java
incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/XMLTest.java
Added: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/Base64Test.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/Base64Test.java?rev=964240&view=auto
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/Base64Test.java (added)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/Base64Test.java Wed Jul 14 22:52:57 2010
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE.txt 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
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.oodt.commons.util;
+
+import java.io.*;
+import java.util.*;
+import junit.framework.*;
+
+/** Unit test the {@link Base64} class.
+ *
+ * @author Kelly
+ */
+public class Base64Test extends TestCase {
+ /** Construct the test case for the {@link Base64} class. */
+ public Base64Test(String name) {
+ super(name);
+ }
+
+ /** Test encoding and decoding.
+ */
+ public void testEncDec() {
+ byte[] a = Base64.encode("abcde".getBytes());
+ assertTrue("Base-64 encoding failed", Arrays.equals("YWJjZGU=".getBytes(), a));
+ byte[] b = Base64.decode("YWJjZGU=".getBytes());
+ assertTrue("Base-64 decoding failed", Arrays.equals("abcde".getBytes(), b));
+ }
+}
Added: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/CacheMapTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/CacheMapTest.java?rev=964240&view=auto
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/CacheMapTest.java (added)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/CacheMapTest.java Wed Jul 14 22:52:57 2010
@@ -0,0 +1,112 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE.txt 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
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.oodt.commons.util;
+
+import java.io.*;
+import java.util.*;
+import junit.framework.*;
+
+/** Unit test the {@link CacheMap} class.
+ *
+ * @author Kelly
+ */
+public class CacheMapTest extends TestCase {
+ /** Construct the test case for the {@link CacheMap} class. */
+ public CacheMapTest(String name) {
+ super(name);
+ }
+
+ /** Test the caching operation. */
+ public void testCache() {
+ CacheMap c = new CacheMap(3);
+ c.put("alpha", "1");
+ c.put("beta", "2");
+ c.put("gamma", "3");
+ // gamma beta alpha
+ assertEquals("2", c.get("beta"));
+ // beta gamma alpha
+ c.put("delta", "4");
+ // delta beta gamma
+ assertNull(c.get("alpha"));
+ }
+
+ /** Test the {@link CacheMap#size} and {@link CacheMap#isEmpty} methods. */
+ public void testSize() {
+ CacheMap c = new CacheMap(3);
+ assertEquals(0, c.size());
+ assertTrue(c.isEmpty());
+ c.put("alpha", "1");
+ // alpha
+ assertEquals(1, c.size());
+ c.put("beta", "2");
+ // beta alpha
+ assertEquals(2, c.size());
+ c.put("gamma", "3");
+ // gamma beta alpha
+ assertEquals(3, c.size());
+ c.put("delta", "4");
+ // delta gamma beta
+ assertEquals(3, c.size());
+ c.clear();
+ assertTrue(c.isEmpty());
+ }
+
+ /** Test the {@link CacheMap#containsKey} and {@link CacheMap#containsValue} methods. */
+ public void testContains() {
+ CacheMap c = new CacheMap(3);
+ c.put("alpha", "1");
+ c.put("beta", "2");
+ c.put("gamma", "3");
+
+ assertTrue(c.containsKey("alpha"));
+ assertTrue(!c.containsKey("hungus"));
+ assertTrue(c.containsValue("2"));
+ assertTrue(!c.containsValue("x"));
+ }
+
+ /** Test value replacement for the same key. */
+ public void testRePut() {
+ CacheMap c = new CacheMap(3);
+ c.put("alpha", "1");
+ c.put("beta", "2");
+ c.put("gamma", "3");
+ // (gamma, 3) (beta, 2) (alpha, 1)
+ c.put("alpha", "x");
+ // (alpha, x), (gamma, 3) (beta, 2)
+ assertEquals("x", c.get("alpha"));
+ // (alpha, x), (gamma, 3) (beta, 2)
+ c.put("delta", "y");
+ // (delta, y) (alpha, x), (gamma, 3)
+ assertEquals(3, c.size());
+ assertNull(c.get("beta"));
+ }
+
+ /** Test the {@link CacheMap#remove} method. */
+ public void testRemove() {
+ CacheMap c = new CacheMap(3);
+ c.put("alpha", "1");
+ c.put("beta", "2");
+ c.put("gamma", "3");
+ // gamma beta alpha
+ c.put("delta", "4");
+ // delta gamma beta
+ assertEquals("3", c.remove("gamma"));
+ // delta beta
+ assertNull(c.remove("gamma"));
+ assertNull(c.remove("alpha"));
+ }
+}
+
Added: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/EnterpriseEntityResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/EnterpriseEntityResolverTest.java?rev=964240&view=auto
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/EnterpriseEntityResolverTest.java (added)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/EnterpriseEntityResolverTest.java Wed Jul 14 22:52:57 2010
@@ -0,0 +1,121 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE.txt 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
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.oodt.commons.util;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import junit.framework.TestCase;
+
+/**
+ * Unit test the EnterpriseEntityResolver class.
+ *
+ * @author Kelly
+ */
+public class EnterpriseEntityResolverTest extends TestCase {
+ /** Construct the test case for the XML class.
+ *
+ * @param name Case name
+ */
+ public EnterpriseEntityResolverTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Create a temporary directory with a temporary file as the test entity.
+ *
+ * @throws Exception if an error occurs.
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ testDir = File.createTempFile("eet", ".dir");
+ testDir.delete();
+ testDir.mkdir();
+ testFile = new File(testDir, "test-entry-do-not-remove.dtd");
+ if (!testFile.createNewFile())
+ throw new Exception(testFile + " already exists, but shouldn't");
+ }
+
+ /**
+ * Delete the temporary file entity and test directory.
+ *
+ * @throws Exception if an error occurs.
+ */
+ public void tearDown() throws Exception{
+ testFile.delete();
+ testDir.delete();
+ super.tearDown();
+ }
+
+ /**
+ * Test if the entity parser works at initialization time.
+ */
+ public void testEntityParsing() {
+ assertEquals("test-entry-do-not-remove.dtd",
+ EnterpriseEntityResolver.entities.get("-//JPL//DTD TEST ENTRY DO NOT REMOVE//EN"));
+ }
+
+ /**
+ * Test if the resolver computes filenames based on public and system identifiers.
+ */
+ public void testFilenameComputation() {
+ assertNull(EnterpriseEntityResolver.computeFilename(null, null));
+ assertNull(EnterpriseEntityResolver.computeFilename(null, "unknown"));
+ assertNull(EnterpriseEntityResolver.computeFilename("unknown", null));
+ assertNull(EnterpriseEntityResolver.computeFilename("unknown", "unknown"));
+
+ assertEquals("test-entry-do-not-remove.dtd",
+ EnterpriseEntityResolver.computeFilename("-//JPL//DTD TEST ENTRY DO NOT REMOVE//EN", null));
+ assertEquals("test-entry-do-not-remove.dtd",
+ EnterpriseEntityResolver.computeFilename(null, "http://oodt.jpl.nasa.gov/test-entry-do-not-remove.dtd"));
+ assertEquals("test-entry-do-not-remove.dtd",
+ EnterpriseEntityResolver.computeFilename("-//JPL//DTD TEST ENTRY DO NOT REMOVE//EN",
+ "illegal-url:test-entry-do-not-remove.dtd"));
+ assertEquals("test-entry-do-not-remove.dtd",
+ EnterpriseEntityResolver.computeFilename("illegal-FPI",
+ "http://oodt.jpl.nasa.gov/test-entry-do-not-remove.dtd"));
+ assertEquals("test-entry-do-not-remove.dtd",
+ EnterpriseEntityResolver.computeFilename("-//JPL//DTD TEST ENTRY DO NOT REMOVE//EN",
+ "http://oodt.jpl.nasa.gov/test-entry-do-not-remove.dtd"));
+ }
+
+ /**
+ * Test if the resolver finds a file based on a list of directories and name.
+ */
+ public void testFileFinding() {
+ List dirs = Collections.singletonList(testDir.toString());
+ assertEquals(testFile, EnterpriseEntityResolver.findFile(dirs, testFile.getName()));
+ }
+
+ /**
+ * Test if the resolver can convert a string specification of entity references
+ * into a {@link List}.
+ */
+ public void testDirFinding() {
+ List dirs = EnterpriseEntityResolver.getEntityRefDirs("");
+ assertTrue(dirs.isEmpty());
+ dirs = EnterpriseEntityResolver.getEntityRefDirs("/tmp,/usr/local/xml");
+ assertEquals(2, dirs.size());
+ assertEquals("/tmp", dirs.get(0));
+ assertEquals("/usr/local/xml", dirs.get(1));
+ }
+
+ /** Test directory to hold <var>testFile</var>, the test entity. */
+ private File testDir;
+
+ /** The test entity. */
+ private File testFile;
+}
Added: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/LDAPTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/LDAPTest.java?rev=964240&view=auto
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/LDAPTest.java (added)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/LDAPTest.java Wed Jul 14 22:52:57 2010
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE.txt 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
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.oodt.commons.util;
+
+import java.io.*;
+import java.util.*;
+import junit.framework.*;
+
+/** Unit test the {@link LDAP} class.
+ *
+ * @author Kelly
+ */
+public class LDAPTest extends TestCase {
+ /** Construct the test case for the {@link LDAP} class. */
+ public LDAPTest(String name) {
+ super(name);
+ }
+
+ /** Test the {@link LDAP#toLDAPString} method. */
+ public void testToLDAPString() {
+ String str = "Hello (World), \\How are you*?";
+ String result = LDAP.toLDAPString(str);
+ assertEquals("Hello \\28World\\29, \\5cHow are you\\2a?", result);
+ }
+}
+
Added: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/UtilityTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/UtilityTest.java?rev=964240&view=auto
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/UtilityTest.java (added)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/UtilityTest.java Wed Jul 14 22:52:57 2010
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE.txt 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
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.oodt.commons.util;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.TestCase;
+
+public class UtilityTest extends TestCase {
+ public UtilityTest(String caseName) {
+ super(caseName);
+ }
+
+ public void testDelete() throws IOException {
+ File top = File.createTempFile("topdir", ".dir");
+ top.delete();
+ top.mkdir();
+ File f1 = File.createTempFile("nesteddir", ".file", top);
+ File f2 = File.createTempFile("nesteddir", ".file", top);
+ File d1 = File.createTempFile("nesteddir", ".dir", top);
+ d1.delete();
+ d1.mkdir();
+ File f3 = File.createTempFile("nesteddir", ".file", d1);
+ File d2 = File.createTempFile("nesteddir", ".dir", d1);
+ d2.delete();
+ d2.mkdir();
+ File f4 = File.createTempFile("nesteddir", ".file", d2);
+
+ assertTrue(Utility.delete(top));
+ assertTrue(!top.exists());
+ }
+}
Added: incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/XMLTest.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/XMLTest.java?rev=964240&view=auto
==============================================================================
--- incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/XMLTest.java (added)
+++ incubator/oodt/trunk/commons/src/test/org/apache/oodt/commons/util/XMLTest.java Wed Jul 14 22:52:57 2010
@@ -0,0 +1,180 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE.txt 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
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.oodt.commons.util;
+
+import java.io.*;
+import java.util.*;
+import junit.framework.*;
+import org.w3c.dom.*;
+import org.xml.sax.*;
+
+/** Unit test the XML class.
+ *
+ * @author Kelly
+ */
+public class XMLTest extends TestCase {
+ /** Construct the test case for the XML class. */
+ public XMLTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("test.xml")));
+ inputSource = new InputSource(reader);
+ }
+
+ protected void tearDown() throws Exception {
+ reader.close();
+ }
+
+ /** Test the {@link XML#createDocument} method.
+ */
+ public void testDocumentCreation() {
+ Document doc = XML.createDocument();
+ assertTrue(doc instanceof Document);
+ }
+
+ /** Test the {@link XML#createDOMParser} and {@link XML#serialize} methods.
+ */
+ public void testDOM() throws Exception {
+ DOMParser p = XML.createDOMParser();
+ p.parse(inputSource);
+ Document doc = p.getDocument();
+ doc.normalize();
+ assertEquals("log", doc.getDocumentElement().getTagName());
+ java.util.zip.CRC32 crc = new java.util.zip.CRC32();
+ String result = XML.serialize(doc);
+ System.err.println("FUCK YOU: " + result);
+ crc.update(result.getBytes());
+ long value = crc.getValue();
+ assertTrue("Stringified DOM document CRC mismatch, got value = " + value, 3880488030L == value || 2435419114L == value || /* added by Chris Mattmann: pretty print fix */3688328384L == value || /* other newline treatment */ 750262163L == value || 3738296466L == value /* Apache incubator warmed up the file, so it suffered thermal expansion */);
+ }
+
+ /** Test the {@link XML#createSAXParser} method.
+ */
+ public void testSAXParser() throws Exception {
+ SAXParser p = XML.createSAXParser();
+ MyHandler handler = new MyHandler();
+ p.setContentHandler(handler);
+ p.parse(inputSource);
+ // 25 refers to the 25 elements in the test.xml document.
+ assertEquals(25, handler.getElementCount());
+ }
+
+ /** Test the {@link XML#dump(PrintWriter,Node)} method. */
+ public void testDump() throws Exception {
+ DOMParser p = XML.createDOMParser();
+ p.parse(inputSource);
+ Document doc = p.getDocument();
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter);
+ XML.dump(printWriter, doc);
+ printWriter.close();
+ java.util.zip.CRC32 crc = new java.util.zip.CRC32();
+ crc.update(stringWriter.getBuffer().toString().getBytes());
+ long value = crc.getValue();
+ assertTrue("Dumped DOM tree CRC mismatch; got " + value, value == 828793L || value == 2241317601L);
+ }
+
+ /** Test the {@link XML#unwrappedText} method. */
+ public void testUnwrappedText() throws Exception {
+ DOMParser p = XML.createDOMParser();
+ p.parse(inputSource);
+ Document doc = p.getDocument();
+ doc.normalize();
+
+ Node node = doc.getDocumentElement().getFirstChild().getFirstChild().getNextSibling()
+ .getNextSibling().getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling();
+ assertEquals("Geeba, geeba. Geeba geeba geeba! Geeba, geeba, blooor? Bloorien bloreinda!",
+ XML.unwrappedText(node));
+ assertNull(XML.unwrappedText(null));
+ }
+
+ /** Test the {@link XML#add(Node,String,String)} method. */
+ public void testAddString() throws Exception {
+ Document doc = XML.createDocument();
+ Element root = doc.createElement("root");
+ doc.appendChild(root);
+ XML.add(root, "child", "child text");
+ assertEquals("child", root.getFirstChild().getNodeName());
+ assertEquals("child text", root.getFirstChild().getFirstChild().getNodeValue());
+ NodeList children = root.getChildNodes();
+ assertEquals(1, children.getLength());
+ try {
+ XML.add(null, "child", "child text");
+ } catch (IllegalArgumentException ex) {
+ return;
+ }
+ fail("Adding to a null node should fail by throwing IllegalArgumentException");
+ }
+
+ /** Test the {@link XML#add(Node,String,Object)} method. */
+ public void testAddObject() throws Exception {
+ Object obj = new Object() {
+ public String toString() {
+ return "child text";
+ }
+ };
+ Document doc = XML.createDocument();
+ Element root = doc.createElement("root");
+ doc.appendChild(root);
+ XML.add(root, "child", obj);
+ assertEquals("child", root.getFirstChild().getNodeName());
+ assertEquals("child text", root.getFirstChild().getFirstChild().getNodeValue());
+ NodeList children = root.getChildNodes();
+ assertEquals(1, children.getLength());
+ try {
+ XML.add(null, "child", obj);
+ } catch (IllegalArgumentException ex) {
+ return;
+ }
+ fail("Adding to a null node should fail by throwing IllegalArgumentException");
+ }
+
+ /** Test the {@link XML#escape} method. */
+ public void testEscape() {
+ assertEquals("", XML.escape(""));
+ assertEquals("So I said, "She said, 'Both 3 & 2 are < 5 but > 0' but he said ꯍ",
+ XML.escape("So I said, \"She said, 'Both 3 & 2 are < 5 but > 0' but he said \uabcd"));
+ }
+
+
+ /** Test the {@link XML#getDOMImplementation} method. */
+ public void testGetDOMImplementation() {
+ DOMImplementation impl = XML.getDOMImplementation();
+ assertNotNull(impl);
+ DOMImplementation impl2 = XML.getDOMImplementation();
+ assertSame(impl, impl2);
+ }
+
+ /** Used by {@link #testSAXParser} */
+ private static class MyHandler extends org.xml.sax.helpers.DefaultHandler {
+ private int elementCount = 0;
+ public void endElement(String uri, String localName, String rawName) {
+ ++elementCount;
+ }
+ public int getElementCount() {
+ return elementCount;
+ }
+ }
+
+ /** Reader for the test data file. */
+ private BufferedReader reader;
+
+ /** Input source for the {@link #reader}. */
+ private InputSource inputSource;
+}
+