1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 package org.mockito.internal.junit;
6 
7 import org.mockito.exceptions.verification.ArgumentsAreDifferent;
8 
9 public class JUnitTool {
10 
11     private static boolean hasJUnit;
12 
13     static {
14         try {
15             Class.forName("junit.framework.ComparisonFailure");
16             hasJUnit = true;
17         } catch (Throwable t) {
18             hasJUnit = false;
19         }
20     }
21 
hasJUnit()22     public static boolean hasJUnit() {
23         return hasJUnit;
24     }
25 
createArgumentsAreDifferentException(String message, String wanted, String actual)26     public static AssertionError createArgumentsAreDifferentException(String message, String wanted, String actual)  {
27         try {
28             Class<?> clazz = Class.forName("org.mockito.exceptions.verification.junit.ArgumentsAreDifferent");
29             AssertionError throwable = (AssertionError) clazz.getConstructors()[0].newInstance(message, wanted, actual);
30             return throwable;
31         } catch (Throwable t) {
32 //            throw the default exception in case of problems
33             return new ArgumentsAreDifferent(message);
34         }
35     }
36 }