001: /*
002: * @(#)ClassUtilOnlineUTest.java 0.9.0 17-APR-2001 - 14:40
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 junit.framework.Test;
030: import junit.framework.TestCase;
031: import junit.framework.TestSuite;
032:
033: /**
034: * Tests only the ClassUtil tests that are online.
035: *
036: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
037: * @version $Date: 2003/02/10 22:52:38 $
038: * @since June 28, 2002
039: */
040: public class ClassUtilOnlineUTest extends TestCase {
041: private static final Class THIS_CLASS = ClassUtilOnlineUTest.class;
042:
043: public ClassUtilOnlineUTest(String name) {
044: super (name);
045: }
046:
047: public static Test suite() {
048: TestSuite suite = new TestSuite(THIS_CLASS);
049:
050: return suite;
051: }
052:
053: public static void main(String[] args) {
054: String[] name = { THIS_CLASS.getName() };
055:
056: // junit.textui.TestRunner.main( name );
057: // junit.swingui.TestRunner.main( name );
058:
059: junit.textui.TestRunner.main(name);
060: }
061:
062: protected void setUp() throws Exception {
063: super .setUp();
064:
065: // set ourself up
066: }
067:
068: protected void tearDown() throws Exception {
069: // tear ourself down
070:
071: super .tearDown();
072: }
073:
074: private static final String BELIEF_CLASS = "BeliefOfTheDay";
075: private static final String BELIEF_JAR = "http://groboutils.sourceforge.net/Belief.jar";
076:
077: public static class InnerClass {
078: public InnerClass() {
079: // do nothing
080: }
081: }
082:
083: public void testGetClass1() {
084: ClassUtil util = startTest();
085:
086: Class c = util.getClass(BELIEF_CLASS, BELIEF_JAR);
087: assertNotNull(
088: "getClass( " + BELIEF_CLASS + " ) returned null.", c);
089: assertEquals("getClass( " + BELIEF_CLASS
090: + " ) returned the wrong class.", BELIEF_CLASS, c
091: .getName());
092: }
093:
094: public void testCreateObject1() {
095: ClassUtil util = startTest();
096:
097: Object o = util.createObject(BELIEF_CLASS, BELIEF_JAR);
098: assertEquals("createObject( " + BELIEF_CLASS + ", "
099: + BELIEF_JAR
100: + " ) did not instantiate the remote class.",
101: BELIEF_CLASS, o.getClass().getName());
102: }
103:
104: //---------------------------------
105:
106: // we must assert that the ClassUtil is fresh to avoid incorrect
107: // behavior.
108: protected ClassUtil startTest() {
109: ClassUtil util = ClassUtil.getInstance();
110: util.flush();
111: return util;
112: }
113: }
|