Skip to content

Commit

Permalink
Fixed variable name declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
rollno748 committed Apr 23, 2022
1 parent 2371c67 commit 2a0756c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/main/java/com/di/jmeter/config/ExtendedCsvDataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public void iterationStart(LoopIterationEvent iterEvent) {
String[] lineValues = {};
if (variables == null) {
ExtFileServer.setReadPos(0);
initVars(fServer, context, delimiter);
try {
initVars(fServer, context, delimiter);
} catch (IOException e) {
e.printStackTrace();
}
}

JMeterVariables jMeterVariables = context.getVariables();
Expand Down Expand Up @@ -148,15 +152,10 @@ public void iterationStart(LoopIterationEvent iterEvent) {
}
}

private void initBlockFeatures(String filename, JMeterContext context, ExtFileServer fServer, boolean autoAllocate, String blockSize) throws IOException{
private void initBlockFeatures(String filename, JMeterContext context, ExtFileServer fServer, boolean autoAllocate, String blockSize) {
int blockSizeInt;
String threadName = context.getThread().getThreadName();

if(fServer.getListSize() < 1){
fServer.reserveFile(filename, getFileEncoding(), alias, ignoreFirstLine);
fServer.loadCsv(filename, ignoreFirstLine);
}

if(autoAllocate){
blockSizeInt = ExtFileServer.getListSize() / JMeterContextService.getTotalThreads();
}else{
Expand All @@ -176,7 +175,7 @@ private void initBlockFeatures(String filename, JMeterContext context, ExtFileSe
}
}

private void initVars(ExtFileServer server, final JMeterContext context, String delim) {
private void initVars(ExtFileServer server, final JMeterContext context, String delim) throws IOException {
String fileName = getFilename().trim();
final String names = getVariableNames();
setAlias(context, fileName);
Expand All @@ -189,20 +188,22 @@ private void initVars(ExtFileServer server, final JMeterContext context, String
try {
variables = CSVSaveService.csvSplitString(header, delim.charAt(0));
firstLineIsNames = true;ignoreFirstLine = true;
trimVarNames(variables);
} catch (IOException e) {
throw new IllegalArgumentException("Could not split CSV header line from file:" + fileName, e);
}
} else {
}

if(getSelectRow().equalsIgnoreCase("selectRow.sequential")){
server.reserveFile(fileName, getFileEncoding(), alias, ignoreFirstLine);
variables = JOrphanUtils.split(names, ",");
}
trimVarNames(variables);
if(getSelectRow().equalsIgnoreCase("selectRow.unique")){
try {
initBlockFeatures(alias, context, server, isAutoAllocate(), getBlockSize());
} catch (IOException e) {
e.printStackTrace();
}
trimVarNames(variables);
}else if(getSelectRow().equalsIgnoreCase("selectRow.unique") || getSelectRow().equalsIgnoreCase("selectRow.random")){
server.reserveFile(filename, getFileEncoding(), alias, ignoreFirstLine);
server.loadCsv(filename, ignoreFirstLine);
initBlockFeatures(alias, context, server, isAutoAllocate(), getBlockSize());
variables = JOrphanUtils.split(names, ",");
trimVarNames(variables);
}
}

Expand Down Expand Up @@ -255,7 +256,6 @@ public String getVariableNames() {
}

public void setVariableNames(String variableNames) {
// this.variableNames = variableNames;
if(!ignoreFirstLine){
this.variableNames = variableNames;
}
Expand Down

0 comments on commit 2a0756c

Please sign in to comment.