001: /*
002: * @(#)DefaultTestInfo.java
003: *
004: * Copyright (C) 2002-2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Part of the GroboUtils package at:
009: * http://groboutils.sourceforge.net
010: *
011: * Permission is hereby granted, free of charge, to any person obtaining a
012: * copy of this software and associated documentation files (the "Software"),
013: * to deal in the Software without restriction, including without limitation
014: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
015: * and/or sell copies of the Software, and to permit persons to whom the
016: * Software is furnished to do so, subject to the following conditions:
017: *
018: * The above copyright notice and this permission notice shall be included in
019: * all copies or substantial portions of the Software.
020: *
021: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
022: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
024: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
025: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
026: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
027: * DEALINGS IN THE SOFTWARE.
028: */
029: package net.sourceforge.groboutils.autodoc.v1.testserver;
030:
031: import junit.framework.Test;
032: import junit.framework.TestSuite;
033: import junit.framework.TestCase;
034:
035: /**
036: * An implementation of TestInfo which is specific to JUnit.
037: *
038: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
039: * @since March 17, 2002
040: * @version $Date: 2003/02/10 22:52:13 $
041: */
042: public class DefaultTestInfo implements TestInfo {
043: private String suite;
044: private String method;
045:
046: /**
047: * Only allowed to be implemented by subclasses.
048: */
049: protected DefaultTestInfo() {
050: // do nothing
051: }
052:
053: /**
054: *
055: */
056: public DefaultTestInfo(String suite, String method) {
057: this .suite = suite;
058: this .method = method;
059: }
060:
061: /**
062: *
063: */
064: public String getSuite() {
065: return this .suite;
066: }
067:
068: /**
069: *
070: */
071: public String getMethod() {
072: return this .method;
073: }
074:
075: /**
076: * This method does not care about the specific sub-type, jsut as long
077: * as the suite and method are identical.
078: */
079: public boolean equals(Object obj) {
080: if (obj == null) {
081: return false;
082: }
083: if (this == obj) {
084: return true;
085: }
086: if (obj instanceof TestInfo) {
087: TestInfo ti = (TestInfo) obj;
088: if (this .getSuite() == null) {
089: if (ti.getSuite() != null) {
090: return false;
091: }
092: } else if (!this .getSuite().equals(ti.getSuite())) {
093: return false;
094: }
095:
096: if (this .getMethod() == null) {
097: if (ti.getMethod() != null) {
098: return false;
099: }
100: } else if (!this .getMethod().equals(ti.getMethod())) {
101: return false;
102: }
103:
104: // else
105: return true;
106: }
107: // else
108: return false;
109: }
110:
111: public int hashCode() {
112: int hc = 0;
113: String s = getSuite();
114: String m = getMethod();
115: if (s != null) {
116: hc += s.hashCode();
117: }
118: if (m != null) {
119: hc += m.hashCode();
120: }
121: return hc;
122: }
123:
124: protected void setSuite(String name) {
125: this .suite = name;
126: }
127:
128: protected void setMethod(String name) {
129: this.method = name;
130: }
131: }
|