Search in sources :

Example 36 with EnabledOnOs

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();
}
Also used : HttpServletRequest(jakarta.servlet.http.HttpServletRequest) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) File(java.io.File) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)36 EnabledOnOs (org.junit.jupiter.api.condition.EnabledOnOs)36 File (java.io.File)14 Path (java.nio.file.Path)7 URI (java.net.URI)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 EnabledForRepository (org.opengrok.indexer.condition.EnabledForRepository)5 TestRepository (org.opengrok.indexer.util.TestRepository)5 URL (java.net.URL)3 URLClassLoader (java.net.URLClassLoader)3 Date (java.util.Date)3 LinkedList (java.util.LinkedList)3 StringBinding (javafx.beans.binding.StringBinding)3 DisplayName (org.junit.jupiter.api.DisplayName)3 EnabledIf (org.junit.jupiter.api.condition.EnabledIf)3 CommandLine (com.thoughtworks.go.util.command.CommandLine)2 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)2 HashSet (java.util.HashSet)2 DummyHttpServletRequest (org.opengrok.indexer.web.DummyHttpServletRequest)2 NantTask (com.thoughtworks.go.config.NantTask)1