add some getValue tests

This commit is contained in:
Doug MacEachern 2008-09-12 00:19:57 +00:00
parent 19a76d5fa1
commit 898e933070
1 changed files with 40 additions and 2 deletions

View File

@ -18,10 +18,12 @@
package org.hyperic.sigar.win32.test;
import junit.framework.TestCase;
import java.util.ArrayList;
import org.hyperic.sigar.test.SigarTestCase;
import org.hyperic.sigar.win32.RegistryKey;
public class TestRegistryKey extends TestCase {
public class TestRegistryKey extends SigarTestCase {
private static final boolean TEST_WRITE = false;
@ -37,6 +39,42 @@ public class TestRegistryKey extends TestCase {
software.close();
}
public void testHardwareValues() throws Exception {
RegistryKey hw =
RegistryKey.LocalMachine.openSubKey("HARDWARE\\DESCRIPTION\\System");
try {
ArrayList values = new ArrayList();
hw.getMultiStringValue("SystemBiosVersion", values);
assertGtZeroTrace("SystemBiosVersion.size()", values.size());
traceln("SystemBiosVersion=" + values);
} catch (Exception e) {}
RegistryKey cpu0 = hw.openSubKey("CentralProcessor\\0");
String cpu = cpu0.getStringValue("ProcessorNameString");
assertLengthTrace("cpu0", cpu);
cpu0.close();
hw.close();
}
public void testSoftwareValues() throws Exception {
RegistryKey ms =
RegistryKey.LocalMachine.openSubKey("SOFTWARE\\Microsoft");
RegistryKey msmq = null;
try {
msmq = ms.openSubKey("MSMQ\\Parameters");
} catch (Exception e) { /*not installed - ok*/ }
if (msmq != null) {
traceln("MSMQ...");
assertTrue(msmq.getSubKeyNames().length > 0);
String build = msmq.getStringValue("CurrentBuild");
assertLengthTrace("CurrentBuild", build);
int id = msmq.getIntValue("SeqID");
assertGtZeroTrace("SeqID", id);
}
ms.close();
}
//dont want to be writing to the registry
public void testRegistryWrite() throws Exception {
if (!TEST_WRITE) {