Search in sources :

Example 66 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project dropwizard by dropwizard.

the class DropwizardSSLConnectionSocketFactoryTest method shouldReturn200IfAbleToClientAuthSpecifyingCertAliasForGoodCert.

@Test
// https://github.com/dropwizard/dropwizard/issues/4330
@DisabledOnOs(OS.WINDOWS)
void shouldReturn200IfAbleToClientAuthSpecifyingCertAliasForGoodCert() throws Exception {
    tlsConfiguration.setKeyStorePath(toFile("stores/client/twokeys.p12"));
    tlsConfiguration.setKeyStorePassword("password");
    tlsConfiguration.setKeyStoreType("PKCS12");
    tlsConfiguration.setCertAlias("1");
    final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).build("client_auth_using_cert_alias_working");
    final Response response = client.target(String.format("https://localhost:%d", TLS_APP_RULE.getPort(2))).request().get();
    assertThat(response.getStatus()).isEqualTo(200);
}
Also used : ClientResponse(org.glassfish.jersey.client.ClientResponse) Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 67 with DisabledOnOs

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

the class SingleFilePageSwapperTest method mustCloseFilesIfTakingFileLockThrows.

@Test
@DisabledOnOs(OS.WINDOWS)
void mustCloseFilesIfTakingFileLockThrows() throws Exception {
    final AtomicInteger openFilesCounter = new AtomicInteger();
    PageSwapperFactory factory = createSwapperFactory(new DelegatingFileSystemAbstraction(fileSystem) {

        @Override
        public StoreChannel open(Path fileName, Set<OpenOption> options) throws IOException {
            openFilesCounter.getAndIncrement();
            return new DelegatingStoreChannel(super.open(fileName, options)) {

                @Override
                public void close() throws IOException {
                    openFilesCounter.getAndDecrement();
                    super.close();
                }
            };
        }
    });
    Path file = testDir.file("file");
    try (StoreChannel ch = fileSystem.write(file);
        FileLock ignore = ch.tryLock()) {
        createSwapper(factory, file, 4, NO_CALLBACK, false).close();
        fail("Creating a page swapper for a locked channel should have thrown");
    } catch (FileLockException e) {
    // As expected.
    }
    assertThat(openFilesCounter.get()).isEqualTo(0);
}
Also used : Path(java.nio.file.Path) PageSwapperFactory(org.neo4j.io.pagecache.PageSwapperFactory) OpenOption(java.nio.file.OpenOption) OverlappingFileLockException(java.nio.channels.OverlappingFileLockException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StoreChannel(org.neo4j.io.fs.StoreChannel) DelegatingStoreChannel(org.neo4j.io.fs.DelegatingStoreChannel) FileLock(java.nio.channels.FileLock) DelegatingStoreChannel(org.neo4j.io.fs.DelegatingStoreChannel) IOException(java.io.IOException) DelegatingFileSystemAbstraction(org.neo4j.io.fs.DelegatingFileSystemAbstraction) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) PageSwapperTest(org.neo4j.io.pagecache.PageSwapperTest) Test(org.junit.jupiter.api.Test)

Example 68 with DisabledOnOs

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

the class SingleFilePageSwapperTest method mustUnlockFileWhenThePageSwapperIsClosed.

@Test
@DisabledOnOs(OS.WINDOWS)
void mustUnlockFileWhenThePageSwapperIsClosed() throws Exception {
    PageSwapperFactory factory = createSwapperFactory(fileSystem);
    Path file = testDir.file("file");
    ((StoreChannel) fileSystem.write(file)).close();
    createSwapper(factory, file, 4, NO_CALLBACK, false).close();
    try (StoreFileChannel channel = fileSystem.write(file);
        FileLock fileLock = channel.tryLock()) {
        assertThat(fileLock).isNotNull();
    }
}
Also used : Path(java.nio.file.Path) PageSwapperFactory(org.neo4j.io.pagecache.PageSwapperFactory) StoreFileChannel(org.neo4j.io.fs.StoreFileChannel) StoreChannel(org.neo4j.io.fs.StoreChannel) DelegatingStoreChannel(org.neo4j.io.fs.DelegatingStoreChannel) FileLock(java.nio.channels.FileLock) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) PageSwapperTest(org.neo4j.io.pagecache.PageSwapperTest) Test(org.junit.jupiter.api.Test)

Example 69 with DisabledOnOs

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

the class LoaderTest method shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsNotWritable.

@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsNotWritable() throws IOException {
    Path archive = testDirectory.file("the-archive.dump");
    Path destination = testDirectory.directory("subdir/the-destination");
    DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(destination);
    Path parentPath = databaseLayout.databaseDirectory().getParent();
    try (Closeable ignored = withPermissions(parentPath, emptySet())) {
        AccessDeniedException exception = assertThrows(AccessDeniedException.class, () -> new Loader().load(archive, databaseLayout));
        assertEquals(parentPath.toString(), exception.getMessage());
    }
}
Also used : Path(java.nio.file.Path) AccessDeniedException(java.nio.file.AccessDeniedException) Closeable(java.io.Closeable) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test) DisabledForRoot(org.neo4j.test.extension.DisabledForRoot)

Example 70 with DisabledOnOs

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

the class DefaultFileSystemWatcherTest method shouldHandleMultipleSubscribersToSameFile.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldHandleMultipleSubscribersToSameFile() throws Exception {
    try (OtherThreadExecutor executor = new OtherThreadExecutor("watcher");
        DefaultFileSystemWatcher watcher = new DefaultFileSystemWatcher(FileSystems.getDefault().newWatchService())) {
        // Given
        AssertableFileEventListener listener = new AssertableFileEventListener();
        watcher.addFileWatchEventListener(listener);
        Path foo = testDirectory.createFile("foo");
        Path bar = testDirectory.createFile("bar");
        executor.executeDontWait(() -> {
            try {
                watcher.startWatching();
            } catch (Exception ignored) {
            // Expected
            }
            return null;
        });
        WatchedResource firstWatch = watcher.watch(testDirectory.homePath());
        firstWatch.close();
        assertThat(firstWatch.getWatchKey().isValid()).isFalse();
        WatchedResource secondWatch = watcher.watch(testDirectory.homePath());
        WatchedResource thirdWatch = watcher.watch(testDirectory.homePath());
        executor.waitUntilWaiting(location -> location.isAt(DefaultFileSystemWatcher.class, "startWatching"));
        // When
        testDirectory.getFileSystem().delete(foo);
        // Then
        assertEventually("Foo deleted", () -> listener.containsDeleted("foo"), TRUE, 30, SECONDS);
        // When
        // Closing the first should still allow the second to observe deletions
        secondWatch.close();
        assertThat(thirdWatch.getWatchKey().isValid()).isTrue();
        testDirectory.getFileSystem().delete(bar);
        assertEventually("Bar deleted", () -> listener.containsDeleted("bar"), TRUE, 30, SECONDS);
        thirdWatch.close();
        assertThat(thirdWatch.getWatchKey().isValid()).isFalse();
    }
}
Also used : Path(java.nio.file.Path) OtherThreadExecutor(org.neo4j.test.OtherThreadExecutor) WatchedResource(org.neo4j.io.fs.watcher.resource.WatchedResource) IOException(java.io.IOException) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)87 Test (org.junit.jupiter.api.Test)80 Path (java.nio.file.Path)39 File (java.io.File)26 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 PathsBaseTest (org.assertj.core.internal.PathsBaseTest)12 AssertionsUtil.expectAssertionError (org.assertj.core.util.AssertionsUtil.expectAssertionError)11 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)6 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)6 PageSwapperTest (org.neo4j.io.pagecache.PageSwapperTest)6 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)5 DelegatingStoreChannel (org.neo4j.io.fs.DelegatingStoreChannel)5 StoreChannel (org.neo4j.io.fs.StoreChannel)5 DisabledForRoot (org.neo4j.test.extension.DisabledForRoot)5 Closeable (java.io.Closeable)4 URI (java.net.URI)4 FileUtils.writeByteArrayToFile (org.apache.commons.io.FileUtils.writeByteArrayToFile)4 ShouldBeFile.shouldBeFile (org.assertj.core.error.ShouldBeFile.shouldBeFile)4 FilesBaseTest (org.assertj.core.internal.FilesBaseTest)4 Files.newFile (org.assertj.core.util.Files.newFile)4