Skip to content

Commit 5e4d097

Browse files
authored
Support body params for jmeter (#8101)
1 parent a4f1d1b commit 5e4d097

File tree

7 files changed

+65
-4
lines changed

7 files changed

+65
-4
lines changed

modules/openapi-generator/src/main/resources/jmeter-client/api.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
</HeaderManager>
9191
<hashTree/>
9292
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="{{operationId}} - ${testCase}" enabled="true">
93+
{{#hasBodyParam}}<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>{{/hasBodyParam}}
9394
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
9495
<collectionProp name="Arguments.arguments">{{#queryParams}}
9596
<elementProp name="{{paramName}}" elementType="HTTPArgument">
@@ -98,7 +99,12 @@
9899
<stringProp name="Argument.metadata">=</stringProp>
99100
<boolProp name="HTTPArgument.use_equals">true</boolProp>
100101
<stringProp name="Argument.name">{{paramName}}</stringProp>
101-
</elementProp>{{/queryParams}}
102+
</elementProp>{{/queryParams}}{{#bodyParam}}
103+
<elementProp name="{{paramName}}" elementType="HTTPArgument">
104+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
105+
{{=<% %>=}}<stringProp name="Argument.value">${<% paramName %>}</stringProp><%={{ }}=%>
106+
<stringProp name="Argument.metadata">=</stringProp>
107+
</elementProp>{{/bodyParam}}
102108
</collectionProp>
103109
</elementProp>
104110
<stringProp name="HTTPSampler.domain"></stringProp>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
testCase,httpStatusCode,pet,petId,apiKey,status,tags,petId,pet,petId,name,status,petId,additionalMetadata,file
1+
testCase,httpStatusCode,body,petId,apiKey,status,tags,petId,body,petId,name,status,petId,additionalMetadata,file
22
Success,200,0,0,0,0,0,0,0,0,0,0,0,0,0

samples/client/petstore/jmeter/PetApi.jmx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@
121121
</HeaderManager>
122122
<hashTree/>
123123
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="addPet - ${testCase}" enabled="true">
124+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
124125
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
125126
<collectionProp name="Arguments.arguments">
127+
<elementProp name="body" elementType="HTTPArgument">
128+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
129+
<stringProp name="Argument.value">${body}</stringProp>
130+
<stringProp name="Argument.metadata">=</stringProp>
131+
</elementProp>
126132
</collectionProp>
127133
</elementProp>
128134
<stringProp name="HTTPSampler.domain"></stringProp>
@@ -191,6 +197,7 @@
191197
</HeaderManager>
192198
<hashTree/>
193199
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="deletePet - ${testCase}" enabled="true">
200+
194201
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
195202
<collectionProp name="Arguments.arguments">
196203
</collectionProp>
@@ -257,6 +264,7 @@
257264
</HeaderManager>
258265
<hashTree/>
259266
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="findPetsByStatus - ${testCase}" enabled="true">
267+
260268
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
261269
<collectionProp name="Arguments.arguments">
262270
<elementProp name="status" elementType="HTTPArgument">
@@ -330,6 +338,7 @@
330338
</HeaderManager>
331339
<hashTree/>
332340
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="findPetsByTags - ${testCase}" enabled="true">
341+
333342
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
334343
<collectionProp name="Arguments.arguments">
335344
<elementProp name="tags" elementType="HTTPArgument">
@@ -403,6 +412,7 @@
403412
</HeaderManager>
404413
<hashTree/>
405414
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="getPetById - ${testCase}" enabled="true">
415+
406416
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
407417
<collectionProp name="Arguments.arguments">
408418
</collectionProp>
@@ -469,8 +479,14 @@
469479
</HeaderManager>
470480
<hashTree/>
471481
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="updatePet - ${testCase}" enabled="true">
482+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
472483
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
473484
<collectionProp name="Arguments.arguments">
485+
<elementProp name="body" elementType="HTTPArgument">
486+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
487+
<stringProp name="Argument.value">${body}</stringProp>
488+
<stringProp name="Argument.metadata">=</stringProp>
489+
</elementProp>
474490
</collectionProp>
475491
</elementProp>
476492
<stringProp name="HTTPSampler.domain"></stringProp>
@@ -535,6 +551,7 @@
535551
</HeaderManager>
536552
<hashTree/>
537553
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="updatePetWithForm - ${testCase}" enabled="true">
554+
538555
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
539556
<collectionProp name="Arguments.arguments">
540557
</collectionProp>
@@ -601,6 +618,7 @@
601618
</HeaderManager>
602619
<hashTree/>
603620
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="uploadFile - ${testCase}" enabled="true">
621+
604622
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
605623
<collectionProp name="Arguments.arguments">
606624
</collectionProp>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
testCase,httpStatusCode,orderId,orderId,order
1+
testCase,httpStatusCode,orderId,orderId,body
22
Success,200,0,0,0

samples/client/petstore/jmeter/StoreApi.jmx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
</HeaderManager>
102102
<hashTree/>
103103
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="deleteOrder - ${testCase}" enabled="true">
104+
104105
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
105106
<collectionProp name="Arguments.arguments">
106107
</collectionProp>
@@ -167,6 +168,7 @@
167168
</HeaderManager>
168169
<hashTree/>
169170
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="getInventory - ${testCase}" enabled="true">
171+
170172
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
171173
<collectionProp name="Arguments.arguments">
172174
</collectionProp>
@@ -233,6 +235,7 @@
233235
</HeaderManager>
234236
<hashTree/>
235237
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="getOrderById - ${testCase}" enabled="true">
238+
236239
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
237240
<collectionProp name="Arguments.arguments">
238241
</collectionProp>
@@ -299,8 +302,14 @@
299302
</HeaderManager>
300303
<hashTree/>
301304
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="placeOrder - ${testCase}" enabled="true">
305+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
302306
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
303307
<collectionProp name="Arguments.arguments">
308+
<elementProp name="body" elementType="HTTPArgument">
309+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
310+
<stringProp name="Argument.value">${body}</stringProp>
311+
<stringProp name="Argument.metadata">=</stringProp>
312+
</elementProp>
304313
</collectionProp>
305314
</elementProp>
306315
<stringProp name="HTTPSampler.domain"></stringProp>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
testCase,httpStatusCode,user,user,user,username,username,username,password,username,user
1+
testCase,httpStatusCode,body,body,body,username,username,username,password,username,body
22
Success,200,0,0,0,0,0,0,0,0,0

samples/client/petstore/jmeter/UserApi.jmx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@
121121
</HeaderManager>
122122
<hashTree/>
123123
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="createUser - ${testCase}" enabled="true">
124+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
124125
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
125126
<collectionProp name="Arguments.arguments">
127+
<elementProp name="body" elementType="HTTPArgument">
128+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
129+
<stringProp name="Argument.value">${body}</stringProp>
130+
<stringProp name="Argument.metadata">=</stringProp>
131+
</elementProp>
126132
</collectionProp>
127133
</elementProp>
128134
<stringProp name="HTTPSampler.domain"></stringProp>
@@ -187,8 +193,14 @@
187193
</HeaderManager>
188194
<hashTree/>
189195
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="createUsersWithArrayInput - ${testCase}" enabled="true">
196+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
190197
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
191198
<collectionProp name="Arguments.arguments">
199+
<elementProp name="body" elementType="HTTPArgument">
200+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
201+
<stringProp name="Argument.value">${body}</stringProp>
202+
<stringProp name="Argument.metadata">=</stringProp>
203+
</elementProp>
192204
</collectionProp>
193205
</elementProp>
194206
<stringProp name="HTTPSampler.domain"></stringProp>
@@ -253,8 +265,14 @@
253265
</HeaderManager>
254266
<hashTree/>
255267
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="createUsersWithListInput - ${testCase}" enabled="true">
268+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
256269
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
257270
<collectionProp name="Arguments.arguments">
271+
<elementProp name="body" elementType="HTTPArgument">
272+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
273+
<stringProp name="Argument.value">${body}</stringProp>
274+
<stringProp name="Argument.metadata">=</stringProp>
275+
</elementProp>
258276
</collectionProp>
259277
</elementProp>
260278
<stringProp name="HTTPSampler.domain"></stringProp>
@@ -319,6 +337,7 @@
319337
</HeaderManager>
320338
<hashTree/>
321339
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="deleteUser - ${testCase}" enabled="true">
340+
322341
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
323342
<collectionProp name="Arguments.arguments">
324343
</collectionProp>
@@ -385,6 +404,7 @@
385404
</HeaderManager>
386405
<hashTree/>
387406
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="getUserByName - ${testCase}" enabled="true">
407+
388408
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
389409
<collectionProp name="Arguments.arguments">
390410
</collectionProp>
@@ -451,6 +471,7 @@
451471
</HeaderManager>
452472
<hashTree/>
453473
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="loginUser - ${testCase}" enabled="true">
474+
454475
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
455476
<collectionProp name="Arguments.arguments">
456477
<elementProp name="username" elementType="HTTPArgument">
@@ -531,6 +552,7 @@
531552
</HeaderManager>
532553
<hashTree/>
533554
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="logoutUser - ${testCase}" enabled="true">
555+
534556
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
535557
<collectionProp name="Arguments.arguments">
536558
</collectionProp>
@@ -597,8 +619,14 @@
597619
</HeaderManager>
598620
<hashTree/>
599621
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="updateUser - ${testCase}" enabled="true">
622+
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
600623
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
601624
<collectionProp name="Arguments.arguments">
625+
<elementProp name="body" elementType="HTTPArgument">
626+
<boolProp name="HTTPArgument.always_encode">false</boolProp>
627+
<stringProp name="Argument.value">${body}</stringProp>
628+
<stringProp name="Argument.metadata">=</stringProp>
629+
</elementProp>
602630
</collectionProp>
603631
</elementProp>
604632
<stringProp name="HTTPSampler.domain"></stringProp>

0 commit comments

Comments
 (0)