View | Details | Raw Unified | Return to bug 59140
Collapse All | Expand All

(-)bin/jmeter.properties (-1 / +3 lines)
Lines 703-711 Link Here
703
#---------------------------------------------------------------------------
703
#---------------------------------------------------------------------------
704
704
705
# Space-separated list of parser groups
705
# Space-separated list of parser groups
706
HTTPResponse.parsers=htmlParser wmlParser
706
HTTPResponse.parsers=htmlParser cssParser wmlParser
707
# for each parser, there should be a parser.types and a parser.className property
707
# for each parser, there should be a parser.types and a parser.className property
708
708
709
cssParser.className=org.apache.jmeter.protocol.http.parser.CssParser
710
cssParser.types=text/css
709
#---------------------------------------------------------------------------
711
#---------------------------------------------------------------------------
710
# HTML Parser configuration
712
# HTML Parser configuration
711
#---------------------------------------------------------------------------
713
#---------------------------------------------------------------------------
(-)build.properties (+10 lines)
Lines 264-269 Link Here
264
mongo-java-driver.loc       = ${maven2.repo}/org/mongodb/mongo-java-driver/${mongo-java-driver.version}
264
mongo-java-driver.loc       = ${maven2.repo}/org/mongodb/mongo-java-driver/${mongo-java-driver.version}
265
mongo-java-driver.md5       = 90647a53231eb75715fda30759ff4ff7
265
mongo-java-driver.md5       = 90647a53231eb75715fda30759ff4ff7
266
266
267
ph-css.version              = 4.1.0
268
ph-css.jar                  = ph-css-${ph-css.version}.jar
269
ph-css.loc                  = ${maven2.repo}/com/helger/ph-css/${ph-css.version}
270
ph-css.md5                  = c8913e7877b389c08e85269587217914
271
272
ph-commons.version          = 6.2.4
273
ph-commons.jar              = ph-commons-${ph-commons.version}.jar
274
ph-commons.loc              = ${maven2.repo}/com/helger/ph-commons/${ph-commons.version}
275
ph-commons.md5              = 344fc45ad36dd7f8ddc98141afad0cfe
276
267
rsyntaxtextarea.version     = 2.5.8
277
rsyntaxtextarea.version     = 2.5.8
268
rsyntaxtextarea.jar         = rsyntaxtextarea-${rsyntaxtextarea.version}.jar
278
rsyntaxtextarea.jar         = rsyntaxtextarea-${rsyntaxtextarea.version}.jar
269
rsyntaxtextarea.loc         = ${maven2.repo}/com/fifesoft/rsyntaxtextarea/${rsyntaxtextarea.version}
279
rsyntaxtextarea.loc         = ${maven2.repo}/com/fifesoft/rsyntaxtextarea/${rsyntaxtextarea.version}
(-)build.xml (+6 lines)
Lines 401-406 Link Here
401
    <include name="${lib.dir}/${junit.jar}"/>
401
    <include name="${lib.dir}/${junit.jar}"/>
402
    <include name="${lib.dir}/${logkit.jar}"/>
402
    <include name="${lib.dir}/${logkit.jar}"/>
403
    <include name="${lib.dir}/${mongo-java-driver.jar}"/>
403
    <include name="${lib.dir}/${mongo-java-driver.jar}"/>
404
  	<include name="${lib.dir}/${ph-css.jar}"/>
405
  	<include name="${lib.dir}/${ph-commons.jar}"/>
404
    <include name="${lib.dir}/${rsyntaxtextarea.jar}"/>
406
    <include name="${lib.dir}/${rsyntaxtextarea.jar}"/>
405
    <include name="${lib.dir}/${serializer.jar}"/>
407
    <include name="${lib.dir}/${serializer.jar}"/>
406
    <include name="${lib.dir}/${slf4j-api.jar}"/>
408
    <include name="${lib.dir}/${slf4j-api.jar}"/>
Lines 475-480 Link Here
475
    <pathelement location="${lib.dir}/${junit.jar}"/>
477
    <pathelement location="${lib.dir}/${junit.jar}"/>
476
    <pathelement location="${lib.dir}/${logkit.jar}"/>
478
    <pathelement location="${lib.dir}/${logkit.jar}"/>
477
    <pathelement location="${lib.dir}/${mongo-java-driver.jar}"/>
479
    <pathelement location="${lib.dir}/${mongo-java-driver.jar}"/>
480
  	<pathelement location="${lib.dir}/${ph-css.jar}"/>
481
  	<pathelement location="${lib.dir}/${ph-commons.jar}"/>
478
    <pathelement location="${lib.dir}/${rsyntaxtextarea.jar}"/>
482
    <pathelement location="${lib.dir}/${rsyntaxtextarea.jar}"/>
479
    <pathelement location="${lib.dir}/${serializer.jar}"/>
483
    <pathelement location="${lib.dir}/${serializer.jar}"/>
480
    <pathelement location="${lib.dir}/${slf4j-api.jar}"/>
484
    <pathelement location="${lib.dir}/${slf4j-api.jar}"/>
Lines 2896-2901 Link Here
2896
        <process_jarfile jarname="junit"/>
2900
        <process_jarfile jarname="junit"/>
2897
        <process_jarfile jarname="logkit"/>
2901
        <process_jarfile jarname="logkit"/>
2898
        <process_jarfile jarname="mongo-java-driver"/>
2902
        <process_jarfile jarname="mongo-java-driver"/>
2903
    	<process_jarfile jarname="ph-css" />
2904
    	<process_jarfile jarname="ph-commons" />
2899
        <process_jarfile jarname="rsyntaxtextarea"/>
2905
        <process_jarfile jarname="rsyntaxtextarea"/>
2900
        <process_jarfile jarname="serializer"/>
2906
        <process_jarfile jarname="serializer"/>
2901
        <process_jarfile jarname="slf4j-api"/>
2907
        <process_jarfile jarname="slf4j-api"/>
(-)res/maven/ApacheJMeter_parent.pom (+12 lines)
Lines 93-98 Link Here
93
      <junit.version>4.12</junit.version>
93
      <junit.version>4.12</junit.version>
94
      <logkit.version>2.0</logkit.version>
94
      <logkit.version>2.0</logkit.version>
95
      <mongo-java-driver.version>2.11.3</mongo-java-driver.version>
95
      <mongo-java-driver.version>2.11.3</mongo-java-driver.version>
96
      <ph-css.version>4.1.0</ph-css.version>
97
      <ph-commons.version>6.2.4</ph-commons.version>
96
      <rsyntaxtextarea.version>2.5.8</rsyntaxtextarea.version>
98
      <rsyntaxtextarea.version>2.5.8</rsyntaxtextarea.version>
97
      <slf4j-api.version>1.7.13</slf4j-api.version>
99
      <slf4j-api.version>1.7.13</slf4j-api.version>
98
      <slf4j-nop.version>1.7.13</slf4j-nop.version>
100
      <slf4j-nop.version>1.7.13</slf4j-nop.version>
Lines 366-371 Link Here
366
        <version>${mongo-java-driver.version}</version>
368
        <version>${mongo-java-driver.version}</version>
367
      </dependency>
369
      </dependency>
368
      <dependency>
370
      <dependency>
371
        <groupId>com.helger</groupId>
372
        <artifactId>ph-css</artifactId>
373
        <version>${ph-css.version}</version>
374
      </dependency>
375
      <dependency>
376
        <groupId>com.helger</groupId>
377
        <artifactId>ph-commons</artifactId>
378
        <version>${ph-commons.version}</version>
379
      </dependency>
380
      <dependency>
369
        <groupId>com.fifesoft</groupId>
381
        <groupId>com.fifesoft</groupId>
370
        <artifactId>rsyntaxtextarea</artifactId>
382
        <artifactId>rsyntaxtextarea</artifactId>
371
        <version>${rsyntaxtextarea.version}</version>
383
        <version>${rsyntaxtextarea.version}</version>
(-)src/protocol/http/org/apache/jmeter/protocol/http/parser/CssParser.java (+90 lines)
Line 0 Link Here
1
/**
2
 * 
3
 */
4
package org.apache.jmeter.protocol.http.parser;
5
6
import java.net.URL;
7
import java.nio.charset.Charset;
8
import java.util.ArrayList;
9
import java.util.Iterator;
10
import java.util.List;
11
12
import org.apache.jorphan.logging.LoggingManager;
13
import org.apache.log.Logger;
14
15
import com.helger.css.ECSSVersion;
16
import com.helger.css.decl.CSSDeclaration;
17
import com.helger.css.decl.CSSExpressionMemberTermURI;
18
import com.helger.css.decl.CSSImportRule;
19
import com.helger.css.decl.CascadingStyleSheet;
20
import com.helger.css.decl.ICSSTopLevelRule;
21
import com.helger.css.decl.visit.CSSVisitor;
22
import com.helger.css.decl.visit.DefaultCSSUrlVisitor;
23
import com.helger.css.reader.CSSReader;
24
25
/**
26
 * @since 3.0
27
 */
28
public class CssParser implements LinkExtractorParser {
29
    private static final Logger LOG = LoggingManager.getLoggerForClass();
30
31
    /**
32
     * 
33
     */
34
    public CssParser() {
35
    }
36
37
    /**
38
     * 
39
     * @see
40
     * org.apache.jmeter.protocol.http.parser.LinkExtractorParser#getEmbeddedResourceURLs
41
     * (java.lang.String, byte[], java.net.URL,
42
     * org.apache.jmeter.protocol.http.parser.URLCollection, java.lang.String)
43
     */
44
    @Override
45
    public Iterator<URL> getEmbeddedResourceURLs(String userAgent, byte[] data,
46
            final URL baseUrl, String encoding) throws LinkExtractorParseException {
47
        try {
48
            String cssContent = new String(data, encoding);
49
            final CascadingStyleSheet aCSS = CSSReader.readFromString(
50
                    cssContent, 
51
                    Charset.forName(encoding),
52
                    ECSSVersion.CSS30);
53
            final List<URLString> list = new ArrayList<URLString>();
54
            final URLCollection urlCollection = new URLCollection(list);
55
            CSSVisitor.visitCSSUrl(aCSS, new DefaultCSSUrlVisitor() {
56
                @Override
57
                public void onImport(final CSSImportRule importRule) {
58
                    urlCollection.addURL(importRule.getLocationString(), 
59
                                baseUrl);
60
                }
61
                // Call for URLs outside of URLs
62
                @Override
63
                public void onUrlDeclaration(
64
                        final ICSSTopLevelRule aTopLevelRule,
65
                        final CSSDeclaration aDeclaration,
66
                        final CSSExpressionMemberTermURI aURITerm) {
67
                    urlCollection.addURL(aURITerm.getURIString(),
68
                            baseUrl);
69
                }
70
            });
71
            if(LOG.isDebugEnabled()) {
72
                StringBuilder builder = new StringBuilder();
73
                for (Iterator iterator = urlCollection.iterator(); iterator.hasNext();) {
74
                    URL urlString = (URL) iterator.next();
75
                    builder.append(urlString).append(",");
76
                }
77
                LOG.debug("Parsed:"+baseUrl+", got:"+builder.toString());
78
            }
79
            return urlCollection.iterator();
80
        } catch (Exception e) {
81
            throw new LinkExtractorParseException(e);
82
        }
83
    }
84
85
    @Override
86
    public boolean isReusable() {
87
        return true;
88
    }
89
90
}

Return to bug 59140