// Tests whether an iterator's next method throws // a NoSuchElementException private void catchNoSuchElementException (String name, Iterator it) { boolean result = true; try { it.next(); result = false; // this should not happen } catch (NoSuchElementException e) { result = true; // this should happen } catch (Exception e) { result = false; // this should not happen } finally { assertTrue (name, result); } }