Search in sources :

Example 21 with PatternMatcher

use of org.apache.oro.text.regex.PatternMatcher in project jmeter by apache.

the class ApdexPerTransactionTest method testSampleNameMatching.

@Test
public void testSampleNameMatching() {
    /* matching pairs :
         * sample(\d+) sample2
         * sample(\d+) sample12
         * scenar01-12 scenar01-12
         * samples12 samples12
         * */
    String[] sampleNames = { "sample2", "sample12", "scenar01-12", "samples12" };
    Map<String, Long[]> apdex = ReportGeneratorConfiguration.getApdexPerTransactionParts(apdexString);
    for (String sampleName : sampleNames) {
        boolean hasMatched = false;
        for (Map.Entry<String, Long[]> entry : apdex.entrySet()) {
            org.apache.oro.text.regex.Pattern regex = JMeterUtils.getPatternCache().getPattern(entry.getKey());
            PatternMatcher matcher = JMeterUtils.getMatcher();
            if (matcher.matches(sampleName, regex)) {
                hasMatched = true;
            }
        }
        assertTrue(hasMatched);
    }
}
Also used : Map(java.util.Map) PatternMatcher(org.apache.oro.text.regex.PatternMatcher) Test(org.junit.jupiter.api.Test)

Aggregations

PatternMatcher (org.apache.oro.text.regex.PatternMatcher)21 Perl5Matcher (org.apache.oro.text.regex.Perl5Matcher)15 Pattern (org.apache.oro.text.regex.Pattern)9 MalformedPatternException (org.apache.oro.text.regex.MalformedPatternException)7 ArrayList (java.util.ArrayList)6 MatchResult (org.apache.oro.text.regex.MatchResult)5 PatternCompiler (org.apache.oro.text.regex.PatternCompiler)5 Perl5Compiler (org.apache.oro.text.regex.Perl5Compiler)5 Map (java.util.Map)3 PatternMatcherInput (org.apache.oro.text.regex.PatternMatcherInput)3 IOException (java.io.IOException)2 NoSuchElementException (java.util.NoSuchElementException)2 Perl5Substitution (org.apache.oro.text.regex.Perl5Substitution)2 PluginException (org.apache.wiki.api.exceptions.PluginException)2 BaseOtterTest (com.alibaba.otter.shared.common.BaseOtterTest)1 ConfigException (com.alibaba.otter.shared.common.model.config.ConfigException)1 ModeValue (com.alibaba.otter.shared.common.model.config.data.DataMedia.ModeValue)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 ResourceBundle (java.util.ResourceBundle)1