-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from Blazemeter/RELEASE_v2.6
Release v2.6
- Loading branch information
Showing
30 changed files
with
495 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 6 additions & 9 deletions
15
...zemeter/jmeter/correlation/core/automatic/extraction/location/BodyExtractionStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
package com.blazemeter.jmeter.correlation.core.automatic.extraction.location; | ||
|
||
import com.blazemeter.jmeter.correlation.core.automatic.ExtractorGenerator; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.apache.jmeter.samplers.SampleResult; | ||
|
||
public class BodyExtractionStrategy implements ExtractionStrategy { | ||
|
||
@Override | ||
public LocationType identifyLocationInResponse(SampleResult response, String value) { | ||
public Pair<LocationType, String> identifyLocationInResponse(SampleResult response, | ||
String value) { | ||
String bodyResponse = | ||
response.getDataType().equals("bin") ? "" : response.getResponseDataAsString(); | ||
boolean isInBody = bodyResponse.contains(value); | ||
String encodedValue = ExtractorGenerator.encodeValue(value); | ||
boolean isInBodyEncoded = !isInBody && bodyResponse.contains(encodedValue); | ||
if (isInBody || isInBodyEncoded) { | ||
return LocationType.BODY; | ||
} | ||
return LocationType.UNKNOWN; | ||
return ExtractionStrategy.getLocationAndValue(bodyResponse, value, | ||
LocationType.BODY); | ||
} | ||
} |
17 changes: 6 additions & 11 deletions
17
...meter/jmeter/correlation/core/automatic/extraction/location/CookieExtractionStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
.../blazemeter/jmeter/correlation/core/automatic/extraction/location/ExtractionStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
package com.blazemeter.jmeter.correlation.core.automatic.extraction.location; | ||
|
||
import com.blazemeter.jmeter.correlation.core.automatic.replacement.method.ReplacementString; | ||
import java.util.Arrays; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.apache.jmeter.samplers.SampleResult; | ||
|
||
public interface ExtractionStrategy { | ||
LocationType identifyLocationInResponse(SampleResult response, String value); | ||
|
||
Pair<LocationType, String> identifyLocationInResponse(SampleResult response, String value); | ||
|
||
static Pair<LocationType, String> getLocationAndValue(String content, String value, | ||
LocationType location) { | ||
// Lambda need a final mutable variable, we use the string array for that | ||
final String[] appliedValue = new String[1]; | ||
return Arrays.stream(ReplacementString.values()) | ||
.filter(r -> { | ||
appliedValue[0] = r.applyFunction(value); | ||
return content.contains(appliedValue[0]); | ||
}).findFirst() | ||
.map(string -> Pair.of(location, appliedValue[0])) | ||
.orElseGet(() -> Pair.of(LocationType.UNKNOWN, "")); | ||
} | ||
} |
16 changes: 6 additions & 10 deletions
16
...meter/jmeter/correlation/core/automatic/extraction/location/HeaderExtractionStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...om/blazemeter/jmeter/correlation/core/automatic/replacement/method/ReplacementString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.blazemeter.jmeter.correlation.core.automatic.replacement.method; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLDecoder; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.function.Function; | ||
|
||
public enum ReplacementString { | ||
NONE("", s -> s), | ||
URL_DECODE("__urldecode", s -> { | ||
try { | ||
return URLDecoder.decode(s, StandardCharsets.UTF_8.name()); | ||
} catch (UnsupportedEncodingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
}), | ||
URL_ENCODE("__urlencode", s -> { | ||
try { | ||
return URLEncoder.encode(s, StandardCharsets.UTF_8.name()); | ||
} catch (UnsupportedEncodingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
}); | ||
|
||
private final String replacementString; | ||
private final Function<String, String> replacementFunction; | ||
|
||
ReplacementString(String replacementString, Function<String, String> replacementFunction) { | ||
this.replacementString = replacementString; | ||
this.replacementFunction = replacementFunction; | ||
} | ||
|
||
public String getExpression(String refName) { | ||
if (replacementString.isEmpty()) { | ||
return ""; | ||
} else { | ||
return String.format("${%s(${%s})}", this.replacementString, refName); | ||
} | ||
} | ||
|
||
public String applyFunction(String value) { | ||
return replacementFunction.apply(value); | ||
} | ||
} |
Oops, something went wrong.