我正在从头开始创建JMeter测试计划。这是我的代码:
public static void main(String[] args) throws Exception {
StandardJMeterEngine jmeterEngine = new StandardJMeterEngine();
JMeterUtils.setJMeterHome("/Users/myDir/Documents/JMeter/apache-jmeter-3.3");
JMeterUtils.loadJMeterProperties("src/main/resources/jmeter.properties");
JMeterUtils.initLocale();
//create test plan
TestPlan testPlan = new TestPlan();
testPlan.setEnabled(true);
testPlan.setName("Test Plan");
//create thread group
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(1);
threadGroup.setRampUp(1);
// create http sampler
HTTPSampler httpSampler = new HTTPSampler();
httpSampler.setProtocol("https");
httpSampler.setDomain("myDomain.services.company.com");
httpSampler.setPath("ims/login/v1/token");
httpSampler.setMethod("POST");
httpSampler.setFollowRedirects(true);
httpSampler.setAutoRedirects(false);
httpSampler.setUseKeepAlive(true);
httpSampler.addArgument("client_id", "argValue1");
httpSampler.addArgument("scope", "argValue2");
httpSampler.addArgument("userName", "abc%2B249%40gmail.com");
httpSampler.addArgument("password", "Abc123");
//Add sampler to the thread group
threadGroup.addTestElement(httpSampler);
HashTree testPlanHashTree = new HashTree();
testPlanHashTree.add(testPlan);
testPlanHashTree.add(threadGroup);
// Generating the JMX file
SaveService.saveTree(testPlanHashTree, new FileOutputStream(JMeterUtils.getJMeterHome() + "/bin/Test2.jmx"));
}
当我执行这段代码时,我的Test2。jmx已经创建。
接下来,我尝试通过使用以下命令运行Test2.jmx通过Jmetm的非GUI模式:
杰米。sh-n-t测试2。jmx
Jmeter没有运行我的测试计划,而是抛出以下错误:
Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'/Users/chandrat/Documents/JMeter/apache-jmeter-3.3/bin/Test2.jmx', missing class com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception : com.thoughtworks.xstream.converters.ConversionException
cause-message :
first-jmeter-class : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
class : org.apache.jmeter.save.ScriptWrapper
required-type : org.apache.jmeter.threads.ThreadGroup
converter-type : org.apache.jmeter.save.ScriptWrapperConverter
path : /jmeterTestPlan/org.apache.jorphan.collections.HashTree/org.apache.jorphan.collections.HashTree/ThreadGroup
line number : 6
version : 3.3 r1808647
-------------------------------
我不知道如何解决这个问题?原因-消息是空白的?我应该怎么做才能在没有上述错误的情况下执行我的测试计划?
2) 你能看看我的测试计划生成代码吗?那代码对吗?测试组应该直接添加到树中还是先添加到测试计划中,然后再将测试计划添加到树中?
以下是pom文件中的依赖项,以防我丢失一个jar。
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>jorphan</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_http</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies>
请帮忙。谢谢
为了能够在JMeter GUI中打开生成的测试计划,您需要定义更多的属性,修改代码如下:
public static void main(String[] args) throws Exception {
StandardJMeterEngine jmeterEngine = new StandardJMeterEngine();
JMeterUtils.setJMeterHome("/Users/myDir/Documents/JMeter/apache-jmeter-3.3");
JMeterUtils.loadJMeterProperties("src/main/resources/jmeter.properties");
JMeterUtils.initLocale();
//create test plan
TestPlan testPlan = new TestPlan();
testPlan.setEnabled(true);
testPlan.setName("Test Plan");
testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().createTestElement());
LoopController loopController = new LoopController();
loopController.setLoops(1);
loopController.setFirst(true);
loopController.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());
loopController.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName());
loopController.initialize();
//create thread group
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(1);
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName());
threadGroup.setProperty(TestElement.GUI_CLASS, ThreadGroupGui.class.getName());
// create http sampler
HTTPSampler httpSampler = new HTTPSampler();
httpSampler.setProtocol("https");
httpSampler.setDomain("myDomain.services.company.com");
httpSampler.setPath("ims/login/v1/token");
httpSampler.setMethod("POST");
httpSampler.setFollowRedirects(true);
httpSampler.setAutoRedirects(false);
httpSampler.setUseKeepAlive(true);
httpSampler.addArgument("client_id", "argValue1");
httpSampler.addArgument("scope", "argValue2");
httpSampler.addArgument("userName", "abc%2B249%40gmail.com");
httpSampler.addArgument("password", "Abc123");
httpSampler.setProperty(TestElement.TEST_CLASS, HTTPSampler.class.getName());
httpSampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName());
//Add sampler to the thread group
HashTree testPlanHashTree = new HashTree();
HashTree threadGroupHashTree = testPlanHashTree.add(testPlan, threadGroup);
threadGroupHashTree.add(httpSampler);
// Generating the JMX file
SaveService.saveTree(testPlanHashTree, new FileOutputStream(JMeterUtils.getJMeterHome() + "/bin/Test2.jmx"));
}
参考文献:
我在代码上收到一条错误消息,以查找支付200美元佣金的员工的总工资。一旦输入了所有员工的总销售额,就应该打印出属于每个不同薪酬类别的员工销售额。下面是代码: 这是我收到的确切错误消息: 我相信这与双重转换有关,但我不确定这有什么问题?有没有人能帮我搞清楚哪里出问题了(它编译没有错误)?我也尝试过只有双精度(包括数组),但这并没有解决问题。
问题内容: 我的JSF页面中有p:selectOneMenu,当我运行JSF页面时,我从Converter类收到以下异常。 我该如何解决这个问题? 我在实体类中有以下内容 EmployeeConverter类 并在jsf页面中 更新1 修改的转换器方法 更新2 问题答案: 用您的方法,您无法达到自己的价值。在这里,您将收到,因此您必须将其转换为(可能必须实现使用Service locator 加载
我有一个使用jersey JAR的web应用程序(WAR文件)。现在,当我试图部署它时,我遇到了类转换异常(一些引导servlet使用了jersey)。经过分析,我发现weblogic本身在Common\Modules中有jersey JAR。而我的web应用程序有不同版本的jersey JAR。现在,如果我删除了Common/Modules jar,那么我的web应用程序就被部署了。我想知道如何
例外情况: java.lang.ClassCastException:com.interconnect.library.gcm.util.checkplayServices(util.java:96),com.interconnect.library.gcm.regiseter.handleRegister(regiseter.java:53),com.interconnect.library.g
但是,如果web服务器没有回复任何东西(成功登录),那么通过改型,我会得到一个异常,因为是空的,web服务器回复的是一个简单的空字符串消息,而不是字符串数组。如果我将更改为,它就可以工作,但我不能,因为如果登录失败,它必须是一个字符串数组。
我有一把钥匙: 信息: 十六进制的hmac输出: 因此,如果我创建一个新的BigInteger(测试),如: 如果我想得到十六进制值,比如: 我明白了: 问题出在哪里?或者,如何从消息中计算hmac-sha256并使用Beginning中的大整数。 key、message和hmac是字节数组。 如果我尝试将字节“11010100”转换为Bigintger,它会转换为负“-101100”为什么Big