001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.tools.ant.taskdefs.optional.junit;
019:
020: import junit.framework.Test;
021: import junit.framework.TestCase;
022: import junit.framework.TestResult;
023:
024: /**
025: */
026: public class JUnitVersionHelperTest extends TestCase {
027:
028: public JUnitVersionHelperTest(String name) {
029: super (name);
030: }
031:
032: public void testMyOwnName() {
033: assertEquals("testMyOwnName", JUnitVersionHelper
034: .getTestCaseName(this ));
035: }
036:
037: public void testNonTestCaseName() {
038: assertEquals("I'm a foo", JUnitVersionHelper
039: .getTestCaseName(new Foo1()));
040: }
041:
042: public void testNoStringReturn() {
043: assertEquals("unknown", JUnitVersionHelper
044: .getTestCaseName(new Foo2()));
045: }
046:
047: public void testNoGetName() {
048: assertEquals("unknown", JUnitVersionHelper
049: .getTestCaseName(new Foo3()));
050: }
051:
052: public void testNameNotGetName() {
053: assertEquals("I'm a foo, too", JUnitVersionHelper
054: .getTestCaseName(new Foo4()));
055: }
056:
057: public void testNull() {
058: assertEquals("unknown", JUnitVersionHelper
059: .getTestCaseName(null));
060: }
061:
062: public void testTestCaseSubClass() {
063: assertEquals("overridden getName", JUnitVersionHelper
064: .getTestCaseName(new Foo5()));
065: }
066:
067: public static class Foo implements Test {
068: public int countTestCases() {
069: return 0;
070: }
071:
072: public void run(TestResult result) {
073: }
074: }
075:
076: public static class Foo1 extends Foo {
077: public String getName() {
078: return "I'm a foo";
079: }
080: }
081:
082: public static class Foo2 extends Foo {
083: public int getName() {
084: return 1;
085: }
086: }
087:
088: public static class Foo3 extends Foo {
089: }
090:
091: public static class Foo4 extends Foo {
092: public String name() {
093: return "I'm a foo, too";
094: }
095: }
096:
097: public static class Foo5 extends TestCase {
098: public String getName() {
099: return "overridden getName";
100: }
101: }
102:
103: }
|