KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit4 > runner > JUnit4TestMethodReference


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * David Saff (saff@mit.edu) - initial API and implementation
10  * (bug 102632: [JUnit] Support for JUnit 4.)
11  *******************************************************************************/

12
13 package org.eclipse.jdt.internal.junit4.runner;
14
15 import org.eclipse.jdt.internal.junit.runner.ITestIdentifier;
16 import org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees;
17 import org.junit.runner.Description;
18 import org.junit.runner.Request;
19
20 public class JUnit4TestMethodReference extends JUnit4TestReference {
21     private final Description fDescription;
22
23     public JUnit4TestMethodReference(Class JavaDoc<?> clazz, String JavaDoc methodName) {
24         super(Request.method(clazz, methodName));
25         fDescription = Description.createTestDescription(clazz, methodName);
26     }
27
28     public int countTestCases() {
29         return 1;
30     }
31
32     public void sendTree(IVisitsTestTrees notified) {
33         notified.visitTreeEntry(getIdentifier(), false, 1);
34     }
35
36     public String JavaDoc getName() {
37         return fDescription.toString();
38     }
39
40     @Override JavaDoc
41     public boolean equals(Object JavaDoc obj) {
42         if (! (obj instanceof JUnit4TestMethodReference))
43             return false;
44
45         JUnit4TestMethodReference ref = (JUnit4TestMethodReference) obj;
46         return (ref.fDescription.equals(fDescription));
47     }
48
49     @Override JavaDoc
50     public int hashCode() {
51         return fDescription.hashCode();
52     }
53
54     @Override JavaDoc
55     public String JavaDoc toString() {
56         return fDescription.toString();
57     }
58
59     public ITestIdentifier getIdentifier() {
60         return new JUnit4Identifier(fDescription);
61     }
62 }
63
Popular Tags