-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJMeter-cpf-cnpj.jmx
327 lines (288 loc) · 12.1 KB
/
JMeter-cpf-cnpj.jmx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">true</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="email" elementType="Argument">
<stringProp name="Argument.name">email</stringProp>
<stringProp name="Argument.value">daileonteste${__Random(1,99999,)}@teste.com</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="TestPlan.user_define_classpath">/Users/esouza/Walmart/Jmeter/DriverSQL/sqljdbc4-4.0.jar</stringProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">3</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.start_time">1370729701000</longProp>
<longProp name="ThreadGroup.end_time">1370729701000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.delayedStart">true</boolProp>
</ThreadGroup>
<hashTree>
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="CPF Generator" enabled="true">
<stringProp name="BeanShellSampler.query">import java.util.ArrayList;
import java.util.List;
import javax.swing.text.MaskFormatter;
List listaAleatoria = new ArrayList();
List listaNumMultiplicados = null;
// Primeiro executamos os metodos de geracao
for (int i = 0; i < 9; i++) {
listaAleatoria.add((int) (Math.random() * 10));
}
listaNumMultiplicados = new ArrayList();
int primeiroDigito;
int totalSomatoria = 0;
int restoDivisao;
int peso = 10;
// Para cada item na lista multiplicamos seu valor pelo seu peso
for (int i = 0 ; i < listaAleatoria.size() ; i++) {
listaNumMultiplicados.add((Integer)listaAleatoria.get(i) * peso);
peso--;
}
// Agora somamos todos os itens que foram multiplicados
for (int i = 0 ; i < listaNumMultiplicados.size() ; i++) {
totalSomatoria += (Integer)listaNumMultiplicados.get(i);
}
restoDivisao = (totalSomatoria % 11);
// Se o resto da divisao for menor que 2 o primeiro digito sera 0, senao
// subtraimos o numero 11 pelo resto da divisao
if (restoDivisao < 2) {
primeiroDigito = 0;
} else {
primeiroDigito = 11 - restoDivisao;
}
// Apos gerar o primeiro digito o adicionamos a lista
listaAleatoria.add(primeiroDigito);
listaNumMultiplicados = new ArrayList();
int segundoDigitos;
int totalSomatorias = 0;
int restoDivisaos;
int pesos = 11;
// Para cada item na lista multiplicamos seu valor pelo seu peso
// (observe que com o aumento da lista o peso tambem aumenta)
for (int i = 0 ; i < listaAleatoria.size() ; i++) {
listaNumMultiplicados.add((Integer)listaAleatoria.get(i) * pesos);
pesos--;
}
// Agora somamos todos os itens que foram multiplicados
for (int i = 0 ; i < listaNumMultiplicados.size() ; i++) {
totalSomatorias += (Integer)listaNumMultiplicados.get(i);
}
restoDivisaos = (totalSomatorias % 11);
// Se o resto da divisao for menor que 2 o segundo digito sera 0, senao
// subtraimos o numero 11 pelo resto da divisao
if (restoDivisaos < 2) {
segundoDigitos = 0;
} else {
segundoDigitos = 11 - restoDivisaos;
}
// Apos gerar o segundo digito o adicionamos a lista
listaAleatoria.add(segundoDigitos);
String cpf = "";
String texto = "";
/*
* Aqui vamos concatenar todos os valores da lista em uma string. Por
* que isso? Porque a formatacao que o ArrayList gera me
* impossibilitaria de usar a mascara, pois junto com os numeros gerados
* ele tambem gera caracteres especias. Ex.: a saída de uma lista de
* inteiros (de 1 a 5) seria essa: [1 , 2 , 3 , 4 , 5] Dessa forma o
* sistema geraria a excecao ParseException
*/
for (int i = 0 ; i < listaAleatoria.size() ; i++) {
texto += listaAleatoria.get(i);
}
// Dentro do bloco try.. catch.. tentaremos adicionar uma mascara ao
// nosso CPF
try {
MaskFormatter mf = new MaskFormatter("###########");
mf.setValueContainsLiteralCharacters(false);
cpf = mf.valueToString(texto);
} catch (Exception ex) {
ex.printStackTrace();
}
return cpf;</stringProp>
<stringProp name="BeanShellSampler.filename"></stringProp>
<stringProp name="BeanShellSampler.parameters"></stringProp>
<boolProp name="BeanShellSampler.resetInterpreter">true</boolProp>
</BeanShellSampler>
<hashTree>
<RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Regular Expression Extractor" enabled="true">
<stringProp name="RegexExtractor.useHeaders">false</stringProp>
<stringProp name="RegexExtractor.refname">cpf</stringProp>
<stringProp name="RegexExtractor.regex">(.*)</stringProp>
<stringProp name="RegexExtractor.template">$1$</stringProp>
<stringProp name="RegexExtractor.default">NOT FOUND</stringProp>
<stringProp name="RegexExtractor.match_number">1</stringProp>
</RegexExtractor>
<hashTree/>
</hashTree>
<BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="CNPJ Gerador" enabled="true">
<stringProp name="BeanShellSampler.query">import java.util.ArrayList;
import java.util.List;
List listaAleatoria = new ArrayList();
List listaPeso = new ArrayList();
List listaNumMultiplicados = new ArrayList();
List listaNumMultiplicados2 = new ArrayList();
int primeiroDigito;
int segundoDigito;
int totalSomatoria = 0;
int restoDivisao;
// Primeiro executamos os metodos de geracao
for (int i = 0; i < 7; i++) {
listaAleatoria.add((int) (Math.random() * 10));
}
//Adiciona os três 0
for (int i = 0; i < 4; i++) {
listaAleatoria.add((int) 0 );
}
listaAleatoria.add((int) 1 );
listaPeso.add((int) 5);
listaPeso.add((int) 4);
listaPeso.add((int) 3);
listaPeso.add((int) 2);
listaPeso.add((int) 9);
listaPeso.add((int) 8);
listaPeso.add((int) 7);
listaPeso.add((int) 6);
listaPeso.add((int) 5);
listaPeso.add((int) 4);
listaPeso.add((int) 3);
listaPeso.add((int) 2);
// Para cada item na lista multiplicamos seu valor pelo seu peso
for (int i = 0 ; i < listaAleatoria.size() ; i++) {
listaNumMultiplicados.add( listaAleatoria.get(i) * listaPeso.get(i) );
}
// Agora somamos todos os itens que foram multiplicados
for (int i = 0 ; i < listaNumMultiplicados.size() ; i++) {
totalSomatoria += (Integer)listaNumMultiplicados.get(i);
}
restoDivisao = (totalSomatoria % 11);
if (restoDivisao < 2) {
primeiroDigito = 0;
} else {
primeiroDigito = 11 - restoDivisao;
}
//-----------------------Segundo Digito ---------------------------
totalSomatoria = 0;
restoDivisao = 0;
listaAleatoria.add(primeiroDigito);
listaPeso.add(0, (int) 6);
for (int i = 0 ; i < listaAleatoria.size() ; i++) {
listaNumMultiplicados2.add( listaAleatoria.get(i) * listaPeso.get(i) );
}
for (int i = 0 ; i < listaNumMultiplicados2.size() ; i++) {
totalSomatoria += (Integer)listaNumMultiplicados2.get(i);
}
restoDivisao = (totalSomatoria % 11);
if (restoDivisao < 2) {
segundoDigito = 0;
} else {
segundoDigito = 11 - restoDivisao;
}
listaAleatoria.add(segundoDigito);
String cnpj="";
for (int i = 0 ; i < listaAleatoria.size() ; i++) {
cnpj += listaAleatoria.get(i);
}
return cnpj;</stringProp>
<stringProp name="BeanShellSampler.filename"></stringProp>
<stringProp name="BeanShellSampler.parameters"></stringProp>
<boolProp name="BeanShellSampler.resetInterpreter">true</boolProp>
</BeanShellSampler>
<hashTree>
<RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Regular Expression Extractor" enabled="true">
<stringProp name="RegexExtractor.useHeaders">false</stringProp>
<stringProp name="RegexExtractor.refname">cnpj</stringProp>
<stringProp name="RegexExtractor.regex">(.*)</stringProp>
<stringProp name="RegexExtractor.template">$1$</stringProp>
<stringProp name="RegexExtractor.default">NOT FOUND</stringProp>
<stringProp name="RegexExtractor.match_number">1</stringProp>
</RegexExtractor>
<hashTree/>
</hashTree>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<objProp>
<name></name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>false</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>false</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>true</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<hostname>true</hostname>
<threadCounts>true</threadCounts>
<sampleCount>true</sampleCount>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>