示例#1
0
 @Test
 public void testIterator() {
   PathIterator it = PathIterator.of(Paths.get(""));
   for (Path path : it) {
     assertEquals(Paths.get(""), path);
     break;
   }
 }
示例#2
0
 @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);
 }
示例#3
0
 @Test
 public void testStreamOfPath() {
   Stream<Path> st = PathIterator.streamOf(Paths.get(""));
   ImmArray<Path> a = ImmArray.of(st);
   assertEquals(Paths.get(""), a.head());
 }