package baseCode.util;

import junit.framework.TestCase;

/**
 * <hr>
 * <p>
 * Copyright (c) 2004-2005 Columbia University
 * 
 * @author pavlidis
 * @version $Id$
 */
public class RCommandTest extends TestCase {

    RCommand rc = null;

    public void setUp() {
        rc = RCommand.newInstance();
    }

    public void tearDown() {
        rc.disconnect();
        rc.stopServer();
    }

    /*
     * Test method for 'edu.columbia.gemma.tools.RCommand.exec(String)'
     */
    public void testExec() throws Exception {
        assertTrue( rc.eval( "R.version.string" ).asString().startsWith( "R version 2" ) );
    }

    /*
     * Test method for 'edu.columbia.gemma.tools.RCommand.exec(String)'
     */
    public void testExecDoubleArray() throws Exception {
        assertTrue( RegressionTesting.closeEnough( new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, rc
                .doubleArrayEval( "rep(1, 10)" ), 0.001 ) );
    }
}

@@ -1,25 +1,932 @@
-package baseCode.util
+/*%0A * The baseCode project%0A * %0A * Copyright (c) 2005 Columbia University%0A * %0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA%0A *%0A */%0Apackage baseCode.util;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory
 ;%0A%0Ai
@@ -1118,31 +1118,142 @@
 e %7B%0A
-%0A    RCommand rc = null
+    private static Log log = LogFactory.getLog( RCommandTest.class.getName() );%0A%0A    RCommand rc = null;%0A    boolean connected = false
 ;%0A%0A 
@@ -1273,24 +1273,42 @@
 d setUp() %7B%0A
+        try %7B%0A    
         rc =
@@ -1328,24 +1328,136 @@
 Instance();%0A
+            connected = true;%0A        %7D catch ( RuntimeException e ) %7B%0A            connected = false;%0A        %7D%0A
     %7D%0A%0A    p
@@ -1662,32 +1662,161 @@
 ows Exception %7B%0A
+        if ( !connected ) %7B%0A            log.warn( %22Could not connect to RServe, skipping test.%22 );%0A            return;%0A        %7D%0A
         assertTr
@@ -2034,32 +2034,161 @@
 ows Exception %7B%0A
+        if ( !connected ) %7B%0A            log.warn( %22Could not connect to RServe, skipping test.%22 );%0A            return;%0A        %7D%0A
         assertTr

make test conditional on server running