| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.rice.test; |
| 17 |
|
|
| 18 |
|
import org.junit.Assert; |
| 19 |
|
|
| 20 |
|
import java.lang.annotation.Annotation; |
| 21 |
|
import java.lang.reflect.Method; |
| 22 |
|
import java.util.ArrayList; |
| 23 |
|
import java.util.List; |
| 24 |
|
import java.util.Set; |
| 25 |
|
|
|
|
|
| 0% |
Uncovered Elements: 69 (69) |
Complexity: 19 |
Complexity Density: 0.44 |
|
| 26 |
|
public final class TestUtilities { |
| 27 |
|
|
| 28 |
|
private static Thread exceptionThreader; |
| 29 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 30 |
0
|
private TestUtilities() {... |
| 31 |
0
|
throw new UnsupportedOperationException("do not call"); |
| 32 |
|
} |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
0
|
public static void waitForExceptionRouting() {... |
| 43 |
0
|
waitForExceptionRouting(5*60*1000); |
| 44 |
|
} |
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 46 |
0
|
public static void waitForExceptionRouting(long milliseconds) {... |
| 47 |
0
|
try { |
| 48 |
0
|
Thread thread = getExceptionThreader(); |
| 49 |
0
|
if (thread == null) { |
| 50 |
0
|
throw new IllegalStateException("No exception thread was established, likely message is not being processed for exception routing."); |
| 51 |
|
} |
| 52 |
0
|
thread.join(milliseconds); |
| 53 |
|
} catch (InterruptedException e) { |
| 54 |
0
|
Assert.fail("This thread was interuppted while waiting for exception routing."); |
| 55 |
|
} |
| 56 |
0
|
if (getExceptionThreader().isAlive()) { |
| 57 |
0
|
Assert.fail("Document was not put into exception routing within the specified amount of time " + milliseconds); |
| 58 |
|
} |
| 59 |
|
} |
| 60 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 61 |
0
|
public static Thread getExceptionThreader() {... |
| 62 |
0
|
return exceptionThreader; |
| 63 |
|
} |
| 64 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 65 |
0
|
public static void setExceptionThreader(Thread exceptionThreader) {... |
| 66 |
0
|
TestUtilities.exceptionThreader = exceptionThreader; |
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 69 |
0
|
protected static boolean contains(Class[] list, Class target) {... |
| 70 |
0
|
for (Class c: list) { |
| 71 |
0
|
if (c.getName().equals(target.getName())) { |
| 72 |
0
|
return true; |
| 73 |
|
} |
| 74 |
|
} |
| 75 |
0
|
return false; |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
@throws |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 98 |
0
|
public static List<Class> getHierarchyClassesToHandle(Class testClass, Class[] annotationClasses, Set<String> classesHandled) throws Exception {... |
| 99 |
0
|
List<Class> classesThatNeedHandling = new ArrayList<Class>(); |
| 100 |
|
|
| 101 |
0
|
List<Class> classesToCheck = new ArrayList<Class>(); |
| 102 |
|
|
| 103 |
|
{ |
| 104 |
0
|
Class clazz = testClass; |
| 105 |
0
|
superClassLoop: while (!clazz.getName().equals(Object.class.getName())) { |
| 106 |
0
|
for (Annotation annotation : clazz.getDeclaredAnnotations()) { |
| 107 |
|
|
| 108 |
0
|
if (!contains(annotationClasses, annotation.annotationType())) { |
| 109 |
0
|
continue; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
|
| 113 |
0
|
classesToCheck.add(0, clazz); |
| 114 |
|
|
| 115 |
|
|
| 116 |
0
|
if (annotationOverridesSuperClass(annotation)) { |
| 117 |
|
|
| 118 |
0
|
break superClassLoop; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
0
|
break; |
| 123 |
|
} |
| 124 |
0
|
clazz = clazz.getSuperclass(); |
| 125 |
|
} |
| 126 |
|
} |
| 127 |
|
|
| 128 |
0
|
for (Class clazz: classesToCheck) { |
| 129 |
0
|
if (!classesHandled.contains(clazz.getName())) { |
| 130 |
0
|
classesThatNeedHandling.add(clazz); |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
0
|
return classesThatNeedHandling; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
@param |
| 141 |
|
@return |
| 142 |
|
@throws |
| 143 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 144 |
0
|
protected static boolean annotationOverridesSuperClass(Annotation annotation) throws Exception {... |
| 145 |
0
|
boolean overrides = true; |
| 146 |
0
|
Method m = null;; |
| 147 |
0
|
try { |
| 148 |
0
|
m = annotation.getClass().getMethod("overrideSuperClasses", null); |
| 149 |
|
} catch (NoSuchMethodException nsme) { |
| 150 |
|
|
| 151 |
|
} |
| 152 |
0
|
if (m != null) { |
| 153 |
0
|
Object result = m.invoke(annotation, (Object[]) null); |
| 154 |
0
|
if (result instanceof Boolean) { |
| 155 |
0
|
overrides = (Boolean) result; |
| 156 |
|
} else { |
| 157 |
0
|
throw new RuntimeException("Annotation 'overrideSuperClasses' did not return Boolean value"); |
| 158 |
|
} |
| 159 |
|
} |
| 160 |
0
|
return overrides; |
| 161 |
|
} |
| 162 |
|
} |