@Test public void testIterator() { PathIterator it = PathIterator.of(Paths.get("")); for (Path path : it) { assertEquals(Paths.get(""), path); break; } }
@Test public void testErr() { // prepare mock STDERR PrintStream err = System.err; ByteArrayOutputStream bos = new ByteArrayOutputStream(); System.setErr(new PrintStream(bos)); // main PathIterator x = PathIterator.of(Paths.get("")); x.err(new IOException("test1"), Paths.get(".")); assertEquals("potf: '.': test1 (IOException)", StringUtils.chomp(bos.toString())); bos.reset(); x.err(new AccessDeniedException("test2"), Paths.get(".")); assertEquals("potf: '.': access denied", StringUtils.chomp(bos.toString())); bos.reset(); x.err(new NoSuchFileException("test3"), Paths.get(".")); assertEquals("potf: '.': no such file or directory", StringUtils.chomp(bos.toString())); // restore STDERR System.setErr(err); }