001: /*
002: * Copyright (c) 2001-2007, Jean Tessier
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: *
009: * * Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * * Neither the name of Jean Tessier nor the names of his contributors
017: * may be used to endorse or promote products derived from this software
018: * without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031: */
032:
033: package com.jeantessier.classreader;
034:
035: import java.io.*;
036: import java.util.*;
037:
038: import junit.framework.*;
039:
040: import org.apache.log4j.*;
041:
042: public abstract class TestClassfileLoaderBase extends TestCase
043: implements LoadListener {
044: public static final String TEST_DIR = "tests" + File.separator
045: + "JarJarDiff";
046:
047: private LinkedList<LoadEvent> beginSessionEvents;
048: private LinkedList<LoadEvent> beginGroupEvents;
049: private LinkedList<LoadEvent> beginFileEvents;
050: private LinkedList<LoadEvent> beginClassfileEvents;
051: private LinkedList<LoadEvent> endClassfileEvents;
052: private LinkedList<LoadEvent> endFileEvents;
053: private LinkedList<LoadEvent> endGroupEvents;
054: private LinkedList<LoadEvent> endSessionEvents;
055:
056: protected void setUp() throws Exception {
057: super .setUp();
058:
059: Logger.getLogger(getClass())
060: .info("Starting test: " + getName());
061:
062: beginSessionEvents = new LinkedList<LoadEvent>();
063: beginGroupEvents = new LinkedList<LoadEvent>();
064: beginFileEvents = new LinkedList<LoadEvent>();
065: beginClassfileEvents = new LinkedList<LoadEvent>();
066: endClassfileEvents = new LinkedList<LoadEvent>();
067: endFileEvents = new LinkedList<LoadEvent>();
068: endGroupEvents = new LinkedList<LoadEvent>();
069: endSessionEvents = new LinkedList<LoadEvent>();
070: }
071:
072: protected void tearDown() throws Exception {
073: Logger.getLogger(getClass()).info("End of " + getName());
074:
075: super .tearDown();
076: }
077:
078: protected LinkedList<LoadEvent> getBeginSessionEvents() {
079: return beginSessionEvents;
080: }
081:
082: protected LinkedList<LoadEvent> getBeginGroupEvents() {
083: return beginGroupEvents;
084: }
085:
086: protected LinkedList<LoadEvent> getBeginFileEvents() {
087: return beginFileEvents;
088: }
089:
090: protected LinkedList<LoadEvent> getBeginClassfileEvents() {
091: return beginClassfileEvents;
092: }
093:
094: protected LinkedList<LoadEvent> getEndClassfileEvents() {
095: return endClassfileEvents;
096: }
097:
098: protected LinkedList<LoadEvent> getEndFileEvents() {
099: return endFileEvents;
100: }
101:
102: protected LinkedList<LoadEvent> getEndGroupEvents() {
103: return endGroupEvents;
104: }
105:
106: protected LinkedList<LoadEvent> getEndSessionEvents() {
107: return endSessionEvents;
108: }
109:
110: public void beginSession(LoadEvent event) {
111: getBeginSessionEvents().add(event);
112: }
113:
114: public void beginGroup(LoadEvent event) {
115: getBeginGroupEvents().add(event);
116: }
117:
118: public void beginFile(LoadEvent event) {
119: getBeginFileEvents().add(event);
120: }
121:
122: public void beginClassfile(LoadEvent event) {
123: getBeginClassfileEvents().add(event);
124: }
125:
126: public void endClassfile(LoadEvent event) {
127: getEndClassfileEvents().add(event);
128: }
129:
130: public void endFile(LoadEvent event) {
131: getEndFileEvents().add(event);
132: }
133:
134: public void endGroup(LoadEvent event) {
135: getEndGroupEvents().add(event);
136: }
137:
138: public void endSession(LoadEvent event) {
139: getEndSessionEvents().add(event);
140: }
141: }
|