s

阿里巴巴Java开发规范手册.zip

http://dl.iteye.com/topics/download/ffc4ddcf-8b65-3b3c-b146-96468e2baf40

/**

关于日志打印

System.out.println(result); 这个应该只是在当前验证页面打印;
grinder.logger.info(result);这个可以打印到日志中

*/

nGrinder 平台调试groovy压测脚本,成功!

C:\Users\Lindows\workspace\GroovyTest\src\com\iteye\lindows\mysql\TestRunnerInsertMysqlSingle.groovy

package com.iteye.lindows.mysql

import junit.framework.Assert
import net.grinder.script.GTest
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.AfterThread
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
import org.junit.Test
import org.junit.runner.RunWith import java.sql.Connection
import java.sql.DriverManager
import java.sql.ResultSet
import java.sql.Statement import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.assertTrue /**
* java代码示例,连接数据库进行查询
*
* @author Lindows
*/
@RunWith(GrinderRunner)
class TestRunnerInsertMysqlSingle {
public static GTest insertTable
public static Connection conn;
public static Statement stmt; //创建Statement对象 @BeforeProcess
public static void beforeProcess() {
insertTable = new GTest(1, "插入表数据")
try {
Class.forName("com.mysql.jdbc.Driver");
grinder.logger.info("成功加载MySQL驱动!");
String url="jdbc:mysql://10.37.136.162:3306/performance_test"; //JDBC的URL
String username = "performance_user";
String passwd = "performance!QAZ";
conn = DriverManager.getConnection(url, username, passwd);
stmt = conn.createStatement(); //创建Statement对象
grinder.logger.info("成功创建stmt!");
} catch (Exception e) {
e.printStackTrace()
}
} @BeforeThread
public void beforeThread() {
insertTable.record(this, "insertTable")
grinder.statistics.delayReports=true
} @Test
public void insertTable() {
try{
grinder.logger.info("成功连接到数据库!");
StringBuffer sql = new StringBuffer()
sql.append("insert into tab_002(column_int,column_double,column_decimal,column_varchar_name,column_varchar_address,column_text,column_timestamp_create_time,column_timestamp_update_time) values (1000,300.25,600.98,'jack','")
.append("China BeiJing")
.append(new Random().nextInt(99999999))
.append("', 'work in passat for 3 years','2017-06-12 18:00:00','2017-06-13 15:00:00')")
grinder.logger.info(sql.toString())
Thread.sleep(new Random().nextInt(10)) //这里可以设置思考时间10ms
assertTrue(!stmt.execute(sql.toString()))//执行sql insert,!stmt.execute(sql)该写法只于insert true确认
//assertTrue(stmt.execute(sql));//执行sql query , !stmt.execute(sql)该写法只适用于query true确认
}catch(Exception e) {
e.printStackTrace();
}
} @AfterThread
public void afterThread() {
stmt.close();
conn.close();
}
}

C:\Users\Lindows\Desktop\lab\groovy\libs

asm-3.3.1.jar
commons-lang-2.6.jar
commons-lang3-3.3.2.jar
commons-logging-1.0.4.jar
grinder-core-3.9.1.jar
grinder-dcr-agent-3.9.1.jar
grinder-http-3.9.1.jar
grinder-http-patch-3.9.1-patch.jar
grinder-httpclient-3.9.1.jar
grinder-httpclient-patch-3.9.1-patch.jar
grinder-patch-3.9.1-patch.jar
hamcrest-all-1.1.jar
json-20090211.jar
junit-dep-4.11.jar
log4j-1.2.15.jar
logback-classic-1.0.0.jar
logback-core-1.0.0.jar
mysql-connector-java-5.1.36 (1).jar
ngrinder-core-3.4.jar
ngrinder-groovy-3.4.jar
ngrinder-runtime-3.4.jar
ngrinder-sh-3.4.jar
slf4j-api-1.6.4.jar

junit  test运行异常:

java.lang.RuntimeException: Please add 
-javaagent:C:\Users\Lindows\Desktop\lab\groovy\libs\grinder-dcr-agent-3.9.1.jar
in 'Run As JUnit' vm argument.
at net.grinder.engine.process.JUnitThreadContextInitializer.initialize(JUnitThreadContextInitializer.java:72)
at net.grinder.scriptengine.groovy.junit.GrinderRunner.initializeGrinderContext(GrinderRunner.java:142)
at net.grinder.scriptengine.groovy.junit.GrinderRunner.<init>(GrinderRunner.java:112)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

解决一: -javaagent:C:\Users\Lindows\Desktop\lab\groovy\libs\grinder-dcr-agent-3.9.1.jar

Debug As JUnit Test ,,,ok!

end

script nGrinder_TestRunnerInsertMysqlSingle.groovy的更多相关文章

  1. SoapUI Pro Project Solution Collection –Easy develop Groovy Script to improve SoapUI ability

    As you know the groovy script and java script language is the soapui supported .but unfortunately So ...

  2. atitit groovy 总结java 提升效率

    atitit groovy 总结java 提升效率 #---环境配置 1 #------安装麻烦的 2 三.创建groovy项目 2 3.  添加 Groovy 类 2 4.  编译运行groovy类 ...

  3. groovyConsole — the Groovy Swing console

    1. Groovy : Groovy Console The Groovy Swing Console allows a user to enter and run Groovy scripts. T ...

  4. Groovy的脚本统一于类的世界

    http://groovy-lang.org/structure.html 3.2. Script class A script is always compiled into a class. Th ...

  5. Java集成groovy之GroovyShell、GroovyScriptEngine、GroovyClassLoader

    GroovyClassLoader 用 Groovy 的 GroovyClassLoader ,动态地加载一个脚本并执行它的行为.GroovyClassLoader是一个定制的类装载器,负责解释加载J ...

  6. 24.基于groovy脚本进行partial update

    主要知识点 在es中其实是有内置的脚本支持的,可以基于groovy脚本实现各种各样的复杂操作 基于groovy脚本,如何执行partial update es scripting module,我们会 ...

  7. Elasticsearch由浅入深(五)_version乐观锁、external version乐观锁、partial update、groovy脚本实现partial update

    基于_version进行乐观锁并发控制 先构造一条数据出来 PUT /test_index/test_type/ { "test_field": "test test&q ...

  8. 4: ES内执行Groovy脚本,做文档部分更新、执行判断改变操作类型

    ES有内置的Groovy脚本执行内核,可以在命令的Json内嵌入Groovy脚本语句   前提数据:           

  9. ElasticSearch 自定义排序处理

    使用function_score进行分组处理,利用分组函数script_score进行自定义分值处理, 注意:使用script功能需要在配置中打开脚本功能: script.inline: on   s ...

随机推荐

  1. 自定义django-admin命令

    我们可以通过manage.py编写和注册自定义的命令. 自定义的管理命令对于独立脚本非常有用,特别是那些使用Linux的crontab服务,或者Windows的调度任务执行的脚本.比如,你有个需求,需 ...

  2. [十]SpringBoot 之 普通类获取Spring容器中的bean

    我们知道如果我们要在一个类使用spring提供的bean对象,我们需要把这个类注入到spring容器中,交给spring容器进行管理,但是在实际当中,我们往往会碰到在一个普通的Java类中,想直接使用 ...

  3. 洛谷3704 [SDOI2017] 数字表格 【莫比乌斯反演】

    题目分析: 比较有意思,但是套路的数学题. 题目要求$ \prod_{i=1}^{n} \prod_{j=1}^{m}Fib(gcd(i,j)) $. 注意到$ gcd(i,j) $有大量重复,采用莫 ...

  4. 修改KVM的模拟网卡类型

    修改KVM的模拟网卡类型 来源 https://www.cnblogs.com/EasonJim/p/9751051.html 在KVM下可以生成两种型号的网卡,RTL8139和E1000,其实应该是 ...

  5. linux环境node服务器配置流程

    一. 安装node Node 官网已经把 linux 下载版本更改为已编译好的版本了,我们可以直接下载解压后使用: # wget https://nodejs.org/dist/v10.9.0/nod ...

  6. 【hdu6188】Duizi and Shunzi(贪心)

    2017ACM/ICPC广西邀请赛 重现赛1007 Duizi and Shunzi 题意 有n张牌,问你最多能组成多少对子+顺子?一个牌只能用在一个顺子或者对子中. 题解 本来想写dp的,不会..小 ...

  7. 【HDU-6148】 Valley Numer(数位dp)

    百度之星2017复赛1005 HDU-6148 Valley Numer 题意 不出现上升后直接下降数位的数,不超过n的有几个.前导零不算. 题解 dfs(当前数位的位置len,这位的数num,是否在 ...

  8. Android 性能优化提示

    原文 http://developer.android.com/guide/practices/design/performance.html 性能优化 Android应用程序运行的移动设备受限于其运 ...

  9. android 读取EXcel 文件 读取文件内存卡的权限

    android 采用Java的读取xls文件的方式实现. 需要导入第三方Jxl.jar 包.  代码改自 其他博主  : 这只摘录下 读取xls文件的部分代码,当然这个代码在安卓平台需要添加下面的权限 ...

  10. Bug预防体系(上千bug分析后总结的最佳实践)

    Bug预防体系(上千bug分析后总结的最佳实践) 原创 2017-08-16俞美玲 光荣之路 吴老的<selenium webdriver 实战宝典>出版了!  web常见产品问题及预防 ...