[Remoterengine-commits] r143 - in pkg/RemoteREngine.test/inst/java_src/src: . org org/rosuda org/rosuda/REngine org/rosuda/REngine/remote org/rosuda/REngine/remote/client org/rosuda/REngine/remote/common
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Sep 17 12:49:48 CEST 2009
Author: romain
Date: 2009-09-17 12:49:47 +0200 (Thu, 17 Sep 2009)
New Revision: 143
Added:
pkg/RemoteREngine.test/inst/java_src/src/org/
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/client/
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/client/TestFactors.java
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/common/
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/common/RemoteREngineTestBase.java
pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/server/
Removed:
pkg/RemoteREngine.test/inst/java_src/src/test/
Log:
remove test directories
Added: pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/client/TestFactors.java
===================================================================
--- pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/client/TestFactors.java (rev 0)
+++ pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/client/TestFactors.java 2009-09-17 10:49:47 UTC (rev 143)
@@ -0,0 +1,60 @@
+package org.rosuda.REngine.remote.client;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.rosuda.REngine.REXP;
+import org.rosuda.REngine.REXPFactor;
+import org.rosuda.REngine.RFactor;
+import org.rosuda.REngine.remote.common.RemoteREngineTestBase;
+
+/*
+ * Copyright Stoat Software & Services 2009 <ilong at stoatsoftware.com>
+ *
+ * This file is part of the RemoteREngine project
+ *
+ * The RemoteREngine project is free software:
+ * you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The RemoteREngine project 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 the RemoteREngine project. If not, see <http://www.gnu.org/licenses/>.
+ * @author $Author: ian_long $
+ * @version $Rev: 129 $ as of $Date: 2009-09-15 12:18:19 +0200 (Tue, 15 Sep 2009) $
+ * <p>URL : $HeadURL: svn+ssh://romain@svn.r-forge.r-project.org/svnroot/remoterengine/pkg/RemoteREngine/inst/java_src/test/org/rosuda/REngine/remote/client/TestFactors.java $
+ */
+public class TestFactors extends RemoteREngineTestBase {
+
+ @Test
+ public void testFactors() throws Exception {
+ System.out.println("* Test support of factors");
+ REXP f = r.parseAndEval("factor(paste('F',as.integer(runif(20)*5),sep=''))");
+ System.out.println(" f="+f);
+ System.out.println(" isFactor: "+f.isFactor()+", asFactor: "+f.asFactor());
+ Assert.assertNotNull( f.isFactor(), "Returned a null factor");
+ assert( f.isFactor()) : "Failed to return a factor";
+
+/* System.out.println(" singe-level factor used to degenerate:");
+ f = r.parseAndEval("factor('foo')");
+ System.out.println(" isFactor: "+f.isFactor()+", asFactor: "+f.asFactor());
+ if (!f.isFactor() || f.asFactor() == null) throw new TestException("single factor test failed (not a factor)");
+ if (!f.asFactor().at(0).equals("foo")) throw new TestException("single factor test failed (wrong value)");
+ System.out.println(" test factors with null elements contents:");
+ r.assign("f", new REXPFactor(new RFactor(new String[] { "foo", "bar", "foo", "foo", null, "bar" })));
+ f = r.parseAndEval("f");
+ if (!f.isFactor() || f.asFactor() == null) throw new TestException("factor assign-eval test failed (not a factor)");
+ System.out.println(" f = "+f.asFactor());
+ f = r.parseAndEval("as.factor(c(1,'a','b',1,'b'))");
+ System.out.println(" f = "+f);
+ if (!f.isFactor() || f.asFactor() == null) throw new TestException("factor test failed (not a factor)");
+ System.out.println("PASSED");
+*/
+ }
+}
Added: pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/common/RemoteREngineTestBase.java
===================================================================
--- pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/common/RemoteREngineTestBase.java (rev 0)
+++ pkg/RemoteREngine.test/inst/java_src/src/org/rosuda/REngine/remote/common/RemoteREngineTestBase.java 2009-09-17 10:49:47 UTC (rev 143)
@@ -0,0 +1,74 @@
+package org.rosuda.REngine.remote.common;
+
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.rosuda.REngine.remote.client.RemoteREngine;
+import org.testng.annotations.BeforeSuite;
+
+/*
+ * Copyright Stoat Software & Services 2009 <ilong at stoatsoftware.com>
+ *
+ * This file is part of the RemoteREngine project
+ *
+ * The RemoteREngine project is free software:
+ * you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The RemoteREngine project 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 the RemoteREngine project. If not, see <http://www.gnu.org/licenses/>.
+ * @author $Author: ian_long $
+ * @version $Rev: 129 $ as of $Date: 2009-09-15 12:18:19 +0200 (Tue, 15 Sep 2009) $
+ * <p>URL : $HeadURL: svn+ssh://romain@svn.r-forge.r-project.org/svnroot/remoterengine/pkg/RemoteREngine/inst/java_src/test/org/rosuda/REngine/remote/common/RemoteREngineTestBase.java $
+ */
+public class RemoteREngineTestBase {
+ /** Instance of the Remote R Engine available for tests */
+ protected static RemoteREngine r = init();
+
+ /**
+ * Create a connection to a running remote server
+ * @return Reference to a remote engine
+ */
+ @BeforeSuite
+ protected static RemoteREngine init(){
+/* Properties props = System.getProperties();
+ for (Enumeration<?> enumerator = props.keys(); enumerator.hasMoreElements(); ) {
+ String key = (String)enumerator.nextElement();
+ String value = props.getProperty(key);
+ System.out.println(key + " : " + value);
+ }
+*/
+ RemoteREngine r = null ;
+ String name = "RemoteREngineTest";
+ int registryPort = RemoteREngineConstants.RMIPORT;
+ try{
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new SecurityManager());
+ }
+ r = new RemoteREngine( name , RemoteREngineConstants.RMIHOSTNAME , registryPort );
+ System.out.println("Connected to " + name + " via " + RemoteREngineConstants.RMIHOSTNAME +
+ " registry on port " + registryPort);
+ } catch( Exception e ){
+ System.err.println( "cannot connect to R engine" ) ;
+ System.exit(1);
+ }
+ return r;
+ }
+
+ protected static RemoteREngine cleanR(){
+ try{
+ r.parseAndEval( "rm( list = ls() )" ) ;
+ } catch(Exception e){
+ // should not happen
+ }
+ return r;
+ }
+
+}
More information about the Remoterengine-commits
mailing list