package kg.apc.perfmon.metrics;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 *
 * @author undera
 */
public class ExecMetricTest extends TestCase {

    public ExecMetricTest(String testName) {
        super(testName);
    }

    public static Test suite() {
        TestSuite suite = new TestSuite(ExecMetricTest.class);
        return suite;
    }

    protected void setUp() throws Exception {
        super.setUp();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Test of getValue method, of class RunMetric.
     */
    public void testGetValue() throws Exception {
        System.out.println("getValue");
        StringBuffer res = new StringBuffer();
        ExecMetric instance = new ExecMetric(MetricParams.createFromString("echo:123"));
        instance.getValue(res);
        assertTrue(Double.parseDouble(res.toString()) > 0);
    }

    /*
    public void testGetValue2() throws Exception {
    System.out.println("getValue");
    StringBuffer res = new StringBuffer();
    ExecMetric instance = new ExecMetric(MetricParams.createFromString("/usr/bin/perl:-e:\"print 100*rand(1);\""));
    instance.getValue(res);
    assertTrue(Double.parseDouble(res.toString()) > 0);
    }
     */
}

@@ -761,24 +761,217 @@
 ngBuffer();%0A
+        //default is linux os%0A        String cmd = %22echo:123%22;%0A        if(System.getProperty(%22os.name%22).toLowerCase().indexOf(%22windows%22) != -1) %7B%0A            cmd = %22cmd:/C:echo:123%22;%0A        %7D%0A
         Exec
@@ -1033,26 +1033,19 @@
 mString(
-%22echo:123%22
+cmd
 ));%0A    
@@ -1118,35 +1118,38 @@
 res.toString()) 
-%3E 0
+== 123
 );%0A    %7D%0A%0A    /*

make test windows compatible