Jmeter Software Test 3 -- send binary packets, jmeter3 --
Pipeline is compressed. the materials found at night can be implemented by modifying the Jmeter configuration, but the test is not successful. Therefore, Jmeter is used to customize the Java request method. The steps are as follows:
1. Create a Java Project
2. Main jar packages used
3. The new Code is as follows:
1 package com. test. jmeter; 2 3 import java. io. IOException; 4 5 import javacommon. util. resultClass; 6 import javacommon. util. send. innerSendZip; 7 8 import org. apache. http. client. clientProtocolException; 9 import org. apache. jmeter. config. arguments; 10 import org. apache. jmeter. protocol. java. sampler. abstract‑amplerclient; 11 import org. apache. jmeter. protocol. java. sampler. using amplercontext; 12 impo Rt org. apache. jmeter. samplers. sampleResult; 13 14 public class Jmeter_Byte extends abstract=amplerclient {15 16 private static String label = "ByteResponse"; // defines the label name, which is displayed in jmeter's result window 17 private String url; 18 private String data; 19 20 public void setupTest () {21 // define the initial test value. setupTest only uses 22 System before the test starts. out. println ("setupTest"); 23} 24 25 @ Override26 public SampleResult runTest (using amplercontex T arg0) {27 28 url = arg0.getParameter ("url"); 29 data = arg0.getParameter ("data"); 30 SampleResult sr; 31 sr = new SampleResult (); 32 sr. setSampleLabel (label); 33 ResultClass resultClass = new ResultClass (); 34 sr. sampleStart (); 35 // Method for calling the pressure test interface 36 resultClass = InnerSendZip. sendData (url, data, 8000,90000); 37 if (resultClass. getResult () = 0) {38 sr. setSuccessful (true); 39} else {40 sr. setSuccessful (false); 41} 42 sr. sampleEnd (); // jmeter end statistics response time mark 43 sr. setResponseCode (String. valueOf (resultClass. getResultCode (); // response value 44 sr. setResponseMessage (resultClass. getResultDesc (); // response information 45 return sr; 46} 47 48 public void teardownTest (using amplercontext arg0) {49 super. teardownTest (arg0); 50} 51 52 public Arguments getdefaparameparameters () {53 // Parameter definition, which is displayed on the foreground. You can also define 54 Arguments params = new Arguments (); 55 params. AddArgument ("url", "http: // 127.0.0.1: 8080/Interface/api/CisInnerSync? Platform = cis & correlateid = 2fd5473db72740bfa18b68abc09409e9 "); 56 params. addArgument ("data", "{\" areaNo \ ": \" TEST \ ", \" bit_rate \ ": \" 1.5 \ ", \" xmlPath \": \ "ftp: // ti111: 123456@192.168.4.135/ADI/test/20161115/Hangzhou/XML/second time 20th 02. xml \ ", \" tsPath \ ": \" ftp: // t1111: 123456@192.168.4.135/ADI/second time 20th 02. ts \ ", \" priviewTsPath \ ": \" \ ", \" imagePath \ ": \" ftp: // tiest: 123456@192.168.4.135/ADI/test/20161115/Hangzhou/poster/ 02.jpg \ "}"); 57 return params; 58} 59}
4. compress the jar package to the Jmeter {Jmeter} \ lib \ ext directory.
4. Restart Jmeter and create a test thread.
5. view results
6. The Technical Reference Links are as follows:
Http://www.cnblogs.com/liu-ke/p/4325607.html