/*
 * Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
 * This file is part of SIGAR.
 * 
 * SIGAR is free software; you can redistribute it and/or modify
 * it under the terms version 2 of the GNU General Public License as
 * published by the Free Software Foundation. This program 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 General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA.
 */

package org.hyperic.sigar.win32.test;

import junit.framework.TestCase;
import org.hyperic.sigar.win32.RegistryKey;

public class TestRegistryKey extends TestCase {

    private static final boolean TEST_WRITE = false;
    
    public TestRegistryKey(String name) {
        super(name);
    }

    public void testRegistryRead() throws Exception {
        RegistryKey software =
            RegistryKey.LocalMachine.openSubKey("SOFTWARE");
        String[] keys = software.getSubKeyNames();
        assertTrue(keys.length > 0);
        software.close();
    }

    //dont want to be writing to the registry
    public void testRegistryWrite() throws Exception {
        if (!TEST_WRITE) {
            return;
        }
        RegistryKey key = RegistryKey.LocalMachine.
            createSubKey("SOFTWARE\\Hyperic\\Test", "Hyperic Test");
        
        key.setStringValue("TestString", "Hello World");
        key.setIntValue("Test Int", 100);
            
        String[] astrNames = key.getValueNames();
        String strValue = key.getStringValue(astrNames[0]);
        //assertTrue(strValue.equals("Covalent Test"));

        int iValue = key.getIntValue(astrNames[1]);
        //assertTrue(iValue == 100);
        
        key = RegistryKey.LocalMachine.openSubKey("SOFTWARE\\Hyperic");
        astrNames = key.getSubKeyNames();

        // Clean up
        key.deleteSubKey("Test");
    }
}

@@ -778,23 +778,64 @@
 rt j
-unit.framework.
+ava.util.ArrayList;%0A%0Aimport org.hyperic.sigar.test.Sigar
 Test
@@ -922,16 +922,21 @@
 extends 
+Sigar
 TestCase
@@ -1330,24 +1330,1370 @@
 e();%0A    %7D%0A%0A
+    public void testHardwareValues() throws Exception %7B%0A        RegistryKey hw =%0A            RegistryKey.LocalMachine.openSubKey(%22HARDWARE%5C%5CDESCRIPTION%5C%5CSystem%22);%0A        try %7B%0A            ArrayList values = new ArrayList();%0A            hw.getMultiStringValue(%22SystemBiosVersion%22, values);%0A            assertGtZeroTrace(%22SystemBiosVersion.size()%22, values.size());%0A            traceln(%22SystemBiosVersion=%22 + values);%0A        %7D catch (Exception e) %7B%7D%0A        RegistryKey cpu0 = hw.openSubKey(%22CentralProcessor%5C%5C0%22);%0A        String cpu = cpu0.getStringValue(%22ProcessorNameString%22);%0A        assertLengthTrace(%22cpu0%22, cpu);%0A        cpu0.close();%0A        hw.close();%0A    %7D%0A%0A    public void testSoftwareValues() throws Exception %7B%0A        RegistryKey ms =%0A            RegistryKey.LocalMachine.openSubKey(%22SOFTWARE%5C%5CMicrosoft%22);%0A%0A        RegistryKey msmq = null;%0A        try %7B%0A            msmq = ms.openSubKey(%22MSMQ%5C%5CParameters%22);%0A%0A        %7D catch (Exception e) %7B /*not installed - ok*/ %7D%0A        if (msmq != null) %7B%0A            traceln(%22MSMQ...%22);%0A            assertTrue(msmq.getSubKeyNames().length %3E 0);%0A            String build = msmq.getStringValue(%22CurrentBuild%22);%0A            assertLengthTrace(%22CurrentBuild%22, build);%0A            int id = msmq.getIntValue(%22SeqID%22);%0A            assertGtZeroTrace(%22SeqID%22, id);%0A        %7D%0A        ms.close();%0A    %7D%0A%0A
     //dont w

add some getValue tests