Author: sebb
Date: Sat Feb 27 13:34:10 2016
New Revision: 1732642

URL: http://svn.apache.org/viewvc?rev=1732642&view=rev
Log:
Restore HC3 Cookie Handler tests
Copied from 
https://svn.apache.org/repos/asf/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java@1649126

Added:
    
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java
      - copied, changed from r1649126, 
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java

Copied: 
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java
 (from r1649126, 
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java)
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java?p2=jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java&p1=jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java&r1=1649126&r2=1732642&rev=1732642&view=diff
==============================================================================
--- 
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
 (original)
+++ 
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java
 Sat Feb 27 13:34:10 2016
@@ -18,6 +18,12 @@
 
 package org.apache.jmeter.protocol.http.control;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.net.URL;
 
 import org.apache.commons.httpclient.cookie.CookiePolicy;
@@ -27,25 +33,29 @@ import org.apache.jmeter.protocol.http.s
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
 import org.apache.jmeter.threads.JMeterContext;
 import org.apache.jmeter.threads.JMeterContextService;
+import org.junit.Before;
+import org.junit.Test;
 
-public class TestCookieManager extends JMeterTestCase {
+/**
+ * HC3CookieHandler tests
+ */
+public class TestHC3CookieManager extends JMeterTestCase {
         private CookieManager man = null;
 
-        public TestCookieManager(String name) {
-            super(name);
-        }
-
         private JMeterContext jmctx = null;
 
-        @Override
+        @Before
         public void setUp() throws Exception {
-            super.setUp();
             jmctx = JMeterContextService.getContext();
-            man = new CookieManager();
+            man = new CookieManager(); // defaults to HC3/compatibility
+            // but make double-sure that this is the case
+            man.setImplementation(HC3CookieHandler.class.getName());
+            man.setCookiePolicy(HC3CookieHandler.DEFAULT_POLICY_NAME);
             man.setThreadContext(jmctx);
             man.testStarted();// This is needed in order to set up the cookie 
policy
         }
 
+        @Test
         public void testRemoveCookie() throws Exception {
             man.setThreadContext(jmctx);
             Cookie c = new Cookie("id", "me", "127.0.0.1", "/", false, 0);
@@ -63,6 +73,7 @@ public class TestCookieManager extends J
             assertEquals(1, man.getCookieCount());
         }
 
+        @Test
         public void testSendCookie() throws Exception {
             man.add(new Cookie("id", "value", "jakarta.apache.org", "/", 
false, 9999999999L));
             HTTPSamplerBase sampler = new HTTPNullSampler();
@@ -72,6 +83,7 @@ public class TestCookieManager extends J
             assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
         }
 
+        @Test
         public void testSendCookie2() throws Exception {
             man.add(new Cookie("id", "value", ".apache.org", "/", false, 
9999999999L));
             HTTPSamplerBase sampler = new HTTPNullSampler();
@@ -87,12 +99,14 @@ public class TestCookieManager extends J
          *
          * @throws Exception if something fails
          */
+        @Test
         public void testDomainHandling() throws Exception {
             URL url = new URL("http://jakarta.apache.org/";);
             man.addCookieFromHeader("test=1;domain=.jakarta.apache.org", url);
             assertNotNull(man.getCookieHeaderForURL(url));
         }
 
+        @Test
         public void testCrossDomainHandling() throws Exception {
             URL url = new URL("http://jakarta.apache.org/";);
             assertEquals(0,man.getCookieCount()); // starts empty
@@ -108,6 +122,7 @@ public class TestCookieManager extends J
          *
          * @throws Exception if something fails
          */
+        @Test
         public void testSimilarHostNames() throws Exception {
             URL url = new URL("http://ache.org/";);
             man.addCookieFromHeader("test=1", url);
@@ -116,6 +131,7 @@ public class TestCookieManager extends J
         }
 
         // Test session cookie is returned
+        @Test
         public void testSessionCookie() throws Exception {
             URL url = new URL("http://a.b.c/";);
             man.addCookieFromHeader("test=1", url);
@@ -125,6 +141,7 @@ public class TestCookieManager extends J
         }
 
         // Bug 2063
+        @Test
         public void testCookieWithEquals() throws Exception {
             URL url = new URL("http://a.b.c/";);
             man.addCookieFromHeader("NSCP_USER_LOGIN1_NEW=SHA=xxxxx", url);
@@ -137,6 +154,7 @@ public class TestCookieManager extends J
         }
 
         // Test Old cookie is not returned
+        @Test
         public void testOldCookie() throws Exception {
             URL url = new URL("http://a.b.c/";);
             man.addCookieFromHeader("test=1; expires=Mon, 01-Jan-1990 00:00:00 
GMT", url);
@@ -145,6 +163,7 @@ public class TestCookieManager extends J
         }
 
         // Test New cookie is returned
+        @Test
         public void testNewCookie() throws Exception {
             URL url = new URL("http://a.b.c/";);
             man.addCookieFromHeader("test=1; expires=Mon, 01-Jan-2990 00:00:00 
GMT", url);
@@ -155,6 +174,7 @@ public class TestCookieManager extends J
         }
 
         // Test multi-cookie header handling
+        @Test
         public void testCookies1() throws Exception {
             URL url = new URL("http://a.b.c.d/testCookies1";);
             man.addCookieFromHeader("test1=1; comment=\"how,now\", test2=2; 
version=1", url);
@@ -164,6 +184,7 @@ public class TestCookieManager extends J
             assertEquals("test1=1; test2=2", s);
         }
         
+        @Test
         public void testCookies2() throws Exception {
             URL url = new URL("https://a.b.c.d/testCookies2";);
             man.addCookieFromHeader("test1=1;secure, test2=2;secure", url);
@@ -174,6 +195,7 @@ public class TestCookieManager extends J
         }
 
         // Test duplicate cookie handling
+        @Test
         public void testDuplicateCookie() throws Exception {
             URL url = new URL("http://a.b.c/";);
             man.addCookieFromHeader("test=1", url);
@@ -185,6 +207,8 @@ public class TestCookieManager extends J
             assertNotNull(s);
             assertEquals("test=2", s);
         }
+
+        @Test
         public void testDuplicateCookie2() throws Exception {
             URL url = new URL("http://a.b.c/";);
             man.addCookieFromHeader("test=1", url);
@@ -206,6 +230,7 @@ public class TestCookieManager extends J
          *
          * @throws Exception if something fails
          */
+        @Test
         public void testMissingPath0() throws Exception {
             URL url = new URL("http://d.e.f/goo.html";);
             man.addCookieFromHeader("test=moo", url);
@@ -219,6 +244,7 @@ public class TestCookieManager extends J
          *
          * @throws Exception if something fails
          */
+        @Test
         public void testMissingPath1() throws Exception {
             URL url = new URL("http://d.e.f/moo.html";);
             man.addCookieFromHeader("test=moo", url);
@@ -231,6 +257,7 @@ public class TestCookieManager extends J
          *
          * @throws Exception if something fails
          */
+        @Test
         public void testRootPath0() throws Exception {
             URL url = new URL("http://d.e.f/goo.html";);
             man.addCookieFromHeader("test=moo;path=/", url);
@@ -243,6 +270,7 @@ public class TestCookieManager extends J
          *
          * @throws Exception if something fails
          */
+        @Test
         public void testRootPath1() throws Exception {
             URL url = new URL("http://d.e.f/moo.html";);
             man.addCookieFromHeader("test=moo;path=/", url);
@@ -252,6 +280,7 @@ public class TestCookieManager extends J
         }
         
         // Test cookie matching
+        @Test
         public void testCookieMatching() throws Exception {
             URL url = new URL("http://a.b.c:8080/TopDir/fred.jsp";);
             man.addCookieFromHeader("ID=abcd; Path=/TopDir", url);
@@ -276,6 +305,7 @@ public class TestCookieManager extends J
             assertNull(s);
         }
 
+        @Test
         public void testCookieOrdering1() throws Exception {
             URL url = new URL("http://order.now/sub1/moo.html";);
             man.addCookieFromHeader("test1=moo1;path=/", url);
@@ -287,6 +317,7 @@ public class TestCookieManager extends J
             assertEquals("test2=moo2; test1=moo1; test2=moo3", s);
         }
 
+        @Test
         public void testCookieOrdering2() throws Exception {
             URL url = new URL("http://order.now/sub1/moo.html";);
             man.addCookieFromHeader("test1=moo1;", url);
@@ -310,6 +341,7 @@ public class TestCookieManager extends J
             assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
         }
         
+        @Test
         public void testCookiePolicy2109() throws Exception {
             man.setCookiePolicy(CookiePolicy.RFC_2109);
             man.testStarted(); // ensure policy is picked up
@@ -336,6 +368,7 @@ public class TestCookieManager extends J
             assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; 
test2=moo3; $Path=/", s);
         }
 
+        @Test
         public void testCookiePolicyNetscape() throws Exception {
             man.setCookiePolicy(CookiePolicy.NETSCAPE);
             man.testStarted(); // ensure policy is picked up
@@ -363,6 +396,7 @@ public class TestCookieManager extends J
             assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
         }
 
+        @Test
         public void testCookiePolicyIgnore() throws Exception {
             man.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
             man.testStarted(); // ensure policy is picked up
@@ -391,6 +425,7 @@ public class TestCookieManager extends J
             assertEquals(0,c.length); // Cookies again ignored
         }
 
+        @Test
         public void testLoad() throws Exception{
             assertEquals(0,man.getCookieCount());
             man.addFile(findTestPath("testfiles/cookies.txt"));


Reply via email to