Added tests for WindowRegistry.getValueNames
This commit is contained in:
@@ -556,8 +556,8 @@ Java_net_rubygrapefruit_platform_internal_jni_WindowsRegistryFunctions_getSubkey
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_net_rubygrapefruit_platform_internal_jni_WindowsRegistryFunctions_getValueNames(JNIEnv *env, jclass target, jint keyNum, jstring subkey, jobject names, jobject result) {
|
||||
wchar_t* subkeyStr = java_to_wchar(env, subkey, result);
|
||||
jclass subkeys_class = env->GetObjectClass(names);
|
||||
jmethodID method = env->GetMethodID(subkeys_class, "add", "(Ljava/lang/Object;)Z");
|
||||
jclass names_class = env->GetObjectClass(names);
|
||||
jmethodID method = env->GetMethodID(names_class, "add", "(Ljava/lang/Object;)Z");
|
||||
|
||||
HKEY key;
|
||||
LONG retval = RegOpenKeyExW(get_key_from_ordinal(keyNum), subkeyStr, 0, KEY_READ, &key);
|
||||
|
||||
@@ -47,4 +47,18 @@ class WindowsRegistryTest extends Specification {
|
||||
def e = thrown(MissingRegistryEntryException)
|
||||
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"() {
|
||||
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"() {
|
||||
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./
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user