package net.hyperic.sigar.test;

import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

import net.hyperic.sigar.Sigar;

public class TestFQDN extends SigarTestCase {

    public TestFQDN(String name) {
        super(name);
    }

    public void testCreate() throws Exception {
        Properties props = new Properties();
        File f = new File(System.getProperty("user.home"),
                          ".sigar.properties");

        if (f.exists()) {
            try {
                props.load(new FileInputStream(f));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        String fqdn = getSigar().getFQDN();

        traceln("fqdn=" + fqdn);

        boolean validFQDN = fqdn.indexOf(".") > 0;
        if (!validFQDN) {
            //wont get a valid fqdn on laptop at home
            //allow to fake with ant -Dsigar.fqdn=foo.bar
            String pfake = props.getProperty("sigar.fqdn");
            String fake = 
                System.getProperty("sigar.fqdn", pfake);
            if ("".equals(fake)) {
                fake = pfake;
            }
            if (fake != null) {
                traceln("fake='" + fake + "'");
                validFQDN = fake.indexOf(".") > 0;
            }
        }
        assertTrue(validFQDN);
    }
}

@@ -30,119 +30,8 @@
 t;%0A%0A
-import java.io.IOException;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.util.Properties;%0A%0A
 impo
@@ -58,16 +58,16 @@
 .Sigar;%0A
+
 %0Apublic 
@@ -220,356 +220,8 @@
 on %7B
-%0A        Properties props = new Properties();%0A        File f = new File(System.getProperty(%22user.home%22),%0A                          %22.sigar.properties%22);%0A%0A        if (f.exists()) %7B%0A            try %7B%0A                props.load(new FileInputStream(f));%0A            %7D catch (IOException e) %7B%0A                e.printStackTrace();%0A            %7D%0A        %7D
 %0A%0A  
@@ -486,16 +486,16 @@
 foo.bar%0A
+
         
@@ -517,14 +517,8 @@
 e = 
-props.
 getP

use super class getProperty