Examples of Perl5Matcher


Examples of org.apache.oro.text.regex.Perl5Matcher

        }
        log.debug("End of Thread");
    }

    private static String getRequestHeaderValue(String requestHeaders, String headerName) {
        Perl5Matcher localMatcher = JMeterUtils.getMatcher();
        // We use multi-line mask so can prefix the line with ^
        // also match \w+ to catch Transfer-Encoding: chunked
        // TODO: may need to be extended to allow for other header values with non-word contents
        String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$ $NON-NLS-2$
        Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
        if(localMatcher.contains(requestHeaders, pattern)) {
            // The value is in the first group, group 0 is the whole match
            return localMatcher.getMatch().group(1);
        }
        else {
            return null;
        }
    }
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

            return null;
        }
    }

    private static int getPositionOfBody(String stringToCheck) {
        Perl5Matcher localMatcher = JMeterUtils.getMatcher();
        // The headers and body are divided by a blank line (the \r is to allow for the CR before LF)
        String regularExpression = "^\\r$"; // $NON-NLS-1$
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);

        PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
        if(localMatcher.contains(input, pattern)) {
            MatchResult match = localMatcher.getMatch();
            return match.beginOffset(0);
        }
        // No divider was found
        return -1;
    }
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

            }
            res = container;

            // Get the URL matcher
            String re=getEmbeddedUrlRE();
            Perl5Matcher localMatcher = null;
            Pattern pattern = null;
            if (re.length()>0){
                try {
                    pattern = JMeterUtils.getPattern(re);
                    localMatcher = JMeterUtils.getMatcher();// don't fetch unless pattern compiles
                } catch (MalformedCachePatternException e) {
                    log.warn("Ignoring embedded URL match string: "+e.getMessage());
                }
            }
           
            // For concurrent get resources
            final List<Callable<HTTPSampleResult>> liste = new ArrayList<Callable<HTTPSampleResult>>();
           
            while (urls.hasNext()) {
                Object binURL = urls.next(); // See catch clause below
                try {
                    URL url = (URL) binURL;
                    if (url == null) {
                        log.warn("Null URL detected (should not happen)");
                    } else {
                        String urlstr = url.toString();
                        String urlStrEnc=encodeSpaces(urlstr);
                        if (!urlstr.equals(urlStrEnc)){// There were some spaces in the URL
                            try {
                                url = new URL(urlStrEnc);
                            } catch (MalformedURLException e) {
                                res.addSubResult(errorResult(new Exception(urlStrEnc + " is not a correct URI"), res));
                                res.setSuccessful(false);
                                continue;
                            }
                        }
                        // I don't think localMatcher can be null here, but check just in case
                        if (pattern != null && localMatcher != null && !localMatcher.matches(urlStrEnc, pattern)) {
                            continue; // we have a pattern and the URL does not match, so skip it
                        }
                       
                        if (isConcurrentDwn()) {
                            // if concurrent download emb. resources, add to a list for async gets later
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

    }

    protected String getIpAddress(String logLine) {
        Pattern incIp = JMeterUtils.getPatternCache().getPattern("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",
                Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK);
        Perl5Matcher matcher = JMeterUtils.getMatcher();
        matcher.contains(logLine, incIp);
        return matcher.getMatch().group(0);
    }
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

        if (required || StringUtils.isNotEmpty(testValue))
        {
            if (maskPattern != null)
            {
                /** perl5 matcher */
                Perl5Matcher patternMatcher = new Perl5Matcher();

                boolean patternMatch =
                        patternMatcher.matches(testValue, maskPattern);

                log.debug("Trying to match " + testValue
                        + " to pattern " + maskString);

                if (!patternMatch)
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

        // Adapt loggerPattern for oro
        String realLoggerPattern = StringUtils
                .replace(loggerPattern, "" + WILDCARD, "." + WILDCARD);

        Perl5Compiler compiler = new Perl5Compiler();
        Perl5Matcher matcher = new Perl5Matcher();
        Pattern compiled;
        try
        {
            compiled = compiler.compile(realLoggerPattern);
        }
        catch (MalformedPatternException e)
        {
            throw new ApplicationRuntimeException("Malformed Logger Pattern:" + realLoggerPattern);
        }
        return matcher.matches(loggerName, compiled);

    }
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

  /**
   * @see Regex#match(String)
   */
  public Match match(String input) {
    Perl5Matcher matcher = new Perl5Matcher();
    boolean matches = matcher.matches(input, pattern);

    String[] groups = null;
    if (matches) {
      MatchResult matchResult = matcher.getMatch();
      int groupCount = matchResult.groups();

      groups = new String[groupCount];
      for (int i = 0; i < groupCount; i++) {
        groups[i] = matchResult.group(i);
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

    }

    protected PatternMatcher getPatternMatcher()
    {
        if (_matcher == null)
            _matcher = new Perl5Matcher();

        return _matcher;
    }
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

        } catch (MalformedPatternException ex)
        {
            throw new ApplicationRuntimeException(ex);
        }

        _patternMatcher = new Perl5Matcher();

        _factory = new TemplateTokenFactory();
    }
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Matcher

            {"Host-From:envonly", ".*"}};

    public void init() {
        //No condition passed... just compile a bunch of regular expressions
        try {
            matcher = new Perl5Matcher();
            for (int i = 0; i < patterns.length; i++) {
                String pattern = (String)patterns[i][1];
                patterns[i][1] = new Perl5Compiler().compile(pattern);
            }
        } catch(MalformedPatternException mp) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.