Nuiton-j2r-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- 316 discussions
Author: tchemit
Date: 2010-11-21 15:30:33 +0100 (Sun, 21 Nov 2010)
New Revision: 245
Url: http://nuiton.org/repositories/revision/nuiton-j2r/245
Log:
Update mavenpom4redmineAndCentral to 2.4.1.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-29 08:29:16 UTC (rev 244)
+++ trunk/pom.xml 2010-11-21 14:30:33 UTC (rev 245)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.4</version>
+ <version>2.4.1</version>
</parent>
<artifactId>nuiton-j2r</artifactId>
1
0
Author: tchemit
Date: 2010-10-29 10:29:16 +0200 (Fri, 29 Oct 2010)
New Revision: 244
Url: http://nuiton.org/repositories/revision/nuiton-j2r/244
Log:
Update mavenpom4redmineAndCentral to 2.4.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-26 12:57:28 UTC (rev 243)
+++ trunk/pom.xml 2010-10-29 08:29:16 UTC (rev 244)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.4-SNAPSHOT</version>
+ <version>2.4</version>
</parent>
<artifactId>nuiton-j2r</artifactId>
1
0
Author: tchemit
Date: 2010-10-26 14:57:28 +0200 (Tue, 26 Oct 2010)
New Revision: 243
Url: http://nuiton.org/repositories/revision/nuiton-j2r/243
Log:
fix build (use inheritance from mavenpom for commons libs)
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-26 12:07:02 UTC (rev 242)
+++ trunk/pom.xml 2010-10-26 12:57:28 UTC (rev 243)
@@ -118,7 +118,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <scope>test</scope>
</dependency>
1
0
Author: tchemit
Date: 2010-10-26 14:07:02 +0200 (Tue, 26 Oct 2010)
New Revision: 242
Url: http://nuiton.org/repositories/revision/nuiton-j2r/242
Log:
use mavenpom 2.4-SNAPSHOT
use camelCase style for version properties
use default libraries version from mavenpom
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-22 08:51:00 UTC (rev 241)
+++ trunk/pom.xml 2010-10-26 12:07:02 UTC (rev 242)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.3.2</version>
+ <version>2.4-SNAPSHOT</version>
</parent>
<artifactId>nuiton-j2r</artifactId>
@@ -92,7 +92,6 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
</dependency>
<dependency>
@@ -105,21 +104,20 @@
<dependency>
<groupId>org.nuiton.thirdparty</groupId>
<artifactId>REngine</artifactId>
- <version>${rengine.version}</version>
+ <version>${rengineVersion}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.nuiton.thirdparty</groupId>
<artifactId>Rserve</artifactId>
- <version>${rengine.version}</version>
+ <version>${rengineVersion}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.1</version>
<scope>test</scope>
</dependency>
@@ -145,7 +143,7 @@
<properties>
- <rengine.version>0.6-1</rengine.version>
+ <rengineVersion>0.6-1</rengineVersion>
<!-- Jar main class -->
<!--maven.jar.main.class>org.codelutin.j2r.RProxy</maven.jar.main.class-->
@@ -165,7 +163,7 @@
<dependency>
<groupId>org.nuiton.jrst</groupId>
<artifactId>doxia-module-jrst</artifactId>
- <version>${jrst.version}</version>
+ <version>${jrstPluginVersion}</version>
</dependency>
</dependencies>
</plugin>
1
0
r241 - in trunk/src: main/java/org/nuiton/j2r main/java/org/nuiton/j2r/types site/rst test/java/org/nuiton/j2r
by jcouteau@users.nuiton.org 22 Oct '10
by jcouteau@users.nuiton.org 22 Oct '10
22 Oct '10
Author: jcouteau
Date: 2010-10-22 10:51:00 +0200 (Fri, 22 Oct 2010)
New Revision: 241
Url: http://nuiton.org/repositories/revision/nuiton-j2r/241
Log:
Improve code : use string builders, close streams in finally blocks, replace private by protected
Modified:
trunk/src/main/java/org/nuiton/j2r/REngine.java
trunk/src/main/java/org/nuiton/j2r/REngineAbstract.java
trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java
trunk/src/main/java/org/nuiton/j2r/types/REXPAbstract.java
trunk/src/main/java/org/nuiton/j2r/types/RList.java
trunk/src/site/rst/installTest.rst
trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java
trunk/src/test/java/org/nuiton/j2r/NetTest.java
Modified: trunk/src/main/java/org/nuiton/j2r/REngine.java
===================================================================
--- trunk/src/main/java/org/nuiton/j2r/REngine.java 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/main/java/org/nuiton/j2r/REngine.java 2010-10-22 08:51:00 UTC (rev 241)
@@ -289,7 +289,7 @@
*/
void saveRData(String filename) throws RException;
- public void plot(String filename, String x, String y, String type,
+ void plot(String filename, String x, String y, String type,
String main, String sub, String xlab, String ylab,
String asp) throws RException;
} //REngine
Modified: trunk/src/main/java/org/nuiton/j2r/REngineAbstract.java
===================================================================
--- trunk/src/main/java/org/nuiton/j2r/REngineAbstract.java 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/main/java/org/nuiton/j2r/REngineAbstract.java 2010-10-22 08:51:00 UTC (rev 241)
@@ -39,7 +39,7 @@
* If true, commit each R instruction on the fly, if false, commit only when
* the commit() method is called.
*/
- private Boolean autocommit = true;
+ protected Boolean autocommit = true;
/**
* Load a specific R session :
@@ -343,45 +343,58 @@
eval("jpeg(\"" + filename + ".jpg\")");
- String Rinstruction = "plot(";
+ StringBuilder rinstruction = new StringBuilder("plot(");
if ((x != null) && (!x.isEmpty())) {
- Rinstruction += x;
+ rinstruction.append(x);
} else {
throw new IllegalArgumentException("x argument must be filled");
}
if ((y != null) && (!y.isEmpty())) {
- Rinstruction += ",y=" + y;
+ rinstruction.append(",y=");
+ rinstruction.append(y);
}
if (type != null) {
- Rinstruction += ",type=\"" + type + "\"";
+ rinstruction.append(",type=\"");
+ rinstruction.append(type);
+ rinstruction.append("\"");
}
if (main != null) {
- Rinstruction += ",main=\"" + main + "\"";
+ rinstruction.append(",main=\"");
+ rinstruction.append(main);
+ rinstruction.append("\"");
}
if (sub != null) {
- Rinstruction += ",sub=\"" + sub + "\"";
+ rinstruction.append(",sub=\"");
+ rinstruction.append(sub);
+ rinstruction.append("\"");
}
if (xlab != null) {
- Rinstruction += ",xlab=\"" + xlab + "\"";
+ rinstruction.append(",xlab=\"");
+ rinstruction.append(xlab);
+ rinstruction.append("\"");
}
if (ylab != null) {
- Rinstruction += ",ylab=\"" + ylab + "\"";
+ rinstruction.append(",ylab=\"");
+ rinstruction.append(ylab);
+ rinstruction.append("\"");
}
if (asp != null) {
- Rinstruction += ",asp=" + asp + "\"";
+ rinstruction.append(",asp=");
+ rinstruction.append(asp);
+ rinstruction.append("\"");
}
- Rinstruction += ")";
+ rinstruction.append(")");
- eval(Rinstruction);
+ eval(rinstruction.toString());
eval("dev.off()");
}
Modified: trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java
===================================================================
--- trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/main/java/org/nuiton/j2r/types/RDataFrame.java 2010-10-22 08:51:00 UTC (rev 241)
@@ -273,15 +273,17 @@
this.rowNames = rowNames;
//Create the r instruction (row.names(var)<-c("name 1",...,"name x")).
- String rowNamesString = "";
+ StringBuilder rowNamesString = new StringBuilder();
for (int i = 0; i < this.rowNames.size(); i++) {
if (i != 0) {
- rowNamesString += ",";
+ rowNamesString.append(",");
}
- rowNamesString += "\"" + rowNames.get(i) + "\"";
+ rowNamesString.append("\"");
+ rowNamesString.append(rowNames.get(i));
+ rowNamesString.append("\"");
}
String rexp = String.format(RInstructions.SET_ROW_NAMES,
- this.variable, rowNamesString);
+ this.variable, rowNamesString.toString());
//Send the r instruction to the engine.
engine.voidEval(rexp);
@@ -333,17 +335,21 @@
public String toRString() throws RException {
checkVariable();
- String returnString = this.variable + "<-data.frame(";
+ StringBuilder returnString = new StringBuilder();
+ returnString.append(this.variable);
+ returnString.append("<-data.frame(");
+
for (List<?> column:this.data){
if (!column.isEmpty()){
if (!(this.names.isEmpty())) {
int index = this.data.indexOf(column);
- returnString += this.names.get(index) + "=c(";
+ returnString.append(this.names.get(index));
+ returnString.append("=c(");
} else {
- returnString += "c(";
+ returnString.append("c(");
}
Object firstElement = column.get(0);
@@ -351,56 +357,62 @@
if (firstElement instanceof String) {
for (Object obj:column) {
- returnString += "\"" + obj + "\",";
+ returnString.append("\"");
+ returnString.append(obj);
+ returnString.append("\",");
}
} else if (firstElement instanceof Boolean) {
for (Object obj:column) {
if ((Boolean) obj) {
- returnString += RInstructions.TRUE + ",";
+ returnString.append(RInstructions.TRUE + ",");
} else {
- returnString += RInstructions.FALSE + ",";
+ returnString.append(RInstructions.FALSE + ",");
}
}
} else if (firstElement instanceof Integer) {
for (Object obj:column) {
- returnString += String.format(RInstructions.AS_INTEGER,
- obj) + ",";
+ returnString.append(
+ String.format(RInstructions.AS_INTEGER,obj));
+ returnString.append(",");
}
} else {
for (Object obj:column) {
- returnString += obj + ",";
+ returnString.append(obj);
+ returnString.append(",");
}
}
- returnString = returnString.substring(0,
- returnString.length() - 1);
- returnString = returnString + "),";
+ returnString = new StringBuilder(returnString.substring(0,
+ returnString.length() - 1));
+ returnString.append("),");
}
}
if (!(this.rowNames.isEmpty())) {
- returnString += "row.names=c(";
+ returnString.append("row.names=c(");
for (String rowName : rowNames) {
- returnString += "\"" + rowName + "\",";
+ returnString.append("\"");
+ returnString.append(rowName);
+ returnString.append("\",");
}
- returnString =
- returnString.substring(0, returnString.length() - 1) +
- "),stringsAsFactors=FALSE)";
+ returnString = new StringBuilder(returnString.substring(0, returnString.length() - 1));
+ returnString.append("),stringsAsFactors=FALSE)");
+
} else if (this.data.isEmpty()) {
- returnString += ")";
+ returnString.append(")");
} else {
- returnString += "stringsAsFactors=FALSE)";
+ returnString.append("stringsAsFactors=FALSE)");
}
if(log.isDebugEnabled()){
log.debug(returnString);
}
- return returnString;
+ return returnString.toString();
}
/**
@@ -656,28 +668,35 @@
*/
public void exportCsv(File outputFile, boolean rowNames, boolean names)
throws IOException {
- BufferedWriter file = new BufferedWriter(new FileWriter(outputFile));
- if (names) {
- if (rowNames) {
- file.write(";");
+ BufferedWriter file = null;
+ try {
+ file = new BufferedWriter(new FileWriter(outputFile));
+
+ if (names) {
+ if (rowNames) {
+ file.write(";");
+ }
+ for (String name : this.names) {
+ file.write(name + ";");
+ }
+ file.newLine();
}
- for (String name : this.names) {
- file.write(name + ";");
- }
- file.newLine();
- }
- for (int i = 0; i < this.data.get(0).size(); i++) {
- if (rowNames) {
- file.write(this.rowNames.get(i) + ";");
+ for (int i = 0; i < this.data.get(0).size(); i++) {
+ if (rowNames) {
+ file.write(this.rowNames.get(i) + ";");
+ }
+ for (List<?> aData : this.data) {
+ file.write(aData.get(i) + ";");
+ }
+ file.newLine();
}
- for (List<?> aData : this.data) {
- file.write(aData.get(i) + ";");
+ } finally {
+ if (file!=null){
+ file.close();
}
- file.newLine();
}
- file.close();
}
@@ -760,93 +779,100 @@
//temporary String to read lines.
String tmp;
+ //temporary data list.
+ List<List<?>> tempData = new ArrayList<List<?>>();
+
Integer dataSize;
- //get the first line of the file
- BufferedReader br = new BufferedReader(new FileReader(inputFile));
- tmp = br.readLine();
- String[] splitted = tmp.split(";");
+ BufferedReader br = null;
+ try {
+ //get the first line of the file
+ br = new BufferedReader(new FileReader(inputFile));
+ tmp = br.readLine();
+ String[] splitted = tmp.split(";");
- //get the data size (number of columns)
- if (rowNames) {
- dataSize = splitted.length - 1;
- } else {
- dataSize = splitted.length;
- }
+ //get the data size (number of columns)
+ if (rowNames) {
+ dataSize = splitted.length - 1;
+ } else {
+ dataSize = splitted.length;
+ }
- //clear data, rowNames and names
- this.data.clear();
- this.rowNames.clear();
- this.names.clear();
+ //clear data, rowNames and names
+ this.data.clear();
+ this.rowNames.clear();
+ this.names.clear();
- if (names) {
- //if names are present in the file, parse the first line to get
- //the names.
- this.names.addAll(Arrays.asList(splitted).subList(1, splitted.length));
- }
+ if (names) {
+ //if names are present in the file, parse the first line to get
+ //the names.
+ this.names.addAll(Arrays.asList(splitted).subList(1, splitted.length));
+ }
- //temporary data list.
- List<List<?>> tempData = new ArrayList<List<?>>();
+ //Initialize all the data columns with empty lists
+ for (int i = 0; i < dataSize; i++) {
+ List<Object> column = new ArrayList<Object>();
+ tempData.add(column);
+ }
- //Initialize all the data columns with empty lists
- for (int i = 0; i < dataSize; i++) {
- List<Object> column = new ArrayList<Object>();
- tempData.add(column);
- }
+ while ((tmp = br.readLine()) != null) {
- while ((tmp = br.readLine()) != null) {
+ //parse each line
+ splitted = tmp.split(";");
- //parse each line
- splitted = tmp.split(";");
+ //to determine the data index on the line.
+ int index = 0;
- //to determine the data index on the line.
- int index = 0;
+ //if there are row names, extract the first item as the row name
+ if (rowNames) {
+ this.rowNames.add(splitted[0]);
+ index = 1;
+ }
- //if there are row names, extract the first item as the row name
- if (rowNames) {
- this.rowNames.add(splitted[0]);
- index = 1;
- }
+ for (int i = index; i < splitted.length; i++) {
+ //cast the data imported to the specified type.
+ //test the size of the inputType list. If 1 import all the
+ //columns as the type of the first element.
- for (int i = index; i < splitted.length; i++) {
- //cast the data imported to the specified type.
- //test the size of the inputType list. If 1 import all the
- //columns as the type of the first element.
+ //Get the column for index
+ ArrayList<Object> objects = (ArrayList<Object>)tempData.get(i - index);
- //Get the column for index
- ArrayList<Object> objects = (ArrayList<Object>)tempData.get(i - index);
-
- //add to the column the converted value. If importTypes contains
- //only one element, cast into this type, else cast into the
- //column type.
- if (((importTypes.size() == 1) &&
+ //add to the column the converted value. If importTypes contains
+ //only one element, cast into this type, else cast into the
+ //column type.
+ if (((importTypes.size() == 1) &&
(importTypes.get(0) instanceof String) ) ||
- ((importTypes.size() > (i -index )) &&
- (importTypes.get(i - index) instanceof String)) ) {
+ ((importTypes.size() > (i -index )) &&
+ (importTypes.get(i - index) instanceof String)) ) {
- //We import strings so no cast in case of string
- objects.add(splitted[i]);
+ //We import strings so no cast in case of string
+ objects.add(splitted[i]);
- } else if (((importTypes.size() == 1) &&
- (importTypes.get(0) instanceof Double) ) ||
- ((importTypes.size() > (i -index )) &&
- (importTypes.get(i - index) instanceof Double))) {
+ } else if (((importTypes.size() == 1) &&
+ (importTypes.get(0) instanceof Double) ) ||
+ ((importTypes.size() > (i -index )) &&
+ (importTypes.get(i - index) instanceof Double))) {
- //in case of Double
- objects.add(Double.valueOf(splitted[i]));
+ //in case of Double
+ objects.add(Double.valueOf(splitted[i]));
- } else if (((importTypes.size() == 1) &&
- (importTypes.get(0) instanceof Integer) ) ||
- ((importTypes.size() > (i -index )) &&
- (importTypes.get(i - index) instanceof Integer))) {
+ } else if (((importTypes.size() == 1) &&
+ (importTypes.get(0) instanceof Integer) ) ||
+ ((importTypes.size() > (i -index )) &&
+ (importTypes.get(i - index) instanceof Integer))) {
- //in case of Integer
- objects.add(Integer.valueOf(splitted[i]));
+ //in case of Integer
+ objects.add(Integer.valueOf(splitted[i]));
+ }
}
}
+ } finally {
+ if (br != null){
+ br.close();
+ }
}
- br.close();
+
this.data = tempData;
if (log.isDebugEnabled()){
@@ -857,7 +883,13 @@
}
- private void checkY(int y) {
+ /**
+ * Check if the index is into the data.frame length throws a
+ * IndexOutOfBoundsException if the index is too big.
+ *
+ * @param y index
+ */
+ protected void checkY(int y) {
if (!(this.data.get(0).isEmpty()) && (y > this.data.get(0).size())) {
throw new IndexOutOfBoundsException(String.format(indexExceptionText,
y, this.data.size()));
@@ -866,7 +898,7 @@
/**
* Check if the index is into the data.frame length throws a
- * IndexOutOfBoundsException if not the index is too big.
+ * IndexOutOfBoundsException if the index is too big.
*
* @param x index
*/
@@ -878,7 +910,7 @@
}
}
- private void checkType(Object o) throws RException {
+ protected void checkType(Object o) throws RException {
if (!(o instanceof String) && !(o instanceof Double) &&
!(o instanceof Integer) && !(o instanceof Boolean)) {
throw new RException("Not supported type");
@@ -1001,12 +1033,13 @@
}
}
- String returnString = "";
+ StringBuffer returnString = new StringBuffer();
for (String str:linesToDisplay){
- returnString+= str +"\n";
+ returnString.append(str);
+ returnString.append("\n");
}
- return returnString;
+ return returnString.toString();
}
}
Modified: trunk/src/main/java/org/nuiton/j2r/types/REXPAbstract.java
===================================================================
--- trunk/src/main/java/org/nuiton/j2r/types/REXPAbstract.java 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/main/java/org/nuiton/j2r/types/REXPAbstract.java 2010-10-22 08:51:00 UTC (rev 241)
@@ -352,12 +352,14 @@
this.names = names;
//Create the r instruction (names(var)<-c("name 1",...,"name x")).
- String namesString = "";
+ StringBuilder namesString = new StringBuilder("");
for (int i = 0; i < this.names.size(); i++) {
if (i != 0) {
- namesString += ",";
+ namesString.append(",");
}
- namesString += "\"" + names.get(i) + "\"";
+ namesString.append("\"");
+ namesString.append(names.get(i));
+ namesString.append("\"");
}
String rexp = String.format(RInstructions.SET_NAMES, this.variable,
namesString);
Modified: trunk/src/main/java/org/nuiton/j2r/types/RList.java
===================================================================
--- trunk/src/main/java/org/nuiton/j2r/types/RList.java 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/main/java/org/nuiton/j2r/types/RList.java 2010-10-22 08:51:00 UTC (rev 241)
@@ -44,8 +44,8 @@
public class RList extends REXPAbstract implements REXP {
//Content of the list (eg elements of the list in R)
- private List<Object> data;
- private Log log = LogFactory.getLog(RDataFrame.class);
+ protected List<Object> data;
+ protected Log log = LogFactory.getLog(RDataFrame.class);
/**
* Create a default RList linked to a R engine (the List is not initialized
* in R.)
@@ -138,20 +138,22 @@
@Override
public String toRString() throws RException {
checkVariable();
- String returnString = this.variable + "<-list(";
+ StringBuilder returnString = new StringBuilder();
+ returnString.append(this.variable);
+ returnString.append("<-list(");
if ((this.data != null) && (!(this.data.isEmpty()))) {
for (int i = 0; i < data.size(); i++) {
- returnString += toRString(i);
+ returnString.append(toRString(i));
}
- returnString = returnString.substring(0, returnString.length() - 1);
+ returnString = new StringBuilder(returnString.substring(0, returnString.length() - 1));
}
- returnString += ")";
+ returnString.append(")");
if (log.isDebugEnabled()){
log.debug(returnString);
}
- return returnString;
+ return returnString.toString();
}
/**
@@ -160,7 +162,7 @@
* @return the corresponding R instruction
* @throws RException if an error occur creating R instruction for REXPs
*/
- private String toRString(int i) throws RException {
+ protected String toRString(int i) throws RException {
String returnString="";
Object obj = data.get(i);
@@ -295,7 +297,7 @@
}
- private void setInData(int x, Object data){
+ protected void setInData(int x, Object data){
for (int i = 0; i <= x; i++) {
try {
this.data.get(i);
@@ -431,20 +433,25 @@
@Override
public String toString(){
- String returnString="";
+ StringBuilder returnString = new StringBuilder("");
for(int i=0;i<this.data.size();i++){
//display the index
if( (names!=null) && (!names.isEmpty()) && (names.get(i)!=null)){
- returnString += "[[" + names.get(i) + "]]\n";
+ returnString.append("[[");
+ returnString.append(names.get(i));
+ returnString.append("]]\n");
} else {
- returnString += "[[" + i + "]]\n";
+ returnString.append("[[");
+ returnString.append(i);
+ returnString.append("]]\n");
}
//display the item at index i
- returnString += this.data.get(i) + "\n\n";
+ returnString.append(this.data.get(i));
+ returnString.append("\n\n");
}
- return returnString;
+ return returnString.toString();
}
}
Modified: trunk/src/site/rst/installTest.rst
===================================================================
--- trunk/src/site/rst/installTest.rst 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/site/rst/installTest.rst 2010-10-22 08:51:00 UTC (rev 241)
@@ -1,3 +1,27 @@
+.. -
+.. * #%L
+.. * Nuiton Java-2-R library
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2006 - 2010 CodeLutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * 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 Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
Installer l'environnement de tests
==================================
@@ -77,5 +101,12 @@
(C:\Program Files\R\R-(version) ou ...) (en fait sur le dossier contenant la
librairie R.dll)
+Lancer les tests
+================
+
+Il faut lancer un serveur Rserve, en lançant la commande ::
+
+ R CMD Rserve
+
Tout doit maintenant être prêt et vous pouvez faire tourner les tests de
nuiton-j2r.
\ No newline at end of file
Modified: trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java 2010-10-22 08:51:00 UTC (rev 241)
@@ -1,3 +1,27 @@
+/*
+ * #%L
+ * Nuiton Java-2-R library
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2006 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package org.nuiton.j2r;
import java.io.File;
Modified: trunk/src/test/java/org/nuiton/j2r/NetTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/NetTest.java 2010-10-19 15:12:39 UTC (rev 240)
+++ trunk/src/test/java/org/nuiton/j2r/NetTest.java 2010-10-22 08:51:00 UTC (rev 241)
@@ -8,16 +8,16 @@
* Copyright (C) 2006 - 2010 CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
- *
+ *
* 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
+ *
+ * You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
1
0
Author: jcouteau
Date: 2010-10-19 17:12:39 +0200 (Tue, 19 Oct 2010)
New Revision: 240
Url: http://nuiton.org/repositories/revision/nuiton-j2r/240
Log:
Add to test to prove anno #940 is obsolete
Modified:
trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java
Modified: trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java 2010-10-19 14:47:28 UTC (rev 239)
+++ trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java 2010-10-19 15:12:39 UTC (rev 240)
@@ -382,4 +382,17 @@
Assert.assertTrue(pictureFile.exists());
//engine.eval("plot(seq(1,10))");
}
+
+ @Test
+ public void testAno940RErrorNotThrown() throws Exception {
+
+ try {
+ engine.eval("FiletPoisson-LangousteCorse(Langousterouge)" +
+ "(Selectivity).equation.Ktemp<-c(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0)");
+ Assert.fail("Exception should have been thrown");
+ } catch (RException eee){
+ Assert.assertTrue(eee.getMessage().contains("FiletPoisson-LangousteCorse(Langousterouge)(Selectivity).equation.Ktemp"));
+ }
+
+ }
}
1
0
Author: jcouteau
Date: 2010-10-19 16:47:28 +0200 (Tue, 19 Oct 2010)
New Revision: 239
Url: http://nuiton.org/repositories/revision/nuiton-j2r/239
Log:
Add Third-party licenses
Added:
trunk/src/license/THIRD-PARTY.properties
Added: trunk/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/src/license/THIRD-PARTY.properties 2010-10-19 14:47:28 UTC (rev 239)
@@ -0,0 +1,14 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD License
+# - Common Public License Version 1.0
+# - The Apache Software License, Version 2.0
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Mon Oct 18 12:45:36 CEST 2010
+org.nuiton.thirdparty--JRI--0.8-4=LGPLv2.1
+org.nuiton.thirdparty--REngine--0.6-1=LGPLv2.1
+org.nuiton.thirdparty--Rserve--0.6-1=LGPLv2.1
1
0
Author: jcouteau
Date: 2010-10-19 16:31:02 +0200 (Tue, 19 Oct 2010)
New Revision: 238
Url: http://nuiton.org/repositories/revision/nuiton-j2r/238
Log:
Add doc about how to install test environment
Added:
trunk/src/site/rst/installTest.rst
Modified:
trunk/src/site/site.xml
Added: trunk/src/site/rst/installTest.rst
===================================================================
--- trunk/src/site/rst/installTest.rst (rev 0)
+++ trunk/src/site/rst/installTest.rst 2010-10-19 14:31:02 UTC (rev 238)
@@ -0,0 +1,81 @@
+Installer l'environnement de tests
+==================================
+
+Pour pouvoir effctuer les tests de nuiton-j2r, il faut un environnement
+spécial : R doit être installé de même que Rserve, certaines variables
+d'environnement doivent être déclarées et des librairies natives doivent être
+utilisées.
+
+Installation de R
+-----------------
+
+Pour installer R, référez-vous au site du projet : http://cran.r-project.org/
+
+Pour information, sur les distributions linux de type debian/ubuntu, il faut
+faire, en root, un petit ::
+
+ apt-get install r-base-core
+
+Installation de Rserve
+----------------------
+
+Pour installer Rserve, deux solutions sont possibles. Soit démarrer R (sous
+linux par la commande R) puis lancer la commande ::
+
+ install.packages("Rserve")
+
+Soit, pour les utilisateurs linux, installer par les packets, soit pour
+debian/ubuntu, en root ::
+
+ apt-get install r-cran-rserve
+
+Installation de JRI
+-------------------
+
+Pour installer JRI, le processus est plus complexe. Soit vous pouvez vous
+satisfaire des versions précompilées, soit vous devrez compiler la librairie
+pour votre système.
+
+Installation sans compilation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Dans le dossier src/main/resources, vous pourrez trouver la librairie jri
+précompilée pour la plupart des environnements. Vous pouvez la recompiler si
+besoin, ou si les version précompilées ne fonctionnent pas.
+
+Copiez le fichier correspondant à votre système dans le dossier que vous
+souhaitez.
+
+Passez maintenant à la phase de configuration
+
+Installation avec compilation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Pour compiler la librairie, dézippez dans un premier temps l'archive
+*JRI-sources.zip*. Ensuite, excécutez le script nommé "configure" de manière à
+préparer votre système à la compilation. Enfin, effectuez la compilation à
+l'aide de la commande "make".
+
+La compilation effectuée, un fichier a été généré, dont le nom est propre à la
+plateforme (libjri.so, jri.dll, ...).
+
+Copiez le fichier correspondant à votre système dans le dossier que vous
+souhaitez.
+
+Passez maintenant à la phase de configuration.
+
+Configuration
+~~~~~~~~~~~~~
+
+Vous devez modifier vos variables d'environnement :
+
+- R_HOME : doit pointer sur le dossier d'installation de R (soit /usr/lib/R sous
+ Linux ou C:\Program Files\R\R-(version) sous Windows ou ...)
+- LD_LIBRARY_PATH : doit pointer sur le dossier lib contenu dans R_HOME (soit
+ R_HOME/lib/ sous Linux ou R_HOME\lib sous Windows ou ...)
+- PATH (pour Windows) : doit pointer sur le dossier d'installation de R
+ (C:\Program Files\R\R-(version) ou ...) (en fait sur le dossier contenant la
+ librairie R.dll)
+
+Tout doit maintenant être prêt et vous pouvez faire tourner les tests de
+nuiton-j2r.
\ No newline at end of file
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2010-10-19 14:28:46 UTC (rev 237)
+++ trunk/src/site/site.xml 2010-10-19 14:31:02 UTC (rev 238)
@@ -48,6 +48,7 @@
<item href="etude.html" name="Etude"/>
<item href="installation.html" name="Installation"/>
<item href="module.html" name="Utilisation"/>
+ <item href="installTest.html" name="Environnement de tests"/>
</menu>
<menu name="Téléchargement">
1
0
Author: jcouteau
Date: 2010-10-19 16:28:46 +0200 (Tue, 19 Oct 2010)
New Revision: 237
Url: http://nuiton.org/repositories/revision/nuiton-j2r/237
Log:
Use an abstract test to not duplicate common tests for R engines
Added:
trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java
Modified:
trunk/src/test/java/org/nuiton/j2r/JNITest.java
trunk/src/test/java/org/nuiton/j2r/NetTest.java
Added: trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java (rev 0)
+++ trunk/src/test/java/org/nuiton/j2r/AbstractEngineTest.java 2010-10-19 14:28:46 UTC (rev 237)
@@ -0,0 +1,385 @@
+package org.nuiton.j2r;
+
+import java.io.File;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.j2r.types.RDataFrame;
+import org.nuiton.j2r.types.RList;
+
+import static org.nuiton.j2r.TestConstants.S_NB_LOOPS;
+import static org.nuiton.j2r.TestConstants.S_OP;
+import static org.nuiton.j2r.TestConstants.S_T_MAX;
+import static org.nuiton.j2r.TestConstants.V_MAX;
+import static org.nuiton.j2r.TestConstants.V_NB_LOOPS;
+import static org.nuiton.j2r.TestConstants.V_OP_A;
+import static org.nuiton.j2r.TestConstants.V_OP_AB;
+import static org.nuiton.j2r.TestConstants.V_OP_B;
+import static org.nuiton.j2r.TestConstants.V_OP_R;
+
+/**
+ * User: couteau
+ * Date: 19 oct. 2010
+ */
+public abstract class AbstractEngineTest {
+
+ protected REngine engine;
+ protected String savedRType;
+
+ @Test
+ public void testDouble() throws Exception {
+ Assert.assertEquals(5.0, engine.eval("5.0"));
+ engine.voidEval("t<-sin(0)");
+ double d = (Double) engine.eval("t");
+ Assert.assertEquals(0.0, d, 0);
+ }
+
+ @Test
+ public void testDoubleArray() throws Exception {
+ Object result = engine.eval("5.5:10.5");
+ Assert.assertEquals(double[].class, result.getClass());
+ double[] doubleArray = (double[]) result;
+ Assert.assertEquals(6, doubleArray.length);
+ for (int i = 5; i < 11; i++) {
+ double d = i + 0.5;
+ Assert.assertEquals(d, doubleArray[i - 5], 0);
+ }
+ }
+
+ @Test
+ public void testSimpleOp() throws Exception {
+ LutinTimer t = new LutinTimer();
+ for (int loop = 0; loop < S_NB_LOOPS; loop++) {
+ engine.voidEval("t<-0");
+ t.startTiming();
+ engine.voidEval(S_OP);
+ t.endTiming();
+ double d = (Double) engine.eval("t");
+ Assert.assertEquals((double) S_T_MAX, d, 0);
+ }
+ double[] results = t.computeResults();
+ System.err.println("[SO]min: " + results[0]);
+ System.err.println("[SO]avg: " + results[1]);
+ System.err.println("[SO]max: " + results[2]);
+ System.err.println("[SO]etype: " + results[3]);
+ }
+
+ @Test
+ public void testVector() throws Exception {
+ System.err.println(V_OP_R);
+ LutinTimer t = new LutinTimer();
+ for (int loop = 0; loop < V_NB_LOOPS; loop++) {
+ t.startTiming();
+ engine.voidEval(V_OP_A);
+ engine.voidEval(V_OP_B);
+ double[] r = (double[]) engine.eval(V_OP_AB);
+ t.endTiming();
+ Assert.assertEquals(V_MAX, r.length);
+ }
+ double[] results = t.computeResults();
+ System.err.println("[V]min: " + results[0]);
+ System.err.println("[V]avg: " + results[1]);
+ System.err.println("[V]max: " + results[2]);
+ System.err.println("[V]etype: " + results[3]);
+ }
+
+ @Test
+ public void testString() throws Exception {
+ engine.voidEval("a<-\"testing string\"");
+ String testString = (String) engine.eval("a");
+ Assert.assertEquals("testing string", testString);
+ }
+
+ @Test
+ public void testInt() throws Exception {
+ engine.voidEval("a<-as.integer(5)");
+ Integer testInteger = (Integer) engine.eval("a");
+ Integer toCompare = 5;
+ Assert.assertEquals(toCompare, testInteger);
+ }
+
+ @Test
+ public void testIntArray() throws Exception {
+ engine.voidEval("a<-as.integer(5)");
+ engine.voidEval("b<-as.integer(6)");
+ engine.voidEval("z<-c(a,b)");
+ int[] testIntArray = (int[]) engine.eval("z");
+ Assert.assertEquals(5, testIntArray[0]);
+ Assert.assertEquals(6, testIntArray[1]);
+ }
+
+ @Test
+ public void testBool() throws Exception {
+ engine.voidEval("a<-TRUE");
+ engine.voidEval("b<-FALSE");
+ Boolean testA = (Boolean) engine.eval("a");
+ Boolean testB = (Boolean) engine.eval("b");
+ Assert.assertTrue(testA);
+ Assert.assertFalse(testB);
+ }
+
+ @Test
+ public void testArrayBool() throws Exception {
+ engine.voidEval("a<-c(TRUE,FALSE,TRUE)");
+ Boolean[] testBoolArray = (Boolean[]) engine.eval("a");
+ Assert.assertTrue(testBoolArray[0]);
+ Assert.assertFalse(testBoolArray[1]);
+ Assert.assertTrue(testBoolArray[2]);
+ }
+
+ @Test
+ public void testWorkingDirectory() throws Exception {
+
+ //test linux paths
+ File workingDirectory = new File("/tmp");
+ engine.setwd(workingDirectory);
+ File testWorkingDirectory = engine.getwd();
+ Assert.assertEquals(workingDirectory.getAbsolutePath(),
+ testWorkingDirectory.getAbsolutePath());
+
+ //test windows paths
+ File tempFile = File.createTempFile("test", "", new File(System.getProperty("java.io.tmpdir")));
+ Boolean tempBoolean = tempFile.delete();
+ tempBoolean = tempFile.mkdirs();
+ workingDirectory = new File(System.getProperty("java.io.tmpdir") +
+ "\\" + tempFile.getName());
+ engine.setwd(workingDirectory);
+ testWorkingDirectory = engine.getwd();
+ Assert.assertEquals(tempFile.getAbsolutePath(),
+ testWorkingDirectory.getAbsolutePath());
+ }
+
+ @Test
+ public void testRData() throws Exception {
+ File workingdir = new File("/tmp");
+ engine.voidEval("a<-5.0");
+ engine.saveRData(workingdir);
+ engine.remove("a");
+ engine.loadRData(workingdir);
+ Double testDouble = (Double) engine.eval("a");
+ Double compareTo = 5.0;
+ Assert.assertEquals(compareTo, testDouble);
+ }
+
+ @Test
+ public void testDputDget() throws Exception {
+ File workingdir = new File("/tmp");
+ File testingFile = new File("/tmp/testfile");
+
+ // test method using the workingdir
+ engine.voidEval("a<-5.0");
+ engine.setwd(workingdir);
+ engine.dput("a", "testDputDgetfile");
+ engine.remove("a");
+ engine.dget("a", "testDputDgetfile");
+ Double testDouble = (Double) engine.eval("a");
+ Double compareTo = 5.0;
+ Assert.assertEquals(compareTo, testDouble);
+
+ //test method using absolute path
+ workingdir = new File("/");
+ engine.setwd(workingdir);
+ engine.voidEval("a<-6.0");
+ engine.dput("a", testingFile);
+ engine.remove("a");
+ engine.dget("a", testingFile);
+ Double testDouble2 = (Double) engine.eval("a");
+ Double compareTo2 = 6.0;
+ Assert.assertEquals(compareTo2, testDouble2);
+ File testWorkingDirectory = engine.getwd();
+ Assert.assertEquals(workingdir.getAbsolutePath(),
+ testWorkingDirectory.getAbsolutePath());
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+ engine.voidEval("a<-6.0");
+ Assert.assertEquals(6.0, engine.eval("a"));
+ try {
+ engine.remove("a");
+ engine.eval("a");
+ Assert.fail("Exception should have been thrown at this point");
+ } catch (RException re) {
+ System.out.println(re.getMessage());
+ Assert.assertTrue(
+ re.getMessage().contains("object \'a\' not found"));
+ }
+ }
+
+ @Test
+ public void testMvCp() throws Exception {
+ //Test only mv as mv uses cp.
+ engine.voidEval("a<-5.0");
+ engine.remove("b");
+ engine.mv("a", "b");
+ Assert.assertEquals(5.0, engine.eval("b"));
+ Assert.assertFalse((Boolean) engine.eval("exists(\"a\")"));
+ }
+
+ @Test
+ public void testLsClearSession() throws Exception {
+ //Test only ClearSession as it uses ls
+ engine.voidEval("a<-5.0");
+ engine.voidEval("b<-5.0");
+ engine.voidEval("d<-5.0");
+ engine.voidEval("e<-5.0");
+ engine.voidEval("f<-5.0");
+ engine.clearSession();
+ Assert.assertFalse((Boolean) engine.eval("exists(\"a\")"));
+ Assert.assertFalse((Boolean) engine.eval("exists(\"b\")"));
+ Assert.assertFalse((Boolean) engine.eval("exists(\"d\")"));
+ Assert.assertFalse((Boolean) engine.eval("exists(\"e\")"));
+ Assert.assertFalse((Boolean) engine.eval("exists(\"f\")"));
+ }
+
+ @Test
+ public void testAutoCommitFalse() throws Exception {
+ engine.clearSession();
+ engine.setAutoCommit(false);
+ engine.voidEval("a<-5.0");
+ engine.voidEval("a<-a+5.0");
+ engine.voidEval("b<-5.0");
+ engine.voidEval("d<-5.0");
+ engine.voidEval("e<-5.0");
+ engine.voidEval("f<-5.0");
+ engine.commit();
+ Assert.assertEquals(10.0, engine.eval("a"));
+ Assert.assertEquals(5.0, engine.eval("b"));
+ Assert.assertEquals(5.0, engine.eval("d"));
+ Assert.assertEquals(5.0, engine.eval("e"));
+ Assert.assertEquals(5.0, engine.eval("f"));
+ }
+
+ @Test
+ public void testThrowException() throws Exception {
+ engine.clearSession();
+ //Test that the exception is normally thrown in voidEval
+ try {
+ engine.voidEval("a<-b");
+ Assert.fail("Exception should have been thrown at this point");
+ } catch (RException e) {
+ Assert.assertTrue(
+ e.getMessage().contains("object \'b\' not found"));
+ }
+
+ engine.clearSession();
+ //Test that the exception is normally thrown in eval
+ try {
+ engine.eval("a");
+ Assert.fail("Exception should have been thrown at this point");
+ } catch (RException e) {
+ Assert.assertTrue(
+ e.getMessage().contains("object \'a\' not found"));
+ }
+ }
+
+ @Test
+ public void testDataFrame() throws Exception {
+ engine.voidEval("a<-data.frame(c(3,4,5,6),c(as.integer(3),as.integer(4),as.integer(5),as.integer(6)),c(\"a\",\"b\",\"c\",\"d\"),c(TRUE,FALSE,TRUE,FALSE),stringsAsFactors=FALSE)");
+ RDataFrame testA = (RDataFrame) engine.eval("a");
+ engine.setAutoCommit(false);
+ Assert.assertEquals(testA.get(0, 0), 3.0);
+ Assert.assertEquals(testA.get(0, 1), 4.0);
+ Assert.assertEquals(testA.get(0, 2), 5.0);
+ Assert.assertEquals(testA.get(0, 3), 6.0);
+ Assert.assertEquals(testA.get(1, 0), 3);
+ Assert.assertEquals(testA.get(1, 1), 4);
+ Assert.assertEquals(testA.get(1, 2), 5);
+ Assert.assertEquals(testA.get(1, 3), 6);
+ Assert.assertEquals(testA.get(2, 0), "a");
+ Assert.assertEquals(testA.get(2, 1), "b");
+ Assert.assertEquals(testA.get(2, 2), "c");
+ Assert.assertEquals(testA.get(2, 3), "d");
+ Assert.assertEquals(testA.get(3, 0), true);
+ Assert.assertEquals(testA.get(3, 1), false);
+ Assert.assertEquals(testA.get(3, 2), true);
+ Assert.assertEquals(testA.get(3, 3), false);
+ engine.setAutoCommit(true);
+ }
+
+ @Test
+ public void testList() throws Exception {
+ //create a data.frame to be added to the list
+ engine.voidEval("b<-data.frame(c(3,4,5,6),c(as.integer(3),as.integer(4),as.integer(5),as.integer(6)),c(\"a\",\"b\",\"c\",\"d\"),c(TRUE,FALSE,TRUE,FALSE),stringsAsFactors=FALSE)");
+ engine.voidEval("a<-list(one=as.integer(2),two=3.0,three=TRUE,four=\"b\",five=b)");
+ RList testA = (RList) engine.eval("a");
+ engine.setAutoCommit(false);
+ Assert.assertEquals(testA.get(0), 2);
+ Assert.assertEquals(testA.get(1), 3.0);
+ Assert.assertEquals(testA.get(2), true);
+ Assert.assertEquals(testA.get(3), "b");
+ Assert.assertTrue(testA.get(4) instanceof RDataFrame);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(0, 0), 3.0);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(0, 1), 4.0);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(0, 2), 5.0);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(0, 3), 6.0);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(1, 0), 3);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(1, 1), 4);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(1, 2), 5);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(1, 3), 6);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(2, 0), "a");
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(2, 1), "b");
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(2, 2), "c");
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(2, 3), "d");
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(3, 0), true);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(3, 1), false);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(3, 2), true);
+ Assert.assertEquals(((RDataFrame) testA.get(4)).get(3, 3), false);
+ Assert.assertEquals(testA.getName(0), "one");
+ Assert.assertEquals(testA.getName(1), "two");
+ Assert.assertEquals(testA.getName(2), "three");
+ Assert.assertEquals(testA.getName(3), "four");
+ Assert.assertEquals(testA.getName(4), "five");
+ engine.setAutoCommit(true);
+
+ }
+
+ @Test
+ public void testLongLines() throws Exception {
+ engine.voidEval("SensitivityBiomassY3<-c(2.179694924446179E7,2.179468496519559E7,2.1818736174725175E7,2.1816429067949396E7,2.1800098718126506E7,2.1838067907599747E7,2.183569971088971E7,2.1833313097146016E7,2.185719149559428E7,2.1854762634011697E7,2.185231549094628E7,2.187610838662306E7,2.187361928018277E7,2.1871112026349083E7,2.189482001091965E7,2.1892271074663457E7,2.1889704123663016E7,2.1913327781288046E7,2.1910719425357413E7,2.1908093185913157E7,2.193163309335182E7,2.192896572306039E7,2.1926280599087697E7,2.1949737325799696E7,2.1964830419511076E7,2.1944267732381735E7,2.1967641840627935E7,2.196485763859664E7,2.1962055938437656E7,2.198534798337946E7,2.198250595466467E7,2.19796465535838E7,2.2002857083381277E7,2.1999957614685252E7,2.1997040898068156E7,2.2020170453976974E7,2.2017213927520543E7,2.201424027629076E7,2.201424027629076E7,2.2007088929931033E7,2.1999922487316884E7,2.197681420767298E7,2.196962074430254E7,2.1962412278355762E7,2.1939244418647803E7,2.19320089340683E7,2.1924758538858987E7,2.1901530675850462E7,2.1894253260547817E7,2.1886961024817027E7,2.186367272884308E7,2.1856353467938498E7,2.1849019475049105E7,2.182567030993665E7,2.181830928313515E7,2.1810933611020483E7,2.1787523134007405E7,2.178012041554803E7,2.1772703136661157E7,2.1749230898314577E7,2.1749758710004635E7,2.1734327738178723E7,2.171079328231229E7,2.1703307381126277E7,2.1695807083871227E7,2.167220994746149E7,2.1664682544012114E7,2.1657140823937435E7,2.1633480537039224E7,2.162591168317374E7,2.161832859028344E7,2.1594604675944276E7,2.158699441777762E7,2.157936999632849E7,2.1555581970502105E7,2.1547930348361045E7,2.155103621183836E7,2.152717169457966E7,2.1530236120902758E7,2.153328412702021E7,2.1509330625330385E7,2.1512336892940816E7,2.1515326604867205E7,2.1491283471099153E7,2.1494231139260102E7,2.1497162114652816E7,2.147302869279387E7,2.14759173151992E7,2.147878910612182E7,2.1454564731677204E7,2.1457393856367446E7,2.1462383791402113E7,2.1435890009080574E7,2.143865917835912E7,2.1441411233736E7,2.1417002926115625E7,2.141971167646219E7,2.1424717356960263E7,2.1397901863381278E7,2.1400549725365438E7,2.140318018420746E7,2.137858518066629E7,2.1381171678860184E7,2.1383740626669012E7,2.135905121665088E7,2.1361575869539354E7,2.1364082823016256E7,2.1339298288600616E7,2.1341760608492017E7,2.1344205078135047E7,2.1319324692060333E7,2.1321724184994433E7,2.132410567500613E7,2.132410567500613E7,2.1331536055398986E7,2.133895052044593E7,2.1363853672607094E7,2.137123650604985E7,2.137860336066902E7,2.140343328441597E7,2.1410768581059605E7,2.1418087833224125E7,2.1442845113907605E7,2.1450132877092432E7,2.1457404527983494E7,2.148208974251862E7,2.1489329968841057E7,2.1496554012913797E7,2.1521167729882605E7,2.1528360409261446E7,2.1535536834311184E7,2.1560079614063937E7,2.156722472980476E7,2.1563254271749333E7,2.1598825911786724E7,2.1605923440646578E7,2.1613004564718306E7,2.1637407118662428E7,2.1644457030912723E7,2.1651490460029803E7,2.167582370941422E7,2.1682825968903817E7,2.1689811664860353E7,2.171407613809878E7,2.1721030702315085E7,2.172796862056064E7,2.1752164838324733E7,2.1759071658455327E7,2.1765961748155564E7,2.1790090223469418E7,2.179694924446179E7,2.180379144855871E7,2.182785268689249E7,2.18346638475134E7,2.184145810278461E7,2.1865452602147E7,2.1872215835041337E7,2.1878962072157502E7,2.1902890323187094E7,2.1909605554935444E7,2.191630369851899E7,2.1940166184574656E7,2.1946833335751027E7,2.1953483304432537E7,2.1977280501682773E7,2.198389948690986E7,2.1990501193384256E7,2.20142335708955E7,2.2020804298901647E7,2.20273576499835E7,2.205102566980741E7,2.205754804348026E7,2.2064052940158665E7,2.20876570574184E7,2.2094130973859813E7,2.2100587311352342E7,2.2124127974327955E7,2.2130553324907117E7,2.2136960992712937E7,2.2160438642925616E7,2.2166815313332282E7,2.2173174195284456E7,2.2196589267580014E7,2.2202917137875687E7,2.2209227112193614E7,2.2232580034824714E7,2.2238858979494706E7,2.2245119918834776E7,2.2245119918834776E7,2.2247156092664756E7,2.2249172537482113E7,2.222580215006561E7,2.2227776978241052E7,2.2229731947289977E7,2.2206281851083208E7,2.2208194947734725E7,2.221008805387345E7,2.2186557726205546E7,2.2188408701148424E7,2.219023955290159E7,2.2166628464420535E7,2.2168416923091725E7,2.217018512458671E7,2.2146492739166215E7,2.2148218282559495E7,2.214992343346224E7,2.2126149208107647E7,2.212781143270992E7,2.21294531281596E7,2.21055965129125E7,2.21071950106372E7,2.21087728411807E7,2.2084833279022325E7,2.208636763714323E7,2.2087881188668158E7,2.2063858115421828E7,2.2065327916506168E7,2.2066776770173687E7,2.2042669614405714E7,2.2044074436245814E7,2.2045458168422367E7,2.2021266351342022E7,2.2022605766886715E7,2.2023923949074898E7,2.1999646884433046E7,2.200092046171817E7,2.1995009663381506E7,2.1970654681075428E7,2.196470853722463E7,2.195874261494959E7,2.1934317104578134E7,2.1928315823420756E7,2.1922294864394967E7,2.1897798306555357E7,2.1891741970889103E7,2.1885666055779688E7,2.1861097923225783E7,2.1854986609282427E7,2.1848855812173687E7,2.1824215569718488E7,2.1818049347101532E7,2.1811863735432312E7,2.1787150839849222E7,2.1780929771470487E7,2.177468940597102E7,2.174990330589387E7,2.174362744790923E7,2.1737332382536206E7,2.1712472518358346E7,2.1706141920103204E7,2.1699792201974563E7,2.167485800574659E7,2.1668472709669497E7,2.1662068378999148E7,2.163705927432551E7,2.1630619315921858E7,2.162416040595164E7,2.159907580788612E7,2.1592581215630468E7,2.1586067752563022E7,2.1560907067502897E7,2.1554357862780496E7,2.154778986571032E7,2.154778986571032E7,2.1546318044922113E7,2.1544825743281327E7,2.1569967765090413E7,2.1568428834061984E7,2.156686958059507E7,2.1591916967334844E7,2.159031142387256E7,2.158868571459585E7,2.1613639174591307E7,2.1611967510410193E7,2.161027583527415E7,2.1635136067757037E7,2.1633398768567167E7,2.163164161154166E7,2.165640930677329E7,2.165460685236462E7,2.1652784691524632E7,2.167746053091718E7,2.1675593395243883E7,2.1673706702852983E7,2.169829135908928E7,2.169636001035316E7,2.1694409252946746E7,2.1718903390098736E7,2.171690829083134E7,2.1714893929297917E7,2.1739298202943414E7,2.173723981008732E7,2.173516229975055E7,2.1759477357088927E7,2.1757356122077797E7,2.1755215912775498E7,2.1779442392741513E7,2.1777258761579778E7,2.178652675221615E7,2.1799194831120383E7,2.179694924446179E7,2.1210710366918586E7,2.0627838516436625E7,2.0073198124600604E7,2.0549043683745503E7,2.117617571938369E7,2.183569971088971E7,2.251575186207285E7,2.3202940491524644E7,2.3925578765007686E7,2.3793188782694403E7,2.3138942654097542E7,2.2516415708366465E7,2.1910735239279598E7,2.1308393153166354E7,2.0735369629764337E7,2.062075197238507E7,2.1249415366315708E7,2.1910719425357413E7,2.259259256512906E7,2.3281412413469028E7,2.4005949681793142E7,2.4574434204009376E7,2.3898455248209067E7,2.3255404417702474E7,2.262975868639601E7,2.200742405102502E7,2.1415521959997784E7,2.083963435585132E7,2.131951539029141E7,2.198250595466467E7,2.2666103736809526E7,2.3356464740940552E7,2.408279910221071E7,2.4831709742932335E7,2.4678545581240475E7,2.4014418717275385E7,2.336827049681634E7,2.2701638689529963E7,2.208683280168035E7,2.1488775533901934E7,2.1311501623371568E7,2.196962074430254E7,2.2648053985047437E7,2.3288386059390273E7,2.4007555430756032E7,2.474892353613376E7,2.5265224263798002E7,2.4580599089304656E7,2.391463458979512E7,2.3207892262497313E7,2.2579298145611316E7,2.1967830705018844E7,2.131877140228872E7,2.181830928313515E7,2.249157157422271E7,2.3126786933162935E7,2.3840438079766467E7,2.457610205488776E7,2.5270239604048863E7,2.5124739696302816E7,2.4443945095785588E7,2.3721312789605163E7,2.3078729441986065E7,2.2453656465589404E7,2.1790012717726383E7,2.1664682544012114E7,2.2332706673176605E7,2.2962731499231942E7,2.3670793068546023E7,2.440067947692717E7,2.508909057246626E7,2.567639023587526E7,2.498055401716986E7,2.424178659806919E7,2.358501525826246E7,2.2874950937338676E7,2.2198548154310785E7,2.1530236120902758E7,2.1965503936487645E7,2.2584629567022495E7,2.320849669835539E7,2.384970751062438E7,2.45221053058604E7,2.5199807825752024E7,2.497663210108002E7,2.4237269925320312E7,2.350704443679568E7,2.2798810309156775E7,2.2123949376097146E7,2.1457393856367446E7,2.1267154434465587E7,2.186632936271173E7,2.2470263114487886E7,2.309098302604801E7,2.3741694406832688E7,2.4397726677086536E7,2.4891263455218945E7,2.415364079136865E7,2.3425395629407085E7,2.2719097290006068E7,2.204587078549588E7,2.1381171678860184E7,2.073900458098361E7,2.1166832797286097E7,2.175135042538578E7,2.235211102801546E7,2.2981695918150727E7,2.361661976445475E7,2.4269194166454904E7,2.4066108134309478E7,2.3339955269476753E7,2.2635701478342265E7,2.1989961404597342E7,2.1331536055398986E7,2.0692815253972054E7,2.0567634415260237E7,2.1140548759382922E7,2.1729519249264557E7,2.239368387026964E7,2.3017741380537957E7,2.365929520573126E7,2.4206701581383433E7,2.348135733257032E7,2.2777736161977123E7,2.2153147761613276E7,2.1490754107489396E7,2.084539277225918E7,2.0273814573353328E7,2.068819355156516E7,2.1264457718227006E7,2.191411528874908E7,2.2524699062038783E7,2.315239814183554E7,2.3859881227222998E7,2.3652744106745705E7,2.2943451323818333E7,2.231358810227405E7,2.1644457030912723E7,2.0995380304288536E7,2.041902359479725E7,2.0241553740604583E7,2.080528000864457E7,2.1440642248132315E7,2.2037931744211115E7,2.265196079778825E7,2.334386505298643E7,2.382125038917487E7,2.3106368725026328E7,2.2471315736226093E7,2.179694924446179E7,2.114280859614047E7,2.0561751071342427E7,1.9944682760952137E7,2.0350159569657844E7,2.0973412533695985E7,2.155759032627611E7,2.2158137251554392E7,2.283469632473654E7,2.3470999338094838E7,2.3266517442576505E7,2.262635851712963E7,2.1946833335751027E7,2.1287703290811926E7,2.0702021560467873E7,2.0080279995467488E7,1.990513870532304E7,2.051255252742858E7,2.1083803801994085E7,2.1671059161511026E7,2.2332508169542134E7,2.2954719241943117E7,2.34239211469535E7,2.277873906946373E7,2.2094130973859813E7,2.1430085140456423E7,2.0839854889200248E7,2.021350938890342E7,1.9605976414660845E7,2.0058169000206765E7,2.061668109380032E7,2.1190837643538114E7,2.1837412735002644E7,2.244573693600014E7,2.3071107465361953E7,2.2928475004387636E7,2.2238858979494706E7,2.156997020837422E7,2.0953327634262163E7,2.031928213123918E7,1.9704409478000913E7,1.9541523597534645E7,2.008178918447587E7,2.063708154184719E7,2.1222097881208595E7,2.1782167960600212E7,2.2412409214834034E7,2.288129069845474E7,2.2188408701148424E7,2.15164929188283E7,2.0878899065220114E7,2.0246637990616675E7,1.9633509009368904E7,1.9051741734870337E7,1.943691348751304E7,1.9974288495292652E7,2.054031454051603E7,2.1108353968718503E7,2.1692195304523874E7,2.2307045752282713E7,2.21071950106372E7,2.14372382543343E7,2.080136258699364E7,2.0170976443629496E7,1.9559679007026408E7,1.8979519529000968E7,1.8809283014624868E7,1.93292166557891E7,1.9876754569292802E7,2.0426347190258507E7,2.0991225086705297E7,2.1585975945808336E7,2.2022605766886715E7,2.1354706270342696E7,2.072063602091685E7,2.0092217646871667E7,1.9547542072900824E7,1.8967197285597503E7,1.845315493151521E7,1.88885315004027E7,1.9423221602180608E7,2.0026269354807056E7,2.0648023852639187E7,2.123254141631277E7,2.1891741970889103E7,2.1766843919877376E7,2.11202361159165E7,2.0547498003043916E7,1.9990375859496813E7,1.9396653734149992E7,1.8870873471726857E7,1.8763303218098205E7,1.9293827317314055E7,1.9892377693907846E7,2.050948101367075E7,2.1089394951270908E7,2.174362744790923E7,2.2256048212515533E7,2.1594636798160095E7,2.1008919924772583E7,2.0439176253408026E7,1.9831872060683697E7,1.929418962356003E7,1.877116511955032E7,1.9161829949933916E7,1.9755805516186837E7,2.036817790478417E7,2.0943401537336618E7,2.1592581215630468E7,2.226186697834365E7,2.207520884537028E7,2.150042212522819E7,2.0893799125253893E7,2.0296482026974823E7,1.975080361854921E7,1.9219878954244867E7,1.9103331447423942E7,1.969971166041202E7,2.0314695355330423E7,2.0936715189178452E7,2.159031142387256E7,2.2264295589739572E7,2.278023273354139E7,2.2167399452806022E7,2.1571145688384026E7,2.0978751356566936E7,2.0414621112687685E7,1.9865747259597294E7,1.9320301685983643E7,1.977913755335712E7,2.039610798916919E7,2.1019920570274755E7,2.1675593395243883E7,2.235170388479439E7,2.3035350368316166E7,2.2908356203498308E7,2.2292060248826306E7,2.1679592173124865E7,2.109651200763306E7,2.0529204331880063E7,1.996529365701334E7,1.985533137222209E7,2.047419246080403E7,2.1099708315389667E7,2.1757356122077797E7,2.2435488309007194E7,2.3120953305239443E7,2.366944962251461E7,2.303257115592817E7,2.239949051917674E7,2.179694924446179E7,2.1582800974755637E7,2.132220069552558E7,2.11185307878848E7,2.1300085123832006E7,2.1489528672464654E7,2.1736105267599385E7,2.198861916011158E7,2.2193554178466234E7,2.2457935854459632E7,2.2412186365163937E7,2.213057294206349E7,2.1907952140411254E7,2.169068649422258E7,2.142664453126697E7,2.122005824647036E7,2.118128447617866E7,2.1367566254266616E7,2.161075181662697E7,2.1859762569234636E7,2.206122758866795E7,2.2321875708625615E7,2.2525810552501842E7,2.2239737444893744E7,2.2013925463701107E7,2.1793570223308872E7,2.152613268334539E7,2.1316657773628376E7,2.1112096708960515E7,2.1240944809821565E7,2.148073900218816E7,2.1726247176682107E7,2.192426483120831E7,2.2181182026772894E7,2.244441874563338E7,2.2343965586001858E7,2.2114989687818263E7,2.189157217722438E7,2.1657826684049536E7,2.1481861134108696E7,2.1310252383222595E7,2.1291347515805926E7,2.1566643386439852E7,2.184848374525294E7,2.212099677165949E7,2.2416407281501427E7,2.2719070295959707E7,2.2948119668591738E7,2.274961574759145E7,2.2556164993357025E7,2.23512613904517E7,2.2167552537808113E7,2.1988405842782084E7,2.1797702239891656E7,2.2020726285927694E7,2.2306401811247114E7,2.258232341259566E7,2.2881670928634193E7,2.3188326435314238E7,2.3485266775847882E7,2.3476131980370786E7,2.3274195584546782E7,2.306036373905514E7,2.2868626133802254E7,2.268166433271607E7,2.2482696884429052E7,2.2477917896325614E7,2.276739128485571E7,2.30466605563571E7,2.3349903694826085E7,2.3660508278237984E7,2.396093157217119E7,2.4218903733917497E7,2.400817095216517E7,2.3785073969811365E7,2.3585015258262463E7,2.331744627757713E7,2.3110555462957747E7,2.2854656147084348E7,2.3015747009194948E7,2.329569902877019E7,2.352682183843316E7,2.3763595550652813E7,2.4062787877269357E7,2.4312045364394195E7,2.422605003323576E7,2.3998389588862572E7,2.3720508444658138E7,2.344921021315164E7,2.323879969201972E7,2.2979398848798577E7,2.2908514230288062E7,2.317843503805836E7,2.3406229476741273E7,2.363956721378428E7,2.393468756390962E7,2.4180270050182305E7,2.4363700074971378E7,2.4132154914224472E7,2.3850425399392366E7,2.3575403674530827E7,2.336145454882542E7,2.3098559659378957E7,2.284173125333958E7,2.3055480880316418E7,2.3279914564995393E7,2.3509783969288055E7,2.380077829850311E7,2.404265337521539E7,2.4290565645753462E7,2.4260010642767034E7,2.397444172413691E7,2.3695706229231913E7,2.344269054528998E7,2.314165334501904E7,2.2847617039811883E7,2.2753802012594562E7,2.293840026763693E7,2.312765269094679E7,2.3340650997364912E7,2.3539855804151304E7,2.3744215648609586E7,2.3906272591229875E7,2.358672878959545E7,2.3274896029086925E7,2.2989060548060637E7,2.2691627934628997E7,2.2401151307133447E7,2.213521218864193E7,2.2233697486671917E7,2.243673498704297E7,2.2640960988426235E7,2.2840282445538927E7,2.3027808515149347E7,2.3247410698483635E7,2.312776918021058E7,2.28196915866069E7,2.2537018610587217E7,2.236588221206764E7,2.195639121440947E7,2.1693499155164544E7,2.158564929535018E7,2.1759558502130054E7,2.1955324631112434E7,2.213832390612545E7,2.2326030617057707E7,2.2536488275080547E7,2.2670694454728946E7,2.2366430382259358E7,2.208699936159411E7,2.179694924446181E7,2.1513758481920857E7,2.125398523455025E7,2.0983612842204567E7,2.109628427519062E7,2.128389504203701E7,2.1459210724855714E7,2.163902271099347E7,2.1840666883719392E7,2.20300919715181E7,2.191552349058341E7,2.1639406437831394E7,2.1353121527253184E7,2.1073644505494516E7,2.0817054812208567E7,2.0550302057201367E7,2.0447032525084432E7,2.0626784465038262E7,2.079468773941211E7,2.0966884332654934E7,2.1160037325478908E7,2.134141261153796E7,2.1467352175718762E7,2.1194614044124752E7,2.0912135723046537E7,2.0636411887780488E7,2.038306384233572E7,2.011996627976353E7,1.9862964308494963E7,1.998406758446474E7,2.014482325506297E7,2.0309677182599295E7,2.0494652542036593E7,2.0668267840910804E7,2.0846422601373654E7,2.0752968445634652E7,2.0474332543329127E7,2.0202395902872443E7,1.9986682536912356E7,1.9760783130720664E7,1.954012785927571E7,1.9522960082094874E7,1.9712048810959406E7,1.9905695371214602E7,2.015416369746075E7,2.0357915944941416E7,2.057028078195899E7,2.0774294803816352E7,2.0528646016777497E7,2.0288910016423583E7,2.0104803904727656E7,1.987573241675546E7,1.965200603795866E7,1.948178428520774E7,1.961812604291848E7,1.9809037937128045E7,2.0054303216014933E7,2.0255131313945077E7,2.046092617504088E7,2.0723211319667727E7,2.064888077648577E7,2.0405765289619416E7,2.0218535995389506E7,1.9986293836112317E7,1.9759498533282418E7,1.9586432159852266E7,1.9519652120447874E7,1.970780474520424E7,1.9949825653636657E7,2.0147705058135226E7,2.0350455509476036E7,2.060917061217219E7,2.076448699013356E7,2.0517994842178896E7,2.032762600569117E7,2.0094532572243024E7,1.992826566491457E7,1.9751750631704066E7,1.959596157545169E7,1.979762799759906E7,2.003872797416884E7,2.030269428304801E7,2.0573039811826043E7,2.0832368015315235E7,2.111591827455593E7,2.1108926062609725E7,2.091082189492144E7,2.0735169770109635E7,2.0563940105959684E7,2.037967933771062E7,2.021699863297404E7,2.021385253589832E7,2.0457917553273804E7,2.0725379982846912E7,2.099926924265825E7,2.126168137899885E7,2.1548867561324272E7,2.1782102633357514E7,2.157531083889262E7,2.139190792954339E7,2.1213135769972038E7,2.1020838240174975E7,2.0851016532201312E7,2.068537553775501E7,2.087914392806134E7,2.1150053600132417E7,2.1427435630355682E7,2.1692855929514192E7,2.1983622377098937E7,2.228156314295964E7,2.2253718670445587E7,2.2062286164065335E7,2.1875700901274793E7,2.16421155231462E7,2.1432541076814383E7,2.12279161177933E7,2.11406015194917E7,2.138029925476085E7,2.162567378947092E7,2.182469883557617E7,2.2081413149714403E7,2.234440567100169E7,2.249678298707227E7,2.226712223265128E7,2.204307246241817E7,2.177224617969986E7,2.1559367015092243E7,2.1351538647396944E7,2.109796385286568E7,2.1280348766236868E7,2.152256335771631E7,2.171838083469002E7,2.19717253498737E7,2.223123375820159E7,2.2443167564732175E7,2.2399210234947044E7,2.217165957284462E7,2.1896949965474334E7,2.1680795126377612E7,2.146979246769457E7,2.121268092757171E7,2.1174895022551663E7,2.1413937683383066E7,2.1606560535874575E7,2.1856524594306666E7,2.2112538879026916E7,2.2320964295446754E7,2.252591870060584E7,2.2294895699372217E7,2.2016351148507055E7,2.179694924446179E7,2.2331824429699514E7,2.2855433361901157E7,2.3404487214268394E7,2.294142103956324E7,2.2324441999097317E7,2.1736105267599385E7,2.1157628653165985E7,2.0571940996573642E7,2.001321950420239E7,2.012001521949783E7,2.0610767161002416E7,2.1125120342784844E7,2.164651010639106E7,2.2156678383773886E7,2.2691918664613448E7,2.2805112652218632E7,2.219354176321105E7,2.161075181662697E7,2.1037735985237803E7,2.0457219288610935E7,1.9903793747161057E7,1.9488637544425823E7,1.9966665391087614E7,2.0467920301008943E7,2.0976050836749885E7,2.1473027341601636E7,2.199468580517517E7,2.2523424240659732E7,2.205791439697501E7,2.148073900218816E7,2.0913250056273438E7,2.033798567507657E7,1.978991846894483E7,1.9251159123297397E7,1.9337016475624252E7,1.982539976317407E7,2.0320500278302457E7,2.0840234256234802E7,2.1385944860698376E7,2.194030469414052E7,2.210590277779634E7,2.1566643386439852E7,2.1035276284650847E7,2.052916558712231E7,2.0012885688423205E7,1.9504240212668225E7,1.914597245636108E7,1.966564970768373E7,2.019365888132567E7,2.0747578982121963E7,2.129296337826814E7,2.1846984486465834E7,2.2428472535802145E7,2.20207262859277E7,2.1481059856196947E7,2.0966801053767882E7,2.044242611337692E7,1.9925785984183084E7,1.9445287866034742E7,1.9569464602423172E7,2.0097071911044825E7,2.0650197120948106E7,2.1195143034974054E7,2.174871092095583E7,2.2329323898903012E7,2.247791789632563E7,2.1929942224403653E7,2.1407504349966824E7,2.0875024935201477E7,2.0350380737533808E7,1.9849734706027746E7,1.946867528159764E7,1.9995768957046025E7,2.0547974113317214E7,2.1092364920947142E7,2.166394686541127E7,2.226314941013937E7,2.2854656147084344E7,2.2458540272984866E7,2.1944900002136175E7,2.14203655338795E7,2.090289713492715E7,2.0408796196330402E7,1.990484878917003E7,2.006108299669223E7,2.0634694427358806E7,2.120175864847823E7,2.1778463552713715E7,2.2382616792808183E7,2.2979398848798577E7,2.315131943473774E7,2.2624412031072915E7,2.2086607573908266E7,2.1556030220523257E7,2.1049134932153124E7,2.0532394305307217E7,2.0155591800375476E7,2.0733841117966734E7,2.130586365490205E7,2.188760285404254E7,2.2496595819886178E7,2.3098559659378957E7,2.3710626159261644E7,2.3317646387790464E7,2.2766369623098884E7,2.222248331524084E7,2.1702572233762216E7,2.1172843463076215E7,2.0650291112794127E7,2.082750676368124E7,2.1404392701349508E7,2.1991069029673535E7,2.2570531369717266E7,2.314165334501904E7,2.3721248524592787E7,2.384361141338243E7,2.324742537082883E7,2.2660365518774025E7,2.2065367969340097E7,2.1496636553747363E7,2.0936717628245063E7,2.0504862578794934E7,2.1043720865348622E7,2.1590676545610815E7,2.212863152921111E7,2.269162793462899E7,2.3262996016340885E7,2.382431088401486E7,2.337519266281572E7,2.2787036963065572E7,2.2190511690875802E7,2.1620748035310674E7,2.105982235960949E7,2.0491385644285306E7,2.061950674156031E7,2.1158520148774885E7,2.168839965714183E7,2.224325053139479E7,2.2806371268771283E7,2.3359296776102714E7,2.349720266248471E7,2.290809018288732E7,2.231018627306776E7,2.1739523735758387E7,2.1177722084197752E7,2.060801683057323E7,2.019737896084555E7,2.0728438400004502E7,2.1250255491423395E7,2.179694924446179E7,2.2351810845186867E7,2.2896361415497024E7,2.34673816862853E7,2.3023658536161214E7,2.2424519877953082E7,2.1853086965165038E7,2.1290535352017526E7,2.071969638585591E7,2.0175002659378543E7,2.03008146798796E7,2.0814588591157842E7,2.1353121527253184E7,2.1901198553444345E7,2.2435916535651654E7,2.299846519089168E7,2.3133874006937698E7,2.2533639436262306E7,2.196155994087558E7,2.1398379756241336E7,2.0831880676123228E7,2.0281258428302288E7,1.9876004085683852E7,2.0381759861590605E7,2.0912135723046537E7,2.145047510584317E7,2.19783439218411E7,2.250403067372545E7,2.3094738815524373E7,2.2637670594426885E7,2.206506373089962E7,2.1501371873062074E7,2.092865113588225E7,2.0382899411775194E7,1.984574849092129E7,1.9952103012631103E7,2.0474332543329116E7,2.1004423430395804E7,2.1560931405266024E7,2.214531691178439E7,2.2739694435204152E7,2.293183714702572E7,2.2392468378613237E7,2.1860316289117955E7,2.1353463074323934E7,2.083509649568674E7,2.032373871512065E7,1.9968283859677758E7,2.052864601677749E7,2.10986999234755E7,2.1696853675125007E7,2.2287125819984794E7,2.288748409851376E7,2.3517699057573907E7,2.3110838351093642E7,2.256465697425747E7,2.204419087489216E7,2.1512127255885277E7,2.09872383735701E7,2.048655364123707E7,2.0648880776485767E7,2.122458291883902E7,2.182827231603412E7,2.24243705563821E7,2.3030647473853115E7,2.3666655701840118E7,2.3845490098184697E7,2.3285031169750787E7,2.2750687572362773E7,2.2204684529074334E7,2.166602485979557E7,2.115597872152922E7,2.076448699013355E7,2.134577305876403E7,2.195491375186435E7,2.2556769890430007E7,2.3147282149450656E7,2.376620284426716E7,2.4375786394523405E7,2.3931872915482566E7,2.3363614362415303E7,2.278476306724695E7,2.2214436631114103E7,2.166992274332534E7,2.111720637510088E7,2.1262608405934777E7,2.1850997058493238E7,2.2431386797166683E7,2.3020909338318553E7,2.363834581164402E7,2.424687907733571E7,2.440641797253779E7,2.3829612158466004E7,2.3242349369345333E7,2.2663715094404805E7,2.211097304843052E7,2.1548867561324283E7,2.113448349320343E7,2.1721362444207337E7,2.2300655419081565E7,2.2889054497973528E7,2.3504857204500623E7,2.4112200705898315E7,2.472897408636128E7,2.4297366495217163E7,2.3701711277208768E7,2.3114787944667332E7,2.2553810127248496E7,2.1983622377098937E7,2.1421880205984302E7,2.158639021257613E7,2.216445036005833E7,2.2751587222834248E7,2.3330198176623296E7,2.3899141443574466E7,2.4475790187439345E7,2.4580038347294193E7,2.3944009003179368E7,2.331848771734921E7,2.2685904040408395E7,2.2081413149714403E7,2.1487028738378E7,2.1025001579972226E7,2.155823036015128E7,2.2098775932078365E7,2.262913248602956E7,2.318410728953877E7,2.3746616648948003E7,2.429784782814121E7,2.381848647603142E7,2.3198415705305327E7,2.257092092866275E7,2.1971725349873707E7,2.1382556244578436E7,2.078680346996282E7,2.0898066861377403E7,2.1425185257755164E7,2.194210317579236E7,2.248332025721476E7,2.3031903414525803E7,2.3569200583172016E7,2.3687145499773234E7,2.307262263082037E7,2.2450332590421747E7,2.1856524594306674E7,2.1272660891316224E7,2.068189171160841E7,2.0251656789155245E7,2.076555837714624E7,2.126927413321792E7,2.179694924446179E7,2.213116718552735E7,2.246018275214548E7,2.2793386737650182E7,2.251754579935805E7,2.215442388523303E7,2.178854077274378E7,2.1427126685079534E7,2.106157904802944E7,2.0701138214833025E7,2.0773944912109643E7,2.1101465426650804E7,2.1433100464210358E7,2.1764271340060156E7,2.2090015665627636E7,2.2420165109055676E7,2.249132869478557E7,2.2126750183904264E7,2.1767738629090924E7,2.1409186884565722E7,2.1046228244790338E7,2.0688662432563096E7,2.0417344641128927E7,2.074161267764567E7,2.1070184959778205E7,2.1398291111033108E7,2.172076722500235E7,2.2047845484131202E7,2.2374457080896217E7,2.2097893441498995E7,2.1741786556917153E7,2.1386142993088838E7,2.1025830190565377E7,2.067118393968909E7,2.0317001890927445E7,2.0382995002645098E7,2.0708489133795545E7,2.1033515559888493E7,2.136340525201984E7,2.169840487685392E7,2.2033265214395232E7,2.211925454959629E7,2.1776092924952056E7,2.1433050145102777E7,2.1095258360241335E7,2.075235486570361E7,2.040957221310045E7,2.0156420587720197E7,2.0491160162338886E7,2.082575581621871E7,2.1165220453865502E7,2.1499588426140405E7,2.183381015811834E7,2.217306550422337E7,2.191476188237164E7,2.1571952981072295E7,2.123416105086194E7,2.0891507074234065E7,2.054897992897586E7,2.0211169587614678E7,2.0291543958151996E7,2.062546395185741E7,2.0963922971693087E7,2.1297595905977003E7,2.1631115351925932E7,2.196932265075469E7,2.2049149449651577E7,2.1706620175496623E7,2.136885960794005E7,2.1026501555585966E7,2.0684276589569606E7,2.0346531168816715E7,2.0088890876042236E7,2.042207015433829E7,2.075945285553371E7,2.1092364920947142E7,2.1443512902899195E7,2.1799591715697154E7,2.215164384132646E7,2.190919700394338E7,2.1591572878593247E7,2.1266333167743467E7,2.0940659486331966E7,2.0618667809263937E7,2.029657380496712E7,2.038977321780365E7,2.0746703971546523E7,2.1100039606520064E7,2.145379603664496E7,2.1812170196025584E7,2.2292064789759554E7,2.2265949129802387E7,2.1942508824345823E7,2.1614412967304908E7,2.1285886423563544E7,2.096080944025547E7,2.063134218494296E7,2.0387105571562193E7,2.074629946264688E7,2.110219114480961E7,2.145849802944873E7,2.181909587151287E7,2.217627453315524E7,2.25338665516033E7,2.2293329929795306E7,2.1962403947523773E7,2.1631051027927198E7,2.1302894012890726E7,2.0970611448442176E7,2.0637903342391748E7,2.0740233324627433E7,2.1098618786468294E7,2.1457413259454835E7,2.181305404475645E7,2.21653663667723E7,2.2517853759280954E7,2.2606843724317852E7,2.2266409759461284E7,2.192577389687896E7,2.1581245687123094E7,2.1240246186690632E7,2.0899047650914412E7,2.0640782981424157E7,2.0993243544121888E7,2.134587434832578E7,2.169479966535781E7,2.204768539415516E7,2.2400738881680105E7,2.274981089827507E7,2.249513555151646E7,2.2153435522500593E7,2.180748526212628E7,2.146544446275548E7,2.112321306551354E7,2.077684967631617E7,2.0869057477606162E7,2.122222567971505E7,2.1571385156871144E7,2.1924789693298157E7,2.2278354977550384E7,2.2627623389205378E7,2.2720265686633166E7,2.2377576254602447E7,2.203028430628418E7,2.168727610950106E7,2.1344085418163724E7,2.099642788218404E7,2.0740069206834726E7,2.10937215858802E7,2.144307838962735E7,2.179694924446179E7,2.215097412810185E7,2.2500403515029244E7,2.2854640304381732E7,2.259826496351339E7,2.2249708890561175E7,2.1905804502854098E7,2.1561725399713792E7,2.121284956437676E7,2.0868480202648208E7,2.0960618156792175E7,2.13101369141091E7,2.16644236455553E7,2.2018857969948325E7,2.236841433045245E7,2.272304367552804E7,2.2815570534137573E7,2.246582517992849E7,2.212109319241742E7,2.1776193954069816E7,2.1426172998139642E7,2.1081003572337553E7,2.082316155138529E7,2.117280830940476E7,2.152746246234586E7,2.188225804706417E7,2.223190875838836E7,2.258688315926801E7,2.2941996945590645E7,2.267869938466166E7,2.233320585050489E7,2.198755222497734E7,2.1636456734349225E7,2.1290552214313257E7,2.0944489880218506E7,2.103133052028953E7,2.138630556724513E7,2.1741416151269894E7,2.2102177878745247E7,2.2468860631676275E7,2.2836038310408268E7,2.2945687236781634E7,2.2612719279902168E7,2.2273677288560297E7,2.1942267253234595E7,2.1604923806593705E7,2.1267085001947533E7,2.1022105600575626E7,2.1390359289542053E7,2.175910576245078E7,2.2133588608280737E7,2.250502508749301E7,2.2873682908682838E7,2.3249900756728288E7,2.299963321810378E7,2.266013122351906E7,2.232527884072038E7,2.1984691646895032E7,2.1643610560785435E7,2.130687473488357E7,2.1410768581059605E7,2.1782602188130923E7,2.2159884271906532E7,2.253276093273297E7,2.290612601370952E7,2.3285112231117953E7,2.3390658086396478E7,2.3047920674569204E7,2.2709619831580997E7,2.2365803662953384E7,2.202149548465024E7,2.168132727280335E7,2.1425968280136056E7,2.180084296539032E7,2.2180865188004896E7,2.2556769890430007E7,2.2911765048773307E7,2.3271371750394486E7,2.362602129252303E7,2.334940506752772E7,2.2987459560247686E7,2.262092478740898E7,2.22545672732479E7,2.189275834365621E7,2.1526664734883662E7,2.1610979452846672E7,2.196960664655238E7,2.2323770905053537E7,2.267772897583815E7,2.30359135106662E7,2.338950404252862E7,2.3473080167829003E7,2.311140404908859E7,2.2745457342557747E7,2.2387986861214887E7,2.2018193155184593E7,2.1652713020338293E7,2.1377239824947886E7,2.173441405058799E7,2.2087475718837444E7,2.244032285623016E7,2.2797004950716525E7,2.314946176159337E7,2.3501701224178124E7,2.3230032301504742E7,2.286472783809281E7,2.2499614754180383E7,2.2138458506287802E7,2.177364708122389E7,2.140902958136632E7,2.1495936912840076E7,2.1847819703758527E7,2.2199479275088135E7,2.2547232634178057E7,2.2890908920416724E7,2.3234133341663122E7,2.3305089715198282E7,2.2933609691497754E7,2.256256812860144E7,2.2188170320348766E7,2.1818049347101532E7,2.144836871900218E7,2.1164369664856385E7,2.1506519057850003E7,2.1848214021155674E7,2.2185491404237065E7,2.2526194797414433E7,2.2866442538502313E7,2.3202003165464114E7,2.292174846684657E7,2.2553380916979983E7,2.218133086477366E7,2.181390146857249E7,2.1446918157622144E7,2.107638224904164E7,2.1150988251362223E7,2.148969345387186E7,2.182372039746341E7,2.2161423890132982E7,2.2498668436132073E7,2.283095666766323E7,2.2903932219217736E7,2.2538300661784396E7,2.2168673288001645E7,2.180399590267255E7,2.1439769739313908E7,2.1071694686412726E7,2.0795805064918812E7,2.1131495475113433E7,2.14622695284985E7)");
+ double[] test = (double[]) engine.eval("SensitivityBiomassY3");
+ Assert.assertEquals(1500, test.length);
+ }
+
+ @Test
+ public void testNonRegretionOnErrorFromR() throws Exception {
+ try {
+ engine.voidEval("dfresults<-data.frame(c(1,2,3),c(4,5,6))");
+ } catch (NullPointerException npe) {
+ Assert.fail("Error should not have been thrown : " + npe);
+ }
+ }
+
+ @Test
+ public void testListWithNullNames() throws Exception {
+ RList b = new RList(engine);
+ try {
+ b = (RList) engine.eval("b<-list(\"a\",\"b\")");
+ b.setVariable("b");
+ } catch (NullPointerException npe) {
+ npe.printStackTrace();
+ Assert.fail("Error should not have been thrown : " + npe);
+ }
+
+ Assert.assertEquals("a", b.get(0));
+ Assert.assertEquals("b", b.get(1));
+
+ }
+
+ @Test
+ public void testScripts() throws Exception {
+ double d = (Double) engine.evalScript("t<-sin(0)\nt");
+ Assert.assertEquals(0.0, d, 0.001);
+ }
+
+ @Test
+ public void testGraphics() throws Exception {
+
+ File workingDirectory = new File("/tmp");
+ engine.setwd(workingDirectory);
+
+ engine.plot("test", "seq(1,10)", null, null, null, null, null, null, null);
+ File pictureFile = new File("/tmp/test.jpg");
+ Assert.assertTrue(pictureFile.exists());
+ //engine.eval("plot(seq(1,10))");
+ }
+}
Modified: trunk/src/test/java/org/nuiton/j2r/JNITest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/JNITest.java 2010-10-18 09:43:32 UTC (rev 236)
+++ trunk/src/test/java/org/nuiton/j2r/JNITest.java 2010-10-19 14:28:46 UTC (rev 237)
@@ -38,24 +38,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import org.nuiton.j2r.jni.RJniEngine;
-import org.nuiton.j2r.types.RDataFrame;
-import org.nuiton.j2r.types.RList;
-import java.io.File;
+public class JNITest extends AbstractEngineTest {
-import static org.nuiton.j2r.TestConstants.*;
-
-public class JNITest {
-
private static Log log = LogFactory.getLog(JNITest.class);
- private REngine engine;
- private String savedRType;
@BeforeClass
public static void tryREnv() {
@@ -115,364 +105,5 @@
}
System.setProperty("R.type", savedRType);
}
-
- @Test
- public void testDouble() throws Exception {
- Assert.assertEquals(5.0, engine.eval("5.0"));
- engine.voidEval("t<-sin(0)");
- double d = (Double) engine.eval("t");
- Assert.assertEquals(0.0, d, 0);
- }
-
- @Test
- public void testDoubleArray() throws Exception {
- Object result = engine.eval("5.5:10.5");
- Assert.assertEquals(double[].class, result.getClass());
- double[] doubleArray = (double[]) result;
- Assert.assertEquals(6, doubleArray.length);
- for (int i = 5; i < 11; i++) {
- double d = i + 0.5;
- Assert.assertEquals(d, doubleArray[i - 5], 0);
- }
- }
-
- @Test
- public void testSimpleOp() throws Exception {
- LutinTimer t = new LutinTimer();
- for (int loop = 0; loop < S_NB_LOOPS; loop++) {
- engine.voidEval("t<-0");
- t.startTiming();
- engine.voidEval(S_OP);
- t.endTiming();
- double d = (Double) engine.eval("t");
- Assert.assertEquals((double) S_T_MAX, d, 0);
- }
- double[] results = t.computeResults();
- System.err.println("[SO]min: " + results[0]);
- System.err.println("[SO]avg: " + results[1]);
- System.err.println("[SO]max: " + results[2]);
- System.err.println("[SO]etype: " + results[3]);
- }
-
- @Test
- public void testVector() throws Exception {
- System.err.println(V_OP_R);
- LutinTimer t = new LutinTimer();
- for (int loop = 0; loop < V_NB_LOOPS; loop++) {
- t.startTiming();
- engine.voidEval(V_OP_A);
- engine.voidEval(V_OP_B);
- double[] r = (double[]) engine.eval(V_OP_AB);
- t.endTiming();
- Assert.assertEquals(V_MAX, r.length);
- }
- double[] results = t.computeResults();
- System.err.println("[V]min: " + results[0]);
- System.err.println("[V]avg: " + results[1]);
- System.err.println("[V]max: " + results[2]);
- System.err.println("[V]etype: " + results[3]);
- }
-
- @Test
- public void testString() throws Exception {
- engine.voidEval("a<-\"testing string\"");
- String testString = (String) engine.eval("a");
- Assert.assertEquals("testing string", testString);
- }
-
- @Test
- public void testInt() throws Exception {
- engine.voidEval("a<-as.integer(5)");
- Integer testInteger = (Integer) engine.eval("a");
- Integer toCompare = 5;
- Assert.assertEquals(toCompare, testInteger);
- }
-
- @Test
- public void testIntArray() throws Exception {
- engine.voidEval("a<-as.integer(5)");
- engine.voidEval("b<-as.integer(6)");
- engine.voidEval("z<-c(a,b)");
- int[] testIntArray = (int[]) engine.eval("z");
- Assert.assertEquals(5, testIntArray[0]);
- Assert.assertEquals(6, testIntArray[1]);
- }
-
- @Test
- public void testBool() throws Exception {
- engine.voidEval("a<-TRUE");
- engine.voidEval("b<-FALSE");
- Boolean testA = (Boolean) engine.eval("a");
- Boolean testB = (Boolean) engine.eval("b");
- Assert.assertTrue(testA);
- Assert.assertFalse(testB);
- }
-
- @Test
- public void testArrayBool() throws Exception {
- engine.voidEval("a<-c(TRUE,FALSE,TRUE)");
- Boolean[] testBoolArray = (Boolean[]) engine.eval("a");
- Assert.assertTrue(testBoolArray[0]);
- Assert.assertFalse(testBoolArray[1]);
- Assert.assertTrue(testBoolArray[2]);
- }
-
- @Test
- public void testWorkingDirectory() throws Exception {
-
- //test linux paths
- File workingDirectory = new File("/tmp");
- engine.setwd(workingDirectory);
- File testWorkingDirectory = engine.getwd();
- Assert.assertEquals(workingDirectory.getAbsolutePath(),
- testWorkingDirectory.getAbsolutePath());
-
- //test windows paths
- File tempFile = File.createTempFile("test","", new File(System.getProperty("java.io.tmpdir")));
- Boolean tempBoolean = tempFile.delete();
- tempBoolean = tempFile.mkdirs();
- workingDirectory = new File(System.getProperty("java.io.tmpdir") +
- "\\" + tempFile.getName());
- engine.setwd(workingDirectory);
- testWorkingDirectory = engine.getwd();
- Assert.assertEquals(tempFile.getAbsolutePath(),
- testWorkingDirectory.getAbsolutePath());
- }
-
- @Test
- public void testRData() throws Exception {
- File workingdir = new File("/tmp");
- engine.voidEval("a<-5.0");
- engine.saveRData(workingdir);
- engine.remove("a");
- engine.loadRData(workingdir);
- Double testDouble = (Double) engine.eval("a");
- Double compareTo = 5.0;
- Assert.assertEquals(compareTo, testDouble);
- }
-
- @Test
- public void testDputDget() throws Exception {
- File workingdir = new File("/tmp");
- File testingFile = new File("/tmp/testfile");
-
- // test method using the workingdir
- engine.voidEval("a<-5.0");
- engine.setwd(workingdir);
- engine.dput("a", "testDputDgetfile");
- engine.remove("a");
- engine.dget("a", "testDputDgetfile");
- Double testDouble = (Double) engine.eval("a");
- Double compareTo = 5.0;
- Assert.assertEquals(compareTo, testDouble);
-
- //test method using absolute path
- workingdir = new File("/");
- engine.setwd(workingdir);
- engine.voidEval("a<-6.0");
- engine.dput("a", testingFile);
- engine.remove("a");
- engine.dget("a", testingFile);
- Double testDouble2 = (Double) engine.eval("a");
- Double compareTo2 = 6.0;
- Assert.assertEquals(compareTo2, testDouble2);
- File testWorkingDirectory = engine.getwd();
- Assert.assertEquals(workingdir.getAbsolutePath(),
- testWorkingDirectory.getAbsolutePath());
- }
-
- @Test
- public void testRemove() throws Exception {
- engine.voidEval("a<-6.0");
- Assert.assertEquals(6.0, engine.eval("a"));
- try {
- engine.remove("a");
- engine.eval("a");
- Assert.fail("Exception should have been thrown at this point");
- } catch (RException re) {
- System.out.println(re.getMessage());
- Assert.assertTrue(
- re.getMessage().contains("object \'a\' not found"));
- }
- }
-
- @Test
- public void testMvCp() throws Exception {
- //Test only mv as mv uses cp.
- engine.voidEval("a<-5.0");
- engine.remove("b");
- engine.mv("a", "b");
- Assert.assertEquals(5.0, engine.eval("b"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"a\")"));
- }
-
- @Test
- public void testLsClearSession() throws Exception {
- //Test only ClearSession as it uses ls
- engine.voidEval("a<-5.0");
- engine.voidEval("b<-5.0");
- engine.voidEval("d<-5.0");
- engine.voidEval("e<-5.0");
- engine.voidEval("f<-5.0");
- engine.clearSession();
- Assert.assertFalse((Boolean) engine.eval("exists(\"a\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"b\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"d\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"e\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"f\")"));
- }
-
- @Test
- public void testAutoCommitFalse() throws Exception {
- engine.clearSession();
- engine.setAutoCommit(false);
- engine.voidEval("a<-5.0");
- engine.voidEval("a<-a+5.0");
- engine.voidEval("b<-5.0");
- engine.voidEval("d<-5.0");
- engine.voidEval("e<-5.0");
- engine.voidEval("f<-5.0");
- engine.commit();
- Assert.assertEquals(10.0, engine.eval("a"));
- Assert.assertEquals(5.0, engine.eval("b"));
- Assert.assertEquals(5.0, engine.eval("d"));
- Assert.assertEquals(5.0, engine.eval("e"));
- Assert.assertEquals(5.0, engine.eval("f"));
- }
-
- @Test
- public void testThrowException() throws Exception {
- engine.clearSession();
- //Test that the exception is normally thrown in voidEval
- try {
- engine.voidEval("a<-b");
- Assert.fail("Exception should have been thrown at this point");
- } catch (RException e) {
- log.info(e.getMessage());
- Assert.assertTrue(
- e.getMessage().contains("object \'b\' not found"));
- }
-
- engine.clearSession();
- //Test that the exception is normally thrown in eval
- try {
- engine.eval("a");
- Assert.fail("Exception should have been thrown at this point");
- } catch (RException e) {
- Assert.assertTrue(
- e.getMessage().contains("object \'a\' not found"));
- }
- }
-
- @Test
- public void testDataFrame() throws Exception {
- engine.voidEval("a<-data.frame(c(3,4,5,6),c(as.integer(3),as.integer(4),as.integer(5),as.integer(6)),c(\"a\",\"b\",\"c\",\"d\"),c(TRUE,FALSE,TRUE,FALSE),stringsAsFactors=FALSE)");
- RDataFrame testA = (RDataFrame) engine.eval("a");
- engine.setAutoCommit(false);
- Assert.assertEquals(testA.get(0,0),3.0);
- Assert.assertEquals(testA.get(0,1),4.0);
- Assert.assertEquals(testA.get(0,2),5.0);
- Assert.assertEquals(testA.get(0,3),6.0);
- Assert.assertEquals(testA.get(1,0),3);
- Assert.assertEquals(testA.get(1,1),4);
- Assert.assertEquals(testA.get(1,2),5);
- Assert.assertEquals(testA.get(1,3),6);
- Assert.assertEquals(testA.get(2,0),"a");
- Assert.assertEquals(testA.get(2,1),"b");
- Assert.assertEquals(testA.get(2,2),"c");
- Assert.assertEquals(testA.get(2,3),"d");
- Assert.assertEquals(testA.get(3,0),true);
- Assert.assertEquals(testA.get(3,1),false);
- Assert.assertEquals(testA.get(3,2),true);
- Assert.assertEquals(testA.get(3,3),false);
- engine.setAutoCommit(true);
- }
-
- @Test
- public void testList() throws Exception {
- //create a data.frame to be added to the list
- engine.voidEval("b<-data.frame(c(3,4,5,6),c(as.integer(3),as.integer(4),as.integer(5),as.integer(6)),c(\"a\",\"b\",\"c\",\"d\"),c(TRUE,FALSE,TRUE,FALSE),stringsAsFactors=FALSE)");
- engine.voidEval("a<-list(one=as.integer(2),two=3.0,three=TRUE,four=\"b\",five=b)");
- RList testA = (RList)engine.eval("a");
- engine.setAutoCommit(false);
- Assert.assertEquals(testA.get(0), 2);
- Assert.assertEquals(testA.get(1), 3.0);
- Assert.assertEquals(testA.get(2), true);
- Assert.assertEquals(testA.get(3), "b");
- Assert.assertTrue(testA.get(4) instanceof RDataFrame);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,0), 3.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,1), 4.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,2), 5.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,3), 6.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,0), 3);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,1), 4);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,2), 5);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,3), 6);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,0), "a");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,1), "b");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,2), "c");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,3), "d");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,0), true);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,1), false);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,2), true);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,3), false);
- Assert.assertEquals(testA.getName(0),"one");
- Assert.assertEquals(testA.getName(1),"two");
- Assert.assertEquals(testA.getName(2),"three");
- Assert.assertEquals(testA.getName(3),"four");
- Assert.assertEquals(testA.getName(4),"five");
- engine.setAutoCommit(true);
-
- }
-
- @Test
- public void testLongLines() throws Exception{
- engine.voidEval("SensitivityBiomassY3<-c(2.179694924446179E7,2.179468496519559E7,2.1818736174725175E7,2.1816429067949396E7,2.1800098718126506E7,2.1838067907599747E7,2.183569971088971E7,2.1833313097146016E7,2.185719149559428E7,2.1854762634011697E7,2.185231549094628E7,2.187610838662306E7,2.187361928018277E7,2.1871112026349083E7,2.189482001091965E7,2.1892271074663457E7,2.1889704123663016E7,2.1913327781288046E7,2.1910719425357413E7,2.1908093185913157E7,2.193163309335182E7,2.192896572306039E7,2.1926280599087697E7,2.1949737325799696E7,2.1964830419511076E7,2.1944267732381735E7,2.1967641840627935E7,2.196485763859664E7,2.1962055938437656E7,2.198534798337946E7,2.198250595466467E7,2.19796465535838E7,2.2002857083381277E7,2.1999957614685252E7,2.1997040898068156E7,2.2020170453976974E7,2.2017213927520543E7,2.201424027629076E7,2.201424027629076E7,2.2007088929931033E7,2.1999922487316884E7,2.197681420767298E7,2.196962074430254E7,2.1962412278355762E7,2.1939244418647803E7,2.19320089340683E7,2.1924758538858987E7,2.1901530675850462E7,2.1894253260547817E7,2.1886961024817027E7,2.186367272884308E7,2.1856353467938498E7,2.1849019475049105E7,2.182567030993665E7,2.181830928313515E7,2.1810933611020483E7,2.1787523134007405E7,2.178012041554803E7,2.1772703136661157E7,2.1749230898314577E7,2.1749758710004635E7,2.1734327738178723E7,2.171079328231229E7,2.1703307381126277E7,2.1695807083871227E7,2.167220994746149E7,2.1664682544012114E7,2.1657140823937435E7,2.1633480537039224E7,2.162591168317374E7,2.161832859028344E7,2.1594604675944276E7,2.158699441777762E7,2.157936999632849E7,2.1555581970502105E7,2.1547930348361045E7,2.155103621183836E7,2.152717169457966E7,2.1530236120902758E7,2.153328412702021E7,2.1509330625330385E7,2.1512336892940816E7,2.1515326604867205E7,2.1491283471099153E7,2.1494231139260102E7,2.1497162114652816E7,2.147302869279387E7,2.14759173151992E7,2.147878910612182E7,2.1454564731677204E7,2.1457393856367446E7,2.1462383791402113E7,2.1435890009080574E7,2.143865917835912E7,2.1441411233736E7,2.1417002926115625E7,2.141971167646219E7,2.1424717356960263E7,2.1397901863381278E7,2.1400549725365438E7,2.140318018420746E7,2.137858518066629E7,2.1381171678860184E7,2.1383740626669012E7,2.135905121665088E7,2.1361575869539354E7,2.1364082823016256E7,2.1339298288600616E7,2.1341760608492017E7,2.1344205078135047E7,2.1319324692060333E7,2.1321724184994433E7,2.132410567500613E7,2.132410567500613E7,2.1331536055398986E7,2.133895052044593E7,2.1363853672607094E7,2.137123650604985E7,2.137860336066902E7,2.140343328441597E7,2.1410768581059605E7,2.1418087833224125E7,2.1442845113907605E7,2.1450132877092432E7,2.1457404527983494E7,2.148208974251862E7,2.1489329968841057E7,2.1496554012913797E7,2.1521167729882605E7,2.1528360409261446E7,2.1535536834311184E7,2.1560079614063937E7,2.156722472980476E7,2.1563254271749333E7,2.1598825911786724E7,2.1605923440646578E7,2.1613004564718306E7,2.1637407118662428E7,2.1644457030912723E7,2.1651490460029803E7,2.167582370941422E7,2.1682825968903817E7,2.1689811664860353E7,2.171407613809878E7,2.1721030702315085E7,2.172796862056064E7,2.1752164838324733E7,2.1759071658455327E7,2.1765961748155564E7,2.1790090223469418E7,2.179694924446179E7,2.180379144855871E7,2.182785268689249E7,2.18346638475134E7,2.184145810278461E7,2.1865452602147E7,2.1872215835041337E7,2.1878962072157502E7,2.1902890323187094E7,2.1909605554935444E7,2.191630369851899E7,2.1940166184574656E7,2.1946833335751027E7,2.1953483304432537E7,2.1977280501682773E7,2.198389948690986E7,2.1990501193384256E7,2.20142335708955E7,2.2020804298901647E7,2.20273576499835E7,2.205102566980741E7,2.205754804348026E7,2.2064052940158665E7,2.20876570574184E7,2.2094130973859813E7,2.2100587311352342E7,2.2124127974327955E7,2.2130553324907117E7,2.2136960992712937E7,2.2160438642925616E7,2.2166815313332282E7,2.2173174195284456E7,2.2196589267580014E7,2.2202917137875687E7,2.2209227112193614E7,2.2232580034824714E7,2.2238858979494706E7,2.2245119918834776E7,2.2245119918834776E7,2.2247156092664756E7,2.2249172537482113E7,2.222580215006561E7,2.2227776978241052E7,2.2229731947289977E7,2.2206281851083208E7,2.2208194947734725E7,2.221008805387345E7,2.2186557726205546E7,2.2188408701148424E7,2.219023955290159E7,2.2166628464420535E7,2.2168416923091725E7,2.217018512458671E7,2.2146492739166215E7,2.2148218282559495E7,2.214992343346224E7,2.2126149208107647E7,2.212781143270992E7,2.21294531281596E7,2.21055965129125E7,2.21071950106372E7,2.21087728411807E7,2.2084833279022325E7,2.208636763714323E7,2.2087881188668158E7,2.2063858115421828E7,2.2065327916506168E7,2.2066776770173687E7,2.2042669614405714E7,2.2044074436245814E7,2.2045458168422367E7,2.2021266351342022E7,2.2022605766886715E7,2.2023923949074898E7,2.1999646884433046E7,2.200092046171817E7,2.1995009663381506E7,2.1970654681075428E7,2.196470853722463E7,2.195874261494959E7,2.1934317104578134E7,2.1928315823420756E7,2.1922294864394967E7,2.1897798306555357E7,2.1891741970889103E7,2.1885666055779688E7,2.1861097923225783E7,2.1854986609282427E7,2.1848855812173687E7,2.1824215569718488E7,2.1818049347101532E7,2.1811863735432312E7,2.1787150839849222E7,2.1780929771470487E7,2.177468940597102E7,2.174990330589387E7,2.174362744790923E7,2.1737332382536206E7,2.1712472518358346E7,2.1706141920103204E7,2.1699792201974563E7,2.167485800574659E7,2.1668472709669497E7,2.1662068378999148E7,2.163705927432551E7,2.1630619315921858E7,2.162416040595164E7,2.159907580788612E7,2.1592581215630468E7,2.1586067752563022E7,2.1560907067502897E7,2.1554357862780496E7,2.154778986571032E7,2.154778986571032E7,2.1546318044922113E7,2.1544825743281327E7,2.1569967765090413E7,2.1568428834061984E7,2.156686958059507E7,2.1591916967334844E7,2.159031142387256E7,2.158868571459585E7,2.1613639174591307E7,2.1611967510410193E7,2.161027583527415E7,2.1635136067757037E7,2.1633398768567167E7,2.163164161154166E7,2.165640930677329E7,2.165460685236462E7,2.1652784691524632E7,2.167746053091718E7,2.1675593395243883E7,2.1673706702852983E7,2.169829135908928E7,2.169636001035316E7,2.1694409252946746E7,2.1718903390098736E7,2.171690829083134E7,2.1714893929297917E7,2.1739298202943414E7,2.173723981008732E7,2.173516229975055E7,2.1759477357088927E7,2.1757356122077797E7,2.1755215912775498E7,2.1779442392741513E7,2.1777258761579778E7,2.178652675221615E7,2.1799194831120383E7,2.179694924446179E7,2.1210710366918586E7,2.0627838516436625E7,2.0073198124600604E7,2.0549043683745503E7,2.117617571938369E7,2.183569971088971E7,2.251575186207285E7,2.3202940491524644E7,2.3925578765007686E7,2.3793188782694403E7,2.3138942654097542E7,2.2516415708366465E7,2.1910735239279598E7,2.1308393153166354E7,2.0735369629764337E7,2.062075197238507E7,2.1249415366315708E7,2.1910719425357413E7,2.259259256512906E7,2.3281412413469028E7,2.4005949681793142E7,2.4574434204009376E7,2.3898455248209067E7,2.3255404417702474E7,2.262975868639601E7,2.200742405102502E7,2.1415521959997784E7,2.083963435585132E7,2.131951539029141E7,2.198250595466467E7,2.2666103736809526E7,2.3356464740940552E7,2.408279910221071E7,2.4831709742932335E7,2.4678545581240475E7,2.4014418717275385E7,2.336827049681634E7,2.2701638689529963E7,2.208683280168035E7,2.1488775533901934E7,2.1311501623371568E7,2.196962074430254E7,2.2648053985047437E7,2.3288386059390273E7,2.4007555430756032E7,2.474892353613376E7,2.5265224263798002E7,2.4580599089304656E7,2.391463458979512E7,2.3207892262497313E7,2.2579298145611316E7,2.1967830705018844E7,2.131877140228872E7,2.181830928313515E7,2.249157157422271E7,2.3126786933162935E7,2.3840438079766467E7,2.457610205488776E7,2.5270239604048863E7,2.5124739696302816E7,2.4443945095785588E7,2.3721312789605163E7,2.3078729441986065E7,2.2453656465589404E7,2.1790012717726383E7,2.1664682544012114E7,2.2332706673176605E7,2.2962731499231942E7,2.3670793068546023E7,2.440067947692717E7,2.508909057246626E7,2.567639023587526E7,2.498055401716986E7,2.424178659806919E7,2.358501525826246E7,2.2874950937338676E7,2.2198548154310785E7,2.1530236120902758E7,2.1965503936487645E7,2.2584629567022495E7,2.320849669835539E7,2.384970751062438E7,2.45221053058604E7,2.5199807825752024E7,2.497663210108002E7,2.4237269925320312E7,2.350704443679568E7,2.2798810309156775E7,2.2123949376097146E7,2.1457393856367446E7,2.1267154434465587E7,2.186632936271173E7,2.2470263114487886E7,2.309098302604801E7,2.3741694406832688E7,2.4397726677086536E7,2.4891263455218945E7,2.415364079136865E7,2.3425395629407085E7,2.2719097290006068E7,2.204587078549588E7,2.1381171678860184E7,2.073900458098361E7,2.1166832797286097E7,2.175135042538578E7,2.235211102801546E7,2.2981695918150727E7,2.361661976445475E7,2.4269194166454904E7,2.4066108134309478E7,2.3339955269476753E7,2.2635701478342265E7,2.1989961404597342E7,2.1331536055398986E7,2.0692815253972054E7,2.0567634415260237E7,2.1140548759382922E7,2.1729519249264557E7,2.239368387026964E7,2.3017741380537957E7,2.365929520573126E7,2.4206701581383433E7,2.348135733257032E7,2.2777736161977123E7,2.2153147761613276E7,2.1490754107489396E7,2.084539277225918E7,2.0273814573353328E7,2.068819355156516E7,2.1264457718227006E7,2.191411528874908E7,2.2524699062038783E7,2.315239814183554E7,2.3859881227222998E7,2.3652744106745705E7,2.2943451323818333E7,2.231358810227405E7,2.1644457030912723E7,2.0995380304288536E7,2.041902359479725E7,2.0241553740604583E7,2.080528000864457E7,2.1440642248132315E7,2.2037931744211115E7,2.265196079778825E7,2.334386505298643E7,2.382125038917487E7,2.3106368725026328E7,2.2471315736226093E7,2.179694924446179E7,2.114280859614047E7,2.0561751071342427E7,1.9944682760952137E7,2.0350159569657844E7,2.0973412533695985E7,2.155759032627611E7,2.2158137251554392E7,2.283469632473654E7,2.3470999338094838E7,2.3266517442576505E7,2.262635851712963E7,2.1946833335751027E7,2.1287703290811926E7,2.0702021560467873E7,2.0080279995467488E7,1.990513870532304E7,2.051255252742858E7,2.1083803801994085E7,2.1671059161511026E7,2.2332508169542134E7,2.2954719241943117E7,2.34239211469535E7,2.277873906946373E7,2.2094130973859813E7,2.1430085140456423E7,2.0839854889200248E7,2.021350938890342E7,1.9605976414660845E7,2.0058169000206765E7,2.061668109380032E7,2.1190837643538114E7,2.1837412735002644E7,2.244573693600014E7,2.3071107465361953E7,2.2928475004387636E7,2.2238858979494706E7,2.156997020837422E7,2.0953327634262163E7,2.031928213123918E7,1.9704409478000913E7,1.9541523597534645E7,2.008178918447587E7,2.063708154184719E7,2.1222097881208595E7,2.1782167960600212E7,2.2412409214834034E7,2.288129069845474E7,2.2188408701148424E7,2.15164929188283E7,2.0878899065220114E7,2.0246637990616675E7,1.9633509009368904E7,1.9051741734870337E7,1.943691348751304E7,1.9974288495292652E7,2.054031454051603E7,2.1108353968718503E7,2.1692195304523874E7,2.2307045752282713E7,2.21071950106372E7,2.14372382543343E7,2.080136258699364E7,2.0170976443629496E7,1.9559679007026408E7,1.8979519529000968E7,1.8809283014624868E7,1.93292166557891E7,1.9876754569292802E7,2.0426347190258507E7,2.0991225086705297E7,2.1585975945808336E7,2.2022605766886715E7,2.1354706270342696E7,2.072063602091685E7,2.0092217646871667E7,1.9547542072900824E7,1.8967197285597503E7,1.845315493151521E7,1.88885315004027E7,1.9423221602180608E7,2.0026269354807056E7,2.0648023852639187E7,2.123254141631277E7,2.1891741970889103E7,2.1766843919877376E7,2.11202361159165E7,2.0547498003043916E7,1.9990375859496813E7,1.9396653734149992E7,1.8870873471726857E7,1.8763303218098205E7,1.9293827317314055E7,1.9892377693907846E7,2.050948101367075E7,2.1089394951270908E7,2.174362744790923E7,2.2256048212515533E7,2.1594636798160095E7,2.1008919924772583E7,2.0439176253408026E7,1.9831872060683697E7,1.929418962356003E7,1.877116511955032E7,1.9161829949933916E7,1.9755805516186837E7,2.036817790478417E7,2.0943401537336618E7,2.1592581215630468E7,2.226186697834365E7,2.207520884537028E7,2.150042212522819E7,2.0893799125253893E7,2.0296482026974823E7,1.975080361854921E7,1.9219878954244867E7,1.9103331447423942E7,1.969971166041202E7,2.0314695355330423E7,2.0936715189178452E7,2.159031142387256E7,2.2264295589739572E7,2.278023273354139E7,2.2167399452806022E7,2.1571145688384026E7,2.0978751356566936E7,2.0414621112687685E7,1.9865747259597294E7,1.9320301685983643E7,1.977913755335712E7,2.039610798916919E7,2.1019920570274755E7,2.1675593395243883E7,2.235170388479439E7,2.3035350368316166E7,2.2908356203498308E7,2.2292060248826306E7,2.1679592173124865E7,2.109651200763306E7,2.0529204331880063E7,1.996529365701334E7,1.985533137222209E7,2.047419246080403E7,2.1099708315389667E7,2.1757356122077797E7,2.2435488309007194E7,2.3120953305239443E7,2.366944962251461E7,2.303257115592817E7,2.239949051917674E7,2.179694924446179E7,2.1582800974755637E7,2.132220069552558E7,2.11185307878848E7,2.1300085123832006E7,2.1489528672464654E7,2.1736105267599385E7,2.198861916011158E7,2.2193554178466234E7,2.2457935854459632E7,2.2412186365163937E7,2.213057294206349E7,2.1907952140411254E7,2.169068649422258E7,2.142664453126697E7,2.122005824647036E7,2.118128447617866E7,2.1367566254266616E7,2.161075181662697E7,2.1859762569234636E7,2.206122758866795E7,2.2321875708625615E7,2.2525810552501842E7,2.2239737444893744E7,2.2013925463701107E7,2.1793570223308872E7,2.152613268334539E7,2.1316657773628376E7,2.1112096708960515E7,2.1240944809821565E7,2.148073900218816E7,2.1726247176682107E7,2.192426483120831E7,2.2181182026772894E7,2.244441874563338E7,2.2343965586001858E7,2.2114989687818263E7,2.189157217722438E7,2.1657826684049536E7,2.1481861134108696E7,2.1310252383222595E7,2.1291347515805926E7,2.1566643386439852E7,2.184848374525294E7,2.212099677165949E7,2.2416407281501427E7,2.2719070295959707E7,2.2948119668591738E7,2.274961574759145E7,2.2556164993357025E7,2.23512613904517E7,2.2167552537808113E7,2.1988405842782084E7,2.1797702239891656E7,2.2020726285927694E7,2.2306401811247114E7,2.258232341259566E7,2.2881670928634193E7,2.3188326435314238E7,2.3485266775847882E7,2.3476131980370786E7,2.3274195584546782E7,2.306036373905514E7,2.2868626133802254E7,2.268166433271607E7,2.2482696884429052E7,2.2477917896325614E7,2.276739128485571E7,2.30466605563571E7,2.3349903694826085E7,2.3660508278237984E7,2.396093157217119E7,2.4218903733917497E7,2.400817095216517E7,2.3785073969811365E7,2.3585015258262463E7,2.331744627757713E7,2.3110555462957747E7,2.2854656147084348E7,2.3015747009194948E7,2.329569902877019E7,2.352682183843316E7,2.3763595550652813E7,2.4062787877269357E7,2.4312045364394195E7,2.422605003323576E7,2.3998389588862572E7,2.3720508444658138E7,2.344921021315164E7,2.323879969201972E7,2.2979398848798577E7,2.2908514230288062E7,2.317843503805836E7,2.3406229476741273E7,2.363956721378428E7,2.393468756390962E7,2.4180270050182305E7,2.4363700074971378E7,2.4132154914224472E7,2.3850425399392366E7,2.3575403674530827E7,2.336145454882542E7,2.3098559659378957E7,2.284173125333958E7,2.3055480880316418E7,2.3279914564995393E7,2.3509783969288055E7,2.380077829850311E7,2.404265337521539E7,2.4290565645753462E7,2.4260010642767034E7,2.397444172413691E7,2.3695706229231913E7,2.344269054528998E7,2.314165334501904E7,2.2847617039811883E7,2.2753802012594562E7,2.293840026763693E7,2.312765269094679E7,2.3340650997364912E7,2.3539855804151304E7,2.3744215648609586E7,2.3906272591229875E7,2.358672878959545E7,2.3274896029086925E7,2.2989060548060637E7,2.2691627934628997E7,2.2401151307133447E7,2.213521218864193E7,2.2233697486671917E7,2.243673498704297E7,2.2640960988426235E7,2.2840282445538927E7,2.3027808515149347E7,2.3247410698483635E7,2.312776918021058E7,2.28196915866069E7,2.2537018610587217E7,2.236588221206764E7,2.195639121440947E7,2.1693499155164544E7,2.158564929535018E7,2.1759558502130054E7,2.1955324631112434E7,2.213832390612545E7,2.2326030617057707E7,2.2536488275080547E7,2.2670694454728946E7,2.2366430382259358E7,2.208699936159411E7,2.179694924446181E7,2.1513758481920857E7,2.125398523455025E7,2.0983612842204567E7,2.109628427519062E7,2.128389504203701E7,2.1459210724855714E7,2.163902271099347E7,2.1840666883719392E7,2.20300919715181E7,2.191552349058341E7,2.1639406437831394E7,2.1353121527253184E7,2.1073644505494516E7,2.0817054812208567E7,2.0550302057201367E7,2.0447032525084432E7,2.0626784465038262E7,2.079468773941211E7,2.0966884332654934E7,2.1160037325478908E7,2.134141261153796E7,2.1467352175718762E7,2.1194614044124752E7,2.0912135723046537E7,2.0636411887780488E7,2.038306384233572E7,2.011996627976353E7,1.9862964308494963E7,1.998406758446474E7,2.014482325506297E7,2.0309677182599295E7,2.0494652542036593E7,2.0668267840910804E7,2.0846422601373654E7,2.0752968445634652E7,2.0474332543329127E7,2.0202395902872443E7,1.9986682536912356E7,1.9760783130720664E7,1.954012785927571E7,1.9522960082094874E7,1.9712048810959406E7,1.9905695371214602E7,2.015416369746075E7,2.0357915944941416E7,2.057028078195899E7,2.0774294803816352E7,2.0528646016777497E7,2.0288910016423583E7,2.0104803904727656E7,1.987573241675546E7,1.965200603795866E7,1.948178428520774E7,1.961812604291848E7,1.9809037937128045E7,2.0054303216014933E7,2.0255131313945077E7,2.046092617504088E7,2.0723211319667727E7,2.064888077648577E7,2.0405765289619416E7,2.0218535995389506E7,1.9986293836112317E7,1.9759498533282418E7,1.9586432159852266E7,1.9519652120447874E7,1.970780474520424E7,1.9949825653636657E7,2.0147705058135226E7,2.0350455509476036E7,2.060917061217219E7,2.076448699013356E7,2.0517994842178896E7,2.032762600569117E7,2.0094532572243024E7,1.992826566491457E7,1.9751750631704066E7,1.959596157545169E7,1.979762799759906E7,2.003872797416884E7,2.030269428304801E7,2.0573039811826043E7,2.0832368015315235E7,2.111591827455593E7,2.1108926062609725E7,2.091082189492144E7,2.0735169770109635E7,2.0563940105959684E7,2.037967933771062E7,2.021699863297404E7,2.021385253589832E7,2.0457917553273804E7,2.0725379982846912E7,2.099926924265825E7,2.126168137899885E7,2.1548867561324272E7,2.1782102633357514E7,2.157531083889262E7,2.139190792954339E7,2.1213135769972038E7,2.1020838240174975E7,2.0851016532201312E7,2.068537553775501E7,2.087914392806134E7,2.1150053600132417E7,2.1427435630355682E7,2.1692855929514192E7,2.1983622377098937E7,2.228156314295964E7,2.2253718670445587E7,2.2062286164065335E7,2.1875700901274793E7,2.16421155231462E7,2.1432541076814383E7,2.12279161177933E7,2.11406015194917E7,2.138029925476085E7,2.162567378947092E7,2.182469883557617E7,2.2081413149714403E7,2.234440567100169E7,2.249678298707227E7,2.226712223265128E7,2.204307246241817E7,2.177224617969986E7,2.1559367015092243E7,2.1351538647396944E7,2.109796385286568E7,2.1280348766236868E7,2.152256335771631E7,2.171838083469002E7,2.19717253498737E7,2.223123375820159E7,2.2443167564732175E7,2.2399210234947044E7,2.217165957284462E7,2.1896949965474334E7,2.1680795126377612E7,2.146979246769457E7,2.121268092757171E7,2.1174895022551663E7,2.1413937683383066E7,2.1606560535874575E7,2.1856524594306666E7,2.2112538879026916E7,2.2320964295446754E7,2.252591870060584E7,2.2294895699372217E7,2.2016351148507055E7,2.179694924446179E7,2.2331824429699514E7,2.2855433361901157E7,2.3404487214268394E7,2.294142103956324E7,2.2324441999097317E7,2.1736105267599385E7,2.1157628653165985E7,2.0571940996573642E7,2.001321950420239E7,2.012001521949783E7,2.0610767161002416E7,2.1125120342784844E7,2.164651010639106E7,2.2156678383773886E7,2.2691918664613448E7,2.2805112652218632E7,2.219354176321105E7,2.161075181662697E7,2.1037735985237803E7,2.0457219288610935E7,1.9903793747161057E7,1.9488637544425823E7,1.9966665391087614E7,2.0467920301008943E7,2.0976050836749885E7,2.1473027341601636E7,2.199468580517517E7,2.2523424240659732E7,2.205791439697501E7,2.148073900218816E7,2.0913250056273438E7,2.033798567507657E7,1.978991846894483E7,1.9251159123297397E7,1.9337016475624252E7,1.982539976317407E7,2.0320500278302457E7,2.0840234256234802E7,2.1385944860698376E7,2.194030469414052E7,2.210590277779634E7,2.1566643386439852E7,2.1035276284650847E7,2.052916558712231E7,2.0012885688423205E7,1.9504240212668225E7,1.914597245636108E7,1.966564970768373E7,2.019365888132567E7,2.0747578982121963E7,2.129296337826814E7,2.1846984486465834E7,2.2428472535802145E7,2.20207262859277E7,2.1481059856196947E7,2.0966801053767882E7,2.044242611337692E7,1.9925785984183084E7,1.9445287866034742E7,1.9569464602423172E7,2.0097071911044825E7,2.0650197120948106E7,2.1195143034974054E7,2.174871092095583E7,2.2329323898903012E7,2.247791789632563E7,2.1929942224403653E7,2.1407504349966824E7,2.0875024935201477E7,2.0350380737533808E7,1.9849734706027746E7,1.946867528159764E7,1.9995768957046025E7,2.0547974113317214E7,2.1092364920947142E7,2.166394686541127E7,2.226314941013937E7,2.2854656147084344E7,2.2458540272984866E7,2.1944900002136175E7,2.14203655338795E7,2.090289713492715E7,2.0408796196330402E7,1.990484878917003E7,2.006108299669223E7,2.0634694427358806E7,2.120175864847823E7,2.1778463552713715E7,2.2382616792808183E7,2.2979398848798577E7,2.315131943473774E7,2.2624412031072915E7,2.2086607573908266E7,2.1556030220523257E7,2.1049134932153124E7,2.0532394305307217E7,2.0155591800375476E7,2.0733841117966734E7,2.130586365490205E7,2.188760285404254E7,2.2496595819886178E7,2.3098559659378957E7,2.3710626159261644E7,2.3317646387790464E7,2.2766369623098884E7,2.222248331524084E7,2.1702572233762216E7,2.1172843463076215E7,2.0650291112794127E7,2.082750676368124E7,2.1404392701349508E7,2.1991069029673535E7,2.2570531369717266E7,2.314165334501904E7,2.3721248524592787E7,2.384361141338243E7,2.324742537082883E7,2.2660365518774025E7,2.2065367969340097E7,2.1496636553747363E7,2.0936717628245063E7,2.0504862578794934E7,2.1043720865348622E7,2.1590676545610815E7,2.212863152921111E7,2.269162793462899E7,2.3262996016340885E7,2.382431088401486E7,2.337519266281572E7,2.2787036963065572E7,2.2190511690875802E7,2.1620748035310674E7,2.105982235960949E7,2.0491385644285306E7,2.061950674156031E7,2.1158520148774885E7,2.168839965714183E7,2.224325053139479E7,2.2806371268771283E7,2.3359296776102714E7,2.349720266248471E7,2.290809018288732E7,2.231018627306776E7,2.1739523735758387E7,2.1177722084197752E7,2.060801683057323E7,2.019737896084555E7,2.0728438400004502E7,2.1250255491423395E7,2.179694924446179E7,2.2351810845186867E7,2.2896361415497024E7,2.34673816862853E7,2.3023658536161214E7,2.2424519877953082E7,2.1853086965165038E7,2.1290535352017526E7,2.071969638585591E7,2.0175002659378543E7,2.03008146798796E7,2.0814588591157842E7,2.1353121527253184E7,2.1901198553444345E7,2.2435916535651654E7,2.299846519089168E7,2.3133874006937698E7,2.2533639436262306E7,2.196155994087558E7,2.1398379756241336E7,2.0831880676123228E7,2.0281258428302288E7,1.9876004085683852E7,2.0381759861590605E7,2.0912135723046537E7,2.145047510584317E7,2.19783439218411E7,2.250403067372545E7,2.3094738815524373E7,2.2637670594426885E7,2.206506373089962E7,2.1501371873062074E7,2.092865113588225E7,2.0382899411775194E7,1.984574849092129E7,1.9952103012631103E7,2.0474332543329116E7,2.1004423430395804E7,2.1560931405266024E7,2.214531691178439E7,2.2739694435204152E7,2.293183714702572E7,2.2392468378613237E7,2.1860316289117955E7,2.1353463074323934E7,2.083509649568674E7,2.032373871512065E7,1.9968283859677758E7,2.052864601677749E7,2.10986999234755E7,2.1696853675125007E7,2.2287125819984794E7,2.288748409851376E7,2.3517699057573907E7,2.3110838351093642E7,2.256465697425747E7,2.204419087489216E7,2.1512127255885277E7,2.09872383735701E7,2.048655364123707E7,2.0648880776485767E7,2.122458291883902E7,2.182827231603412E7,2.24243705563821E7,2.3030647473853115E7,2.3666655701840118E7,2.3845490098184697E7,2.3285031169750787E7,2.2750687572362773E7,2.2204684529074334E7,2.166602485979557E7,2.115597872152922E7,2.076448699013355E7,2.134577305876403E7,2.195491375186435E7,2.2556769890430007E7,2.3147282149450656E7,2.376620284426716E7,2.4375786394523405E7,2.3931872915482566E7,2.3363614362415303E7,2.278476306724695E7,2.2214436631114103E7,2.166992274332534E7,2.111720637510088E7,2.1262608405934777E7,2.1850997058493238E7,2.2431386797166683E7,2.3020909338318553E7,2.363834581164402E7,2.424687907733571E7,2.440641797253779E7,2.3829612158466004E7,2.3242349369345333E7,2.2663715094404805E7,2.211097304843052E7,2.1548867561324283E7,2.113448349320343E7,2.1721362444207337E7,2.2300655419081565E7,2.2889054497973528E7,2.3504857204500623E7,2.4112200705898315E7,2.472897408636128E7,2.4297366495217163E7,2.3701711277208768E7,2.3114787944667332E7,2.2553810127248496E7,2.1983622377098937E7,2.1421880205984302E7,2.158639021257613E7,2.216445036005833E7,2.2751587222834248E7,2.3330198176623296E7,2.3899141443574466E7,2.4475790187439345E7,2.4580038347294193E7,2.3944009003179368E7,2.331848771734921E7,2.2685904040408395E7,2.2081413149714403E7,2.1487028738378E7,2.1025001579972226E7,2.155823036015128E7,2.2098775932078365E7,2.262913248602956E7,2.318410728953877E7,2.3746616648948003E7,2.429784782814121E7,2.381848647603142E7,2.3198415705305327E7,2.257092092866275E7,2.1971725349873707E7,2.1382556244578436E7,2.078680346996282E7,2.0898066861377403E7,2.1425185257755164E7,2.194210317579236E7,2.248332025721476E7,2.3031903414525803E7,2.3569200583172016E7,2.3687145499773234E7,2.307262263082037E7,2.2450332590421747E7,2.1856524594306674E7,2.1272660891316224E7,2.068189171160841E7,2.0251656789155245E7,2.076555837714624E7,2.126927413321792E7,2.179694924446179E7,2.213116718552735E7,2.246018275214548E7,2.2793386737650182E7,2.251754579935805E7,2.215442388523303E7,2.178854077274378E7,2.1427126685079534E7,2.106157904802944E7,2.0701138214833025E7,2.0773944912109643E7,2.1101465426650804E7,2.1433100464210358E7,2.1764271340060156E7,2.2090015665627636E7,2.2420165109055676E7,2.249132869478557E7,2.2126750183904264E7,2.1767738629090924E7,2.1409186884565722E7,2.1046228244790338E7,2.0688662432563096E7,2.0417344641128927E7,2.074161267764567E7,2.1070184959778205E7,2.1398291111033108E7,2.172076722500235E7,2.2047845484131202E7,2.2374457080896217E7,2.2097893441498995E7,2.1741786556917153E7,2.1386142993088838E7,2.1025830190565377E7,2.067118393968909E7,2.0317001890927445E7,2.0382995002645098E7,2.0708489133795545E7,2.1033515559888493E7,2.136340525201984E7,2.169840487685392E7,2.2033265214395232E7,2.211925454959629E7,2.1776092924952056E7,2.1433050145102777E7,2.1095258360241335E7,2.075235486570361E7,2.040957221310045E7,2.0156420587720197E7,2.0491160162338886E7,2.082575581621871E7,2.1165220453865502E7,2.1499588426140405E7,2.183381015811834E7,2.217306550422337E7,2.191476188237164E7,2.1571952981072295E7,2.123416105086194E7,2.0891507074234065E7,2.054897992897586E7,2.0211169587614678E7,2.0291543958151996E7,2.062546395185741E7,2.0963922971693087E7,2.1297595905977003E7,2.1631115351925932E7,2.196932265075469E7,2.2049149449651577E7,2.1706620175496623E7,2.136885960794005E7,2.1026501555585966E7,2.0684276589569606E7,2.0346531168816715E7,2.0088890876042236E7,2.042207015433829E7,2.075945285553371E7,2.1092364920947142E7,2.1443512902899195E7,2.1799591715697154E7,2.215164384132646E7,2.190919700394338E7,2.1591572878593247E7,2.1266333167743467E7,2.0940659486331966E7,2.0618667809263937E7,2.029657380496712E7,2.038977321780365E7,2.0746703971546523E7,2.1100039606520064E7,2.145379603664496E7,2.1812170196025584E7,2.2292064789759554E7,2.2265949129802387E7,2.1942508824345823E7,2.1614412967304908E7,2.1285886423563544E7,2.096080944025547E7,2.063134218494296E7,2.0387105571562193E7,2.074629946264688E7,2.110219114480961E7,2.145849802944873E7,2.181909587151287E7,2.217627453315524E7,2.25338665516033E7,2.2293329929795306E7,2.1962403947523773E7,2.1631051027927198E7,2.1302894012890726E7,2.0970611448442176E7,2.0637903342391748E7,2.0740233324627433E7,2.1098618786468294E7,2.1457413259454835E7,2.181305404475645E7,2.21653663667723E7,2.2517853759280954E7,2.2606843724317852E7,2.2266409759461284E7,2.192577389687896E7,2.1581245687123094E7,2.1240246186690632E7,2.0899047650914412E7,2.0640782981424157E7,2.0993243544121888E7,2.134587434832578E7,2.169479966535781E7,2.204768539415516E7,2.2400738881680105E7,2.274981089827507E7,2.249513555151646E7,2.2153435522500593E7,2.180748526212628E7,2.146544446275548E7,2.112321306551354E7,2.077684967631617E7,2.0869057477606162E7,2.122222567971505E7,2.1571385156871144E7,2.1924789693298157E7,2.2278354977550384E7,2.2627623389205378E7,2.2720265686633166E7,2.2377576254602447E7,2.203028430628418E7,2.168727610950106E7,2.1344085418163724E7,2.099642788218404E7,2.0740069206834726E7,2.10937215858802E7,2.144307838962735E7,2.179694924446179E7,2.215097412810185E7,2.2500403515029244E7,2.2854640304381732E7,2.259826496351339E7,2.2249708890561175E7,2.1905804502854098E7,2.1561725399713792E7,2.121284956437676E7,2.0868480202648208E7,2.0960618156792175E7,2.13101369141091E7,2.16644236455553E7,2.2018857969948325E7,2.236841433045245E7,2.272304367552804E7,2.2815570534137573E7,2.246582517992849E7,2.212109319241742E7,2.1776193954069816E7,2.1426172998139642E7,2.1081003572337553E7,2.082316155138529E7,2.117280830940476E7,2.152746246234586E7,2.188225804706417E7,2.223190875838836E7,2.258688315926801E7,2.2941996945590645E7,2.267869938466166E7,2.233320585050489E7,2.198755222497734E7,2.1636456734349225E7,2.1290552214313257E7,2.0944489880218506E7,2.103133052028953E7,2.138630556724513E7,2.1741416151269894E7,2.2102177878745247E7,2.2468860631676275E7,2.2836038310408268E7,2.2945687236781634E7,2.2612719279902168E7,2.2273677288560297E7,2.1942267253234595E7,2.1604923806593705E7,2.1267085001947533E7,2.1022105600575626E7,2.1390359289542053E7,2.175910576245078E7,2.2133588608280737E7,2.250502508749301E7,2.2873682908682838E7,2.3249900756728288E7,2.299963321810378E7,2.266013122351906E7,2.232527884072038E7,2.1984691646895032E7,2.1643610560785435E7,2.130687473488357E7,2.1410768581059605E7,2.1782602188130923E7,2.2159884271906532E7,2.253276093273297E7,2.290612601370952E7,2.3285112231117953E7,2.3390658086396478E7,2.3047920674569204E7,2.2709619831580997E7,2.2365803662953384E7,2.202149548465024E7,2.168132727280335E7,2.1425968280136056E7,2.180084296539032E7,2.2180865188004896E7,2.2556769890430007E7,2.2911765048773307E7,2.3271371750394486E7,2.362602129252303E7,2.334940506752772E7,2.2987459560247686E7,2.262092478740898E7,2.22545672732479E7,2.189275834365621E7,2.1526664734883662E7,2.1610979452846672E7,2.196960664655238E7,2.2323770905053537E7,2.267772897583815E7,2.30359135106662E7,2.338950404252862E7,2.3473080167829003E7,2.311140404908859E7,2.2745457342557747E7,2.2387986861214887E7,2.2018193155184593E7,2.1652713020338293E7,2.1377239824947886E7,2.173441405058799E7,2.2087475718837444E7,2.244032285623016E7,2.2797004950716525E7,2.314946176159337E7,2.3501701224178124E7,2.3230032301504742E7,2.286472783809281E7,2.2499614754180383E7,2.2138458506287802E7,2.177364708122389E7,2.140902958136632E7,2.1495936912840076E7,2.1847819703758527E7,2.2199479275088135E7,2.2547232634178057E7,2.2890908920416724E7,2.3234133341663122E7,2.3305089715198282E7,2.2933609691497754E7,2.256256812860144E7,2.2188170320348766E7,2.1818049347101532E7,2.144836871900218E7,2.1164369664856385E7,2.1506519057850003E7,2.1848214021155674E7,2.2185491404237065E7,2.2526194797414433E7,2.2866442538502313E7,2.3202003165464114E7,2.292174846684657E7,2.2553380916979983E7,2.218133086477366E7,2.181390146857249E7,2.1446918157622144E7,2.107638224904164E7,2.1150988251362223E7,2.148969345387186E7,2.182372039746341E7,2.2161423890132982E7,2.2498668436132073E7,2.283095666766323E7,2.2903932219217736E7,2.2538300661784396E7,2.2168673288001645E7,2.180399590267255E7,2.1439769739313908E7,2.1071694686412726E7,2.0795805064918812E7,2.1131495475113433E7,2.14622695284985E7)");
- double[] test = (double[])engine.eval("SensitivityBiomassY3");
- Assert.assertEquals(1500, test.length);
- }
-
- @Test
- public void testNonRegretionOnErrorFromR() throws Exception{
- try{
- engine.voidEval("dfresults<-data.frame(c(1,2,3),c(4,5,6))");
- } catch (NullPointerException npe){
- Assert.fail("Error should not have been thrown : " + npe);
- }
- }
-
- @Test
- public void testListWithNullNames() throws Exception {
- RList b= new RList(engine);
- try {
- b = (RList)engine.eval("b<-list(\"a\",\"b\")");
- b.setVariable("b");
- } catch (NullPointerException npe) {
- npe.printStackTrace();
- Assert.fail("Error should not have been thrown : " + npe);
- }
-
- Assert.assertEquals("a",b.get(0));
- Assert.assertEquals("b", b.get(1));
-
- }
-
- @Test
- public void testScripts() throws Exception {
- double d = (Double)engine.evalScript("t<-sin(0)\nt");
- Assert.assertEquals(0.0,d,0.001);
- }
-
- @Test
- public void testGraphics() throws Exception {
-
- File workingDirectory = new File("/tmp");
- engine.setwd(workingDirectory);
-
- engine.plot("test","seq(1,10)",null,null,null,null,null,null,null);
- File pictureFile = new File("/tmp/test.jpg");
- Assert.assertTrue(pictureFile.exists());
- //engine.eval("plot(seq(1,10))");
- }
} // JNITest
Modified: trunk/src/test/java/org/nuiton/j2r/NetTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/NetTest.java 2010-10-18 09:43:32 UTC (rev 236)
+++ trunk/src/test/java/org/nuiton/j2r/NetTest.java 2010-10-19 14:28:46 UTC (rev 237)
@@ -35,29 +35,15 @@
* par : */
package org.nuiton.j2r;
-import static org.nuiton.j2r.TestConstants.S_NB_LOOPS;
-import static org.nuiton.j2r.TestConstants.S_OP;
-import static org.nuiton.j2r.TestConstants.S_T_MAX;
-import static org.nuiton.j2r.TestConstants.V_MAX;
-import static org.nuiton.j2r.TestConstants.V_NB_LOOPS;
-import static org.nuiton.j2r.TestConstants.V_OP_A;
-import static org.nuiton.j2r.TestConstants.V_OP_AB;
-import static org.nuiton.j2r.TestConstants.V_OP_B;
-import java.io.File;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Test;
import org.nuiton.j2r.net.RNetEngine;
-import org.nuiton.j2r.types.RDataFrame;
-import org.nuiton.j2r.types.RList;
-public class NetTest {
+public class NetTest extends AbstractEngineTest {
private static Log log = LogFactory.getLog(NetTest.class);
private REngine engine;
@@ -121,318 +107,5 @@
System.setProperty("R.type", savedRType);
}
- @Test
- public void testDouble() throws Exception {
- Assert.assertEquals(5.0, engine.eval("5.0"));
- engine.voidEval("t<-sin(0)");
- double d = (Double) engine.eval("t");
- Assert.assertEquals(0.0, d, 0);
- }
- @Test
- public void testIntArray() throws Exception {
- Object result = engine.eval("5:10");
- Assert.assertNotNull(result);
- Assert.assertEquals(int[].class, result.getClass());
- int[] intArray = (int[]) result;
- Assert.assertEquals(6, intArray.length);
- for (int i = 5; i < 11; i++) {
- Assert.assertEquals(i, intArray[i - 5]);
- }
- }
-
- @Test
- public void testSimpleOp() throws Exception {
- LutinTimer t = new LutinTimer();
- for (int loop = 0; loop < S_NB_LOOPS; loop++) {
- engine.voidEval("t<-0");
- t.startTiming();
- engine.voidEval(S_OP);
- t.endTiming();
- double d = (Double) engine.eval("t");
- Assert.assertEquals((double) S_T_MAX, d, 0);
- }
- double[] results = t.computeResults();
- System.err.println("[SO]min: " + results[0]);
- System.err.println("[SO]avg: " + results[1]);
- System.err.println("[SO]max: " + results[2]);
- System.err.println("[SO]etype: " + results[3]);
- }
-
- @Test
- public void testVector() throws Exception {
- LutinTimer t = new LutinTimer();
- for (int loop = 0; loop < V_NB_LOOPS; loop++) {
- t.startTiming();
- engine.voidEval(V_OP_A);
- engine.voidEval(V_OP_B);
- double[] r = (double[]) engine.eval(V_OP_AB);
- t.endTiming();
- Assert.assertEquals(V_MAX, r.length);
- }
- double[] results = t.computeResults();
- System.err.println("[V]min: " + results[0]);
- System.err.println("[V]avg: " + results[1]);
- System.err.println("[V]max: " + results[2]);
- System.err.println("[V]etype: " + results[3]);
- }
-
- @Test
- public void testString() throws Exception {
- engine.voidEval("a<-\"testing string\"");
- String testString = (String) engine.eval("a");
- Assert.assertEquals("testing string", testString);
- }
-
- @Test
- public void testInt() throws Exception {
- engine.voidEval("a<-as.integer(5)");
- Integer testInteger = (Integer) engine.eval("a");
- Integer toCompare = 5;
- Assert.assertEquals(toCompare, testInteger);
- }
-
- @Test
- public void testBool() throws Exception {
- engine.voidEval("a<-TRUE");
- engine.voidEval("b<-FALSE");
- Boolean testA = (Boolean) engine.eval("a");
- Boolean testB = (Boolean) engine.eval("b");
- Assert.assertTrue(testA);
- Assert.assertFalse(testB);
- }
-
- @Test
- public void testDataFrame() throws Exception {
- engine.voidEval("a<-data.frame(c(3,4,5,6),c(as.integer(3),as.integer(4),as.integer(5),as.integer(6)),c(\"a\",\"b\",\"c\",\"d\"),c(TRUE,FALSE,TRUE,FALSE),stringsAsFactors=FALSE)");
- RDataFrame testA = (RDataFrame) engine.eval("a");
- engine.setAutoCommit(false);
- Assert.assertEquals(testA.get(0,0),3.0);
- Assert.assertEquals(testA.get(0,1),4.0);
- Assert.assertEquals(testA.get(0,2),5.0);
- Assert.assertEquals(testA.get(0,3),6.0);
- Assert.assertEquals(testA.get(1,0),3);
- Assert.assertEquals(testA.get(1,1),4);
- Assert.assertEquals(testA.get(1,2),5);
- Assert.assertEquals(testA.get(1,3),6);
- Assert.assertEquals(testA.get(2,0),"a");
- Assert.assertEquals(testA.get(2,1),"b");
- Assert.assertEquals(testA.get(2,2),"c");
- Assert.assertEquals(testA.get(2,3),"d");
- Assert.assertEquals(testA.get(3,0),true);
- Assert.assertEquals(testA.get(3,1),false);
- Assert.assertEquals(testA.get(3,2),true);
- Assert.assertEquals(testA.get(3,3),false);
- engine.setAutoCommit(true);
- }
-
- @Test
- public void testList() throws Exception {
- //create a data.frame to be added to the list
- engine.voidEval("b<-data.frame(c(3,4,5,6),c(as.integer(3),as.integer(4),as.integer(5),as.integer(6)),c(\"a\",\"b\",\"c\",\"d\"),c(TRUE,FALSE,TRUE,FALSE),stringsAsFactors=FALSE)");
- engine.voidEval("a<-list(one=as.integer(2),two=3.0,three=TRUE,four=\"b\",five=b)");
- RList testA = (RList)engine.eval("a");
- engine.setAutoCommit(false);
- Assert.assertEquals(testA.get(0), 2);
- Assert.assertEquals(testA.get(1), 3.0);
- Assert.assertEquals(testA.get(2), true);
- Assert.assertEquals(testA.get(3), "b");
- Assert.assertTrue(testA.get(4) instanceof RDataFrame);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,0), 3.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,1), 4.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,2), 5.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(0,3), 6.0);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,0), 3);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,1), 4);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,2), 5);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(1,3), 6);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,0), "a");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,1), "b");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,2), "c");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(2,3), "d");
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,0), true);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,1), false);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,2), true);
- Assert.assertEquals(((RDataFrame)testA.get(4)).get(3,3), false);
- Assert.assertEquals(testA.getName(0),"one");
- Assert.assertEquals(testA.getName(1),"two");
- Assert.assertEquals(testA.getName(2),"three");
- Assert.assertEquals(testA.getName(3),"four");
- Assert.assertEquals(testA.getName(4),"five");
- engine.setAutoCommit(true);
-
- }
-
- @Test
- public void testArrayBool() throws Exception {
- engine.voidEval("a<-c(TRUE,FALSE,TRUE)");
- Boolean[] testBoolArray = (Boolean[]) engine.eval("a");
- Assert.assertTrue(testBoolArray[0]);
- Assert.assertFalse(testBoolArray[1]);
- Assert.assertTrue(testBoolArray[2]);
- }
-
- @Test
- public void testWorkingDirectory() throws Exception {
- File workingDirectory = new File("/tmp");
- engine.setwd(workingDirectory);
- File testWorkingDirectory = engine.getwd();
- Assert.assertEquals(workingDirectory.getAbsolutePath(),
- testWorkingDirectory.getAbsolutePath());
- }
-
- @Test
- public void testRData() throws Exception {
- File workingdir = new File("/tmp");
- engine.voidEval("a<-5.0");
- engine.saveRData(workingdir);
- engine.remove("a");
- engine.loadRData(workingdir);
- Assert.assertEquals(5.0, engine.eval("a"));
- }
-
- @Test
- public void testDputDget() throws Exception {
- File workingdir = new File("/tmp");
- File testingFile = new File("/tmp/testfile");
-
- // test method using the workingdir
- engine.voidEval("a<-5.0");
- engine.setwd(workingdir);
- engine.dput("a", "testDputDgetfile");
- engine.remove("a");
- engine.dget("a", "testDputDgetfile");
- Assert.assertEquals(5.0, engine.eval("a"));
-
- workingdir = new File("/");
- //test method using absolute path
- engine.setwd(workingdir);
- engine.voidEval("a<-6.0");
- engine.dput("a", testingFile);
- engine.remove("a");
- engine.dget("a", testingFile);
- Assert.assertEquals(6.0, engine.eval("a"));
- File testWorkingDirectory = engine.getwd();
- Assert.assertEquals(workingdir.getAbsolutePath(),
- testWorkingDirectory.getAbsolutePath());
- }
-
- @Test
- public void testRemove() throws Exception {
- engine.voidEval("a<-6.0");
- Assert.assertEquals(6.0, engine.eval("a"));
- engine.remove("a");
- Assert.assertFalse((Boolean) engine.eval("exists(\"a\")"));
- }
-
- @Test
- public void testMvCp() throws Exception {
- //Test only mv as mv uses cp.
- engine.voidEval("a<-5.0");
- engine.remove("b");
- engine.mv("a", "b");
- Assert.assertEquals(5.0, engine.eval("b"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"a\")"));
- }
-
- @Test
- public void testLsClearSession() throws Exception {
- //Test only ClearSession as it uses ls
- engine.voidEval("a<-5.0");
- engine.voidEval("b<-5.0");
- engine.voidEval("d<-5.0");
- engine.voidEval("e<-5.0");
- engine.voidEval("f<-5.0");
- engine.clearSession();
- Assert.assertFalse((Boolean) engine.eval("exists(\"a\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"b\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"d\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"e\")"));
- Assert.assertFalse((Boolean) engine.eval("exists(\"f\")"));
- }
-
- @Test
- public void testAutoCommitFalse() throws Exception {
- engine.clearSession();
- engine.setAutoCommit(false);
- engine.voidEval("a<-5.0");
- engine.voidEval("a<-a+5.0");
- engine.voidEval("b<-5.0");
- engine.voidEval("d<-5.0");
- engine.voidEval("e<-5.0");
- engine.voidEval("f<-5.0");
- engine.commit();
- Assert.assertEquals(10.0, engine.eval("a"));
- Assert.assertEquals(5.0, engine.eval("b"));
- Assert.assertEquals(5.0, engine.eval("d"));
- Assert.assertEquals(5.0, engine.eval("e"));
- Assert.assertEquals(5.0, engine.eval("f"));
- }
-
- @Test
- public void testThrowException() throws Exception {
- engine.clearSession();
- //Test that the exception is normally thrown in voidEval
- try {
- engine.voidEval("a<-b");
- Assert.fail("Exception should have been thrown at this point");
- } catch (RException e) {
- log.info(e.getMessage());
- Assert.assertTrue(
- e.getMessage().contains("objet \'b\' introuvable"));
- }
-
- engine.clearSession();
- try {
- engine.eval("a");
- Assert.fail("Exception should have been thrown at this point");
- } catch (RException e) {
- Assert.assertTrue(
- e.getMessage().contains("objet \'a\' introuvable"));
- }
- }
-
- @Test
- public void testNonRegretionOnErrorFromR() throws Exception{
- try{
- engine.voidEval("dfresults<-data.frame(c(1,2,3),c(4,5,6))");
- } catch (NullPointerException npe){
- Assert.fail("Error should not have been thrown : " + npe);
- }
- }
-
- @Test
- public void testListWithNullNames() throws Exception {
- RList b = new RList(engine);
- try {
- b = (RList) engine.eval("b<-list(\"b\",\"a\")");
- b.setVariable("b");
- } catch (NullPointerException npe) {
- Assert.fail("Error should not have been thrown : " + npe);
- }
-
- Assert.assertEquals("b", b.get(0));
- Assert.assertEquals("a", b.get(1));
-
- }
-
- @Test
- public void testScripts() throws Exception {
- double d = (Double) engine.evalScript("t<-sin(0)\nt");
- Assert.assertEquals(0.0, d, 0.001);
- }
-
- @Test
- public void testGraphics() throws Exception {
-
- File workingDirectory = new File("/tmp");
- engine.setwd(workingDirectory);
-
- engine.plot("test", "seq(1,10)", null, null, null, null, null, null, null);
- File pictureFile = new File("/tmp/test.jpg");
- Assert.assertTrue(pictureFile.exists());
- //engine.eval("plot(seq(1,10))");
- }
-
-
} // NetTest
1
0
r236 - in trunk/src: main/java/org/nuiton/j2r test/java/org/nuiton/j2r
by jcouteau@users.nuiton.org 18 Oct '10
by jcouteau@users.nuiton.org 18 Oct '10
18 Oct '10
Author: jcouteau
Date: 2010-10-18 11:43:32 +0200 (Mon, 18 Oct 2010)
New Revision: 236
Url: http://nuiton.org/repositories/revision/nuiton-j2r/236
Log:
Proper test skipping when no R environment present
Modified:
trunk/src/main/java/org/nuiton/j2r/RProxy.java
trunk/src/test/java/org/nuiton/j2r/DataframeTest.java
trunk/src/test/java/org/nuiton/j2r/JNITest.java
trunk/src/test/java/org/nuiton/j2r/ListTest.java
trunk/src/test/java/org/nuiton/j2r/NetTest.java
Modified: trunk/src/main/java/org/nuiton/j2r/RProxy.java
===================================================================
--- trunk/src/main/java/org/nuiton/j2r/RProxy.java 2010-10-18 09:21:30 UTC (rev 235)
+++ trunk/src/main/java/org/nuiton/j2r/RProxy.java 2010-10-18 09:43:32 UTC (rev 236)
@@ -669,5 +669,31 @@
engine.plot(filename, x, y, type, main, sub, xlab, ylab, asp);
}
+ /**
+ * To know if the engine interfaced is a RNetEngine.
+ *
+ * @return true if the engine interfaced is a RNetEngine.
+ */
+ public boolean isNet() {
+ if (engine != null) {
+ return engine instanceof RNetEngine;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * To know if the engine interfaced is a RJniEngine.
+ *
+ * @return true if the engine interfaced is a RJniEngine.
+ */
+ public boolean isJni() {
+ if (engine != null) {
+ return engine instanceof RJniEngine;
+ } else {
+ return false;
+ }
+ }
+
} //RProxy
Modified: trunk/src/test/java/org/nuiton/j2r/DataframeTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/DataframeTest.java 2010-10-18 09:21:30 UTC (rev 235)
+++ trunk/src/test/java/org/nuiton/j2r/DataframeTest.java 2010-10-18 09:43:32 UTC (rev 236)
@@ -37,6 +37,7 @@
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.j2r.types.RDataFrame;
@@ -46,17 +47,23 @@
private REngine engine;
- @Before
- public void setUp() throws Exception {
- if (engine == null) {
- try {
- engine = new RProxy();
- } catch (RException eee){
- Assume.assumeTrue(false);
+ @BeforeClass
+ public static void tryREnv(){
+ try {
+ new RProxy();
+ } catch (RException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("No R environment found to run tests. Skip");
}
+ Assume.assumeTrue(false);
}
}
+ @Before
+ public void setUp() throws Exception {
+ engine = new RProxy();
+ }
+
@After
public void tearDown() throws Exception {
if (engine != null){
Modified: trunk/src/test/java/org/nuiton/j2r/JNITest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/JNITest.java 2010-10-18 09:21:30 UTC (rev 235)
+++ trunk/src/test/java/org/nuiton/j2r/JNITest.java 2010-10-18 09:43:32 UTC (rev 236)
@@ -41,6 +41,7 @@
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.j2r.jni.RJniEngine;
import org.nuiton.j2r.types.RDataFrame;
@@ -56,6 +57,37 @@
private REngine engine;
private String savedRType;
+ @BeforeClass
+ public static void tryREnv() {
+
+ RProxy testedEngine = null;
+
+ //Force R.type to net
+ String savedRType = System.getProperty("R.type", "");
+ System.setProperty("R.type", "jni");
+
+ try {
+ testedEngine = new RProxy();
+ } catch (RException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("No R environment found to run tests. Skip");
+ }
+ Assume.assumeTrue(false);
+ }
+
+ //Restore old R.type
+ System.setProperty("R.type", savedRType);
+
+ if (testedEngine != null) {
+ Assume.assumeTrue(testedEngine.isJni());
+ if (log.isErrorEnabled()) {
+ log.error("No JRI environment found. Skip tests.");
+ }
+ }
+
+
+ }
+
@Before
public void setUp() throws Exception {
LutinTimer init = new LutinTimer();
Modified: trunk/src/test/java/org/nuiton/j2r/ListTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/ListTest.java 2010-10-18 09:21:30 UTC (rev 235)
+++ trunk/src/test/java/org/nuiton/j2r/ListTest.java 2010-10-18 09:43:32 UTC (rev 236)
@@ -31,6 +31,7 @@
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.j2r.types.RList;
@@ -47,17 +48,23 @@
private REngine engine;
- @Before
- public void setUp() throws Exception {
- if (engine == null) {
- try {
- engine = new RProxy();
- } catch (RException eee) {
- Assume.assumeTrue(false);
+ @BeforeClass
+ public static void tryREnv() {
+ try {
+ new RProxy();
+ } catch (RException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("No R environment found to run tests. Skip");
}
+ Assume.assumeTrue(false);
}
}
+ @Before
+ public void setUp() throws Exception {
+ engine = new RProxy();
+ }
+
@After
public void tearDown() throws Exception {
if (engine != null) {
Modified: trunk/src/test/java/org/nuiton/j2r/NetTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/j2r/NetTest.java 2010-10-18 09:21:30 UTC (rev 235)
+++ trunk/src/test/java/org/nuiton/j2r/NetTest.java 2010-10-18 09:43:32 UTC (rev 236)
@@ -51,11 +51,11 @@
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.j2r.net.RNetEngine;
import org.nuiton.j2r.types.RDataFrame;
import org.nuiton.j2r.types.RList;
-import org.rosuda.REngine.Rserve.RserveException;
public class NetTest {
@@ -63,6 +63,37 @@
private REngine engine;
private String savedRType;
+ @BeforeClass
+ public static void tryREnv() {
+
+ RProxy testedEngine= null;
+
+ //Force R.type to net
+ String savedRType = System.getProperty("R.type", "");
+ System.setProperty("R.type", "net://:6311");
+
+ try {
+ testedEngine = new RProxy();
+ } catch (RException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("No R environment found to run tests. Skip");
+ }
+ Assume.assumeTrue(false);
+ }
+
+ //Restore old R.type
+ System.setProperty("R.type", savedRType);
+
+ if (testedEngine != null){
+ Assume.assumeTrue(testedEngine.isNet());
+ if (log.isErrorEnabled()) {
+ log.error("No Rserve environment found. Skip tests.");
+ }
+ }
+
+
+ }
+
@Before
public void setUp() throws Exception {
LutinTimer init = new LutinTimer();
1
0