@Test public void noSuchFile() throws IOException { List<LsOutputBean> beans = new LsOutputParser().parse(stream("no-such-file.txt")); Assert.assertTrue(beans.isEmpty()); }
@Test public void nameWithSpaces() throws IOException { List<LsOutputBean> beans = new LsOutputParser().parse(stream("name-with-spaces.txt")); Assert.assertEquals(4, beans.size()); Assert.assertEquals("dir name", beans.get(0).getName()); Assert.assertEquals("file name", beans.get(1).getName()); Assert.assertEquals("file 2", beans.get(2).getName()); Assert.assertEquals("link name", beans.get(3).getName()); Assert.assertEquals("/absolute/link target", beans.get(3).getLinkTarget()); }
@Test public void symLink() throws IOException { List<LsOutputBean> beans = new LsOutputParser().parse(stream("sym-link.txt")); Assert.assertEquals(1, beans.size()); LsOutputBean link = beans.get(0); Assert.assertFalse(link.isDir()); Assert.assertFalse(link.isFile()); Assert.assertTrue(link.isLink()); Assert.assertEquals("link_name", link.getName()); Assert.assertEquals("/absolute/link/target", link.getLinkTarget()); Assert.assertNotNull(link.getDate()); Assert.assertTrue(link.getDate().getTime() > 0); }
@Test public void good() throws IOException { List<LsOutputBean> beans = new LsOutputParser().parse(stream("good.txt")); Assert.assertEquals(3, beans.size());
@Test public void noLinkCount() throws IOException { List<LsOutputBean> beans = new LsOutputParser().parse(stream("no-link-count.txt")); Assert.assertEquals(3, beans.size());