yannrichet / rsession

R sessions wrapping for Java
BSD 2-Clause "Simplified" License
52 stars 31 forks source link

After i start rserver on my windows10, I run the test method error: #12

Closed liango2 closed 8 years ago

liango2 commented 8 years ago

After i start rserver In the RGui on my windows10, I run the test method

@Test
    public void testHardConcurrency() throws REXPMismatchException, InterruptedException {

and got the err in the console window as below:

"C:\Program Files\Java\jdk1.8.0_05\bin\java" -DR_HOME=d:\R\R-3.2.5\bin\x64 ... ...org.math.R.RsessionTest JUnit version 4.0 R version 3.2.5 (2016-04-14) tmpdir=D:\lianxi\lianxi-rstat\rsession\tmp Rserve version 1.8-0

Time: 0 There was 1 failure: 1) testHardConcurrency(org.math.R.RsessionTest) java.lang.NullPointerException at org.math.R.Rsession.(Rsession.java:439) at org.math.R.Rsession.newInstanceTry(Rsession.java:382) at org.math.R.RsessionTest.testHardConcurrency(RsessionTest.java:658) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.junit.internal.runners.CompositeRunner.run(CompositeRunner.java:29) at org.junit.runner.JUnitCore.run(JUnitCore.java:121) at org.junit.runner.JUnitCore.run(JUnitCore.java:100) at org.junit.runner.JUnitCore.run(JUnitCore.java:91) at org.junit.runner.JUnitCore.runMain(JUnitCore.java:75) at org.junit.runner.JUnitCore.main(JUnitCore.java:42) at org.math.R.RsessionTest.main(RsessionTest.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

FAILURES!!! Tests run: 1, Failures: 1

Process finished with exit code 1

Please help:

yannrichet commented 8 years ago

Can you retry without starting any RGUI ? Rsession is supposed to start it by itself. Also, check that no remaining Rserve is still alive in your process exporer.

liango2 commented 8 years ago

oh,yes, I found that:

Rsession is supposed to start it by itself.

when pass RserverConf conf = new RserverConf(null, -1/* RserverConf.RserverDefaultPort*/, null, null, prop); to s = Rsession.newInstanceTry(l, conf); as code in 'public void setUp() {'

But ,when null was passed in the test report "java.lang.NullPointerException" and no new rserve process in the exporer \ as code in testHardConcurrency()

 //@Test
    public void testHardConcurrency() throws REXPMismatchException, InterruptedException {
        final int[] A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        final Rsession[] R = new Rsession[A.length];
        for (int i = 0; i < R.length; i++) {
            R[i] = Rsession.newInstanceTry(new Logger() {

                public void println(String string, Level level) {
                    if (level == Level.INFO) {
                        System.out.println(string);
                    } else {
                        System.err.println(string);
                    }
                }

                public void close() {
                }
            }, null); ** // when null was passed in then the test report "java.lang.NullPointerException" and no new rserve process in the exporer **
        }

Maybe Passing null values is not correct? I want to know What functions do have when you pass a null value

yannrichet commented 8 years ago

ok, you can use RserverConf conf = new RserverConf("localhost", 6311, mylogin, mypasswd, prop) to reach your Rserve instance. null values is supposed to startup a new Rserver which is not working for you, it seems.

liango2 commented 8 years ago

Thank you