use of org.junit.jupiter.api.condition.EnabledOnOs in project OpenGrok by OpenGrok.
the class PageConfigTest method testCheckSourceRootExistence4.
/**
* Test the case when source root can not be read.
* @throws IOException I/O exception
*/
@Test
@EnabledOnOs({ OS.LINUX, OS.MAC, OS.SOLARIS, OS.AIX, OS.OTHER })
public void testCheckSourceRootExistence4() throws IOException {
HttpServletRequest req = new DummyHttpServletRequest();
PageConfig cfg = PageConfig.get(req);
String path = RuntimeEnvironment.getInstance().getSourceRootPath();
File temp = File.createTempFile("opengrok", "-test-file.tmp");
Files.delete(temp.toPath());
Files.createDirectories(temp.toPath());
// skip the test if the implementation does not permit setting permissions
assumeTrue(temp.setReadable(false));
RuntimeEnvironment.getInstance().setSourceRoot(temp.getAbsolutePath());
assertThrows(IOException.class, () -> cfg.checkSourceRootExistence(), "This should throw an exception when the file is not readable");
RuntimeEnvironment.getInstance().setSourceRoot(path);
PageConfig.cleanup(req);
temp.deleteOnExit();
}
Aggregations