158 assertEquals(tr.testOutput.stream() 159 .filter(s -> s.startsWith("WARNING")) 160 .peek(s -> assertTrue(s.contains("not a directory"))) 161 .count(), 162 1, "only show error once"); 163 tr.assertZero("Should still return 0"); 164 } 165 166 @Test 167 public void testDumpDirNotWritable() throws IOException { 168 if (! Files.getFileStore(Paths.get(".")) 169 .supportsFileAttributeView(PosixFileAttributeView.class)) { 170 // No easy way to setup readonly directory without POSIX 171 // We would like to skip the test with a cause with 172 // throw new SkipException("Posix not supported"); 173 // but jtreg will report failure so we just pass the test 174 // which we can look at if jtreg changed its behavior 175 return; 176 } 177 178 Files.createDirectory(Paths.get("readOnly"), 179 asFileAttribute(fromString("r-xr-xr-x"))); 180 181 TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), 182 "-cp", ".", 183 "-Djdk.internal.lambda.dumpProxyClasses=readOnly", 184 "-Djava.security.manager", 185 "com.example.TestLambda"); 186 assertEquals(tr.testOutput.stream() 187 .filter(s -> s.startsWith("WARNING")) 188 .peek(s -> assertTrue(s.contains("not writable"))) 189 .count(), 190 1, "only show error once"); 191 tr.assertZero("Should still return 0"); 192 193 TestUtil.removeAll(Paths.get("readOnly")); 194 } 195 196 @Test 197 public void testLoggingException() throws IOException { | 158 assertEquals(tr.testOutput.stream() 159 .filter(s -> s.startsWith("WARNING")) 160 .peek(s -> assertTrue(s.contains("not a directory"))) 161 .count(), 162 1, "only show error once"); 163 tr.assertZero("Should still return 0"); 164 } 165 166 @Test 167 public void testDumpDirNotWritable() throws IOException { 168 if (! Files.getFileStore(Paths.get(".")) 169 .supportsFileAttributeView(PosixFileAttributeView.class)) { 170 // No easy way to setup readonly directory without POSIX 171 // We would like to skip the test with a cause with 172 // throw new SkipException("Posix not supported"); 173 // but jtreg will report failure so we just pass the test 174 // which we can look at if jtreg changed its behavior 175 return; 176 } 177 178 if ("root".equals(System.getProperty("user.name"))) { 179 // Super user can create files in read-only directories (at least on Linux & Solaris). 180 // The test is not applicable in that case. 181 return; 182 } 183 184 Files.createDirectory(Paths.get("readOnly"), 185 asFileAttribute(fromString("r-xr-xr-x"))); 186 187 TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), 188 "-cp", ".", 189 "-Djdk.internal.lambda.dumpProxyClasses=readOnly", 190 "-Djava.security.manager", 191 "com.example.TestLambda"); 192 assertEquals(tr.testOutput.stream() 193 .filter(s -> s.startsWith("WARNING")) 194 .peek(s -> assertTrue(s.contains("not writable"))) 195 .count(), 196 1, "only show error once"); 197 tr.assertZero("Should still return 0"); 198 199 TestUtil.removeAll(Paths.get("readOnly")); 200 } 201 202 @Test 203 public void testLoggingException() throws IOException { |