mirror of
https://github.com/apache/maven-mvnd.git
synced 2026-01-13 07:04:14 +08:00
Support short variants of boolean properties #279
This commit is contained in:
@@ -596,7 +596,8 @@ public class DaemonParameters {
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
return Boolean.parseBoolean(get());
|
||||
final String val = get();
|
||||
return "".equals(val) || Boolean.parseBoolean(val);
|
||||
}
|
||||
|
||||
public int asInt() {
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mvndaemon.mvnd.client.DaemonParameters.EnvValue;
|
||||
import org.mvndaemon.mvnd.client.DaemonParameters.ValueSource;
|
||||
import org.mvndaemon.mvnd.common.Environment;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -119,6 +121,14 @@ public class EnvironmentTest {
|
||||
assertEquals("C:\\jdk-11.0.2\\", Environment.cygpath("/cygdrive/c/jdk-11.0.2/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyBooleanEnvValueIsTrue() {
|
||||
final String EMPTY_STRING = "";
|
||||
final EnvValue envVal = new EnvValue(Environment.MVND_NO_BUFERING,
|
||||
new ValueSource(sb -> sb.append("envValueAsBoolean"), () -> EMPTY_STRING));
|
||||
assertEquals(true, envVal.asBoolean());
|
||||
}
|
||||
|
||||
static class EnvironmentResource implements AutoCloseable {
|
||||
|
||||
private final Properties props = new Properties();
|
||||
|
||||
Reference in New Issue
Block a user