KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > runner > DefaultClassifier


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  * IBM Corporation - initial API and implementation
10  * David Saff (saff@mit.edu) - initial API and implementation
11  * (bug 102632: [JUnit] Support for JUnit 4.)
12  *******************************************************************************/

13
14 package org.eclipse.jdt.internal.junit.runner;
15
16 import java.io.PrintWriter JavaDoc;
17 import java.io.StringWriter JavaDoc;
18
19
20 public class DefaultClassifier implements IClassifiesThrowables {
21
22     private String JavaDoc fVersion;
23
24     public DefaultClassifier(String JavaDoc version) {
25         fVersion= version;
26     }
27
28     /*
29      * (non-Javadoc)
30      *
31      * @see org.eclipse.jdt.internal.junit.runner.ThrowableClassifier#getTrace(java.lang.Throwable)
32      */

33     public String JavaDoc getTrace(Throwable JavaDoc t) {
34         StringWriter JavaDoc stringWriter= new StringWriter JavaDoc();
35         PrintWriter JavaDoc writer= new PrintWriter JavaDoc(stringWriter);
36         t.printStackTrace(writer);
37         StringBuffer JavaDoc buffer= stringWriter.getBuffer();
38         return buffer.toString();
39     }
40
41     /*
42      * (non-Javadoc)
43      *
44      * @see org.eclipse.jdt.internal.junit.runner.ThrowableClassifier#isComparisonFailure(java.lang.Throwable)
45      */

46     public boolean isComparisonFailure(Throwable JavaDoc throwable) {
47         if (! fVersion.equals("3")) //$NON-NLS-1$
48
return false;
49         // avoid reference to comparison failure to avoid a dependency on 3.8.1
50
return throwable.getClass().getName().equals("junit.framework.ComparisonFailure"); //$NON-NLS-1$
51
}
52 }
53
Popular Tags