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 2009/05/10 20:19:30 UTC

svn commit: r773382 [4/6] - in /jakarta/jmeter/trunk/test/src/org/apache: jmeter/engine/ jmeter/engine/util/ jmeter/extractor/ jmeter/functions/ jmeter/gui/action/ jmeter/gui/util/ jmeter/junit/ jmeter/junit/stubs/ jmeter/monitor/model/ jmeter/monitor/...

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java Sun May 10 18:19:28 2009
@@ -62,20 +62,20 @@
     }
     
     public static Test suite(){
-    	TestSetup setup = new TestSetup(new TestSuite(TestHTTPMirrorThread.class)){    		
-    	    private HttpMirrorServer httpServer;
-    	    
-    		protected void setUp() throws Exception {
-            	httpServer = startHttpMirror(HTTP_SERVER_PORT);
-    		}
-    		
-    		protected void tearDown() throws Exception {
-		        // Shutdown the http server
-    			httpServer.stopServer();
-    			httpServer = null;
-    		}
-    	};
-    	return setup;
+        TestSetup setup = new TestSetup(new TestSuite(TestHTTPMirrorThread.class)){         
+            private HttpMirrorServer httpServer;
+            
+            protected void setUp() throws Exception {
+                httpServer = startHttpMirror(HTTP_SERVER_PORT);
+            }
+            
+            protected void tearDown() throws Exception {
+                // Shutdown the http server
+                httpServer.stopServer();
+                httpServer = null;
+            }
+        };
+        return setup;
     }
 
     /**
@@ -83,28 +83,28 @@
      * Also used by TestHTTPSamplersAgainstHttpMirrorServer
      */
     public static HttpMirrorServer startHttpMirror(int port) throws Exception {
-    	HttpMirrorServer server = null;
-    	server = new HttpMirrorServer(port);
-    	server.start();
+        HttpMirrorServer server = null;
+        server = new HttpMirrorServer(port);
+        server.start();
         Exception e = null;
         for (int i=0; i < 10; i++) {// Wait up to 1 second
-	        try {
-				Thread.sleep(100);
-			} catch (InterruptedException ignored) {
-			}
-			e = server.getException();
-			if (e != null) {// Already failed
-	        	throw new Exception("Could not start mirror server on port: "+port+". "+e);
-			}
-			if (server.isAlive()) {
-			    break; // succeeded
-			}
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException ignored) {
+            }
+            e = server.getException();
+            if (e != null) {// Already failed
+                throw new Exception("Could not start mirror server on port: "+port+". "+e);
+            }
+            if (server.isAlive()) {
+                break; // succeeded
+            }
         }
         
         if (!server.isAlive()){
-        	throw new Exception("Could not start mirror server on port: "+port);
+            throw new Exception("Could not start mirror server on port: "+port);
         }
-    	return server;
+        return server;
     }
 
     public void testGetRequest() throws Exception {        
@@ -129,10 +129,10 @@
         byte[] buffer = new byte[1024];
         int length = 0;
         while(( length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
+            response.write(buffer, 0, length);
         }
         response.close();
-        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());   		
+        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());          
         // Check that the request and response matches
         checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
         // Close the connection
@@ -168,7 +168,7 @@
         buffer = new byte[1024];
         length = 0;
         while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
+            response.write(buffer, 0, length);
         }
         response.close();
         mirroredResponse = getMirroredResponse(response.toByteArray());
@@ -191,7 +191,7 @@
         // Construct body
         StringBuffer postBodyBuffer = new StringBuffer();
         for(int i = 0; i < 1000; i++) {
-        	postBodyBuffer.append("abc");
+            postBodyBuffer.append("abc");
         }
         byte[] postBody = postBodyBuffer.toString().getBytes(ISO_8859_1);
         
@@ -216,10 +216,10 @@
         byte[] buffer = new byte[1024];
         int length = 0;
         while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
+            response.write(buffer, 0, length);
         }
         response.close();
-        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());   		
+        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());          
         // Check that the request and response matches
         checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
         // Close the connection
@@ -258,7 +258,7 @@
         buffer = new byte[1024];
         length = 0;
         while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
+            response.write(buffer, 0, length);
         }
         response.close();
         mirroredResponse = getMirroredResponse(response.toByteArray());
@@ -281,7 +281,7 @@
         // Construct body
         postBodyBuffer = new StringBuffer();
         for(int i = 0; i < 1000; i++) {
-        	postBodyBuffer.append("\u0364\u00c5\u2052");
+            postBodyBuffer.append("\u0364\u00c5\u2052");
         }
         postBody = postBodyBuffer.toString().getBytes(UTF_8);
         
@@ -312,7 +312,7 @@
         buffer = new byte[1024];
         length = 0;
         while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
+            response.write(buffer, 0, length);
         }
         response.close();
         mirroredResponse = getMirroredResponse(response.toByteArray());
@@ -342,32 +342,32 @@
     private void checkArraysHaveSameContent(byte[] expected, byte[] actual) throws UnsupportedEncodingException {
         if(expected != null && actual != null) {
             if(expected.length != actual.length) {
-            	System.out.println(">>>>>>>>>>>>>>>>>>>> (expected) : length " + expected.length);
-            	System.out.println(new String(expected,"UTF-8"));
-            	System.out.println("==================== (actual) : length " + actual.length);
-            	System.out.println(new String(actual,"UTF-8"));
-            	System.out.println("<<<<<<<<<<<<<<<<<<<<");
+                System.out.println(">>>>>>>>>>>>>>>>>>>> (expected) : length " + expected.length);
+                System.out.println(new String(expected,"UTF-8"));
+                System.out.println("==================== (actual) : length " + actual.length);
+                System.out.println(new String(actual,"UTF-8"));
+                System.out.println("<<<<<<<<<<<<<<<<<<<<");
                 fail("arrays have different length, expected is " + expected.length + ", actual is " + actual.length);
             }
             else {
                 for(int i = 0; i < expected.length; i++) {
                     if(expected[i] != actual[i]) {
-                    	System.out.println(">>>>>>>>>>>>>>>>>>>> (expected) : length " + expected.length);
-                       	System.out.println(new String(expected,0,i+1));
-                    	System.out.println("==================== (actual) : length " + actual.length);
-                    	System.out.println(new String(actual,0,i+1));
-                    	System.out.println("<<<<<<<<<<<<<<<<<<<<");
+                        System.out.println(">>>>>>>>>>>>>>>>>>>> (expected) : length " + expected.length);
+                        System.out.println(new String(expected,0,i+1));
+                        System.out.println("==================== (actual) : length " + actual.length);
+                        System.out.println(new String(actual,0,i+1));
+                        System.out.println("<<<<<<<<<<<<<<<<<<<<");
 /*
-                     	// Useful to when debugging
-                    	for(int j = 0; j  < expected.length; j++) {
-                    		System.out.print(expected[j] + " ");
-                    	}
-                    	System.out.println();
-                    	for(int j = 0; j  < actual.length; j++) {
-                    		System.out.print(actual[j] + " ");
-                    	}
-                    	System.out.println();
-*/                    	
+                        // Useful to when debugging
+                        for(int j = 0; j  < expected.length; j++) {
+                            System.out.print(expected[j] + " ");
+                        }
+                        System.out.println();
+                        for(int j = 0; j  < actual.length; j++) {
+                            System.out.print(actual[j] + " ");
+                        }
+                        System.out.println();
+*/                      
                         fail("byte at position " + i + " is different, expected is " + expected[i] + ", actual is " + actual[i]);
                     }
                 }
@@ -379,19 +379,19 @@
     }
     
     private byte[] getMirroredResponse(byte[] allResponse) {
-    	// The response includes the headers from the mirror server,
+        // The response includes the headers from the mirror server,
         // we want to skip those, to only keep the content mirrored.
-   		// Look for the first CRLFCRLF section
-   		int startOfMirrorResponse = 0;
-   		for(int i = 0; i < allResponse.length; i++) {
-   			// TODO : This is a bit fragile
-   			if(allResponse[i] == 0x0d && allResponse[i+1] == 0x0a && allResponse[i+2] == 0x0d && allResponse[i+3] == 0x0a) {
-   				startOfMirrorResponse = i + 4;
-   				break;
-   			}
-   		}
+        // Look for the first CRLFCRLF section
+        int startOfMirrorResponse = 0;
+        for(int i = 0; i < allResponse.length; i++) {
+            // TODO : This is a bit fragile
+            if(allResponse[i] == 0x0d && allResponse[i+1] == 0x0a && allResponse[i+2] == 0x0d && allResponse[i+3] == 0x0a) {
+                startOfMirrorResponse = i + 4;
+                break;
+            }
+        }
         byte[] mirrorResponse = new byte[allResponse.length - startOfMirrorResponse]; 
         System.arraycopy(allResponse, startOfMirrorResponse, mirrorResponse, 0, mirrorResponse.length);
-        return mirrorResponse;    	
+        return mirrorResponse;      
     }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java Sun May 10 18:19:28 2009
@@ -23,23 +23,23 @@
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
 
 public class TestHttpTestSampleGui extends TestCase {
-		private HttpTestSampleGui gui;
+        private HttpTestSampleGui gui;
 
-		public TestHttpTestSampleGui(String name) {
-			super(name);
-		}
+        public TestHttpTestSampleGui(String name) {
+            super(name);
+        }
 
-		public void setUp() {
-			gui = new HttpTestSampleGui();
-		}
+        public void setUp() {
+            gui = new HttpTestSampleGui();
+        }
 
-		public void testCloneSampler() throws Exception {
-			HTTPSamplerBase sampler = (HTTPSamplerBase) gui.createTestElement();
-			sampler.addArgument("param", "value");
-			HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
-			clonedSampler.setRunningVersion(true);
-			sampler.getArguments().getArgument(0).setValue("new value");
-			assertEquals("Sampler didn't clone correctly", "new value", sampler.getArguments().getArgument(0)
-					.getValue());
-		}
+        public void testCloneSampler() throws Exception {
+            HTTPSamplerBase sampler = (HTTPSamplerBase) gui.createTestElement();
+            sampler.addArgument("param", "value");
+            HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
+            clonedSampler.setRunningVersion(true);
+            sampler.getArguments().getArgument(0).setValue("new value");
+            assertEquals("Sampler didn't clone correctly", "new value", sampler.getArguments().getArgument(0)
+                    .getValue());
+        }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java Sun May 10 18:19:28 2009
@@ -34,65 +34,65 @@
 
 public class TestAnchorModifier extends JMeterTestCase {
         private AnchorModifier parser = new AnchorModifier();
-		public TestAnchorModifier(String name) {
-			super(name);
-		}
+        public TestAnchorModifier(String name) {
+            super(name);
+        }
 
-		private JMeterContext jmctx = null;
+        private JMeterContext jmctx = null;
 
-		public void setUp() {
-			jmctx = JMeterContextService.getContext();
+        public void setUp() {
+            jmctx = JMeterContextService.getContext();
             parser.setThreadContext(jmctx);
-		}
+        }
 
-		public void testProcessingHTMLFile(String HTMLFileName) throws Exception {
-			HTTPSamplerBase config = (HTTPSamplerBase) SaveService.loadTree(
-					new FileInputStream(System.getProperty("user.dir") + "/testfiles/load_bug_list.jmx")).getArray()[0];
-			config.setRunningVersion(true);
-			HTTPSampleResult result = new HTTPSampleResult();
-			HTTPSamplerBase context = (HTTPSamplerBase) SaveService.loadTree(
-					new FileInputStream(System.getProperty("user.dir") + "/testfiles/Load_JMeter_Page.jmx")).getArray()[0];
-			jmctx.setCurrentSampler(context);
-			jmctx.setCurrentSampler(config);
-			result.setResponseData(new TextFile(System.getProperty("user.dir") + HTMLFileName).getText().getBytes());
-			result.setSampleLabel(context.toString());
-			result.setSamplerData(context.toString());
-			result.setURL(new URL("http://issues.apache.org/fakepage.html"));
-			jmctx.setPreviousResult(result);
-			AnchorModifier modifier = new AnchorModifier();
-			modifier.setThreadContext(jmctx);
-			modifier.process();
-			assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
-					+ "bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED"
-					+ "&email1=&emailtype1=substring&emailassigned_to1=1"
-					+ "&email2=&emailtype2=substring&emailreporter2=1" + "&bugidtype=include&bug_id=&changedin=&votes="
-					+ "&chfieldfrom=&chfieldto=Now&chfieldvalue="
-					+ "&product=JMeter&short_desc=&short_desc_type=substring"
-					+ "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords="
-					+ "&keywords_type=anywords" + "&field0-0-0=noop&type0-0-0=noop&value0-0-0="
-					+ "&cmdtype=doit&order=Reuse+same+sort+as+last+time", config.toString());
-			config.recoverRunningVersion();
-			assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
-					+ "bug_status=.*&bug_status=.*&bug_status=.*&email1="
-					+ "&emailtype1=substring&emailassigned_to1=1&email2=" + "&emailtype2=substring&emailreporter2=1"
-					+ "&bugidtype=include&bug_id=&changedin=&votes=" + "&chfieldfrom=&chfieldto=Now&chfieldvalue="
-					+ "&product=JMeter&short_desc=&short_desc_type=substring"
-					+ "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords="
-					+ "&keywords_type=anywords&field0-0-0=noop" + "&type0-0-0=noop&value0-0-0=&cmdtype=doit"
-					+ "&order=Reuse+same+sort+as+last+time", config.toString());
-		}
-
-		public void testModifySampler() throws Exception {
-			testProcessingHTMLFile("/testfiles/jmeter_home_page.html");
-		}
-
-		public void testModifySamplerWithRelativeLink() throws Exception {
-			testProcessingHTMLFile("/testfiles/jmeter_home_page_with_relative_links.html");
-		}
-
-		public void testModifySamplerWithBaseHRef() throws Exception {
-			testProcessingHTMLFile("/testfiles/jmeter_home_page_with_base_href.html");
-		}
+        public void testProcessingHTMLFile(String HTMLFileName) throws Exception {
+            HTTPSamplerBase config = (HTTPSamplerBase) SaveService.loadTree(
+                    new FileInputStream(System.getProperty("user.dir") + "/testfiles/load_bug_list.jmx")).getArray()[0];
+            config.setRunningVersion(true);
+            HTTPSampleResult result = new HTTPSampleResult();
+            HTTPSamplerBase context = (HTTPSamplerBase) SaveService.loadTree(
+                    new FileInputStream(System.getProperty("user.dir") + "/testfiles/Load_JMeter_Page.jmx")).getArray()[0];
+            jmctx.setCurrentSampler(context);
+            jmctx.setCurrentSampler(config);
+            result.setResponseData(new TextFile(System.getProperty("user.dir") + HTMLFileName).getText().getBytes());
+            result.setSampleLabel(context.toString());
+            result.setSamplerData(context.toString());
+            result.setURL(new URL("http://issues.apache.org/fakepage.html"));
+            jmctx.setPreviousResult(result);
+            AnchorModifier modifier = new AnchorModifier();
+            modifier.setThreadContext(jmctx);
+            modifier.process();
+            assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
+                    + "bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED"
+                    + "&email1=&emailtype1=substring&emailassigned_to1=1"
+                    + "&email2=&emailtype2=substring&emailreporter2=1" + "&bugidtype=include&bug_id=&changedin=&votes="
+                    + "&chfieldfrom=&chfieldto=Now&chfieldvalue="
+                    + "&product=JMeter&short_desc=&short_desc_type=substring"
+                    + "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords="
+                    + "&keywords_type=anywords" + "&field0-0-0=noop&type0-0-0=noop&value0-0-0="
+                    + "&cmdtype=doit&order=Reuse+same+sort+as+last+time", config.toString());
+            config.recoverRunningVersion();
+            assertEquals("http://issues.apache.org/bugzilla/buglist.cgi?"
+                    + "bug_status=.*&bug_status=.*&bug_status=.*&email1="
+                    + "&emailtype1=substring&emailassigned_to1=1&email2=" + "&emailtype2=substring&emailreporter2=1"
+                    + "&bugidtype=include&bug_id=&changedin=&votes=" + "&chfieldfrom=&chfieldto=Now&chfieldvalue="
+                    + "&product=JMeter&short_desc=&short_desc_type=substring"
+                    + "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords="
+                    + "&keywords_type=anywords&field0-0-0=noop" + "&type0-0-0=noop&value0-0-0=&cmdtype=doit"
+                    + "&order=Reuse+same+sort+as+last+time", config.toString());
+        }
+
+        public void testModifySampler() throws Exception {
+            testProcessingHTMLFile("/testfiles/jmeter_home_page.html");
+        }
+
+        public void testModifySamplerWithRelativeLink() throws Exception {
+            testProcessingHTMLFile("/testfiles/jmeter_home_page_with_relative_links.html");
+        }
+
+        public void testModifySamplerWithBaseHRef() throws Exception {
+            testProcessingHTMLFile("/testfiles/jmeter_home_page_with_base_href.html");
+        }
 
         public void testSimpleParse() throws Exception {
             HTTPSamplerBase config = makeUrlConfig(".*/index\\.html");

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java Sun May 10 18:19:28 2009
@@ -30,21 +30,21 @@
 import org.apache.jmeter.threads.JMeterContextService;
 
 public class TestURLRewritingModifier extends JMeterTestCase {
-		private SampleResult response = null;
+        private SampleResult response = null;
 
-		private JMeterContext context = null;
+        private JMeterContext context = null;
 
-		private URLRewritingModifier mod = null;
+        private URLRewritingModifier mod = null;
 
-		public TestURLRewritingModifier(String name) {
-			super(name);
-		}
+        public TestURLRewritingModifier(String name) {
+            super(name);
+        }
 
-		public void setUp() {
-			context = JMeterContextService.getContext();
-			mod = new URLRewritingModifier();
-			mod.setThreadContext(context);
-		}
+        public void setUp() {
+            context = JMeterContextService.getContext();
+            mod = new URLRewritingModifier();
+            mod.setThreadContext(context);
+        }
 
         public void testNonHTTPSampler() throws Exception {
             Sampler sampler = new NullSampler();
@@ -55,143 +55,143 @@
         }
 
         public void testGrabSessionId() throws Exception {
-			String html = "location: http://server.com/index.html" + "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
-			response = new SampleResult();
-			response.setResponseData(html.getBytes());
-			mod.setArgumentName("session_id");
-			HTTPSamplerBase sampler = createSampler();
-			sampler.addArgument("session_id", "adfasdfdsafasdfasd");
-			context.setCurrentSampler(sampler);
-			context.setPreviousResult(response);
-			mod.process();
-			Arguments args = sampler.getArguments();
-			assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
-					.getValue());
-			assertEquals("http://server.com/index.html?" + "session_id=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
-		}
-
-		public void testGrabSessionId2() throws Exception {
-			String html = "<a href=\"http://server.com/index.html?" + "session_id=jfdkjdkfjddkfdfjkdjfdf\">";
-			response = new SampleResult();
-			response.setResponseData(html.getBytes());
-			mod.setArgumentName("session_id");
-			HTTPSamplerBase sampler = createSampler();
-			context.setCurrentSampler(sampler);
-			context.setPreviousResult(response);
-			mod.process();
-			Arguments args = sampler.getArguments();
-			assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
-		}
-
-		private HTTPSamplerBase createSampler() {
-			HTTPSamplerBase sampler = new HTTPNullSampler();
-			sampler.setDomain("server.com");
-			sampler.setPath("index.html");
-			sampler.setMethod(HTTPSamplerBase.GET);
-			sampler.setProtocol("http");
-			return sampler;
-		}
-
-		public void testGrabSessionId3() throws Exception {
-			String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
-			response = new SampleResult();
-			response.setResponseData(html.getBytes());
-			mod.setArgumentName("session_id");
-			HTTPSamplerBase sampler = createSampler();
-			context.setCurrentSampler(sampler);
-			context.setPreviousResult(response);
-			mod.process();
-			Arguments args = sampler.getArguments();
-			assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
-		}
-
-		public void testGrabSessionIdEndedInTab() throws Exception {
-			String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf\t";
-			response = new SampleResult();
-			response.setResponseData(html.getBytes());
-			mod.setArgumentName("session_id");
-			HTTPSamplerBase sampler = createSampler();
-			context.setCurrentSampler(sampler);
-			context.setPreviousResult(response);
-			mod.process();
-			Arguments args = sampler.getArguments();
-			assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
-		}
-
-		public void testGrabSessionId4() throws Exception {
-			String html = "href='index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT'";
-			response = new SampleResult();
-			response.setResponseData(html.getBytes());
-			mod.setArgumentName("%24sid%24");
-			mod.setPathExtension(true);
-			mod.setPathExtensionNoEquals(true);
-			HTTPSamplerBase sampler = createSampler();
-			context.setCurrentSampler(sampler);
-			context.setPreviousResult(response);
-			mod.process();
-			// Arguments args = sampler.getArguments();
-			assertEquals("index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT", sampler.getPath());
-		}
+            String html = "location: http://server.com/index.html" + "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
+            response = new SampleResult();
+            response.setResponseData(html.getBytes());
+            mod.setArgumentName("session_id");
+            HTTPSamplerBase sampler = createSampler();
+            sampler.addArgument("session_id", "adfasdfdsafasdfasd");
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
+                    .getValue());
+            assertEquals("http://server.com/index.html?" + "session_id=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
+        }
+
+        public void testGrabSessionId2() throws Exception {
+            String html = "<a href=\"http://server.com/index.html?" + "session_id=jfdkjdkfjddkfdfjkdjfdf\">";
+            response = new SampleResult();
+            response.setResponseData(html.getBytes());
+            mod.setArgumentName("session_id");
+            HTTPSamplerBase sampler = createSampler();
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+        }
+
+        private HTTPSamplerBase createSampler() {
+            HTTPSamplerBase sampler = new HTTPNullSampler();
+            sampler.setDomain("server.com");
+            sampler.setPath("index.html");
+            sampler.setMethod(HTTPSamplerBase.GET);
+            sampler.setProtocol("http");
+            return sampler;
+        }
+
+        public void testGrabSessionId3() throws Exception {
+            String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
+            response = new SampleResult();
+            response.setResponseData(html.getBytes());
+            mod.setArgumentName("session_id");
+            HTTPSamplerBase sampler = createSampler();
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+        }
+
+        public void testGrabSessionIdEndedInTab() throws Exception {
+            String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf\t";
+            response = new SampleResult();
+            response.setResponseData(html.getBytes());
+            mod.setArgumentName("session_id");
+            HTTPSamplerBase sampler = createSampler();
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+        }
+
+        public void testGrabSessionId4() throws Exception {
+            String html = "href='index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT'";
+            response = new SampleResult();
+            response.setResponseData(html.getBytes());
+            mod.setArgumentName("%24sid%24");
+            mod.setPathExtension(true);
+            mod.setPathExtensionNoEquals(true);
+            HTTPSamplerBase sampler = createSampler();
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            // Arguments args = sampler.getArguments();
+            assertEquals("index.html;%24sid%24KQNq3AAADQZoEQAxlkX8uQV5bjqVBPbT", sampler.getPath());
+        }
 
         public void testGrabSessionId5() throws Exception {
-			String html = "location: http://server.com/index.html" + "?session[33]=jfdkjdkf%20jddkfdfjkdjfdf%22;";
-			response = new SampleResult();
-			response.setResponseData(html.getBytes());
-			mod.setArgumentName("session[33]");
-			HTTPSamplerBase sampler = createSampler();
-			sampler.addArgument("session[33]", "adfasdfdsafasdfasd");
-			context.setCurrentSampler(sampler);
-			context.setPreviousResult(response);
-			mod.process();
-			Arguments args = sampler.getArguments();
-			assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
-					.getValue());
-			assertEquals("http://server.com/index.html?session%5B33%5D=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
-		}
+            String html = "location: http://server.com/index.html" + "?session[33]=jfdkjdkf%20jddkfdfjkdjfdf%22;";
+            response = new SampleResult();
+            response.setResponseData(html.getBytes());
+            mod.setArgumentName("session[33]");
+            HTTPSamplerBase sampler = createSampler();
+            sampler.addArgument("session[33]", "adfasdfdsafasdfasd");
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
+                    .getValue());
+            assertEquals("http://server.com/index.html?session%5B33%5D=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
+        }
 
 
-		public void testGrabSessionIdFromForm() throws Exception {
-			String[] html = new String[] { 
+        public void testGrabSessionIdFromForm() throws Exception {
+            String[] html = new String[] { 
                     "<input name=\"sid\" value=\"myId\">", 
                     "<input name='sid' value='myId'>",
-					"<input value=\"myId\" NAME='sid'>",
+                    "<input value=\"myId\" NAME='sid'>",
                     "<input VALUE='myId' name=\"sid\">",
-					"<input blah blah value=\"myId\" yoda yoda NAME='sid'>",
+                    "<input blah blah value=\"myId\" yoda yoda NAME='sid'>",
                     "<input type=\"HIDDEN\" name=\"sid\"      value=\"myId\">",
                     "<input type=\"HIDDEN\" name=\"sid\"\tvalue=\"myId\">",
                     };
-			for (int i = 0; i < html.length; i++) {
-				response = new SampleResult();
-				response.setResponseData(html[i].getBytes());
+            for (int i = 0; i < html.length; i++) {
+                response = new SampleResult();
+                response.setResponseData(html[i].getBytes());
                 URLRewritingModifier newMod = new URLRewritingModifier();
-				newMod.setThreadContext(context);
-				newMod.setArgumentName("sid");
-				newMod.setPathExtension(false);
-				HTTPSamplerBase sampler = createSampler();
-				context.setCurrentSampler(sampler);
-				context.setPreviousResult(response);
-				newMod.process();
-				Arguments args = sampler.getArguments();
-				assertEquals("For case i=" + i, "myId", 
+                newMod.setThreadContext(context);
+                newMod.setArgumentName("sid");
+                newMod.setPathExtension(false);
+                HTTPSamplerBase sampler = createSampler();
+                context.setCurrentSampler(sampler);
+                context.setPreviousResult(response);
+                newMod.process();
+                Arguments args = sampler.getArguments();
+                assertEquals("For case i=" + i, "myId", 
                         ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
-			}
-		}
+            }
+        }
 
     public void testGrabSessionIdURLinJSON() throws Exception {
-			String html = 
-			    "<a href=\"#\" onclick=\"$(\'frame\').src=\'/index?param1=bla&sessionid=xyzxyzxyz\\'";
-			response = new SampleResult();
-			response.setResponseData(html.getBytes());
-			mod.setArgumentName("sessionid");
-			HTTPSamplerBase sampler = createSampler();
-			sampler.addArgument("sessionid", "xyzxyzxyz");
-			context.setCurrentSampler(sampler);
-			context.setPreviousResult(response);
-			mod.process();
-			Arguments args = sampler.getArguments();
-			assertEquals("xyzxyzxyz", ((Argument) args.getArguments().get(0).getObjectValue())
-					.getValue());
-		}
+            String html = 
+                "<a href=\"#\" onclick=\"$(\'frame\').src=\'/index?param1=bla&sessionid=xyzxyzxyz\\'";
+            response = new SampleResult();
+            response.setResponseData(html.getBytes());
+            mod.setArgumentName("sessionid");
+            HTTPSamplerBase sampler = createSampler();
+            sampler.addArgument("sessionid", "xyzxyzxyz");
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            assertEquals("xyzxyzxyz", ((Argument) args.getArguments().get(0).getObjectValue())
+                    .getValue());
+        }
 
         public void testCache() throws Exception {
             String[] html = new String[] { 

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java Sun May 10 18:19:28 2009
@@ -26,81 +26,81 @@
 // TODO: need more tests
 public final class TestHtmlParsingUtils extends JMeterTestCase {
 
-		public TestHtmlParsingUtils(String name) {
-			super(name);
-		}
+        public TestHtmlParsingUtils(String name) {
+            super(name);
+        }
 
-		protected void setUp() {
-		}
+        protected void setUp() {
+        }
 
-		public void testGetParser() throws Exception {
+        public void testGetParser() throws Exception {
             HtmlParsingUtils.getParser();
-		}
+        }
 
-		public void testGetDom() throws Exception {
+        public void testGetDom() throws Exception {
             HtmlParsingUtils.getDOM("<HTML></HTML>");
             HtmlParsingUtils.getDOM("");
-		}
+        }
 
-		public void testIsArgumentMatched() throws Exception {
-			Argument arg = new Argument();
-			Argument argp = new Argument();
-			assertTrue(HtmlParsingUtils.isArgumentMatched(arg, argp));
-
-			arg = new Argument("test", "abcd");
-			argp = new Argument("test", "a.*d");
-			assertTrue(HtmlParsingUtils.isArgumentMatched(arg, argp));
-
-			arg = new Argument("test", "abcd");
-			argp = new Argument("test", "a.*e");
-			assertFalse(HtmlParsingUtils.isArgumentMatched(arg, argp));
-		}
-		
-		public void testIsAnchorMatched() throws Exception {
-			HTTPSamplerBase target=new HTTPNullSampler();
-			HTTPSamplerBase pattern=new HTTPNullSampler();
-
-			assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
-
-			target.setProtocol("http:");
-			assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));
-
-			pattern.setProtocol(".*");
-			assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
-			
-			target.setDomain("a.b.c");
-			assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
-
-			pattern.setDomain(".*");
-			assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
-			
-			target.setPath("/abc");
-			assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));
-
-			pattern.setPath(".*");
-			assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
-			
-			target.addArgument("param2", "value2", "=");
-			assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
-			
-			pattern.addArgument("param1", ".*", "=");
-			assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));
-			
-			target.addArgument("param1", "value1", "=");
-			assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
-		}
-		
-		public void testisEqualOrMatches() throws Exception {
-			assertTrue(HtmlParsingUtils.isEqualOrMatches("http:","http:"));
-			assertFalse(HtmlParsingUtils.isEqualOrMatches("http:","htTp:"));
-			assertTrue(HtmlParsingUtils.isEqualOrMatches("http:","ht+p:"));
-			assertFalse(HtmlParsingUtils.isEqualOrMatches("ht+p:","http:"));
-		}
-
-		public void testisEqualOrMatchesCaseBlind() throws Exception {
-			assertTrue(HtmlParsingUtils.isEqualOrMatchesCaseBlind("http:","http:"));
-			assertTrue(HtmlParsingUtils.isEqualOrMatchesCaseBlind("http:","htTp:"));
-			assertTrue(HtmlParsingUtils.isEqualOrMatches("http:","ht+p:"));
-			assertFalse(HtmlParsingUtils.isEqualOrMatches("ht+p:","http:"));
-		}
+        public void testIsArgumentMatched() throws Exception {
+            Argument arg = new Argument();
+            Argument argp = new Argument();
+            assertTrue(HtmlParsingUtils.isArgumentMatched(arg, argp));
+
+            arg = new Argument("test", "abcd");
+            argp = new Argument("test", "a.*d");
+            assertTrue(HtmlParsingUtils.isArgumentMatched(arg, argp));
+
+            arg = new Argument("test", "abcd");
+            argp = new Argument("test", "a.*e");
+            assertFalse(HtmlParsingUtils.isArgumentMatched(arg, argp));
+        }
+        
+        public void testIsAnchorMatched() throws Exception {
+            HTTPSamplerBase target=new HTTPNullSampler();
+            HTTPSamplerBase pattern=new HTTPNullSampler();
+
+            assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
+
+            target.setProtocol("http:");
+            assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));
+
+            pattern.setProtocol(".*");
+            assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
+            
+            target.setDomain("a.b.c");
+            assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
+
+            pattern.setDomain(".*");
+            assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
+            
+            target.setPath("/abc");
+            assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));
+
+            pattern.setPath(".*");
+            assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
+            
+            target.addArgument("param2", "value2", "=");
+            assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
+            
+            pattern.addArgument("param1", ".*", "=");
+            assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));
+            
+            target.addArgument("param1", "value1", "=");
+            assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
+        }
+        
+        public void testisEqualOrMatches() throws Exception {
+            assertTrue(HtmlParsingUtils.isEqualOrMatches("http:","http:"));
+            assertFalse(HtmlParsingUtils.isEqualOrMatches("http:","htTp:"));
+            assertTrue(HtmlParsingUtils.isEqualOrMatches("http:","ht+p:"));
+            assertFalse(HtmlParsingUtils.isEqualOrMatches("ht+p:","http:"));
+        }
+
+        public void testisEqualOrMatchesCaseBlind() throws Exception {
+            assertTrue(HtmlParsingUtils.isEqualOrMatchesCaseBlind("http:","http:"));
+            assertTrue(HtmlParsingUtils.isEqualOrMatchesCaseBlind("http:","htTp:"));
+            assertTrue(HtmlParsingUtils.isEqualOrMatches("http:","ht+p:"));
+            assertFalse(HtmlParsingUtils.isEqualOrMatches("ht+p:","http:"));
+        }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java Sun May 10 18:19:28 2009
@@ -25,125 +25,125 @@
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
 
 public class TestProxyControl  extends TestCase {
-		HTTPSamplerBase sampler;
+        HTTPSamplerBase sampler;
 
-		ProxyControl control;
+        ProxyControl control;
 
-		public TestProxyControl(String name) {
-			super(name);
-		}
-
-		public void setUp() {
-			control = new ProxyControl();
-			control.addIncludedPattern(".*\\.jsp");
-			control.addExcludedPattern(".*apache.org.*");
-			sampler = new HTTPNullSampler();
-		}
-
-		public void testFilter1() throws Exception {
-			sampler.setDomain("jakarta.org");
-			sampler.setPath("index.jsp");
-			assertTrue("Should find jakarta.org/index.jsp", control.filterUrl(sampler));
-		}
-
-		public void testFilter2() throws Exception {
-			sampler.setPath("index.jsp");
-			sampler.setDomain("www.apache.org");
-			assertFalse("Should not match www.apache.org", control.filterUrl(sampler));
-		}
-
-		public void testFilter3() throws Exception {
-			sampler.setPath("header.gif");
-			sampler.setDomain("jakarta.org");
-			assertFalse("Should not match header.gif", control.filterUrl(sampler));
-		}
-
-		public void testContentTypeNoFilters() throws Exception {
-			SampleResult result = new SampleResult();
-			// No filters
-			control.setContentTypeInclude(null);
-			control.setContentTypeExclude(null);
-
-			result.setContentType(null);
-			assertTrue("Should allow if no content-type present", control.filterContentType(result));			
-			result.setContentType("text/html; charset=utf-8");
-			assertTrue("Should allow text/html", control.filterContentType(result));			
-			result.setContentType("image/png");
-			assertTrue("Should allow image/png", control.filterContentType(result));
-
-			// Empty filters
-			control.setContentTypeInclude("");
-			control.setContentTypeExclude("");
-			
-			result.setContentType(null);
-			assertTrue("Should allow if no content-type present", control.filterContentType(result));			
-			result.setContentType("text/html; charset=utf-8");
-			assertTrue("Should allow text/html", control.filterContentType(result));			
-			result.setContentType("image/png");
-			assertTrue("Should allow image/png", control.filterContentType(result));
-			
-			// Non empty filters
-			control.setContentTypeInclude(" ");
-			control.setContentTypeExclude(" ");
-			
-			result.setContentType(null);
-			assertTrue("Should allow if no content-type present", control.filterContentType(result));			
-			result.setContentType("text/html; charset=utf-8");
-			assertFalse("Should not allow text/html", control.filterContentType(result));			
-			result.setContentType("image/png");
-			assertFalse("Should not allow image/png", control.filterContentType(result));
-		}
-		
-		public void testContentTypeInclude() throws Exception {
-			SampleResult result = new SampleResult();
-			control.setContentTypeInclude("text/html|text/ascii");
-
-			result.setContentType(null);
-			assertTrue("Should allow if no content-type present", control.filterContentType(result));			
-			result.setContentType("text/html; charset=utf-8");
-			assertTrue("Should allow text/html", control.filterContentType(result));			
-			result.setContentType("text/css");
-			assertFalse("Should not allow text/css", control.filterContentType(result));
-		}
-		
-		public void testContentTypeExclude() throws Exception {
-			SampleResult result = new SampleResult();
-			control.setContentTypeExclude("text/css");
-
-			result.setContentType(null);
-			assertTrue("Should allow if no content-type present", control.filterContentType(result));			
-			result.setContentType("text/html; charset=utf-8");
-			assertTrue("Should allow text/html", control.filterContentType(result));			
-			result.setContentType("text/css");
-			assertFalse("Should not allow text/css", control.filterContentType(result));
-		}
-		
-		public void testContentTypeIncludeAndExclude() throws Exception {
-			SampleResult result = new SampleResult();
-			// Simple inclusion and exclusion filter
-			control.setContentTypeInclude("text/html|text/ascii");
-			control.setContentTypeExclude("text/css");
-
-			result.setContentType(null);
-			assertTrue("Should allow if no content-type present", control.filterContentType(result));			
-			result.setContentType("text/html; charset=utf-8");
-			assertTrue("Should allow text/html", control.filterContentType(result));			
-			result.setContentType("text/css");
-			assertFalse("Should not allow text/css", control.filterContentType(result));			
-			result.setContentType("image/png");
-			assertFalse("Should not allow image/png", control.filterContentType(result));
-			
-			// Allow all but images
-			control.setContentTypeInclude(null);
-			control.setContentTypeExclude("image/.*");
-			
-			result.setContentType(null);
-			assertTrue("Should allow if no content-type present", control.filterContentType(result));			
-			result.setContentType("text/html; charset=utf-8");
-			assertTrue("Should allow text/html", control.filterContentType(result));			
-			result.setContentType("text/css");
-			assertTrue("Should allow text/css", control.filterContentType(result));			
-			result.setContentType("image/png");
-			assertFalse("Should not allow image/png", control.filterContentType(result));
-		}
+        public TestProxyControl(String name) {
+            super(name);
+        }
+
+        public void setUp() {
+            control = new ProxyControl();
+            control.addIncludedPattern(".*\\.jsp");
+            control.addExcludedPattern(".*apache.org.*");
+            sampler = new HTTPNullSampler();
+        }
+
+        public void testFilter1() throws Exception {
+            sampler.setDomain("jakarta.org");
+            sampler.setPath("index.jsp");
+            assertTrue("Should find jakarta.org/index.jsp", control.filterUrl(sampler));
+        }
+
+        public void testFilter2() throws Exception {
+            sampler.setPath("index.jsp");
+            sampler.setDomain("www.apache.org");
+            assertFalse("Should not match www.apache.org", control.filterUrl(sampler));
+        }
+
+        public void testFilter3() throws Exception {
+            sampler.setPath("header.gif");
+            sampler.setDomain("jakarta.org");
+            assertFalse("Should not match header.gif", control.filterUrl(sampler));
+        }
+
+        public void testContentTypeNoFilters() throws Exception {
+            SampleResult result = new SampleResult();
+            // No filters
+            control.setContentTypeInclude(null);
+            control.setContentTypeExclude(null);
+
+            result.setContentType(null);
+            assertTrue("Should allow if no content-type present", control.filterContentType(result));           
+            result.setContentType("text/html; charset=utf-8");
+            assertTrue("Should allow text/html", control.filterContentType(result));            
+            result.setContentType("image/png");
+            assertTrue("Should allow image/png", control.filterContentType(result));
+
+            // Empty filters
+            control.setContentTypeInclude("");
+            control.setContentTypeExclude("");
+            
+            result.setContentType(null);
+            assertTrue("Should allow if no content-type present", control.filterContentType(result));           
+            result.setContentType("text/html; charset=utf-8");
+            assertTrue("Should allow text/html", control.filterContentType(result));            
+            result.setContentType("image/png");
+            assertTrue("Should allow image/png", control.filterContentType(result));
+            
+            // Non empty filters
+            control.setContentTypeInclude(" ");
+            control.setContentTypeExclude(" ");
+            
+            result.setContentType(null);
+            assertTrue("Should allow if no content-type present", control.filterContentType(result));           
+            result.setContentType("text/html; charset=utf-8");
+            assertFalse("Should not allow text/html", control.filterContentType(result));           
+            result.setContentType("image/png");
+            assertFalse("Should not allow image/png", control.filterContentType(result));
+        }
+        
+        public void testContentTypeInclude() throws Exception {
+            SampleResult result = new SampleResult();
+            control.setContentTypeInclude("text/html|text/ascii");
+
+            result.setContentType(null);
+            assertTrue("Should allow if no content-type present", control.filterContentType(result));           
+            result.setContentType("text/html; charset=utf-8");
+            assertTrue("Should allow text/html", control.filterContentType(result));            
+            result.setContentType("text/css");
+            assertFalse("Should not allow text/css", control.filterContentType(result));
+        }
+        
+        public void testContentTypeExclude() throws Exception {
+            SampleResult result = new SampleResult();
+            control.setContentTypeExclude("text/css");
+
+            result.setContentType(null);
+            assertTrue("Should allow if no content-type present", control.filterContentType(result));           
+            result.setContentType("text/html; charset=utf-8");
+            assertTrue("Should allow text/html", control.filterContentType(result));            
+            result.setContentType("text/css");
+            assertFalse("Should not allow text/css", control.filterContentType(result));
+        }
+        
+        public void testContentTypeIncludeAndExclude() throws Exception {
+            SampleResult result = new SampleResult();
+            // Simple inclusion and exclusion filter
+            control.setContentTypeInclude("text/html|text/ascii");
+            control.setContentTypeExclude("text/css");
+
+            result.setContentType(null);
+            assertTrue("Should allow if no content-type present", control.filterContentType(result));           
+            result.setContentType("text/html; charset=utf-8");
+            assertTrue("Should allow text/html", control.filterContentType(result));            
+            result.setContentType("text/css");
+            assertFalse("Should not allow text/css", control.filterContentType(result));            
+            result.setContentType("image/png");
+            assertFalse("Should not allow image/png", control.filterContentType(result));
+            
+            // Allow all but images
+            control.setContentTypeInclude(null);
+            control.setContentTypeExclude("image/.*");
+            
+            result.setContentType(null);
+            assertTrue("Should allow if no content-type present", control.filterContentType(result));           
+            result.setContentType("text/html; charset=utf-8");
+            assertTrue("Should allow text/html", control.filterContentType(result));            
+            result.setContentType("text/css");
+            assertTrue("Should allow text/css", control.filterContentType(result));         
+            result.setContentType("image/png");
+            assertFalse("Should not allow image/png", control.filterContentType(result));
+        }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/HTTPNullSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/HTTPNullSampler.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/HTTPNullSampler.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/HTTPNullSampler.java Sun May 10 18:19:28 2009
@@ -26,14 +26,14 @@
  */
 public final class HTTPNullSampler extends HTTPSamplerBase {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase#sample(java.net.URL,
-	 *      java.lang.String, boolean, int)
-	 */
-	protected HTTPSampleResult sample(URL u, String s, boolean b, int i) {
-		throw new UnsupportedOperationException("For test purposes only");
-	}
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase#sample(java.net.URL,
+     *      java.lang.String, boolean, int)
+     */
+    protected HTTPSampleResult sample(URL u, String s, boolean b, int i) {
+        throw new UnsupportedOperationException("For test purposes only");
+    }
 
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java Sun May 10 18:19:28 2009
@@ -31,24 +31,24 @@
  */
 public final class NullURLConnection extends URLConnection {
 
-	private Map data = new Properties();
+    private Map data = new Properties();
 
-	public NullURLConnection() throws MalformedURLException {
-		this(new URL("http://localhost"));
-	}
-
-	public NullURLConnection(URL url) {
-		super(url);
-	}
-
-	public void connect() {
-	}
-
-	public void setRequestProperty(String name, String value) {
-		data.put(name, value);
-	}
-
-	public String getRequestProperty(String name) {
-		return (String) data.get(name);
-	}
+    public NullURLConnection() throws MalformedURLException {
+        this(new URL("http://localhost"));
+    }
+
+    public NullURLConnection(URL url) {
+        super(url);
+    }
+
+    public void connect() {
+    }
+
+    public void setRequestProperty(String name, String value) {
+        data.put(name, value);
+    }
+
+    public String getRequestProperty(String name) {
+        return (String) data.get(name);
+    }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java Sun May 10 18:19:28 2009
@@ -31,34 +31,34 @@
 import org.apache.jmeter.protocol.http.util.HTTPArgument;
 
 public class PackageTest extends TestCase {
-	public PackageTest(String arg0) {
-		super(arg0);
-	}
+    public PackageTest(String arg0) {
+        super(arg0);
+    }
 
-	public void testConfiguring() throws Exception {
-		HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
-		configure(sampler);
-	}
+    public void testConfiguring() throws Exception {
+        HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
+        configure(sampler);
+    }
 
-	public void testConfiguring2() throws Exception {
-		HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui2().createTestElement();
-		configure(sampler);
-	}
+    public void testConfiguring2() throws Exception {
+        HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui2().createTestElement();
+        configure(sampler);
+    }
 
-	private void configure(HTTPSamplerBase sampler) throws Exception {
-		sampler.addArgument("arg1", "val1");
-		ConfigTestElement config = (ConfigTestElement) new HttpDefaultsGui().createTestElement();
-		((Arguments) config.getProperty(HTTPSamplerBase.ARGUMENTS).getObjectValue()).addArgument(new HTTPArgument(
-				"config1", "configValue"));
-		config.setRunningVersion(true);
-		sampler.setRunningVersion(true);
-		sampler.setRunningVersion(true);
-		sampler.addTestElement(config);
-		assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
-		sampler.recoverRunningVersion();
-		config.recoverRunningVersion();
-		assertEquals(1, sampler.getArguments().getArgumentCount());
-		sampler.addTestElement(config);
-		assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
-	}
+    private void configure(HTTPSamplerBase sampler) throws Exception {
+        sampler.addArgument("arg1", "val1");
+        ConfigTestElement config = (ConfigTestElement) new HttpDefaultsGui().createTestElement();
+        ((Arguments) config.getProperty(HTTPSamplerBase.ARGUMENTS).getObjectValue()).addArgument(new HTTPArgument(
+                "config1", "configValue"));
+        config.setRunningVersion(true);
+        sampler.setRunningVersion(true);
+        sampler.setRunningVersion(true);
+        sampler.addTestElement(config);
+        assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
+        sampler.recoverRunningVersion();
+        config.recoverRunningVersion();
+        assertEquals(1, sampler.getArguments().getArgumentCount());
+        sampler.addTestElement(config);
+        assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
+    }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java Sun May 10 18:19:28 2009
@@ -41,7 +41,7 @@
 
 public class PostWriterTest extends TestCase {
 
-	private static final Logger log = LoggingManager.getLoggerForClass();
+    private static final Logger log = LoggingManager.getLoggerForClass();
 
     private static final String UTF_8 = "UTF-8";
     private final static String HTTP_ENCODING = "ISO-8859-1";
@@ -80,7 +80,7 @@
      * This method test sending a request which contains both formdata and file content
      */
     public void testSendPostData() throws IOException {
-    	sampler.setMethod(HTTPSamplerBase.POST);
+        sampler.setMethod(HTTPSamplerBase.POST);
         setupFilepart(sampler);
         String titleValue = "mytitle";
         String descriptionValue = "mydescription";
@@ -202,10 +202,10 @@
         String otherEncoding;
         final String fileEncoding = System.getProperty( "file.encoding");// $NON-NLS-1$
         log.info("file.encoding: "+fileEncoding);
-		if (UTF_8.equalsIgnoreCase(fileEncoding) || "UTF8".equalsIgnoreCase(fileEncoding)){// $NON-NLS-1$
-        	otherEncoding="ISO-8859-1"; // $NON-NLS-1$
+        if (UTF_8.equalsIgnoreCase(fileEncoding) || "UTF8".equalsIgnoreCase(fileEncoding)){// $NON-NLS-1$
+            otherEncoding="ISO-8859-1"; // $NON-NLS-1$
         } else {
-        	otherEncoding=UTF_8;
+            otherEncoding=UTF_8;
         }
         log.info("Using other encoding: "+otherEncoding);
         establishConnection();
@@ -217,7 +217,7 @@
         checkContentLength(connection, TEST_FILE_CONTENT.length);        
         checkArraysHaveSameContent(TEST_FILE_CONTENT, connection.getOutputStreamContent());
         // Check that other encoding is not the current encoding
-       	checkArraysHaveDifferentContent(new String(TEST_FILE_CONTENT).getBytes(otherEncoding), connection.getOutputStreamContent());
+        checkArraysHaveDifferentContent(new String(TEST_FILE_CONTENT).getBytes(otherEncoding), connection.getOutputStreamContent());
         
         // If we have both file as body, and form data, then only form data will be sent
         setupFormData(sampler);
@@ -237,7 +237,7 @@
      * This method test sending only a file multipart.
      */
     public void testSendFileData_Multipart() throws IOException {
-    	sampler.setMethod(HTTPSamplerBase.POST);
+        sampler.setMethod(HTTPSamplerBase.POST);
         String fileField = "upload";
         String mimeType = "text/plain";
         File file = temporaryFile;
@@ -291,7 +291,7 @@
      * This method test sending only a formdata, as a multipart/form-data request.
      */
     public void testSendFormData_Multipart() throws IOException {
-    	sampler.setMethod(HTTPSamplerBase.POST);
+        sampler.setMethod(HTTPSamplerBase.POST);
         String titleField = "title";
         String titleValue = "mytitle";
         String descriptionField = "description";
@@ -542,7 +542,7 @@
      * Test method for 'org.apache.jmeter.protocol.http.sampler.postWriter.setHeaders(URLConnection, HTTPSampler)'
      */
     public void testSetHeaders() throws IOException {
-    	sampler.setMethod(HTTPSamplerBase.POST);
+        sampler.setMethod(HTTPSamplerBase.POST);
         setupFilepart(sampler);
         setupFormData(sampler);
         
@@ -813,19 +813,19 @@
     private void checkArraysHaveSameContent(byte[] expected, byte[] actual) throws UnsupportedEncodingException {
         if(expected != null && actual != null) {
             if(expected.length != actual.length) {
-            	System.out.println(new String(expected,UTF_8));
-            	System.out.println("--------------------");
-            	System.out.println(new String(actual,UTF_8));
-            	System.out.println("====================");
+                System.out.println(new String(expected,UTF_8));
+                System.out.println("--------------------");
+                System.out.println(new String(actual,UTF_8));
+                System.out.println("====================");
                 fail("arrays have different length, expected is " + expected.length + ", actual is " + actual.length);
             }
             else {
                 for(int i = 0; i < expected.length; i++) {
                     if(expected[i] != actual[i]) {
-                       	System.out.println(new String(expected,0,i+1));
-                    	System.out.println("--------------------");
-                    	System.out.println(new String(actual,0,i+1));
-                    	System.out.println("====================");
+                        System.out.println(new String(expected,0,i+1));
+                        System.out.println("--------------------");
+                        System.out.println(new String(actual,0,i+1));
+                        System.out.println("====================");
                         fail("byte at position " + i + " is different, expected is " + expected[i] + ", actual is " + actual[i]);
                     }
                 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java Sun May 10 18:19:28 2009
@@ -1,12 +1,12 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.	See the NOTICE file distributed with
+ * 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
+ * the License.  You may obtain a copy of the License at
  *
- *	 http://www.apache.org/licenses/LICENSE-2.0
+ *   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,
@@ -26,20 +26,20 @@
 
 public class PutWriterTest extends TestCase {
 
-	public PutWriterTest(String name) {
-		super(name);
-	}
-
-	public void testSetHeaders() throws Exception {
-		URLConnection uc = new NullURLConnection();
-		HTTPSampler sampler = new HTTPSampler();
-		sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("file1", "", "mime1")});
-		PutWriter pw = new PutWriter();
-		pw.setHeaders(uc, sampler);
-		assertEquals("mime1", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
-		uc = new NullURLConnection();
-		sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("file2", "param2", "mime2")});
-		pw.setHeaders(uc, sampler);
-		assertEquals("mime2", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
-	}
+    public PutWriterTest(String name) {
+        super(name);
+    }
+
+    public void testSetHeaders() throws Exception {
+        URLConnection uc = new NullURLConnection();
+        HTTPSampler sampler = new HTTPSampler();
+        sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("file1", "", "mime1")});
+        PutWriter pw = new PutWriter();
+        pw.setHeaders(uc, sampler);
+        assertEquals("mime1", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
+        uc = new NullURLConnection();
+        sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("file2", "param2", "mime2")});
+        pw.setHeaders(uc, sampler);
+        assertEquals("mime2", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
+    }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java Sun May 10 18:19:28 2009
@@ -54,7 +54,7 @@
  * started when the unit tests are executed.
  */
 public class TestHTTPSamplersAgainstHttpMirrorServer extends JMeterTestCase {
-	private final static int HTTP_SAMPLER = 0;
+    private final static int HTTP_SAMPLER = 0;
     private final static int HTTP_SAMPLER2 = 1;
     
     /** The encodings used for http headers and control information */
@@ -62,7 +62,7 @@
     private static final String US_ASCII = "US-ASCII"; // $NON-NLS-1$
 
     private static final byte[] CRLF = { 0x0d, 0x0A };
-	private static final int MIRROR_PORT = 8081; // Different from TestHTTPMirrorThread port
+    private static final int MIRROR_PORT = 8081; // Different from TestHTTPMirrorThread port
     private static byte[] TEST_FILE_CONTENT;
 
     private static File temporaryFile;
@@ -72,31 +72,31 @@
     }
     
     public static Test suite(){
-    	TestSetup setup = new TestSetup(new TestSuite(TestHTTPSamplersAgainstHttpMirrorServer.class)){
-    	    private HttpMirrorServer httpServer;
-    		protected void setUp() throws Exception {
-	    			httpServer = TestHTTPMirrorThread.startHttpMirror(MIRROR_PORT);
-    		        // Create the test file content
-    		        TEST_FILE_CONTENT = new String("some foo content &?=01234+56789-\u007c\u2aa1\u266a\u0153\u20a1\u0115\u0364\u00c5\u2052\uc385%C3%85").getBytes("UTF-8");
-
-    		        // create a temporary file to make sure we always have a file to give to the PostWriter 
-    		        // Whereever we are or Whatever the current path is.
-    		        temporaryFile = File.createTempFile("TestHTTPSamplersAgainstHttpMirrorServer", "tmp");
-    		        OutputStream output = new FileOutputStream(temporaryFile);
-    		        output.write(TEST_FILE_CONTENT);
-    		        output.flush();
-    		        output.close();
-    		}
-    		
-    		protected void tearDown() throws Exception {
-    		        // Shutdown mirror server
-	    			httpServer.stopServer();
-	    			httpServer = null;
-    		        // delete temporay file
-    		        temporaryFile.delete();
-    		}
-    	};
-    	return setup;
+        TestSetup setup = new TestSetup(new TestSuite(TestHTTPSamplersAgainstHttpMirrorServer.class)){
+            private HttpMirrorServer httpServer;
+            protected void setUp() throws Exception {
+                    httpServer = TestHTTPMirrorThread.startHttpMirror(MIRROR_PORT);
+                    // Create the test file content
+                    TEST_FILE_CONTENT = new String("some foo content &?=01234+56789-\u007c\u2aa1\u266a\u0153\u20a1\u0115\u0364\u00c5\u2052\uc385%C3%85").getBytes("UTF-8");
+
+                    // create a temporary file to make sure we always have a file to give to the PostWriter 
+                    // Whereever we are or Whatever the current path is.
+                    temporaryFile = File.createTempFile("TestHTTPSamplersAgainstHttpMirrorServer", "tmp");
+                    OutputStream output = new FileOutputStream(temporaryFile);
+                    output.write(TEST_FILE_CONTENT);
+                    output.flush();
+                    output.close();
+            }
+            
+            protected void tearDown() throws Exception {
+                    // Shutdown mirror server
+                    httpServer.stopServer();
+                    httpServer = null;
+                    // delete temporay file
+                    temporaryFile.delete();
+            }
+        };
+        return setup;
     }
     
     public void testPostRequest_UrlEncoded() throws Exception {
@@ -1003,10 +1003,10 @@
     }
     
     private void checkHeaderTypeLength(String requestHeaders, String contentType, int contentLen) {
-    	boolean typeOK = isInRequestHeaders(requestHeaders, HTTPSamplerBase.HEADER_CONTENT_TYPE, contentType);
-    	boolean lengOK = isInRequestHeaders(requestHeaders, HTTPSamplerBase.HEADER_CONTENT_LENGTH, Integer.toString(contentLen));
+        boolean typeOK = isInRequestHeaders(requestHeaders, HTTPSamplerBase.HEADER_CONTENT_TYPE, contentType);
+        boolean lengOK = isInRequestHeaders(requestHeaders, HTTPSamplerBase.HEADER_CONTENT_LENGTH, Integer.toString(contentLen));
         if (!typeOK || !lengOK){
-        	fail("Expected type:" + contentType + " & length: " +contentLen + " in:\n"+ requestHeaders);
+            fail("Expected type:" + contentType + " & length: " +contentLen + " in:\n"+ requestHeaders);
         }
     }
    
@@ -1090,21 +1090,21 @@
      * @param httpSampler
      */
     private void setupFileUploadData(
-    		HTTPSamplerBase httpSampler,
-    		boolean isEncoded,
-    		String titleField,
-    		String titleValue,
-    		String descriptionField,
-    		String descriptionValue,
-    		String fileField,
-    		File fileValue,
-    		String fileMimeType) {
-    	// Set the form data
-    	setupFormData(httpSampler, isEncoded, titleField, titleValue, descriptionField, descriptionValue);
-    	// Set the file upload data
-    	httpSampler.setFileField(fileField);
-    	httpSampler.setFilename(fileValue.getAbsolutePath());
-    	httpSampler.setMimetype(fileMimeType);    	
+            HTTPSamplerBase httpSampler,
+            boolean isEncoded,
+            String titleField,
+            String titleValue,
+            String descriptionField,
+            String descriptionValue,
+            String fileField,
+            File fileValue,
+            String fileMimeType) {
+        // Set the form data
+        setupFormData(httpSampler, isEncoded, titleField, titleValue, descriptionField, descriptionValue);
+        // Set the file upload data
+        httpSampler.setFileField(fileField);
+        httpSampler.setFilename(fileValue.getAbsolutePath());
+        httpSampler.setMimetype(fileMimeType);      
     }
 
     /**
@@ -1117,21 +1117,21 @@
     private void checkArraysHaveSameContent(byte[] expected, byte[] actual) throws UnsupportedEncodingException {
         if(expected != null && actual != null) {
             if(expected.length != actual.length) {
-            	System.out.println(">>>>>>>>>>>>>>>>>>>>");
-            	System.out.println(new String(expected,"UTF-8"));
-            	System.out.println("====================");
-            	System.out.println(new String(actual,"UTF-8"));
-            	System.out.println("<<<<<<<<<<<<<<<<<<<<");
+                System.out.println(">>>>>>>>>>>>>>>>>>>>");
+                System.out.println(new String(expected,"UTF-8"));
+                System.out.println("====================");
+                System.out.println(new String(actual,"UTF-8"));
+                System.out.println("<<<<<<<<<<<<<<<<<<<<");
                 fail("arrays have different length, expected is " + expected.length + ", actual is " + actual.length);
             }
             else {
                 for(int i = 0; i < expected.length; i++) {
                     if(expected[i] != actual[i]) {
-                    	System.out.println(">>>>>>>>>>>>>>>>>>>>");
-                       	System.out.println(new String(expected,0,i+1));
-                    	System.out.println("====================");
-                    	System.out.println(new String(actual,0,i+1));
-                    	System.out.println("<<<<<<<<<<<<<<<<<<<<");
+                        System.out.println(">>>>>>>>>>>>>>>>>>>>");
+                        System.out.println(new String(expected,0,i+1));
+                        System.out.println("====================");
+                        System.out.println(new String(actual,0,i+1));
+                        System.out.println("<<<<<<<<<<<<<<<<<<<<");
 /*                        
                         // Useful to when debugging
                         for(int j = 0; j  < expected.length; j++) {

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java Sun May 10 18:19:28 2009
@@ -24,60 +24,60 @@
 import org.apache.jmeter.testelement.property.CollectionProperty;
 
 public class TestHTTPArgument extends TestCase {
-		public TestHTTPArgument(String name) {
-			super(name);
-		}
+        public TestHTTPArgument(String name) {
+            super(name);
+        }
 
-		public void testCloning() throws Exception {
-			HTTPArgument arg = new HTTPArgument("name.?", "value_ here");
-			assertEquals("name.?", arg.getName());
-			assertEquals("value_ here", arg.getValue());
-			assertEquals("name.%3F", arg.getEncodedName());
-			assertEquals("value_+here", arg.getEncodedValue());
-			HTTPArgument clone = (HTTPArgument) arg.clone();
-			assertEquals("name.%3F", clone.getEncodedName());
-			assertEquals("value_+here", clone.getEncodedValue());
-			assertEquals("name.?", clone.getName());
-			assertEquals("value_ here", clone.getValue());
-		}
+        public void testCloning() throws Exception {
+            HTTPArgument arg = new HTTPArgument("name.?", "value_ here");
+            assertEquals("name.?", arg.getName());
+            assertEquals("value_ here", arg.getValue());
+            assertEquals("name.%3F", arg.getEncodedName());
+            assertEquals("value_+here", arg.getEncodedValue());
+            HTTPArgument clone = (HTTPArgument) arg.clone();
+            assertEquals("name.%3F", clone.getEncodedName());
+            assertEquals("value_+here", clone.getEncodedValue());
+            assertEquals("name.?", clone.getName());
+            assertEquals("value_ here", clone.getValue());
+        }
 
-		public void testConversion() throws Exception {
-			Arguments args = new Arguments();
-			args.addArgument("name.?", "value_ here");
-			args.addArgument("name$of property", "value_.+");
-			HTTPArgument.convertArgumentsToHTTP(args);
-			CollectionProperty argList = args.getArguments();
-			HTTPArgument httpArg = (HTTPArgument) argList.get(0).getObjectValue();
-			assertEquals("name.%3F", httpArg.getEncodedName());
-			assertEquals("value_+here", httpArg.getEncodedValue());
-			httpArg = (HTTPArgument) argList.get(1).getObjectValue();
-			assertEquals("name%24of+property", httpArg.getEncodedName());
-			assertEquals("value_.%2B", httpArg.getEncodedValue());
-		}
-		
-		public void testEncoding() throws Exception {
-			HTTPArgument arg;
-			arg = new HTTPArgument("name.?", "value_ here", false);
-			assertEquals("name.?", arg.getName());
-			assertEquals("value_ here", arg.getValue());
-			assertEquals("name.%3F", arg.getEncodedName());
-			assertEquals("value_+here", arg.getEncodedValue());
-			// Show that can bypass encoding:
+        public void testConversion() throws Exception {
+            Arguments args = new Arguments();
+            args.addArgument("name.?", "value_ here");
+            args.addArgument("name$of property", "value_.+");
+            HTTPArgument.convertArgumentsToHTTP(args);
+            CollectionProperty argList = args.getArguments();
+            HTTPArgument httpArg = (HTTPArgument) argList.get(0).getObjectValue();
+            assertEquals("name.%3F", httpArg.getEncodedName());
+            assertEquals("value_+here", httpArg.getEncodedValue());
+            httpArg = (HTTPArgument) argList.get(1).getObjectValue();
+            assertEquals("name%24of+property", httpArg.getEncodedName());
+            assertEquals("value_.%2B", httpArg.getEncodedValue());
+        }
+        
+        public void testEncoding() throws Exception {
+            HTTPArgument arg;
+            arg = new HTTPArgument("name.?", "value_ here", false);
+            assertEquals("name.?", arg.getName());
+            assertEquals("value_ here", arg.getValue());
+            assertEquals("name.%3F", arg.getEncodedName());
+            assertEquals("value_+here", arg.getEncodedValue());
+            // Show that can bypass encoding:
             arg.setAlwaysEncoded(false);
             assertEquals("name.?", arg.getEncodedName());
             assertEquals("value_ here", arg.getEncodedValue());
             
             // The sample does not use a valid encoding
-			arg = new HTTPArgument("name.?", "value_ here", true);
-			assertEquals("name.?", arg.getName());
-			assertEquals("value_ here", arg.getValue());
+            arg = new HTTPArgument("name.?", "value_ here", true);
+            assertEquals("name.?", arg.getName());
+            assertEquals("value_ here", arg.getValue());
             assertEquals("name.%3F", arg.getEncodedName());
             assertEquals("value_+here", arg.getEncodedValue());
-			arg.setAlwaysEncoded(false); // by default, name/value are encoded on fetch 
-			assertEquals("name.?", arg.getEncodedName());
-			assertEquals("value_ here", arg.getEncodedValue());
-			
-			// Try a real encoded argument
+            arg.setAlwaysEncoded(false); // by default, name/value are encoded on fetch 
+            assertEquals("name.?", arg.getEncodedName());
+            assertEquals("value_ here", arg.getEncodedValue());
+            
+            // Try a real encoded argument
             arg = new HTTPArgument("name.%3F", "value_+here", true);
             assertEquals("name.?", arg.getName());
             assertEquals("value_ here", arg.getValue());
@@ -92,5 +92,5 @@
             arg.setAlwaysEncoded(false);
             assertEquals("", arg.getEncodedName());
             assertEquals("\00\01\07", arg.getEncodedValue());
-		}
+        }
 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java?rev=773382&r1=773381&r2=773382&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java Sun May 10 18:19:28 2009
@@ -21,46 +21,46 @@
 import junit.framework.TestCase;
 
 public class TestHTTPFileArg extends TestCase {
-	public TestHTTPFileArg(String name) {
-		super(name);
-	}
+    public TestHTTPFileArg(String name) {
+        super(name);
+    }
 
-	public void testConstructors() throws Exception {
-		HTTPFileArg file = new HTTPFileArg();
-		assertEquals("no parameter failure", "", file.getPath());
-		assertEquals("no parameter failure", "", file.getParamName());
-		assertEquals("no parameter failure", "", file.getMimeType());
-		file = new HTTPFileArg("path");
-		assertEquals("single parameter failure", "path", file.getPath());
-		assertEquals("single parameter failure", "", file.getParamName());
-		assertEquals("single parameter failure", "", file.getMimeType());
-		file = new HTTPFileArg("path", "param", "mimetype");
-		assertEquals("three parameter failure", "path", file.getPath());
-		assertEquals("three parameter failure", "param", file.getParamName());
-		assertEquals("three parameter failure", "mimetype", file.getMimeType());
-		HTTPFileArg file2 = new HTTPFileArg(file);
-		assertEquals("copy constructor failure", "path", file2.getPath());
-		assertEquals("copy constructor failure", "param", file2.getParamName());
-		assertEquals("copy constructor failure", "mimetype", file2.getMimeType());
-	}
+    public void testConstructors() throws Exception {
+        HTTPFileArg file = new HTTPFileArg();
+        assertEquals("no parameter failure", "", file.getPath());
+        assertEquals("no parameter failure", "", file.getParamName());
+        assertEquals("no parameter failure", "", file.getMimeType());
+        file = new HTTPFileArg("path");
+        assertEquals("single parameter failure", "path", file.getPath());
+        assertEquals("single parameter failure", "", file.getParamName());
+        assertEquals("single parameter failure", "", file.getMimeType());
+        file = new HTTPFileArg("path", "param", "mimetype");
+        assertEquals("three parameter failure", "path", file.getPath());
+        assertEquals("three parameter failure", "param", file.getParamName());
+        assertEquals("three parameter failure", "mimetype", file.getMimeType());
+        HTTPFileArg file2 = new HTTPFileArg(file);
+        assertEquals("copy constructor failure", "path", file2.getPath());
+        assertEquals("copy constructor failure", "param", file2.getParamName());
+        assertEquals("copy constructor failure", "mimetype", file2.getMimeType());
+    }
 
-	public void testGettersSetters() throws Exception {
-		HTTPFileArg file = new HTTPFileArg();
-		assertEquals("", file.getPath());
-		assertEquals("", file.getParamName());
-		assertEquals("", file.getMimeType());
-		file.setPath("path");
-		file.setParamName("param");
-		file.setMimeType("mimetype");
-		file.setHeader("header");
-		assertEquals("path", file.getPath());
-		assertEquals("param", file.getParamName());
-		assertEquals("mimetype", file.getMimeType());
-		assertEquals("header", file.getHeader());
-	}
+    public void testGettersSetters() throws Exception {
+        HTTPFileArg file = new HTTPFileArg();
+        assertEquals("", file.getPath());
+        assertEquals("", file.getParamName());
+        assertEquals("", file.getMimeType());
+        file.setPath("path");
+        file.setParamName("param");
+        file.setMimeType("mimetype");
+        file.setHeader("header");
+        assertEquals("path", file.getPath());
+        assertEquals("param", file.getParamName());
+        assertEquals("mimetype", file.getMimeType());
+        assertEquals("header", file.getHeader());
+    }
 
-	public void testToString() throws Exception {
-		HTTPFileArg file = new HTTPFileArg("path1", "param1", "mimetype1");
-		assertEquals("path:'path1'|param:'param1'|mimetype:'mimetype1'", file.toString());
-	}
+    public void testToString() throws Exception {
+        HTTPFileArg file = new HTTPFileArg("path1", "param1", "mimetype1");
+        assertEquals("path:'path1'|param:'param1'|mimetype:'mimetype1'", file.toString());
+    }
 }



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