001: /*
002: * @(#)ChainableExceptionUTest.java
003: *
004: * Copyright (C) 2002-2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.util.throwable.v1;
028:
029: import java.io.PrintStream;
030: import java.io.PrintWriter;
031: import java.io.StringWriter;
032: import java.io.ByteArrayOutputStream;
033: import net.sourceforge.groboutils.autodoc.v1.*;
034: import net.sourceforge.groboutils.junit.v1.iftc.*;
035: import junit.framework.Test;
036: import junit.framework.TestCase;
037: import junit.framework.TestSuite;
038:
039: /**
040: * Tests the ChainableException class.
041: *
042: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
043: * @version $Date: 2003/05/06 05:35:02 $
044: * @since March 17, 2002
045: */
046: public class ChainableExceptionUTest extends TestCase {
047: //-------------------------------------------------------------------------
048: // Standard JUnit Class-specific declarations
049:
050: private static final Class THIS_CLASS = ChainableExceptionUTest.class;
051: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
052:
053: public ChainableExceptionUTest(String name) {
054: super (name);
055: DOC.getLog().info("ChainableExceptionUTest() constructor");
056: }
057:
058: //-------------------------------------------------------------------------
059: // setup
060:
061: /**
062: *
063: * @exception Exception thrown under any exceptional condition.
064: */
065: protected void setUp() throws Exception {
066: super .setUp();
067:
068: // set ourself up
069: }
070:
071: //-------------------------------------------------------------------------
072: // Tests
073:
074: public void testAllTestsCoveredByInterfaceTests() {
075: // do nothing
076: }
077:
078: //-------------------------------------------------------------------------
079: // Helpers
080:
081: //-------------------------------------------------------------------------
082: // Standard JUnit declarations
083:
084: public static class CEFactory implements
085: IChainableExceptionUTestI.IChainableExceptionFactory {
086: public IChainableException createException() {
087: return new ChainableException();
088: }
089:
090: public IChainableException createException(String message) {
091: return new ChainableException(message);
092: }
093:
094: public IChainableException createException(Throwable cause) {
095: return new ChainableException(cause);
096: }
097:
098: public IChainableException createException(String message,
099: Throwable cause) {
100: return new ChainableException(message, cause);
101: }
102:
103: public IChainableException createException(Throwable cause,
104: String message) {
105: return new ChainableException(cause, message);
106: }
107: }
108:
109: public static Test suite() {
110: InterfaceTestSuite suite = IChainableExceptionUTestI.suite();
111:
112: // all tests are covered by the interface tests, so don't need this
113: // line. But will add it for insurance in case tests are needed later.
114: suite.addTestSuite(THIS_CLASS);
115:
116: DOC.getLog().info("Adding factory to suite.");
117: suite.addFactory(new CxFactory("A") {
118: public Object createImplObject() {
119: DOC.getLog().info(
120: "Creating factory implementation object.");
121: return new CEFactory();
122: //return null;
123: }
124: });
125:
126: DOC.getLog().info("Returning suite.");
127: return suite;
128: }
129:
130: public static void main(String[] args) {
131: String[] name = { THIS_CLASS.getName() };
132:
133: // junit.textui.TestRunner.main( name );
134: // junit.swingui.TestRunner.main( name );
135:
136: junit.textui.TestRunner.main(name);
137: }
138:
139: /**
140: *
141: * @exception Exception thrown under any exceptional condition.
142: */
143: protected void tearDown() throws Exception {
144: // tear ourself down
145:
146: super.tearDown();
147: }
148: }
|