aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src/test/java
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-08-08 11:27:03 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-08-08 12:05:12 +0200
commit17a40828946cf3c133b3d8d3ed441c4697bd3229 (patch)
tree4863d984248e420c3dd060264eef3549eaf8e413 /server/sonar-process/src/test/java
parenta9611c345fd6ad51c37f9470b1b08fea0e062946 (diff)
downloadsonarqube-17a40828946cf3c133b3d8d3ed441c4697bd3229.tar.gz
sonarqube-17a40828946cf3c133b3d8d3ed441c4697bd3229.zip
SONAR-4898 - Modularized sonar-process for tests
Diffstat (limited to 'server/sonar-process/src/test/java')
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/AesCipherTest.java185
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java55
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/EncryptionTest.java59
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/MinimumViableSystemTest.java79
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java61
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java68
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/PropsTest.java96
7 files changed, 0 insertions, 603 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/AesCipherTest.java b/server/sonar-process/src/test/java/org/sonar/process/AesCipherTest.java
deleted file mode 100644
index 8350eafaa3e..00000000000
--- a/server/sonar-process/src/test/java/org/sonar/process/AesCipherTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.process;
-
-import com.google.common.io.Resources;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang.StringUtils;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import javax.crypto.BadPaddingException;
-import java.io.File;
-import java.security.InvalidKeyException;
-import java.security.Key;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-
-public class AesCipherTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void generateRandomSecretKey() {
- AesCipher cipher = new AesCipher(null);
-
- String key = cipher.generateRandomSecretKey();
-
- assertThat(StringUtils.isNotBlank(key)).isTrue();
- assertThat(Base64.isArrayByteBase64(key.getBytes())).isTrue();
- }
-
- @Test
- public void encrypt() throws Exception {
- AesCipher cipher = new AesCipher(pathToSecretKey());
-
- String encryptedText = cipher.encrypt("this is a secret");
-
- assertThat(StringUtils.isNotBlank(encryptedText)).isTrue();
- assertThat(Base64.isArrayByteBase64(encryptedText.getBytes())).isTrue();
- }
-
- @Test
- public void encrypt_bad_key() throws Exception {
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("Invalid AES key");
-
- AesCipher cipher = new AesCipher(getPath("bad_secret_key.txt"));
-
- cipher.encrypt("this is a secret");
- }
-
- @Test
- public void decrypt() throws Exception {
- AesCipher cipher = new AesCipher(pathToSecretKey());
-
- // the following value has been encrypted with the key /org/sonar/api/config/AesCipherTest/aes_secret_key.txt
- String clearText = cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
-
- assertThat(clearText).isEqualTo("this is a secret");
- }
-
- @Test
- public void decrypt_bad_key() throws Exception {
- AesCipher cipher = new AesCipher(getPath("bad_secret_key.txt"));
-
- try {
- cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
- fail();
-
- } catch (RuntimeException e) {
- assertThat(e.getCause()).isInstanceOf(InvalidKeyException.class);
- }
- }
-
- @Test
- public void decrypt_other_key() throws Exception {
- AesCipher cipher = new AesCipher(getPath("other_secret_key.txt"));
-
- try {
- // text encrypted with another key
- cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
- fail();
-
- } catch (RuntimeException e) {
- assertThat(e.getCause()).isInstanceOf(BadPaddingException.class);
- }
- }
-
- @Test
- public void encryptThenDecrypt() throws Exception {
- AesCipher cipher = new AesCipher(pathToSecretKey());
-
- assertThat(cipher.decrypt(cipher.encrypt("foo"))).isEqualTo("foo");
- }
-
- @Test
- public void testDefaultPathToSecretKey() {
- AesCipher cipher = new AesCipher(null);
-
- String path = cipher.getPathToSecretKey();
-
- assertThat(StringUtils.isNotBlank(path)).isTrue();
- assertThat(new File(path).getName()).isEqualTo("sonar-secret.txt");
- }
-
- @Test
- public void loadSecretKeyFromFile() throws Exception {
- AesCipher cipher = new AesCipher(null);
- Key secretKey = cipher.loadSecretFileFromFile(pathToSecretKey());
- assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
- assertThat(secretKey.getEncoded().length).isGreaterThan(10);
- }
-
- @Test
- public void loadSecretKeyFromFile_trim_content() throws Exception {
- String path = getPath("non_trimmed_secret_key.txt");
- AesCipher cipher = new AesCipher(null);
-
- Key secretKey = cipher.loadSecretFileFromFile(path);
-
- assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
- assertThat(secretKey.getEncoded().length).isGreaterThan(10);
- }
-
- @Test
- public void loadSecretKeyFromFile_file_does_not_exist() throws Exception {
- thrown.expect(IllegalStateException.class);
-
- AesCipher cipher = new AesCipher(null);
- cipher.loadSecretFileFromFile("/file/does/not/exist");
- }
-
- @Test
- public void loadSecretKeyFromFile_no_property() throws Exception {
- thrown.expect(IllegalStateException.class);
-
- AesCipher cipher = new AesCipher(null);
- cipher.loadSecretFileFromFile(null);
- }
-
- @Test
- public void hasSecretKey() throws Exception {
- AesCipher cipher = new AesCipher(pathToSecretKey());
-
- assertThat(cipher.hasSecretKey()).isTrue();
- }
-
- @Test
- public void doesNotHaveSecretKey() throws Exception {
- AesCipher cipher = new AesCipher("/my/twitter/id/is/SimonBrandhof");
-
- assertThat(cipher.hasSecretKey()).isFalse();
- }
-
- private static String getPath(String file) {
- return Resources.getResource(AesCipherTest.class, "AesCipherTest/" + file).getPath();
- }
-
- private static String pathToSecretKey() throws Exception {
- return getPath("aes_secret_key.txt");
- }
-
-}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
deleted file mode 100644
index 6191eb2ba1f..00000000000
--- a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.process;
-
-import com.google.common.collect.Maps;
-import org.junit.Test;
-
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class ConfigurationUtilsTest {
- @Test
- public void shouldInterpolateVariables() {
- Properties input = new Properties();
- input.setProperty("hello", "world");
- input.setProperty("url", "${env:SONAR_JDBC_URL}");
- input.setProperty("do_not_change", "${SONAR_JDBC_URL}");
- Map<String, String> variables = Maps.newHashMap();
- variables.put("SONAR_JDBC_URL", "jdbc:h2:mem");
-
- Properties output = ConfigurationUtils.interpolateVariables(input, variables);
-
- assertThat(output.size(), is(3));
- assertThat(output.getProperty("hello"), is("world"));
- assertThat(output.getProperty("url"), is("jdbc:h2:mem"));
- assertThat(output.getProperty("do_not_change"), is("${SONAR_JDBC_URL}"));
-
- // input is not changed
- assertThat(input.size(), is(3));
- assertThat(input.getProperty("hello"), is("world"));
- assertThat(input.getProperty("url"), is("${env:SONAR_JDBC_URL}"));
- assertThat(input.getProperty("do_not_change"), is("${SONAR_JDBC_URL}"));
- }
-
-}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/EncryptionTest.java b/server/sonar-process/src/test/java/org/sonar/process/EncryptionTest.java
deleted file mode 100644
index 0c11856b0fa..00000000000
--- a/server/sonar-process/src/test/java/org/sonar/process/EncryptionTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.process;
-
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class EncryptionTest {
-
- @Test
- public void isEncrypted() {
- Encryption encryption = new Encryption(null);
- assertThat(encryption.isEncrypted("{aes}ADASDASAD"), is(true));
- assertThat(encryption.isEncrypted("{b64}ADASDASAD"), is(true));
- assertThat(encryption.isEncrypted("{abc}ADASDASAD"), is(true));
-
- assertThat(encryption.isEncrypted("{}"), is(false));
- assertThat(encryption.isEncrypted("{foo"), is(false));
- assertThat(encryption.isEncrypted("foo{aes}"), is(false));
- }
-
- @Test
- public void decrypt() {
- Encryption encryption = new Encryption(null);
- assertThat(encryption.decrypt("{b64}Zm9v"), is("foo"));
- }
-
- @Test
- public void decrypt_unknown_algorithm() {
- Encryption encryption = new Encryption(null);
- assertThat(encryption.decrypt("{xxx}Zm9v"), is("{xxx}Zm9v"));
- }
-
- @Test
- public void decrypt_uncrypted_text() {
- Encryption encryption = new Encryption(null);
- assertThat(encryption.decrypt("foo"), is("foo"));
- }
-}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/MinimumViableSystemTest.java b/server/sonar-process/src/test/java/org/sonar/process/MinimumViableSystemTest.java
deleted file mode 100644
index 11088902b14..00000000000
--- a/server/sonar-process/src/test/java/org/sonar/process/MinimumViableSystemTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.process;
-
-import org.fest.assertions.Assertions;
-import org.junit.Test;
-
-import static org.fest.assertions.Fail.fail;
-
-public class MinimumViableSystemTest {
-
- /**
- * Verifies that all checks can be verified without error.
- * Test environment does not necessarily follows all checks.
- */
- @Test
- public void check() throws Exception {
- MinimumViableSystem mve = new MinimumViableSystem();
-
- try {
- mve.check();
- // ok
- } catch (MessageException e) {
- // also ok. All other exceptions are errors.
- }
- }
-
- @Test
- public void checkJavaVersion() throws Exception {
- MinimumViableSystem mve = new MinimumViableSystem();
-
- // yes, sources are compiled with a supported Java version!
- mve.checkJavaVersion();
-
- mve.checkJavaVersion("1.6.1_b2");
- try {
- mve.checkJavaVersion("1.5.2");
- fail();
- } catch (MessageException e) {
- Assertions.assertThat(e).hasMessage("Minimal required Java version is 1.6. Got 1.5.2.");
- }
- }
-
- @Test
- public void checkJavaOption() throws Exception {
- String key = "MinimumViableEnvironmentTest.test.prop";
- MinimumViableSystem mve = new MinimumViableSystem()
- .setRequiredJavaOption(key, "true");
-
- try {
- System.setProperty(key, "false");
- mve.checkJavaOptions();
- fail();
- } catch (MessageException e) {
- Assertions.assertThat(e).hasMessage("JVM option '" + key + "' must be set to 'true'. Got 'false'");
- }
-
- System.setProperty(key, "true");
- mve.checkJavaOptions();
- // do not fail
- }
-}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java
deleted file mode 100644
index 09f6a597209..00000000000
--- a/server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.process;
-
-import org.junit.Test;
-
-import java.net.ServerSocket;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class NetworkUtilsTest {
-
-
- @Test
- public void find_free_port() throws Exception {
- int port = NetworkUtils.freePort();
- assertThat(port).isGreaterThan(1024);
- }
-
- @Test
- public void find_multiple_free_port() throws Exception {
- int port1 = NetworkUtils.freePort();
- int port2 = NetworkUtils.freePort();
-
- assertThat(port1).isGreaterThan(1024);
- assertThat(port2).isGreaterThan(1024);
-
- assertThat(port1).isNotSameAs(port2);
- }
-
- @Test
- public void find_multiple_free_non_adjacent_port() throws Exception {
- int port1 = NetworkUtils.freePort();
-
- ServerSocket socket = new ServerSocket(port1 + 1);
-
- int port2 = NetworkUtils.freePort();
-
- assertThat(port1).isGreaterThan(1024);
- assertThat(port2).isGreaterThan(1024);
-
- assertThat(port1).isNotSameAs(port2);
- }
-} \ No newline at end of file
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java
deleted file mode 100644
index 460983290b0..00000000000
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.process;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-
-public class ProcessWrapperTest {
-
- int freePort;
-
- @Before
- public void setup() throws IOException {
- ServerSocket socket = new ServerSocket(0);
- freePort = socket.getLocalPort();
- socket.close();
- }
-
-
- @Test
- public void has_dummy_app(){
-
- }
-
-
-// @Test
-// @Ignore("Not a good idea to assert on # of VMs")
-// public void process_should_run() throws IOException, MalformedObjectNameException, InterruptedException {
-//
-// LocalVirtualMachine.getAllVirtualMachines().size();
-// int VMcount = LocalVirtualMachine.getAllVirtualMachines().size();
-//
-// System.out.println("LocalVirtualMachine.getAllVirtualMachines() = " + LocalVirtualMachine.getAllVirtualMachines());
-//
-// RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
-// ProcessWrapper wrapper = wrapper = new ProcessWrapper(ProcessTest.TestProcess.class.getName(),
-// Collections.EMPTY_MAP, "TEST", freePort, runtime.getClassPath());
-//
-// assertThat(wrapper).isNotNull();
-// assertThat(wrapper.isReady()).isTrue();
-//
-// assertThat(LocalVirtualMachine.getAllVirtualMachines().size()).isEqualTo(VMcount + 1);
-//
-// wrapper.stop();
-// assertThat(LocalVirtualMachine.getAllVirtualMachines().size()).isEqualTo(VMcount);
-//
-// }
-} \ No newline at end of file
diff --git a/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java b/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java
deleted file mode 100644
index 775d24a2a64..00000000000
--- a/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.process;
-
-import org.junit.Test;
-
-import java.util.Properties;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class PropsTest {
-
- @Test
- public void of() throws Exception {
- Properties p = new Properties();
- p.setProperty("foo", "bar");
- Props props = new Props(p);
-
- assertThat(props.of("foo")).isEqualTo("bar");
- assertThat(props.of("foo", "default value")).isEqualTo("bar");
- assertThat(props.of("unknown")).isNull();
- assertThat(props.of("unknown", "default value")).isEqualTo("default value");
- }
-
- @Test
- public void intOf() throws Exception {
- Properties p = new Properties();
- p.setProperty("foo", "33");
- p.setProperty("blank", "");
- Props props = new Props(p);
-
- assertThat(props.intOf("foo")).isEqualTo(33);
- assertThat(props.intOf("foo", 44)).isEqualTo(33);
- assertThat(props.intOf("blank")).isNull();
- assertThat(props.intOf("blank", 55)).isEqualTo(55);
- assertThat(props.intOf("unknown")).isNull();
- assertThat(props.intOf("unknown", 44)).isEqualTo(44);
- }
-
- @Test
- public void intOf_not_integer() throws Exception {
- Properties p = new Properties();
- p.setProperty("foo", "bar");
- Props props = new Props(p);
-
- try {
- props.intOf("foo");
- fail();
- } catch (IllegalStateException e) {
- assertThat(e).hasMessage("Value of property foo is not an integer: bar");
- }
- }
-
- @Test
- public void booleanOf() throws Exception {
- Properties p = new Properties();
- p.setProperty("foo", "True");
- p.setProperty("bar", "false");
- Props props = new Props(p);
-
- assertThat(props.booleanOf("foo")).isTrue();
- assertThat(props.booleanOf("bar")).isFalse();
- assertThat(props.booleanOf("unknown")).isFalse();
- }
-
- @Test
- public void booleanOf_default_value() throws Exception {
- Properties p = new Properties();
- p.setProperty("foo", "true");
- p.setProperty("bar", "false");
- Props props = new Props(p);
-
- assertThat(props.booleanOf("unset", false)).isFalse();
- assertThat(props.booleanOf("unset", true)).isTrue();
- assertThat(props.booleanOf("foo", false)).isTrue();
- assertThat(props.booleanOf("bar", true)).isFalse();
- }
-}