public void testParserCygwin() throws Exception { final Map map = checkStream("CYGWIN_NT-5.1"); final FileAttributes o = (FileAttributes) map.get( "src/main/java/org/codehaus/plexus/components/io/attributes/AttributeConstants.java"); // -rw-r--r-- 1 1020 1030 11108 Mar 16 22:42 build.xml assertEquals("-rw-r--r--", new String(o.getLsModeParts())); assertEquals(203222, o.getUserId().intValue()); assertEquals(10513, o.getGroupId().intValue()); }
public void testParserUbuntu10_04_en() throws Exception { final Map map = checkStream("Linux"); final FileAttributes o = (FileAttributes) map.get( "src/main/java/org/codehaus/plexus/components/io/attributes/AttributeConstants.java"); // -rw-r--r-- 1 1020 1030 11108 Mar 16 22:42 build.xml assertEquals("-rw-rw-r--", new String(o.getLsModeParts())); assertEquals(1020, o.getUserId().intValue()); assertEquals(1030, o.getGroupId().intValue()); // Should probably test pass 2 too... }
public void testReversedMonthDayOrder() throws Exception { String output = // "-rw-r--r-- 1 501 80 7683 31 May 10:06 pom_newer.xml\n" + // "-rwxr--r-- 1 502 81 7683 1 Jun 2010 pom_older.xml"; InputStream byteArrayInputStream = new ByteArrayInputStream(output.getBytes()); NumericUserIDAttributeParser parser = getNumericParser(); parse(byteArrayInputStream, parser); Map<String, PlexusIoResourceAttributes> map = parser.getAttributesByPath(); // 6 months or newer ls date format FileAttributes newerFileAttr = (FileAttributes) map.get("pom_newer.xml"); assertNotNull(newerFileAttr); assertEquals("-rw-r--r--", new String(newerFileAttr.getLsModeParts())); assertEquals(501, newerFileAttr.getUserId().intValue()); assertEquals(80, newerFileAttr.getGroupId().intValue()); // older than 6 months ls date format FileAttributes olderFileAttr = (FileAttributes) map.get("pom_older.xml"); assertNotNull(olderFileAttr); assertEquals("-rwxr--r--", new String(olderFileAttr.getLsModeParts())); assertEquals(502, olderFileAttr.getUserId().intValue()); assertEquals(81, olderFileAttr.getGroupId().intValue()); }