--- /dev/null 2014-09-08 10:45:56.830930409 -0700 +++ new/test/javax/xml/jaxp/libs/org/apache/qetest/CheckingHandler.java 2015-01-09 15:42:25.731193491 -0800 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + */ +/* + * 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 + * + * 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.qetest; + +/** + * Base class defining common functionality of logging handlers. + *

+ * Common functionality used for testing when implementing various Handlers and + * Listeners. Provides common ways to set Loggers and levels, reset, and set + * expected errors or the like. Likely used to implement testing wrapper classes + * for things like javax.xml.transform.ErrorListener and + * org.xml.sax.ErrorHandler

+ *

+ * The best description for this class can be seen in an example; see + * trax.LoggingErrorHandler.java for one.

+ */ +public interface CheckingHandler { + /** + * Reset any items or counters we've handled. Resets any data about what + * we've handled or logged so far, like getLast() and getCounters() data, as + * well as any expected items from setExpected(). Does not change our Logger + * or loggingLevel. + */ + public void reset(); + + /** + * Ask us to report checkPass/Fail for certain events we handle. Since we + * may have to handle many events between when a test will be able to call + * us, testers can set this to have us automatically call checkPass when we + * see an item that matches, or to call checkFail when we get an unexpected + * item. Generally, we only call check* methods when: + * + * Note that most implementations will only validate the first event of a + * specific type, and then will reset validation for that event type. This + * is because many events may be raised in between the time that a calling + * Test class could tell us of the 'next' expected event. + * + * @param itemType which of the various types of items we might handle; + * should be defined as a constant by subclasses + * @param expectation a set expectation if we care this event or not. + */ + public void setExpected(int itemType, Expectation expectation); + + enum Expectation { + ITEM_DONT_CARE, + ITEM_CHECKFAIL, + ITEM_CHECKPASS, + ITEM_RESOLVE + } +}