You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/02/04 20:55:52 UTC

svn commit: r618404 [2/4] - in /jakarta/jmeter/trunk: ./ src/protocol/http/org/apache/jmeter/protocol/http/control/ src/protocol/http/org/apache/jmeter/protocol/http/control/gui/ src/protocol/http/org/apache/jmeter/protocol/http/parser/ src/protocol/ht...

Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java Mon Feb  4 11:55:48 2008
@@ -1,109 +1,109 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.protocol.http.sampler;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.URLConnection;
-
-import org.apache.jmeter.protocol.http.util.HTTPArgument;
-import org.apache.jmeter.protocol.http.util.HTTPConstants;
-import org.apache.jmeter.testelement.property.PropertyIterator;
-
-/**
- * Class for setting the necessary headers for a PUT request, and sending the
- * body of the PUT.
- */
-public class PutWriter extends PostWriter {
-    /**
-     * Constructor for PutWriter.
-     */
-    public PutWriter() {
-        // Put request does not use multipart, so no need for boundary
-        super(null);
-    }
-    
-    public void setHeaders(URLConnection connection, HTTPSampler sampler) throws IOException {
-    	// Get the encoding to use for the request
-        String contentEncoding = sampler.getContentEncoding();
-        if(contentEncoding == null || contentEncoding.length() == 0) {
-            contentEncoding = ENCODING;
-        }
-        long contentLength = 0L;
-        boolean hasPutBody = false;
-
-        // Check if the header manager had a content type header
-        // This allows the user to specify his own content-type for a PUT request
-        String contentTypeHeader = connection.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE);
-        boolean hasContentTypeHeader = contentTypeHeader != null && contentTypeHeader.length() > 0; 
-
-        // If there are no arguments, we can send a file as the body of the request
-        if(sampler.getArguments() != null && sampler.getArguments().getArgumentCount() == 0 && sampler.getSendFileAsPostBody()) {
-            hasPutBody = true;
-            if(!hasContentTypeHeader) {
-                // Allow the mimetype of the file to control the content type
-                if(sampler.getMimetype() != null && sampler.getMimetype().length() > 0) {
-                    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, sampler.getMimetype());
-                }
-            }
-
-            // Create the content length we are going to write
-            File inputFile = new File(sampler.getFilename());
-            contentLength = inputFile.length();
-        }
-        else if(sampler.getSendParameterValuesAsPostBody()) {
-            hasPutBody = true;
-            // Allow the mimetype of the file to control the content type
-            // This is not obvious in GUI if you are not uploading any files,
-            // but just sending the content of nameless parameters
-            if(!hasContentTypeHeader && sampler.getMimetype() != null && sampler.getMimetype().length() > 0) {
-                connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, sampler.getMimetype());
-            }
-
-            // We create the post body content now, so we know the size
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
-            // Just append all the parameter values, and use that as the put body
-            StringBuffer postBodyBuffer = new StringBuffer();
-            PropertyIterator args = sampler.getArguments().iterator();
-            while (args.hasNext()) {
-                HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
-                postBodyBuffer.append(arg.getEncodedValue(contentEncoding));
-            }
-            String postBody = postBodyBuffer.toString();
-
-            // Query string should be encoded in UTF-8
-            bos.write(postBody.getBytes("UTF-8")); // $NON-NLS-1$
-            bos.flush();
-            bos.close();
-
-            // Keep the content, will be sent later
-            formDataUrlEncoded = bos.toByteArray();
-            contentLength = bos.toByteArray().length;
-        }
-        if(hasPutBody) {
-            // Set the content length
-            connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_LENGTH, Long.toString(contentLength));
-
-            // Make the connection ready for sending post data
-            connection.setDoOutput(true);
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.protocol.http.sampler;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.net.URLConnection;
+
+import org.apache.jmeter.protocol.http.util.HTTPArgument;
+import org.apache.jmeter.protocol.http.util.HTTPConstants;
+import org.apache.jmeter.testelement.property.PropertyIterator;
+
+/**
+ * Class for setting the necessary headers for a PUT request, and sending the
+ * body of the PUT.
+ */
+public class PutWriter extends PostWriter {
+    /**
+     * Constructor for PutWriter.
+     */
+    public PutWriter() {
+        // Put request does not use multipart, so no need for boundary
+        super(null);
+    }
+    
+    public void setHeaders(URLConnection connection, HTTPSampler sampler) throws IOException {
+    	// Get the encoding to use for the request
+        String contentEncoding = sampler.getContentEncoding();
+        if(contentEncoding == null || contentEncoding.length() == 0) {
+            contentEncoding = ENCODING;
+        }
+        long contentLength = 0L;
+        boolean hasPutBody = false;
+
+        // Check if the header manager had a content type header
+        // This allows the user to specify his own content-type for a PUT request
+        String contentTypeHeader = connection.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE);
+        boolean hasContentTypeHeader = contentTypeHeader != null && contentTypeHeader.length() > 0; 
+
+        // If there are no arguments, we can send a file as the body of the request
+        if(sampler.getArguments() != null && sampler.getArguments().getArgumentCount() == 0 && sampler.getSendFileAsPostBody()) {
+            hasPutBody = true;
+            if(!hasContentTypeHeader) {
+                // Allow the mimetype of the file to control the content type
+                if(sampler.getMimetype() != null && sampler.getMimetype().length() > 0) {
+                    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, sampler.getMimetype());
+                }
+            }
+
+            // Create the content length we are going to write
+            File inputFile = new File(sampler.getFilename());
+            contentLength = inputFile.length();
+        }
+        else if(sampler.getSendParameterValuesAsPostBody()) {
+            hasPutBody = true;
+            // Allow the mimetype of the file to control the content type
+            // This is not obvious in GUI if you are not uploading any files,
+            // but just sending the content of nameless parameters
+            if(!hasContentTypeHeader && sampler.getMimetype() != null && sampler.getMimetype().length() > 0) {
+                connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, sampler.getMimetype());
+            }
+
+            // We create the post body content now, so we know the size
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+            // Just append all the parameter values, and use that as the put body
+            StringBuffer postBodyBuffer = new StringBuffer();
+            PropertyIterator args = sampler.getArguments().iterator();
+            while (args.hasNext()) {
+                HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
+                postBodyBuffer.append(arg.getEncodedValue(contentEncoding));
+            }
+            String postBody = postBodyBuffer.toString();
+
+            // Query string should be encoded in UTF-8
+            bos.write(postBody.getBytes("UTF-8")); // $NON-NLS-1$
+            bos.flush();
+            bos.close();
+
+            // Keep the content, will be sent later
+            formDataUrlEncoded = bos.toByteArray();
+            contentLength = bos.toByteArray().length;
+        }
+        if(hasPutBody) {
+            // Set the content length
+            connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_LENGTH, Long.toString(contentLength));
+
+            // Make the connection ready for sending post data
+            connection.setDoOutput(true);
+        }
+    }
+}

Propchange: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PutWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java Mon Feb  4 11:55:48 2008
@@ -1,81 +1,81 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.engine;
-
-import org.apache.jmeter.config.Argument;
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.control.GenericController;
-import org.apache.jmeter.reporters.ResultCollector;
-import org.apache.jmeter.testelement.TestPlan;
-import org.apache.jmeter.testelement.property.CollectionProperty;
-import org.apache.jmeter.testelement.property.JMeterProperty;
-import org.apache.jmeter.testelement.property.PropertyIterator;
-import org.apache.jorphan.collections.ListedHashTree;
-
-public class TestTreeCloner extends junit.framework.TestCase {
-		public TestTreeCloner(String name) {
-			super(name);
-		}
-
-		public void testCloning() throws Exception {
-			ListedHashTree original = new ListedHashTree();
-			GenericController controller = new GenericController();
-			controller.setName("controller");
-			Arguments args = new Arguments();
-			args.setName("args");
-			TestPlan plan = new TestPlan();
-			plan.addParameter("server", "jakarta");
-			original.add(controller, args);
-			original.add(plan);
-			ResultCollector listener = new ResultCollector();
-			listener.setName("Collector");
-			original.add(controller, listener);
-			TreeCloner cloner = new TreeCloner();
-			original.traverse(cloner);
-			ListedHashTree newTree = cloner.getClonedTree();
-			assertTrue(original != newTree);
-			assertEquals(original.size(), newTree.size());
-			assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
-			assertTrue(original.getArray()[0] != newTree.getArray()[0]);
-			assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree
-					.getArray()[0]).getName());
-			assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0])
-					.getArray()[1]);
-			TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
-			clonedTestPlan.setRunningVersion(true);
-			clonedTestPlan.recoverRunningVersion();
-			assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
-			assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
-			Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
-			PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
-			while (iter.hasNext()) {
-				JMeterProperty argProp = iter.next();
-				assertTrue(!argProp.isRunningVersion());
-				assertTrue(argProp.getObjectValue() instanceof Argument);
-				Argument arg = (Argument) argProp.getObjectValue();
-				arg.setValue("yahoo");
-				assertEquals("yahoo", arg.getValue());
-			}
-			vars = (Arguments) clonedTestPlan.getUserDefinedVariablesAsProperty().getObjectValue();
-			iter = vars.propertyIterator();
-			while (iter.hasNext()) {
-				assertTrue(iter.next().isRunningVersion());
-			}
-		}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.engine;
+
+import org.apache.jmeter.config.Argument;
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.control.GenericController;
+import org.apache.jmeter.reporters.ResultCollector;
+import org.apache.jmeter.testelement.TestPlan;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+import org.apache.jmeter.testelement.property.JMeterProperty;
+import org.apache.jmeter.testelement.property.PropertyIterator;
+import org.apache.jorphan.collections.ListedHashTree;
+
+public class TestTreeCloner extends junit.framework.TestCase {
+		public TestTreeCloner(String name) {
+			super(name);
+		}
+
+		public void testCloning() throws Exception {
+			ListedHashTree original = new ListedHashTree();
+			GenericController controller = new GenericController();
+			controller.setName("controller");
+			Arguments args = new Arguments();
+			args.setName("args");
+			TestPlan plan = new TestPlan();
+			plan.addParameter("server", "jakarta");
+			original.add(controller, args);
+			original.add(plan);
+			ResultCollector listener = new ResultCollector();
+			listener.setName("Collector");
+			original.add(controller, listener);
+			TreeCloner cloner = new TreeCloner();
+			original.traverse(cloner);
+			ListedHashTree newTree = cloner.getClonedTree();
+			assertTrue(original != newTree);
+			assertEquals(original.size(), newTree.size());
+			assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
+			assertTrue(original.getArray()[0] != newTree.getArray()[0]);
+			assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree
+					.getArray()[0]).getName());
+			assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0])
+					.getArray()[1]);
+			TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
+			clonedTestPlan.setRunningVersion(true);
+			clonedTestPlan.recoverRunningVersion();
+			assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
+			assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
+			Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
+			PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
+			while (iter.hasNext()) {
+				JMeterProperty argProp = iter.next();
+				assertTrue(!argProp.isRunningVersion());
+				assertTrue(argProp.getObjectValue() instanceof Argument);
+				Argument arg = (Argument) argProp.getObjectValue();
+				arg.setValue("yahoo");
+				assertEquals("yahoo", arg.getValue());
+			}
+			vars = (Arguments) clonedTestPlan.getUserDefinedVariablesAsProperty().getObjectValue();
+			iter = vars.propertyIterator();
+			while (iter.hasNext()) {
+				assertTrue(iter.next().isRunningVersion());
+			}
+		}
 }

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java Mon Feb  4 11:55:48 2008
@@ -1,96 +1,96 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.engine.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.jmeter.config.ConfigTestElement;
-import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.testelement.TestPlan;
-import org.apache.jmeter.testelement.property.CollectionProperty;
-import org.apache.jmeter.testelement.property.JMeterProperty;
-import org.apache.jmeter.testelement.property.StringProperty;
-import org.apache.jmeter.threads.JMeterContextService;
-import org.apache.jmeter.threads.JMeterVariables;
-
-/**
- * @author Michael Stover
- * @author <a href="mailto:jsalvata@apache.org">Jordi Salvat i Alabart</a>
- * @version $Revision: 325648 $ updated on $Date: 2005-08-18 21:38:49 +0100 (Thu, 18 Aug 2005) $
- */
-public class TestValueReplacer extends JMeterTestCase {
-		TestPlan variables;
-
-		public TestValueReplacer(String name) {
-			super(name);
-		}
-
-		public void setUp() {
-			variables = new TestPlan();
-			variables.addParameter("server", "jakarta.apache.org");
-			variables.addParameter("username", "jack");
-			// The following used to be jacks_password, but the Arguments class uses
-			// HashMap for which the order is not defined.
-			variables.addParameter("password", "his_password");
-			variables.addParameter("regex", ".*");
-			JMeterVariables vars = new JMeterVariables();
-			vars.put("server", "jakarta.apache.org");
-			JMeterContextService.getContext().setVariables(vars);
-			JMeterContextService.getContext().setSamplingStarted(true);
-		}
-
-		public void testReverseReplacement() throws Exception {
-			ValueReplacer replacer = new ValueReplacer(variables);
-			assertTrue(variables.getUserDefinedVariables().containsKey("server"));
-			assertTrue(replacer.containsKey("server"));
-			TestElement element = new TestPlan();
-			element.setProperty(new StringProperty("domain", "jakarta.apache.org"));
-			List args = new ArrayList();
-			args.add("username is jack");
-			args.add("his_password");
-			element.setProperty(new CollectionProperty("args", args));
-			replacer.reverseReplace(element);
-			assertEquals("${server}", element.getPropertyAsString("domain"));
-			args = (List) element.getProperty("args").getObjectValue();
-			assertEquals("username is ${username}", ((JMeterProperty) args.get(0)).getStringValue());
-			assertEquals("${password}", ((JMeterProperty) args.get(1)).getStringValue());
-		}
-
-		public void testReplace() throws Exception {
-			ValueReplacer replacer = new ValueReplacer();
-			replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
-			TestElement element = new ConfigTestElement();
-			element.setProperty(new StringProperty("domain", "${server}"));
-			replacer.replaceValues(element);
-			//log.debug("domain property = " + element.getProperty("domain"));
-			element.setRunningVersion(true);
-			assertEquals("jakarta.apache.org", element.getPropertyAsString("domain"));
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see junit.framework.TestCase#tearDown()
-		 */
-		protected void tearDown() throws Exception {
-			JMeterContextService.getContext().setSamplingStarted(false);
-		}
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.engine.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.testelement.TestPlan;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+import org.apache.jmeter.testelement.property.JMeterProperty;
+import org.apache.jmeter.testelement.property.StringProperty;
+import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterVariables;
+
+/**
+ * @author Michael Stover
+ * @author <a href="mailto:jsalvata@apache.org">Jordi Salvat i Alabart</a>
+ * @version $Revision: 325648 $ updated on $Date: 2005-08-18 21:38:49 +0100 (Thu, 18 Aug 2005) $
+ */
+public class TestValueReplacer extends JMeterTestCase {
+		TestPlan variables;
+
+		public TestValueReplacer(String name) {
+			super(name);
+		}
+
+		public void setUp() {
+			variables = new TestPlan();
+			variables.addParameter("server", "jakarta.apache.org");
+			variables.addParameter("username", "jack");
+			// The following used to be jacks_password, but the Arguments class uses
+			// HashMap for which the order is not defined.
+			variables.addParameter("password", "his_password");
+			variables.addParameter("regex", ".*");
+			JMeterVariables vars = new JMeterVariables();
+			vars.put("server", "jakarta.apache.org");
+			JMeterContextService.getContext().setVariables(vars);
+			JMeterContextService.getContext().setSamplingStarted(true);
+		}
+
+		public void testReverseReplacement() throws Exception {
+			ValueReplacer replacer = new ValueReplacer(variables);
+			assertTrue(variables.getUserDefinedVariables().containsKey("server"));
+			assertTrue(replacer.containsKey("server"));
+			TestElement element = new TestPlan();
+			element.setProperty(new StringProperty("domain", "jakarta.apache.org"));
+			List args = new ArrayList();
+			args.add("username is jack");
+			args.add("his_password");
+			element.setProperty(new CollectionProperty("args", args));
+			replacer.reverseReplace(element);
+			assertEquals("${server}", element.getPropertyAsString("domain"));
+			args = (List) element.getProperty("args").getObjectValue();
+			assertEquals("username is ${username}", ((JMeterProperty) args.get(0)).getStringValue());
+			assertEquals("${password}", ((JMeterProperty) args.get(1)).getStringValue());
+		}
+
+		public void testReplace() throws Exception {
+			ValueReplacer replacer = new ValueReplacer();
+			replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
+			TestElement element = new ConfigTestElement();
+			element.setProperty(new StringProperty("domain", "${server}"));
+			replacer.replaceValues(element);
+			//log.debug("domain property = " + element.getProperty("domain"));
+			element.setRunningVersion(true);
+			assertEquals("jakarta.apache.org", element.getPropertyAsString("domain"));
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see junit.framework.TestCase#tearDown()
+		 */
+		protected void tearDown() throws Exception {
+			JMeterContextService.getContext().setSamplingStarted(false);
+		}
+}

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java Mon Feb  4 11:55:48 2008
@@ -1,147 +1,147 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.functions;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.apache.jmeter.engine.util.CompoundVariable;
-import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.jmeter.threads.JMeterContext;
-import org.apache.jmeter.threads.JMeterContextService;
-import org.apache.jmeter.threads.JMeterVariables;
-
-public class TestRegexFunction extends JMeterTestCase {
-		RegexFunction variable;
-
-		SampleResult result;
-
-		Collection params;
-
-		private JMeterVariables vars;
-
-		private JMeterContext jmctx = null;
-
-		public TestRegexFunction(String name) {
-			super(name);
-		}
-
-		public void setUp() {
-			variable = new RegexFunction();
-			result = new SampleResult();
-			jmctx = JMeterContextService.getContext();
-			String data = "<company-xmlext-query-ret><row>" + "<value field=\"RetCode\">" + "LIS_OK</value><value"
-					+ " field=\"RetCodeExtension\"></value>" + "<value field=\"alias\"></value><value"
-					+ " field=\"positioncount\"></value>" + "<value field=\"invalidpincount\">0</value><value"
-					+ " field=\"pinposition1\">1</value><value" + " field=\"pinpositionvalue1\"></value><value"
-					+ " field=\"pinposition2\">5</value><value" + " field=\"pinpositionvalue2\"></value><value"
-					+ " field=\"pinposition3\">6</value><value" + " field=\"pinpositionvalue3\"></value>"
-					+ "</row></company-xmlext-query-ret>";
-			result.setResponseData(data.getBytes());
-			vars = new JMeterVariables();
-			jmctx.setVariables(vars);
-			jmctx.setPreviousResult(result);
-		}
-
-		public void testVariableExtraction() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("$2$"));
-			params.add(new CompoundVariable("2"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("5", match);
-		}
-
-		public void testVariableExtraction2() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("$1$"));
-			params.add(new CompoundVariable("3"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("pinposition3", match);
-		}
-
-		public void testVariableExtraction5() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("$1$"));
-			params.add(new CompoundVariable("ALL"));
-			params.add(new CompoundVariable("_"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("pinposition1_pinposition2_pinposition3", match);
-		}
-
-		public void testVariableExtraction6() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("$2$"));
-			params.add(new CompoundVariable("4"));
-			params.add(new CompoundVariable(""));
-			params.add(new CompoundVariable("default"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("default", match);
-		}
-
-		public void testComma() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value,? field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("$1$"));
-			params.add(new CompoundVariable("3"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("pinposition3", match);
-		}
-
-		public void testVariableExtraction3() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("_$1$"));
-			params.add(new CompoundVariable("2"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("_pinposition2", match);
-		}
-
-		public void testVariableExtraction4() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("$2$, "));
-			params.add(new CompoundVariable(".333"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("1, ", match);
-		}
-
-		public void testDefaultValue() throws Exception {
-			params = new LinkedList();
-			params.add(new CompoundVariable("<value,, field=\"(pinposition\\d+)\">(\\d+)</value>"));
-			params.add(new CompoundVariable("$2$, "));
-			params.add(new CompoundVariable(".333"));
-			params.add(new CompoundVariable(""));
-			params.add(new CompoundVariable("No Value Found"));
-			variable.setParameters(params);
-			String match = variable.execute(result, null);
-			assertEquals("No Value Found", match);
-		}
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.functions;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.apache.jmeter.engine.util.CompoundVariable;
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterVariables;
+
+public class TestRegexFunction extends JMeterTestCase {
+		RegexFunction variable;
+
+		SampleResult result;
+
+		Collection params;
+
+		private JMeterVariables vars;
+
+		private JMeterContext jmctx = null;
+
+		public TestRegexFunction(String name) {
+			super(name);
+		}
+
+		public void setUp() {
+			variable = new RegexFunction();
+			result = new SampleResult();
+			jmctx = JMeterContextService.getContext();
+			String data = "<company-xmlext-query-ret><row>" + "<value field=\"RetCode\">" + "LIS_OK</value><value"
+					+ " field=\"RetCodeExtension\"></value>" + "<value field=\"alias\"></value><value"
+					+ " field=\"positioncount\"></value>" + "<value field=\"invalidpincount\">0</value><value"
+					+ " field=\"pinposition1\">1</value><value" + " field=\"pinpositionvalue1\"></value><value"
+					+ " field=\"pinposition2\">5</value><value" + " field=\"pinpositionvalue2\"></value><value"
+					+ " field=\"pinposition3\">6</value><value" + " field=\"pinpositionvalue3\"></value>"
+					+ "</row></company-xmlext-query-ret>";
+			result.setResponseData(data.getBytes());
+			vars = new JMeterVariables();
+			jmctx.setVariables(vars);
+			jmctx.setPreviousResult(result);
+		}
+
+		public void testVariableExtraction() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("$2$"));
+			params.add(new CompoundVariable("2"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("5", match);
+		}
+
+		public void testVariableExtraction2() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("$1$"));
+			params.add(new CompoundVariable("3"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("pinposition3", match);
+		}
+
+		public void testVariableExtraction5() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("$1$"));
+			params.add(new CompoundVariable("ALL"));
+			params.add(new CompoundVariable("_"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("pinposition1_pinposition2_pinposition3", match);
+		}
+
+		public void testVariableExtraction6() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("$2$"));
+			params.add(new CompoundVariable("4"));
+			params.add(new CompoundVariable(""));
+			params.add(new CompoundVariable("default"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("default", match);
+		}
+
+		public void testComma() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value,? field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("$1$"));
+			params.add(new CompoundVariable("3"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("pinposition3", match);
+		}
+
+		public void testVariableExtraction3() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("_$1$"));
+			params.add(new CompoundVariable("2"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("_pinposition2", match);
+		}
+
+		public void testVariableExtraction4() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("$2$, "));
+			params.add(new CompoundVariable(".333"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("1, ", match);
+		}
+
+		public void testDefaultValue() throws Exception {
+			params = new LinkedList();
+			params.add(new CompoundVariable("<value,, field=\"(pinposition\\d+)\">(\\d+)</value>"));
+			params.add(new CompoundVariable("$2$, "));
+			params.add(new CompoundVariable(".333"));
+			params.add(new CompoundVariable(""));
+			params.add(new CompoundVariable("No Value Found"));
+			variable.setParameters(params);
+			String match = variable.execute(result, null);
+			assertEquals("No Value Found", match);
+		}
+}

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/functions/TestRegexFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java Mon Feb  4 11:55:48 2008
@@ -1,37 +1,37 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.gui.action;
-
-import junit.framework.TestCase;
-
-public class PackageTest extends TestCase {
-
-	public PackageTest(String arg0) {
-		super(arg0);
-	}
-
-	//TODO add tests for SaveGraphics
-	public void testSaveGraphics() throws Exception {
-	}
-	
-	//TODO add tests for ReportSaveGraphics
-	public void testReportSaveGraphics() throws Exception {
-	}
-	
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.gui.action;
+
+import junit.framework.TestCase;
+
+public class PackageTest extends TestCase {
+
+	public PackageTest(String arg0) {
+		super(arg0);
+	}
+
+	//TODO add tests for SaveGraphics
+	public void testSaveGraphics() throws Exception {
+	}
+	
+	//TODO add tests for ReportSaveGraphics
+	public void testReportSaveGraphics() throws Exception {
+	}
+	
+}

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/PackageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java Mon Feb  4 11:55:48 2008
@@ -1,49 +1,49 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.gui.action;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.gui.tree.JMeterTreeNode;
-import org.apache.jorphan.collections.HashTree;
-import org.apache.jorphan.collections.ListedHashTree;
-
-public class TestSave extends junit.framework.TestCase {
-		Save save;
-
-		public TestSave(String name) {
-			super(name);
-		}
-
-		public void setUp() {
-			save = new Save();
-		}
-
-		public void testTreeConversion() throws Exception {
-			HashTree tree = new ListedHashTree();
-			JMeterTreeNode root = new JMeterTreeNode(new Arguments(), null);
-			tree.add(root, root);
-			tree.getTree(root).add(root, root);
-			save.convertSubTree(tree);
-			assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
-			tree = tree.getTree(tree.getArray()[0]);
-			assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
-			assertEquals(tree.getTree(tree.getArray()[0]).getArray()[0].getClass().getName(), root.getTestElement()
-					.getClass().getName());
-		}
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.gui.action;
+
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.gui.tree.JMeterTreeNode;
+import org.apache.jorphan.collections.HashTree;
+import org.apache.jorphan.collections.ListedHashTree;
+
+public class TestSave extends junit.framework.TestCase {
+		Save save;
+
+		public TestSave(String name) {
+			super(name);
+		}
+
+		public void setUp() {
+			save = new Save();
+		}
+
+		public void testTreeConversion() throws Exception {
+			HashTree tree = new ListedHashTree();
+			JMeterTreeNode root = new JMeterTreeNode(new Arguments(), null);
+			tree.add(root, root);
+			tree.getTree(root).add(root, root);
+			save.convertSubTree(tree);
+			assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
+			tree = tree.getTree(tree.getArray()[0]);
+			assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
+			assertEquals(tree.getTree(tree.getArray()[0]).getArray()[0].getClass().getName(), root.getTestElement()
+					.getClass().getName());
+		}
+}

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestSave.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java Mon Feb  4 11:55:48 2008
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.gui.util;
-
-import org.apache.jmeter.junit.JMeterTestCase;
-
-public final class TestMenuFactory extends JMeterTestCase {
-
-		public TestMenuFactory() {
-			super();
-		}
-
-		public TestMenuFactory(String name) {
-			super(name);
-		}
-
-		private static void check(String s, int i) throws Exception {
-			assertFalse("The number of " + s + " should not be 0", 0 == i);
-		}
-
-		public void testMenu() throws Exception {
-			check("menumap", MenuFactory.menuMap_size());
-
-			check("assertions", MenuFactory.assertions_size());
-			check("configElements", MenuFactory.configElements_size());
-			check("controllers", MenuFactory.controllers_size());
-			check("listeners", MenuFactory.listeners_size());
-			check("nonTestElements", MenuFactory.nonTestElements_size());
-			check("postProcessors", MenuFactory.postProcessors_size());
-			check("preProcessors", MenuFactory.preProcessors_size());
-			check("samplers", MenuFactory.samplers_size());
-			check("timers", MenuFactory.timers_size());
-
-			check("elementstoskip", MenuFactory.elementsToSkip_size());
-
-		}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.gui.util;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+
+public final class TestMenuFactory extends JMeterTestCase {
+
+		public TestMenuFactory() {
+			super();
+		}
+
+		public TestMenuFactory(String name) {
+			super(name);
+		}
+
+		private static void check(String s, int i) throws Exception {
+			assertFalse("The number of " + s + " should not be 0", 0 == i);
+		}
+
+		public void testMenu() throws Exception {
+			check("menumap", MenuFactory.menuMap_size());
+
+			check("assertions", MenuFactory.assertions_size());
+			check("configElements", MenuFactory.configElements_size());
+			check("controllers", MenuFactory.controllers_size());
+			check("listeners", MenuFactory.listeners_size());
+			check("nonTestElements", MenuFactory.nonTestElements_size());
+			check("postProcessors", MenuFactory.postProcessors_size());
+			check("preProcessors", MenuFactory.preProcessors_size());
+			check("samplers", MenuFactory.samplers_size());
+			check("timers", MenuFactory.timers_size());
+
+			check("elementstoskip", MenuFactory.elementsToSkip_size());
+
+		}
 }

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java Mon Feb  4 11:55:48 2008
@@ -1,382 +1,382 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package org.apache.jmeter.protocol.http.control;
-
-import java.net.URL;
-
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-
-import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
-import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
-import org.apache.jmeter.threads.JMeterContext;
-import org.apache.jmeter.threads.JMeterContextService;
-
-public class TestCookieManager extends JMeterTestCase {
-        private CookieManager man = null;
-
-        public TestCookieManager(String name) {
-            super(name);
-        }
-
-        private JMeterContext jmctx = null;
-
-        public void setUp() throws Exception {
-            super.setUp();
-            jmctx = JMeterContextService.getContext();
-            man = new CookieManager();
-            man.setThreadContext(jmctx);
-        }
-
-        public void testRemoveCookie() throws Exception {
-            man.setThreadContext(jmctx);
-            Cookie c = new Cookie("id", "me", "127.0.0.1", "/", false, 0);
-            man.add(c);
-            assertEquals(1, man.getCookieCount());
-            // This should be ignored, as there is no value
-            Cookie d = new Cookie("id", "", "127.0.0.1", "/", false, 0);
-            man.add(d);
-            assertEquals(0, man.getCookieCount());
-            man.add(c);
-            man.add(c);
-            assertEquals(1, man.getCookieCount());
-            Cookie e = new Cookie("id", "me2", "127.0.0.1", "/", false, 0);
-            man.add(e);
-            assertEquals(1, man.getCookieCount());
-        }
-
-        public void testSendCookie() throws Exception {
-            man.add(new Cookie("id", "value", "jakarta.apache.org", "/", false, 9999999999L));
-            HTTPSamplerBase sampler = new HTTPNullSampler();
-            sampler.setDomain("jakarta.apache.org");
-            sampler.setPath("/index.html");
-            sampler.setMethod(HTTPSamplerBase.GET);
-            assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
-        }
-
-        public void testSendCookie2() throws Exception {
-            man.add(new Cookie("id", "value", ".apache.org", "/", false, 9999999999L));
-            HTTPSamplerBase sampler = new HTTPNullSampler();
-            sampler.setDomain("jakarta.apache.org");
-            sampler.setPath("/index.html");
-            sampler.setMethod(HTTPSamplerBase.GET);
-            assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
-        }
-
-        /**
-         * Test that the cookie domain field is actually handled as browsers do
-         * (i.e.: host X matches domain .X):
-         */
-        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 that we won't be tricked by similar host names (this was a past
-         * bug, although it never got reported in the bug database):
-         */
-        public void testSimilarHostNames() throws Exception {
-            URL url = new URL("http://ache.org/");
-            man.addCookieFromHeader("test=1", url);
-            url = new URL("http://jakarta.apache.org/");
-            assertNull(man.getCookieHeaderForURL(url));
-        }
-
-        // Test session cookie is returned
-        public void testSessionCookie() throws Exception {
-            URL url = new URL("http://a.b.c/");
-            man.addCookieFromHeader("test=1", url);
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test=1", s);
-        }
-
-        // Bug 2063
-        public void testCookieWithEquals() throws Exception {
-            URL url = new URL("http://a.b.c/");
-            man.addCookieFromHeader("NSCP_USER_LOGIN1_NEW=SHA=xxxxx", url);
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("NSCP_USER_LOGIN1_NEW=SHA=xxxxx", s);
-            Cookie c=man.get(0);
-            assertEquals("NSCP_USER_LOGIN1_NEW",c.getName());
-            assertEquals("SHA=xxxxx",c.getValue());
-        }
-
-        // Test Old cookie is not returned
-        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);
-            String s = man.getCookieHeaderForURL(url);
-            assertNull(s);
-        }
-
-        // Test New cookie is returned
-        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);
-            assertEquals(1,man.getCookieCount());
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test=1", s);
-        }
-
-        // Test multi-cookie header handling
-        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);
-            assertEquals(2,man.getCookieCount());
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test1=1; test2=2", s);
-        }
-        
-        public void testCookies2() throws Exception {
-            URL url = new URL("https://a.b.c.d/testCookies2");
-            man.addCookieFromHeader("test1=1;secure, test2=2;secure", url);
-            assertEquals(2,man.getCookieCount());
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test1=1; test2=2", s);
-        }
-
-        // Test duplicate cookie handling
-        public void testDuplicateCookie() throws Exception {
-            URL url = new URL("http://a.b.c/");
-            man.addCookieFromHeader("test=1", url);
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test=1", s);
-            man.addCookieFromHeader("test=2", url);
-            s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test=2", s);
-        }
-        public void testDuplicateCookie2() throws Exception {
-            URL url = new URL("http://a.b.c/");
-            man.addCookieFromHeader("test=1", url);
-            man.addCookieFromHeader("test2=a", url);
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test=1; test2=a", s); // Assumes some kind of list is used
-            man.addCookieFromHeader("test=2", url);
-            man.addCookieFromHeader("test3=b", url);
-            s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test2=a; test=2; test3=b", s);// Assumes some kind of list is use
-            // If not using a list that retains the order, then the asserts would need to change
-        }
-        
-         
- 		/** Tests missing cookie path for a trivial URL fetch from the domain 
- 		 *  Note that this fails prior to a fix for BUG 38256
- 		 */
- 		public void testMissingPath0() throws Exception {
- 			URL url = new URL("http://d.e.f/goo.html");
- 			man.addCookieFromHeader("test=moo", url);
- 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
- 			assertNotNull(s);
- 			assertEquals("test=moo", s);
- 		}
- 		
- 		/** Tests missing cookie path for a non-trivial URL fetch from the 
- 		 *  domain.  Note that this fails prior to a fix for BUG 38256
- 		 */
- 		public void testMissingPath1() throws Exception {
- 			URL url = new URL("http://d.e.f/moo.html");
- 			man.addCookieFromHeader("test=moo", url);
- 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
- 			assertNotNull(s);
- 			assertEquals("test=moo", s);
- 		}
- 		
- 		/** Tests explicit root path with a trivial URL fetch from the domain */
- 		public void testRootPath0() throws Exception {
- 			URL url = new URL("http://d.e.f/goo.html");
- 			man.addCookieFromHeader("test=moo;path=/", url);
- 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
- 			assertNotNull(s);
- 			assertEquals("test=moo", s);
- 		}
- 		
- 		/** Tests explicit root path with a non-trivial URL fetch from the domain */
- 		public void testRootPath1() throws Exception {
- 			URL url = new URL("http://d.e.f/moo.html");
- 			man.addCookieFromHeader("test=moo;path=/", url);
- 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
- 			assertNotNull(s);
- 			assertEquals("test=moo", s);
- 		}
-        
-        // Test cookie matching
-        public void testCookieMatching() throws Exception {
-            URL url = new URL("http://a.b.c:8080/TopDir/fred.jsp");
-            man.addCookieFromHeader("ID=abcd; Path=/TopDir", url);
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("ID=abcd", s);
-
-            url = new URL("http://a.b.c:8080/other.jsp");
-            s=man.getCookieHeaderForURL(url);
-            assertNull(s);
-            
-            url = new URL("http://a.b.c:8080/TopDir/suub/another.jsp");
-            s=man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            
-            url = new URL("http://a.b.c:8080/TopDir");
-            s=man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            
-            url = new URL("http://a.b.d/");
-            s=man.getCookieHeaderForURL(url);
-            assertNull(s);
-        }
-
-        public void testCookieOrdering1() throws Exception {
-            URL url = new URL("http://order.now/sub1/moo.html");
-            man.addCookieFromHeader("test1=moo1;path=/", url);
-            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
-            man.addCookieFromHeader("test2=moo3;path=/", url);
-            assertEquals(3,man.getCookieCount());
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            assertEquals("test2=moo2; test1=moo1; test2=moo3", s);
-        }
-
-        public void testCookieOrdering2() throws Exception {
-            URL url = new URL("http://order.now/sub1/moo.html");
-            man.addCookieFromHeader("test1=moo1;", url);
-            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
-            man.addCookieFromHeader("test2=moo3;path=/", url);
-            assertEquals(3,man.getCookieCount());
-            assertEquals("/sub1",man.get(0).getPath()); // Defaults to caller URL
-            assertEquals("/sub1",man.get(1).getPath());
-            assertEquals("/",man.get(2).getPath());
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
-            assertEquals("/sub1",c[0].getPath());
-            assertFalse(c[0].isPathAttributeSpecified());
-            assertEquals("/sub1",c[1].getPath());
-            assertTrue(c[1].isPathAttributeSpecified());
-            assertEquals("/",c[2].getPath());
-            assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
-        }
-        
-        public void testCookiePolicy2109() throws Exception {
-            man.setCookiePolicy(CookiePolicy.RFC_2109);
-            URL url = new URL("http://order.now/sub1/moo.html");
-            man.addCookieFromHeader("test1=moo1;", url);
-            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
-            man.addCookieFromHeader("test2=moo3;path=/", url);
-            assertEquals(3,man.getCookieCount());
-            //assertEquals("/",man.get(0).getPath());
-            assertEquals("/sub1",man.get(1).getPath());
-            assertEquals("/",man.get(2).getPath());
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
-            assertEquals("/sub1",c[0].getPath());
-            assertFalse(c[0].isPathAttributeSpecified());
-            assertEquals("/sub1",c[1].getPath());
-            assertTrue(c[1].isPathAttributeSpecified());
-            assertEquals("/",c[2].getPath());
-            assertTrue(c[2].isPathAttributeSpecified());
-            assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/", s);
-        }
-
-        public void testCookiePolicyNetscape() throws Exception {
-            man.setCookiePolicy(CookiePolicy.NETSCAPE);
-            URL url = new URL("http://order.now/sub1/moo.html");
-            man.addCookieFromHeader("test1=moo1;", url);
-            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
-            man.addCookieFromHeader("test2=moo3;path=/", url);
-            assertEquals(3,man.getCookieCount());
-            assertEquals("/sub1",man.get(0).getPath());
-            assertEquals("/sub1",man.get(1).getPath());
-            assertEquals("/",man.get(2).getPath());
-            String s = man.getCookieHeaderForURL(url);
-            assertNotNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
-            assertEquals("/sub1",c[0].getPath());
-            assertFalse(c[0].isPathAttributeSpecified());
-            assertEquals("/sub1",c[1].getPath());
-            assertTrue(c[1].isPathAttributeSpecified());
-            assertEquals("/",c[2].getPath());
-            assertTrue(c[2].isPathAttributeSpecified());
-            assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
-        }
-
-        public void testCookiePolicyIgnore() throws Exception {
-            man.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
-            URL url = new URL("http://order.now/sub1/moo.html");
-            man.addCookieFromHeader("test1=moo1;", url);
-            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
-            man.addCookieFromHeader("test2=moo3;path=/", url);
-            assertEquals(0,man.getCookieCount());// Cookies are ignored
-            Cookie cc;
-            cc=new Cookie("test1","moo1",null,"/sub1",false,0,false,false);
-            man.add(cc);
-            cc=new Cookie("test2","moo2",null,"/sub1",false,0,true,false);
-            man.add(cc);
-            cc=new Cookie("test3","moo3",null,"/",false,0,false,false);
-            man.add(cc);
-            assertEquals(3,man.getCookieCount());
-            assertEquals("/sub1",man.get(0).getPath());
-            assertEquals("/sub1",man.get(1).getPath());
-            assertEquals("/",man.get(2).getPath());
-            String s = man.getCookieHeaderForURL(url);
-            assertNull(s);
-            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
-            assertEquals(0,c.length); // Cookies again ignored
-        }
-
-        public void testLoad() throws Exception{
-            assertEquals(0,man.getCookieCount());
-            man.addFile("testfiles/cookies.txt");
-            assertEquals(3,man.getCookieCount());
-
-            int num = 0;
-            assertEquals("name",man.get(num).getName());
-            assertEquals("value",man.get(num).getValue());
-            assertEquals("path",man.get(num).getPath());
-            assertEquals("domain",man.get(num).getDomain());
-            assertTrue(man.get(num).getSecure());
-            assertEquals(num,man.get(num).getExpires());
-
-            num++;
-            assertEquals("name2",man.get(num).getName());
-            assertEquals("value2",man.get(num).getValue());
-            assertEquals("/",man.get(num).getPath());
-            assertEquals("",man.get(num).getDomain());
-            assertFalse(man.get(num).getSecure());
-            assertEquals(0,man.get(num).getExpires());
-
-            num++;
-            assertEquals("a",man.get(num).getName());
-            assertEquals("b",man.get(num).getValue());
-            assertEquals("d",man.get(num).getPath());
-            assertEquals("c",man.get(num).getDomain());
-            assertTrue(man.get(num).getSecure());
-            assertEquals(0,man.get(num).getExpires()); // Show that maxlong now saved as 0
-        }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.protocol.http.control;
+
+import java.net.URL;
+
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterContextService;
+
+public class TestCookieManager extends JMeterTestCase {
+        private CookieManager man = null;
+
+        public TestCookieManager(String name) {
+            super(name);
+        }
+
+        private JMeterContext jmctx = null;
+
+        public void setUp() throws Exception {
+            super.setUp();
+            jmctx = JMeterContextService.getContext();
+            man = new CookieManager();
+            man.setThreadContext(jmctx);
+        }
+
+        public void testRemoveCookie() throws Exception {
+            man.setThreadContext(jmctx);
+            Cookie c = new Cookie("id", "me", "127.0.0.1", "/", false, 0);
+            man.add(c);
+            assertEquals(1, man.getCookieCount());
+            // This should be ignored, as there is no value
+            Cookie d = new Cookie("id", "", "127.0.0.1", "/", false, 0);
+            man.add(d);
+            assertEquals(0, man.getCookieCount());
+            man.add(c);
+            man.add(c);
+            assertEquals(1, man.getCookieCount());
+            Cookie e = new Cookie("id", "me2", "127.0.0.1", "/", false, 0);
+            man.add(e);
+            assertEquals(1, man.getCookieCount());
+        }
+
+        public void testSendCookie() throws Exception {
+            man.add(new Cookie("id", "value", "jakarta.apache.org", "/", false, 9999999999L));
+            HTTPSamplerBase sampler = new HTTPNullSampler();
+            sampler.setDomain("jakarta.apache.org");
+            sampler.setPath("/index.html");
+            sampler.setMethod(HTTPSamplerBase.GET);
+            assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
+        }
+
+        public void testSendCookie2() throws Exception {
+            man.add(new Cookie("id", "value", ".apache.org", "/", false, 9999999999L));
+            HTTPSamplerBase sampler = new HTTPNullSampler();
+            sampler.setDomain("jakarta.apache.org");
+            sampler.setPath("/index.html");
+            sampler.setMethod(HTTPSamplerBase.GET);
+            assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
+        }
+
+        /**
+         * Test that the cookie domain field is actually handled as browsers do
+         * (i.e.: host X matches domain .X):
+         */
+        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 that we won't be tricked by similar host names (this was a past
+         * bug, although it never got reported in the bug database):
+         */
+        public void testSimilarHostNames() throws Exception {
+            URL url = new URL("http://ache.org/");
+            man.addCookieFromHeader("test=1", url);
+            url = new URL("http://jakarta.apache.org/");
+            assertNull(man.getCookieHeaderForURL(url));
+        }
+
+        // Test session cookie is returned
+        public void testSessionCookie() throws Exception {
+            URL url = new URL("http://a.b.c/");
+            man.addCookieFromHeader("test=1", url);
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test=1", s);
+        }
+
+        // Bug 2063
+        public void testCookieWithEquals() throws Exception {
+            URL url = new URL("http://a.b.c/");
+            man.addCookieFromHeader("NSCP_USER_LOGIN1_NEW=SHA=xxxxx", url);
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("NSCP_USER_LOGIN1_NEW=SHA=xxxxx", s);
+            Cookie c=man.get(0);
+            assertEquals("NSCP_USER_LOGIN1_NEW",c.getName());
+            assertEquals("SHA=xxxxx",c.getValue());
+        }
+
+        // Test Old cookie is not returned
+        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);
+            String s = man.getCookieHeaderForURL(url);
+            assertNull(s);
+        }
+
+        // Test New cookie is returned
+        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);
+            assertEquals(1,man.getCookieCount());
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test=1", s);
+        }
+
+        // Test multi-cookie header handling
+        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);
+            assertEquals(2,man.getCookieCount());
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test1=1; test2=2", s);
+        }
+        
+        public void testCookies2() throws Exception {
+            URL url = new URL("https://a.b.c.d/testCookies2");
+            man.addCookieFromHeader("test1=1;secure, test2=2;secure", url);
+            assertEquals(2,man.getCookieCount());
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test1=1; test2=2", s);
+        }
+
+        // Test duplicate cookie handling
+        public void testDuplicateCookie() throws Exception {
+            URL url = new URL("http://a.b.c/");
+            man.addCookieFromHeader("test=1", url);
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test=1", s);
+            man.addCookieFromHeader("test=2", url);
+            s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test=2", s);
+        }
+        public void testDuplicateCookie2() throws Exception {
+            URL url = new URL("http://a.b.c/");
+            man.addCookieFromHeader("test=1", url);
+            man.addCookieFromHeader("test2=a", url);
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test=1; test2=a", s); // Assumes some kind of list is used
+            man.addCookieFromHeader("test=2", url);
+            man.addCookieFromHeader("test3=b", url);
+            s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test2=a; test=2; test3=b", s);// Assumes some kind of list is use
+            // If not using a list that retains the order, then the asserts would need to change
+        }
+        
+         
+ 		/** Tests missing cookie path for a trivial URL fetch from the domain 
+ 		 *  Note that this fails prior to a fix for BUG 38256
+ 		 */
+ 		public void testMissingPath0() throws Exception {
+ 			URL url = new URL("http://d.e.f/goo.html");
+ 			man.addCookieFromHeader("test=moo", url);
+ 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
+ 			assertNotNull(s);
+ 			assertEquals("test=moo", s);
+ 		}
+ 		
+ 		/** Tests missing cookie path for a non-trivial URL fetch from the 
+ 		 *  domain.  Note that this fails prior to a fix for BUG 38256
+ 		 */
+ 		public void testMissingPath1() throws Exception {
+ 			URL url = new URL("http://d.e.f/moo.html");
+ 			man.addCookieFromHeader("test=moo", url);
+ 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
+ 			assertNotNull(s);
+ 			assertEquals("test=moo", s);
+ 		}
+ 		
+ 		/** Tests explicit root path with a trivial URL fetch from the domain */
+ 		public void testRootPath0() throws Exception {
+ 			URL url = new URL("http://d.e.f/goo.html");
+ 			man.addCookieFromHeader("test=moo;path=/", url);
+ 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/"));
+ 			assertNotNull(s);
+ 			assertEquals("test=moo", s);
+ 		}
+ 		
+ 		/** Tests explicit root path with a non-trivial URL fetch from the domain */
+ 		public void testRootPath1() throws Exception {
+ 			URL url = new URL("http://d.e.f/moo.html");
+ 			man.addCookieFromHeader("test=moo;path=/", url);
+ 			String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html"));
+ 			assertNotNull(s);
+ 			assertEquals("test=moo", s);
+ 		}
+        
+        // Test cookie matching
+        public void testCookieMatching() throws Exception {
+            URL url = new URL("http://a.b.c:8080/TopDir/fred.jsp");
+            man.addCookieFromHeader("ID=abcd; Path=/TopDir", url);
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("ID=abcd", s);
+
+            url = new URL("http://a.b.c:8080/other.jsp");
+            s=man.getCookieHeaderForURL(url);
+            assertNull(s);
+            
+            url = new URL("http://a.b.c:8080/TopDir/suub/another.jsp");
+            s=man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            
+            url = new URL("http://a.b.c:8080/TopDir");
+            s=man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            
+            url = new URL("http://a.b.d/");
+            s=man.getCookieHeaderForURL(url);
+            assertNull(s);
+        }
+
+        public void testCookieOrdering1() throws Exception {
+            URL url = new URL("http://order.now/sub1/moo.html");
+            man.addCookieFromHeader("test1=moo1;path=/", url);
+            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
+            man.addCookieFromHeader("test2=moo3;path=/", url);
+            assertEquals(3,man.getCookieCount());
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            assertEquals("test2=moo2; test1=moo1; test2=moo3", s);
+        }
+
+        public void testCookieOrdering2() throws Exception {
+            URL url = new URL("http://order.now/sub1/moo.html");
+            man.addCookieFromHeader("test1=moo1;", url);
+            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
+            man.addCookieFromHeader("test2=moo3;path=/", url);
+            assertEquals(3,man.getCookieCount());
+            assertEquals("/sub1",man.get(0).getPath()); // Defaults to caller URL
+            assertEquals("/sub1",man.get(1).getPath());
+            assertEquals("/",man.get(2).getPath());
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            assertEquals("/sub1",c[0].getPath());
+            assertFalse(c[0].isPathAttributeSpecified());
+            assertEquals("/sub1",c[1].getPath());
+            assertTrue(c[1].isPathAttributeSpecified());
+            assertEquals("/",c[2].getPath());
+            assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
+        }
+        
+        public void testCookiePolicy2109() throws Exception {
+            man.setCookiePolicy(CookiePolicy.RFC_2109);
+            URL url = new URL("http://order.now/sub1/moo.html");
+            man.addCookieFromHeader("test1=moo1;", url);
+            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
+            man.addCookieFromHeader("test2=moo3;path=/", url);
+            assertEquals(3,man.getCookieCount());
+            //assertEquals("/",man.get(0).getPath());
+            assertEquals("/sub1",man.get(1).getPath());
+            assertEquals("/",man.get(2).getPath());
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            assertEquals("/sub1",c[0].getPath());
+            assertFalse(c[0].isPathAttributeSpecified());
+            assertEquals("/sub1",c[1].getPath());
+            assertTrue(c[1].isPathAttributeSpecified());
+            assertEquals("/",c[2].getPath());
+            assertTrue(c[2].isPathAttributeSpecified());
+            assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/", s);
+        }
+
+        public void testCookiePolicyNetscape() throws Exception {
+            man.setCookiePolicy(CookiePolicy.NETSCAPE);
+            URL url = new URL("http://order.now/sub1/moo.html");
+            man.addCookieFromHeader("test1=moo1;", url);
+            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
+            man.addCookieFromHeader("test2=moo3;path=/", url);
+            assertEquals(3,man.getCookieCount());
+            assertEquals("/sub1",man.get(0).getPath());
+            assertEquals("/sub1",man.get(1).getPath());
+            assertEquals("/",man.get(2).getPath());
+            String s = man.getCookieHeaderForURL(url);
+            assertNotNull(s);
+            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            assertEquals("/sub1",c[0].getPath());
+            assertFalse(c[0].isPathAttributeSpecified());
+            assertEquals("/sub1",c[1].getPath());
+            assertTrue(c[1].isPathAttributeSpecified());
+            assertEquals("/",c[2].getPath());
+            assertTrue(c[2].isPathAttributeSpecified());
+            assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
+        }
+
+        public void testCookiePolicyIgnore() throws Exception {
+            man.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
+            URL url = new URL("http://order.now/sub1/moo.html");
+            man.addCookieFromHeader("test1=moo1;", url);
+            man.addCookieFromHeader("test2=moo2;path=/sub1", url);
+            man.addCookieFromHeader("test2=moo3;path=/", url);
+            assertEquals(0,man.getCookieCount());// Cookies are ignored
+            Cookie cc;
+            cc=new Cookie("test1","moo1",null,"/sub1",false,0,false,false);
+            man.add(cc);
+            cc=new Cookie("test2","moo2",null,"/sub1",false,0,true,false);
+            man.add(cc);
+            cc=new Cookie("test3","moo3",null,"/",false,0,false,false);
+            man.add(cc);
+            assertEquals(3,man.getCookieCount());
+            assertEquals("/sub1",man.get(0).getPath());
+            assertEquals("/sub1",man.get(1).getPath());
+            assertEquals("/",man.get(2).getPath());
+            String s = man.getCookieHeaderForURL(url);
+            assertNull(s);
+            org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
+            assertEquals(0,c.length); // Cookies again ignored
+        }
+
+        public void testLoad() throws Exception{
+            assertEquals(0,man.getCookieCount());
+            man.addFile("testfiles/cookies.txt");
+            assertEquals(3,man.getCookieCount());
+
+            int num = 0;
+            assertEquals("name",man.get(num).getName());
+            assertEquals("value",man.get(num).getValue());
+            assertEquals("path",man.get(num).getPath());
+            assertEquals("domain",man.get(num).getDomain());
+            assertTrue(man.get(num).getSecure());
+            assertEquals(num,man.get(num).getExpires());
+
+            num++;
+            assertEquals("name2",man.get(num).getName());
+            assertEquals("value2",man.get(num).getValue());
+            assertEquals("/",man.get(num).getPath());
+            assertEquals("",man.get(num).getDomain());
+            assertFalse(man.get(num).getSecure());
+            assertEquals(0,man.get(num).getExpires());
+
+            num++;
+            assertEquals("a",man.get(num).getName());
+            assertEquals("b",man.get(num).getValue());
+            assertEquals("d",man.get(num).getPath());
+            assertEquals("c",man.get(num).getDomain());
+            assertTrue(man.get(num).getSecure());
+            assertEquals(0,man.get(num).getExpires()); // Show that maxlong now saved as 0
+        }
+}

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org