(总结)JMeter引用java导出的jar包

1.打开eclipse,新建一个Java Project,要求输入Project name(假如名为abc),点击下一步,然后finish。 

Java - Ecli 
Edit Navigate 
Open Filem 
Close 
Close All 
Save Asm 
Save All 
Search 
Project 
Run 
W i ndow 
Ctrl+W 
Ctrl + Shift+W 
Ctrl+S 
Ctrl + Shift* S 
G 
Java Project 
P rajectm 
Package 
Class 
Interface 
E num 
An notatio n

 

2.展开项目名称,选中src文件夹右键新建类(假如类名为def)。 

Go Into 
Open Type Hierarchy 
Show In 
Copy 
Copy Qualified Name 
Paste 
Delete 
Remove from Context 
Build Path 
Alt+Shift+W 
Ctrl+C 
Ctrl+V 
Delete 
Ctrl + Alt* Shift* Dawn 
An outline 
Projectm 
Annotation 
Class 
Interface 
Package 
Source Folder 
Exa mplem 
Otherm 
Ctrl+N

 

3.编写java代码。 

Project Explorer 
*def.java 
P abc 
] avax. crypto. KeyGenerator ; 
def.java 
[Java 
4 
13 
pa c ka 
import 
import 
import 
import 
import 
import 
import 
import 
public 
abc; 
curity. InvalidKeyException ; 
java . security. NoSuchAIgorithmException ; 
java . security. Security; 
javax. crypto. aadPaddingException ; 
] avax. crypto. Cipher; 
] avax. crypto. IllegalaIockSizeException ; 
] avax. crypto. NoSuchPaddingException ; 
Javax. c rypto. SecretKey ; 
clas 
def 
/ / KeyGenerator 
private KeyGenerator keygen; 
//secretKey 
private SecretKey deskey; 
private Cipher c; 
private byteC] cipherayte; 
public def ) throws NoSuchAIgorithmException, NoSuchPaddingException{ 
Sec u . addProvider ( 
keygen =

 

4.导出为jar包(在类上点击右键》Export》jar file,假如命名为xyz.jar)。 

Export 
Select 
Export resources into a JAR file on the local file 
Select an export destination: 
type filter text 
JAR file 
ava ac 
Runnable JAR file

 

JAR Export 
JAR File Specification 
Define which resources should be exported into the JAR. 
_classpath 
@ @ -project 
@ Export generated class files are resources 
C] Export all output folders for checked projects 
C] Export Java source files and resources 
C] Export refactorings for checked projects. Select refactaringsm 
Select the export destination: 
JAR file 
Options: 
@Compress the contents of the JAR file 
Add directory entries 
C] Overwrite existing files without warning 
Back 
Next 
Finish 
Ca ncel

 

5.jmeter引入jar包:点中“测试计划”,在右侧视图中,浏览添加jar包的路径。 

一 qwdsselOOJ 」 」 0 ~ moa

 

6.添加BeanShell Sampler,引用jar包中的方法。 

BeanShell Sampler 
ET. : BeanShell Sampler 
C] Reset bsh.lnterpreterbefore each call 
( > String Parameters *a String []bash.args) 
Script (see below for variables that are defined) 
S{ul} S{u2} S{u3} 
Impor 
def 
abc. 
I = new 
String 
byte ] 
byte ] 
def ; 
msg 
encontent = del . Encrytor (msg) ; 
decontent = del . Decryptor (encontent); 
System. out. printtn( " 
: " + msg); 
System. out. printtn( " 
" + new String (encontent)); 
System. out. printtn( ' 
" + new String (decontent)); 
vars. put ("enconent", new String (encontent)); 
vars. put ("decontent", new String (decontent));
posted @ 2017-11-28 12:41  春田花花同学会  阅读(742)  评论(0编辑  收藏  举报