You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/03/26 19:13:21 UTC

svn commit: r1788769 - /jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java

Author: pmouawad
Date: Sun Mar 26 19:13:21 2017
New Revision: 1788769

URL: http://svn.apache.org/viewvc?rev=1788769&view=rev
Log:
Add Test for parsing errors

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java?rev=1788769&r1=1788768&r2=1788769&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java Sun Mar 26 19:13:21 2017
@@ -31,7 +31,14 @@ import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 
 public class TestCssParser extends JMeterTestCase {
-
+    
+    private static final String CSS_IN_ERROR = "@-webkit-keyframes \"introjspulse\"{"
+            + "0%{-webkit-transform:scale(0);opacity:.0}"
+            + "25%{-webkit-transform:scale(0);opacity:.1}"
+            + "50%{-webkit-transform:scale(0.1);opacity:.3}"
+            + "75%{-webkit-transform:scale(0.5);opacity:.5}"
+            + "100%{-webkit-transform:scale(1);opacity:.0}}";
+    
     private final CssParser parser = new CssParser();
 
     @Test
@@ -47,6 +54,11 @@ public class TestCssParser extends JMete
         result = extractUrls("@import url(http://example.com/abc.css);");
         assertThat(result.isEmpty(), CoreMatchers.is(false));
     }
+    
+    @Test(expected=LinkExtractorParseException.class)
+    public void testGetEmbeddedResourceURLs() throws Exception {
+        extractUrls(CSS_IN_ERROR);
+    }
 
     @Test
     public void testIsReusable() {



Re: svn commit: r1788769 - /jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 26.03.2017 21:13, schrieb pmouawad@apache.org:
> Author: pmouawad
> Date: Sun Mar 26 19:13:21 2017
> New Revision: 1788769
> 
> URL: http://svn.apache.org/viewvc?rev=1788769&view=rev
> Log:
> Add Test for parsing errors
> 
> Modified:
> 
> jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java
> 
> Modified:
> jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java?rev=1788769&r1=1788768&r2=1788769&view=diff
> ==============================================================================
> ---
> jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java
> (original)
> +++
> jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java
> Sun Mar 26 19:13:21 2017
> @@ -31,7 +31,14 @@ import org.hamcrest.CoreMatchers;
>  import org.junit.Test;
> 
>  public class TestCssParser extends JMeterTestCase {
> -
> +
> +    private static final String CSS_IN_ERROR = "@-webkit-keyframes

Would CSS_WITH_ERRORS be a better name?

> \"introjspulse\"{"
> +            + "0%{-webkit-transform:scale(0);opacity:.0}"
> +            + "25%{-webkit-transform:scale(0);opacity:.1}"
> +            + "50%{-webkit-transform:scale(0.1);opacity:.3}"
> +            + "75%{-webkit-transform:scale(0.5);opacity:.5}"
> +            + "100%{-webkit-transform:scale(1);opacity:.0}}";
> +
>      private final CssParser parser = new CssParser();
> 
>      @Test
> @@ -47,6 +54,11 @@ public class TestCssParser extends JMete
>          result = extractUrls("@import 
> url(http://example.com/abc.css);");
>          assertThat(result.isEmpty(), CoreMatchers.is(false));
>      }
> +
> +    @Test(expected=LinkExtractorParseException.class)
> +    public void testGetEmbeddedResourceURLs() throws Exception {

You could probably rename the test to indicate, that you are handling 
broken css data. "testExtractUrlsFromBrokenData" or 
"testExtractUrlsWithInvalidData"?

Regards,
  Felix

> +        extractUrls(CSS_IN_ERROR);
> +    }
> 
>      @Test
>      public void testIsReusable() {