Search in sources :

Example 1 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project cucumber-jvm by cucumber.

the class FeaturePathTest method can_parse_windows_absolute_path_form.

@Test
@EnabledOnOs(WINDOWS)
void can_parse_windows_absolute_path_form() {
    URI uri = FeaturePath.parse("C:\\path\\to\\file.feature");
    assertAll(() -> assertThat(uri.getScheme(), is(is("file"))), () -> assertThat(uri.getSchemeSpecificPart(), is("/C:/path/to/file.feature")));
}
Also used : URI(java.net.URI) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 2 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project cucumber-jvm by cucumber.

the class GluePathTest method absolute_windows_path_form_is_not_valid.

@Test
@EnabledOnOs(OS.WINDOWS)
void absolute_windows_path_form_is_not_valid() {
    Executable testMethod = () -> GluePath.parse("C:\\com\\example\\app");
    IllegalArgumentException actualThrown = assertThrows(IllegalArgumentException.class, testMethod);
    assertThat("Unexpected exception message", actualThrown.getMessage(), is(equalTo("The glue path must have a classpath scheme C:/com/example/app")));
}
Also used : Executable(org.junit.jupiter.api.function.Executable) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 3 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project neo4j by neo4j.

the class TransactionLogFileIT method doNotScanDirectoryOnRotate.

@Test
@EnabledOnOs(OS.LINUX)
void doNotScanDirectoryOnRotate() throws IOException {
    LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fileSystem).withTransactionIdStore(transactionIdStore).withLogVersionRepository(logVersionRepository).withStoreId(StoreId.UNKNOWN).build();
    life.add(logFiles);
    life.start();
    MutableLong rotationObservedVersion = new MutableLong();
    LogRotation logRotation = FileLogRotation.transactionLogRotation(logFiles, Clock.systemUTC(), new DatabaseHealth(NO_OP, NullLog.getInstance()), new LogRotationMonitorAdapter() {

        @Override
        public void startRotation(long currentLogVersion) {
            rotationObservedVersion.setValue(currentLogVersion);
        }
    });
    for (int i = 0; i < 6; i++) {
        for (Path path : logFiles.logFiles()) {
            FileUtils.deleteFile(path);
        }
        logRotation.rotateLogFile(LogAppendEvent.NULL);
    }
    assertEquals(5, rotationObservedVersion.getValue());
    assertEquals(6, logFiles.getLogFile().getCurrentLogVersion());
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) Path(java.nio.file.Path) MutableLong(org.apache.commons.lang3.mutable.MutableLong) FileLogRotation(org.neo4j.kernel.impl.transaction.log.rotation.FileLogRotation) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) LogRotationMonitorAdapter(org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitorAdapter) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 4 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project neo4j by neo4j.

the class RotatingLogFileWriterTest method rotationShouldCompressToGzipIfRequested.

@Test
@EnabledOnOs({ LINUX })
void rotationShouldCompressToGzipIfRequested() throws IOException {
    Path targetFile = dir.homePath().resolve("test.log");
    Path targetFile1 = dir.homePath().resolve("test.log.1.gz");
    writer = new RotatingLogFileWriter(fs, targetFile, 10, 2, ".gz", "");
    assertThat(fs.fileExists(targetFile)).isEqualTo(true);
    writer.printf("test string 1");
    writer.printf("test string 2");
    assertThat(fs.fileExists(targetFile)).isEqualTo(true);
    // The files are compressed asynchronously after the log rotation so wait for the file to exist.
    assertEventually(() -> fs.fileExists(targetFile1), bool -> bool, 5, TimeUnit.SECONDS);
    writer.close();
    assertThat(Files.readAllLines(targetFile)).containsExactly("test string 2");
    try (GZIPInputStream stream = new GZIPInputStream(Files.newInputStream(targetFile1))) {
        assertThat(UTF8.decode(stream.readAllBytes())).isEqualTo("test string 1" + System.lineSeparator());
    }
}
Also used : Path(java.nio.file.Path) GZIPInputStream(java.util.zip.GZIPInputStream) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 5 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project neo4j by neo4j.

the class TransactionLogChannelAllocatorIT method allocateNewTransactionLogFile.

@Test
@EnabledOnOs(OS.LINUX)
void allocateNewTransactionLogFile() throws IOException {
    PhysicalLogVersionedStoreChannel logChannel = fileAllocator.createLogChannel(10, () -> 1L);
    assertEquals(ROTATION_THRESHOLD, logChannel.size());
}
Also used : PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) 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