diff --git a/assertj-swing/src/main/java/org/assertj/swing/util/OSIdentifier.java b/assertj-swing/src/main/java/org/assertj/swing/util/OSIdentifier.java index 7736ff4d..8e261702 100644 --- a/assertj-swing/src/main/java/org/assertj/swing/util/OSIdentifier.java +++ b/assertj-swing/src/main/java/org/assertj/swing/util/OSIdentifier.java @@ -34,7 +34,6 @@ class OSIdentifier { private final boolean isWindows; private final boolean isWindows9x; private final boolean isWindowsXP; - private final boolean isMacintosh; private final boolean isOSX; private final boolean isX11; private final boolean isSolaris; @@ -49,12 +48,10 @@ class OSIdentifier { @VisibleForTesting OSIdentifier(@Nonnull SystemPropertyReader reader) { String osName = checkNotNull(reader.systemProperty("os.name")).toLowerCase(ENGLISH); - String mrjVersion = reader.systemProperty("mrj.version"); isWindows = osName.startsWith("windows"); isWindows9x = isWindows && containsAny(osName, "95", "98", "me"); isWindowsXP = isWindows && osName.contains("xp"); - isMacintosh = mrjVersion != null; - isOSX = isMacintosh && osName.contains("os x"); + isOSX = osName.contains("os x"); isX11 = !isOSX && !isWindows; isSolaris = osName.startsWith("sunos") || osName.startsWith("solaris"); isHPUX = osName.equals("hp-ux"); @@ -98,7 +95,8 @@ boolean isWindowsXP() { } boolean isMacintosh() { - return isMacintosh; + // currently we assume only Mac OS X is used + return isOSX(); } boolean isOSX() { diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_TestCase.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_TestCase.java index 2fc15940..75e44fbd 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_TestCase.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_TestCase.java @@ -35,16 +35,4 @@ public void setUp() { final void returnOSName(String osName) { when(propertyReader.systemProperty("os.name")).thenReturn(osName); } - - final void returnSomeMRJVersion() { - returnMRJVersion("6"); - } - - final void returnNoMRJVersion() { - returnMRJVersion(null); - } - - final void returnMRJVersion(String mrjVersion) { - when(propertyReader.systemProperty("mrj.version")).thenReturn(mrjVersion); - } } diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isHPUX_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isHPUX_Test.java index 7e5ab87e..6bc948e0 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isHPUX_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isHPUX_Test.java @@ -46,7 +46,6 @@ public OSIdentifier_isHPUX_Test(String hpUX) { @Test public void should_return_HPUX_if_OS_name_is_equal_to_HPUX() { returnOSName(hpUX); - returnNoMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isHPUX()).isTrue(); assertThat(osIdentifier.isX11()).isTrue(); diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isLinux_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isLinux_Test.java index 41c11dfe..9ca3c02d 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isLinux_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isLinux_Test.java @@ -46,7 +46,6 @@ public OSIdentifier_isLinux_Test(String linux) { @Test public void shouldReturnLinuxIfOSNameIsEqualToLinux() { returnOSName(linux); - returnNoMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isLinux()).isTrue(); assertThat(osIdentifier.isX11()).isTrue(); diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isMacintosh_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isMacintosh_Test.java index 2b2c78c6..d7475a4f 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isMacintosh_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isMacintosh_Test.java @@ -15,30 +15,47 @@ package org.assertj.swing.util; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.util.Lists.newArrayList; import static org.assertj.swing.util.OSFamily.MAC; +import java.util.Collection; + import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; /** * Tests for {@link OSIdentifier#isMacintosh()}. * * @author Alex Ruiz */ +@RunWith(Parameterized.class) public class OSIdentifier_isMacintosh_Test extends OSIdentifier_TestCase { + private final String osX; + + @Parameters + public static Collection osX() { + return newArrayList(new Object[][] { { "os x" }, { "OS X" } }); + } + + public OSIdentifier_isMacintosh_Test(String osX) { + this.osX = osX; + } + @Test - public void should_return_Macintosh_if_MRJVersion_is_not_null() { - returnOSName(""); - returnSomeMRJVersion(); + public void should_return_OSX_if_OS_name_contains_OSX_even_if_mrj_version_is_Null() { + returnOSName(osX); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isMacintosh()).isTrue(); - assertThat(osIdentifier.isX11()).isTrue(); + assertThat(osIdentifier.isOSX()).isTrue(); assertThat(osIdentifier.isHPUX()).isFalse(); assertThat(osIdentifier.isLinux()).isFalse(); - assertThat(osIdentifier.isOSX()).isFalse(); assertThat(osIdentifier.isSolaris()).isFalse(); assertThat(osIdentifier.isWindows()).isFalse(); assertThat(osIdentifier.isWindows9x()).isFalse(); assertThat(osIdentifier.isWindowsXP()).isFalse(); + assertThat(osIdentifier.isX11()).isFalse(); assertThat(osIdentifier.osFamily()).isEqualTo(MAC); } } diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isOSX_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isOSX_Test.java index f082d11f..b9a9aa91 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isOSX_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isOSX_Test.java @@ -46,7 +46,6 @@ public OSIdentifier_isOSX_Test(String osX) { @Test public void should_return_OSX_if_MRJVersion_not_null_and_OS_name_contains_OSX() { returnOSName(osX); - returnSomeMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isMacintosh()).isTrue(); assertThat(osIdentifier.isOSX()).isTrue(); diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isSolaris_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isSolaris_Test.java index d88ba811..e8e0a33b 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isSolaris_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isSolaris_Test.java @@ -47,7 +47,6 @@ public OSIdentifier_isSolaris_Test(String solaris) { @Test public void should_return_Solaris_if_OS_name_starts_with_SunOS_or_Solaris() { returnOSName(solaris); - returnNoMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isSolaris()).isTrue(); assertThat(osIdentifier.isX11()).isTrue(); diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows9x_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows9x_Test.java index 33217a09..3462ceeb 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows9x_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows9x_Test.java @@ -46,7 +46,6 @@ public OSIdentifier_isWindows9x_Test(String windows9x) { @Test public void should_return_is_Windows9x_if_OS_name_starts_with_Windows_and_contains_any_9x_version() { returnOSName(windows9x); - returnNoMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isWindows()).isTrue(); assertThat(osIdentifier.isWindows9x()).isTrue(); diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindowsXP_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindowsXP_Test.java index 51a52ad8..51ff4371 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindowsXP_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindowsXP_Test.java @@ -46,7 +46,6 @@ public OSIdentifier_isWindowsXP_Test(String windowsXP) { @Test public void should_return_WindowsXP_if_OS_name_starts_with_Windows_and_contains_XP() { returnOSName(windowsXP); - returnNoMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isWindows()).isTrue(); assertThat(osIdentifier.isWindowsXP()).isTrue(); diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows_Test.java index 52368b1f..9ab845d8 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isWindows_Test.java @@ -46,7 +46,6 @@ public OSIdentifier_isWindows_Test(String windows) { @Test public void should_return_is_Windows_if_OS_name_starts_with_Windows() { returnOSName(windows); - returnNoMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isWindows()).isTrue(); assertThat(osIdentifier.isHPUX()).isFalse(); diff --git a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isX11_Test.java b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isX11_Test.java index 2ec419b2..5f1e724b 100644 --- a/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isX11_Test.java +++ b/assertj-swing/src/test/java/org/assertj/swing/util/OSIdentifier_isX11_Test.java @@ -27,7 +27,6 @@ public class OSIdentifier_isX11_Test extends OSIdentifier_TestCase { @Test public void should_return_X11_if_OS_not_OSX_or_Windows() { returnOSName(""); - returnNoMRJVersion(); OSIdentifier osIdentifier = new OSIdentifier(propertyReader); assertThat(osIdentifier.isX11()).isTrue(); assertThat(osIdentifier.isHPUX()).isFalse();