package rserver.function;
import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
//import util.AppUtils;
public class RServiceTest extends RTestBase {
private static final Logger logger = LoggerFactory.getLogger(RServiceTest.class);
private StringBuffer results = new StringBuffer();
@BeforeMethod
public void setUp() {
super.setUpContext();
super.setUpRService();
}
@AfterMethod
public void tearDown() {
super.tearDownRService();
super.tearDownContext();
}
//--------------------------- Tests
@Test
public void testSyncedTransaction() throws InterruptedException, RserveException, REXPMismatchException {
Thread[] group = new Thread[5];
for(Thread th : group) {
th = new Thread(new TestThread());
th.start();
Thread.sleep(500);
}
Thread.sleep(10000);
logger.debug("Sequence:" + results.toString());
Assert.assertTrue(results.length() > 0);
Assert.assertTrue(results.toString().startsWith("012340123401234"));
}
class TestThread implements Runnable {
final RService rService = RServiceTest.this.rService;
public void run() {
logger.debug("Thread started");
RConnection r = rService.startTransaction();
logger.debug("Thread got transaction");
try {
r.eval("1+2");
} catch (RserveException e1) {
rService.endTransaction();
//throw AppUtils.newRuntimeException(null, e1);
}
int count = 0;
while(count<5) {
try {
Thread.sleep(500);
results.append(String.valueOf(count++));
} catch (InterruptedException e) {
//throw AppUtils.newRuntimeException(null, e);
}
}
rService.endTransaction();
logger.debug("Thread ended");
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Rtest.zip (19个子文件)
Rtest
.project 381B
src
cn
Whu
Ryl
R
Rtest.java 1KB
rserver
function
RServiceTest.java 2KB
RServiceNotAvailableException.java 259B
RTestBase.java 1KB
RService.java 2KB
lib
slf4j-api-1.7.5.jar 25KB
RserveEngine.jar 27KB
REngine.jar 32KB
testng-6.8.jar 1.31MB
spring-2.0.jar 2.43MB
.settings
org.eclipse.jdt.core.prefs 629B
.classpath 590B
bin
cn
Whu
Ryl
R
Rtest.class 2KB
rserver
function
RServiceTest.class 2KB
RTestBase.class 3KB
RServiceNotAvailableException.class 544B
RServiceTest$TestThread.class 2KB
RService.class 3KB
共 19 条
- 1
Ronald1991
- 粉丝: 7
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页