From 9719776a8d5d1e30f46bafcb9e9f5e1c349cf9ab Mon Sep 17 00:00:00 2001 From: Adam Murdoch Date: Thu, 12 Dec 2013 12:13:55 +1100 Subject: [PATCH] Some tweaks to error messages. --- .../platform/internal/DefaultWindowsRegistry.java | 6 +++--- .../rubygrapefruit/platform/WindowsRegistryTest.groovy | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/rubygrapefruit/platform/internal/DefaultWindowsRegistry.java b/src/main/java/net/rubygrapefruit/platform/internal/DefaultWindowsRegistry.java index 668381d..2e2785c 100644 --- a/src/main/java/net/rubygrapefruit/platform/internal/DefaultWindowsRegistry.java +++ b/src/main/java/net/rubygrapefruit/platform/internal/DefaultWindowsRegistry.java @@ -29,7 +29,7 @@ public class DefaultWindowsRegistry implements WindowsRegistry { ArrayList subkeys = new ArrayList(); boolean found = WindowsRegistryFunctions.getSubkeys(key.ordinal(), subkey, subkeys, result); if (result.isFailed()) { - throw new NativeException(String.format("Could not get subkeys of registry key '%s\\%s': %s", key, + throw new NativeException(String.format("Could not list the subkeys of registry key '%s\\%s': %s", key, subkey, result.getMessage())); } if (!found) { @@ -44,12 +44,12 @@ public class DefaultWindowsRegistry implements WindowsRegistry { ArrayList names = new ArrayList(); boolean found = WindowsRegistryFunctions.getValueNames(key.ordinal(), subkey, names, result); if (result.isFailed()) { - throw new NativeException(String.format("Could not get value names of registry key '%s\\%s': %s", key, + throw new NativeException(String.format("Could not list the values of registry key '%s\\%s': %s", key, subkey, result.getMessage())); } if (!found) { throw new MissingRegistryEntryException(String.format( - "Could not list the value names of registry key '%s\\%s' as it does not exist.", key, subkey)); + "Could not list the values of registry key '%s\\%s' as it does not exist.", key, subkey)); } return names; } diff --git a/src/test/groovy/net/rubygrapefruit/platform/WindowsRegistryTest.groovy b/src/test/groovy/net/rubygrapefruit/platform/WindowsRegistryTest.groovy index a7b3898..bc1320d 100644 --- a/src/test/groovy/net/rubygrapefruit/platform/WindowsRegistryTest.groovy +++ b/src/test/groovy/net/rubygrapefruit/platform/WindowsRegistryTest.groovy @@ -34,12 +34,12 @@ class WindowsRegistryTest extends Specification { e.message == /Could not get value 'Value' of registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Unknown' as it does not exist./ } - def "can read subkeys"() { + def "can list subkeys of a key"() { expect: windowsRegistry.getSubkeys(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, /SOFTWARE\Microsoft/).flatten().contains("Windows NT") } - def "cannot read subkeys of key that does not exist"() { + def "cannot list subkeys of key that does not exist"() { when: windowsRegistry.getSubkeys(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, /SOFTWARE\Unknown/) @@ -48,17 +48,17 @@ class WindowsRegistryTest extends Specification { e.message == /Could not list the subkeys of registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Unknown' as it does not exist./ } - def "can read value names"() { + def "cannot list values of a key"() { expect: windowsRegistry.getValueNames(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, /SOFTWARE\Microsoft\Windows NT\CurrentVersion/).flatten().contains("CurrentVersion") } - def "cannot read value names of key that does not exist"() { + def "cannot list values of key that does not exist"() { when: windowsRegistry.getValueNames(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, /SOFTWARE\Unknown/) then: def e = thrown(MissingRegistryEntryException) - e.message == /Could not list the value names of registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Unknown' as it does not exist./ + e.message == /Could not list the values of registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Unknown' as it does not exist./ } }