214 }
215
216 private static Object getListener(Object bean, String fieldName) {
217 try {
218 Class clazz = bean.getClass();
219 Field field = clazz.getDeclaredField(fieldName);
220 field.setAccessible(true);
221 return field.get(bean);
222 } catch (Exception e) {
223 e.printStackTrace();
224 }
225 return null;
226 }
227
228 private static List getObservableValueListeners(ObservableValue value) {
229 ArrayList results = new ArrayList();
230 results.addAll(ExpressionHelperUtility.getChangeListeners(value));
231 results.addAll(ExpressionHelperUtility.getInvalidationListeners(value));
232 return results;
233 }
234 }
|
214 }
215
216 private static Object getListener(Object bean, String fieldName) {
217 try {
218 Class clazz = bean.getClass();
219 Field field = clazz.getDeclaredField(fieldName);
220 field.setAccessible(true);
221 return field.get(bean);
222 } catch (Exception e) {
223 e.printStackTrace();
224 }
225 return null;
226 }
227
228 private static List getObservableValueListeners(ObservableValue value) {
229 ArrayList results = new ArrayList();
230 results.addAll(ExpressionHelperUtility.getChangeListeners(value));
231 results.addAll(ExpressionHelperUtility.getInvalidationListeners(value));
232 return results;
233 }
234
235 // methods for temporary setting UncaughtExceptionHandler
236 public static Thread.UncaughtExceptionHandler setHandler() {
237 Thread.UncaughtExceptionHandler exceptionHandler = Thread.currentThread().getUncaughtExceptionHandler();
238 Thread.currentThread().setUncaughtExceptionHandler((Thread t, Throwable e) -> {
239 e.printStackTrace();
240 throw new AssertionError(e);
241 });
242 return exceptionHandler;
243 }
244
245 // the test should call this method in the finally block to ensure
246 // that the handler is reset
247 public static void resetHandler(Thread.UncaughtExceptionHandler exceptionHandler) {
248 Thread.currentThread().setUncaughtExceptionHandler(exceptionHandler);
249 }
250 }
|