use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class ConfigTest method shouldCorrectlyEvaluateCommandFromFile.
@Test
// For some reason it does not work on our test instances on TC
@DisabledOnOs(OS.WINDOWS)
void shouldCorrectlyEvaluateCommandFromFile() throws IOException {
assumeUnixOrWindows();
Path confFile = testDirectory.file("test.conf");
Files.createFile(confFile);
Files.write(confFile, List.of(format("%s=$(expr 3 + 3)", TestSettings.intSetting.name())));
setPosixFilePermissions(confFile, permittedFilePermissionsForCommandExpansion);
// Given
Config config = Config.newBuilder().allowCommandExpansion().addSettingsClass(TestSettings.class).fromFile(confFile).build();
// Then
assertEquals(6, config.get(TestSettings.intSetting));
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class ConfigTest method testThatFileAttributePermissionsDoNotWork.
@Test
@DisabledOnOs(OS.WINDOWS)
void testThatFileAttributePermissionsDoNotWork() throws IOException {
// Given
Path confFile = testDirectory.file("test.conf");
Set<PosixFilePermission> permissions = PosixFilePermissions.fromString("rw---x-w-");
// When
Files.createFile(confFile, PosixFilePermissions.asFileAttribute(permissions));
// Then
// we would expect that the created file has all the permissions that we asked for...
assertThrows(AssertionError.class, () -> assertThat(Files.getPosixFilePermissions(confFile)).containsExactlyInAnyOrderElementsOf(permissions));
// why would you do this to us java ?!
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class ConfigTest method shouldEvaluateK8sConfDirWithCorrectFilePermission.
@Test
@DisabledOnOs({ OS.WINDOWS })
void shouldEvaluateK8sConfDirWithCorrectFilePermission() throws IOException {
var permittedPermissions = permittedFilePermissionsForCommandExpansion;
// Given
Path confDir = createK8sStyleConfigDir(permittedPermissions);
var testSetting = Files.createFile(confDir.resolve(TestSettings.intSetting.name()));
Files.write(testSetting, "$(expr 3 + 3)".getBytes());
Files.setPosixFilePermissions(testSetting, permittedPermissions);
Config.Builder configBuilder = Config.newBuilder().allowCommandExpansion().addSettingsClass(TestSettings.class).fromFile(confDir);
// Then
Config config = buildWithoutErrorsOrWarnings(configBuilder::build);
assertEquals(6, config.get(TestSettings.intSetting));
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class ConfigTest method testForbiddenFilePermissionsShouldBeInvalidWhenCombinedWithPermittedPermissionsForK8sConfDir.
@DisabledOnOs({ OS.WINDOWS })
@ParameterizedTest(name = "{0}")
@MethodSource("forbiddenFilePermissions")
void testForbiddenFilePermissionsShouldBeInvalidWhenCombinedWithPermittedPermissionsForK8sConfDir(Set<PosixFilePermission> forbidden) throws IOException {
// Given
Set<PosixFilePermission> permittedPermissions = permittedFilePermissionsForCommandExpansion;
Path confDir = createK8sStyleConfigDir(Sets.union(permittedPermissions, forbidden));
Config.Builder builder = Config.newBuilder().allowCommandExpansion().addSettingsClass(TestSettings.class).fromFile(confDir);
// when
String errorMessage = assertThrows(IllegalArgumentException.class, builder::build).getMessage();
// then
assertThat(errorMessage).contains("does not have the correct file permissions to evaluate commands");
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project assertj-core by joel-costigliola.
the class Paths_assertHasSameTextualContentAs_Test method should_fail_if_actual_is_not_readable.
@Test
@DisabledOnOs(value = WINDOWS, disabledReason = "gh-2312")
void should_fail_if_actual_is_not_readable() throws IOException {
// GIVEN
Path actual = createFile(tempDir.resolve("actual"));
actual.toFile().setReadable(false);
Path expected = createFile(tempDir.resolve("expected"));
// WHEN
AssertionError error = expectAssertionError(() -> paths.assertHasSameTextualContentAs(info, actual, CHARSET, expected, CHARSET));
// THEN
then(error).hasMessage(shouldBeReadable(actual).create());
}
Aggregations