use of org.neo4j.test.extension.DisabledForRoot 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());
}
}
use of org.neo4j.test.extension.DisabledForRoot in project neo4j by neo4j.
the class NeoStoreOpenFailureTest method mustCloseAllStoresIfNeoStoresFailToOpen.
@Test
@DisabledForRoot
void mustCloseAllStoresIfNeoStoresFailToOpen() {
Config config = Config.defaults();
IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName());
LogProvider logProvider = NullLogProvider.getInstance();
RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
RecordFormatPropertyConfigurator.configureRecordFormat(formats, config);
boolean create = true;
StoreType[] storeTypes = StoreType.values();
ImmutableSet<OpenOption> openOptions = immutable.empty();
NeoStores neoStores = new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions);
Path schemaStore = neoStores.getSchemaStore().getStorageFile();
neoStores.close();
// Make the schema store inaccessible, to sabotage the next initialisation we'll do.
assumeTrue(schemaStore.toFile().setReadable(false));
assumeTrue(schemaStore.toFile().setWritable(false));
assertThrows(RuntimeException.class, () -> new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions));
// We verify that the successfully opened stores were closed again by the failed NeoStores open,
// by closing the page cache, which will throw if not all files have been unmapped.
pageCache.close();
}
use of org.neo4j.test.extension.DisabledForRoot in project neo4j by neo4j.
the class ConfigTest method mustThrowIfConfigFileCouldNotBeRead.
@Test
@DisabledForRoot
void mustThrowIfConfigFileCouldNotBeRead() throws IOException {
Path confFile = testDirectory.file("test.conf");
assertTrue(confFile.toFile().createNewFile());
assumeTrue(confFile.toFile().setReadable(false));
assertThrows(IllegalArgumentException.class, () -> Config.emptyBuilder().fromFile(confFile).build());
}
Aggregations