001: /*
002: * @(#)SPILoaderUTest.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.classes.v1;
028:
029: import org.easymock.EasyMock;
030: import org.easymock.MockControl;
031: import junit.framework.Test;
032: import junit.framework.TestCase;
033: import junit.framework.TestSuite;
034:
035: /**
036: * Tests the SPILoader class.
037: *
038: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
039: * @version $Date: 2003/02/10 22:52:39 $
040: * @since June 29, 2002
041: */
042: public class SPILoaderUTest extends TestCase {
043: //-------------------------------------------------------------------------
044: // Standard JUnit Class-specific declarations
045:
046: private static final Class THIS_CLASS = SPILoaderUTest.class;
047:
048: public SPILoaderUTest(String name) {
049: super (name);
050: }
051:
052: //-------------------------------------------------------------------------
053: // setup
054:
055: /**
056: *
057: * @exception Exception thrown under any exceptional condition.
058: */
059: protected void setUp() throws Exception {
060: super .setUp();
061:
062: // set ourself up
063: }
064:
065: //-------------------------------------------------------------------------
066: // Tests
067:
068: public void testConstructor1() throws Exception {
069: try {
070: new SPILoader(null);
071: fail("Did not throw IllegalArgumentException");
072: } catch (IllegalArgumentException iae) {
073: // examine exception?
074: }
075: }
076:
077: public void testConstructor2() throws Exception {
078: try {
079: new SPILoader(null, null);
080: fail("Did not throw IllegalArgumentException");
081: } catch (IllegalArgumentException iae) {
082: // examine exception?
083: }
084: }
085:
086: public void testConstructor3() throws Exception {
087: new SPILoader(THIS_CLASS);
088: }
089:
090: public void testConstructor4() throws Exception {
091: new SPILoader(THIS_CLASS, null);
092: }
093:
094: public void testHasNext1() throws Exception {
095: SPILoader spil = new SPILoader(THIS_CLASS);
096: assertTrue(
097: "SPILoaderUTest should not have a prop def file, and so should "
098: + "not have a 'next'.", !spil.hasNext());
099: }
100:
101: public void testHasNext2() throws Exception {
102: // this is valid - we put this in the unit test hierarchy
103: SPILoader spil = new SPILoader(Object.class);
104:
105: assertTrue(
106: "Object should have a prop def file in classpath with entries.",
107: spil.hasNext());
108: }
109:
110: //-------------------------------------------------------------------------
111: // Helpers
112:
113: //-------------------------------------------------------------------------
114: // Standard JUnit declarations
115:
116: public static Test suite() {
117: TestSuite suite = new TestSuite(THIS_CLASS);
118:
119: // Test the implementation's interface conformity.
120: /*
121: suite.addTest( IxUTestI.suite(
122: new ImplementationCreator[] {
123: new ImplementationCreator() {
124: public Object createImplementedObject() {
125: // XXXXXXXXXXXXXXXXXXXXXXXX
126: }
127: },
128: } ) );
129: */
130:
131: return suite;
132: }
133:
134: public static void main(String[] args) {
135: String[] name = { THIS_CLASS.getName() };
136:
137: // junit.textui.TestRunner.main( name );
138: // junit.swingui.TestRunner.main( name );
139:
140: junit.textui.TestRunner.main(name);
141: }
142:
143: /**
144: *
145: * @exception Exception thrown under any exceptional condition.
146: */
147: protected void tearDown() throws Exception {
148: // tear ourself down
149:
150: super.tearDown();
151: }
152: }
|