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 [3/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/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=618404&r1=618403&r2=618404&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 Mon Feb  4 11:55:48 2008
@@ -1,395 +1,395 @@
-/*
- * 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.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.Socket;
-/*
-import org.apache.jmeter.engine.util.ValueReplacer;
-import org.apache.jmeter.protocol.http.control.HttpMirrorControl;
-import org.apache.jmeter.protocol.http.sampler.HTTPSampler2;
-import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
-import org.apache.jmeter.protocol.http.util.EncoderCache;
-import org.apache.jmeter.protocol.http.util.HTTPArgument;
-import org.apache.jmeter.testelement.TestPlan;
-import org.apache.jmeter.threads.JMeterContextService;
-import org.apache.jmeter.threads.JMeterVariables;
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.oro.text.regex.MatchResult;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.PatternMatcherInput;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
-*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.extensions.TestSetup;
-
-/**
- * Class for testing the HTTPMirrorThread, which is handling the
- * incoming requests for the HTTPMirrorServer
- */
-public class TestHTTPMirrorThread extends TestCase {
-    /** The encodings used for http headers and control information */
-    private final static String ISO_8859_1 = "ISO-8859-1"; // $NON-NLS-1$
-    private final static String UTF_8 = "UTF-8"; // $NON-NLS-1$
-
-    private static final byte[] CRLF = { 0x0d, 0x0a };
-    private final static int HTTP_SERVER_PORT = 8080;
-
-    public TestHTTPMirrorThread(String arg0) {
-        super(arg0);
-    }
-    
-    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;
-    };
-
-    /**
-     * Utility method to handle starting the HttpMirrorServer for testing.
-     * Also used by TestHTTPSamplersAgainstHttpMirrorServer
-     */
-    public static HttpMirrorServer startHttpMirror(int port) throws Exception {
-    	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
-        }
-        
-        if (!server.isAlive()){
-        	throw new Exception("Could not start mirror server on port: "+port);
-        }
-    	return server;
-    }
-
-    public void testGetRequest() throws Exception {        
-        // Connect to the http server, and do a simple http get
-        Socket clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
-        OutputStream outputStream = clientSocket.getOutputStream();
-        InputStream inputStream = clientSocket.getInputStream();
-        
-        // Write to the socket
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        // Headers
-        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write("Host: localhost".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(CRLF);
-        bos.close();
-        outputStream.write(bos.toByteArray());
-        
-        // Read the response
-        ByteArrayOutputStream response = new ByteArrayOutputStream();        
-        byte[] buffer = new byte[1024];
-        int length = 0;
-        while(( length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
-        }
-        response.close();
-        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());   		
-        // Check that the request and response matches
-        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
-        // Close the connection
-        clientSocket.close();
-
-        // Connect to the http server, and do a simple http get, with
-        // a pause in the middle of transmitting the header
-        clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
-        outputStream = clientSocket.getOutputStream();
-        inputStream = clientSocket.getInputStream();
-        
-        // Write to the socket
-        bos = new ByteArrayOutputStream();
-        // Headers
-        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        // Write the start of the headers, and then sleep, so that the mirror
-        // thread will have to block to wait for more data to appear
-        bos.close();
-        byte[] firstChunk = bos.toByteArray(); 
-        outputStream.write(firstChunk);
-        Thread.sleep(300);
-        // Write the rest of the headers
-        bos = new ByteArrayOutputStream();
-        bos.write("Host: localhost".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(CRLF);
-        bos.close();
-        byte[] secondChunk = bos.toByteArray(); 
-        outputStream.write(secondChunk);
-        // Read the response
-        response = new ByteArrayOutputStream();        
-        buffer = new byte[1024];
-        length = 0;
-        while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
-        }
-        response.close();
-        mirroredResponse = getMirroredResponse(response.toByteArray());
-        // The content sent
-        bos = new ByteArrayOutputStream();
-        bos.write(firstChunk);
-        bos.write(secondChunk);
-        bos.close();        
-        // Check that the request and response matches
-        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
-        // Close the connection
-        clientSocket.close();        
-    }
-
-    public void testPostRequest() throws Exception {
-        // Connect to the http server, and do a simple http post
-        Socket clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
-        OutputStream outputStream = clientSocket.getOutputStream();
-        InputStream inputStream = clientSocket.getInputStream();
-        // Construct body
-        StringBuffer postBodyBuffer = new StringBuffer();
-        for(int i = 0; i < 1000; i++) {
-        	postBodyBuffer.append("abc");
-        }
-        byte[] postBody = postBodyBuffer.toString().getBytes(ISO_8859_1);
-        
-        // Write to the socket
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        // Headers
-        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write("Host: localhost".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(("Content-type: text/plain; charset=" + ISO_8859_1).getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(("Content-length: " + postBody.length).getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(CRLF);
-        bos.write(postBody);
-        bos.close();
-        // Write the headers and body
-        outputStream.write(bos.toByteArray());
-        // Read the response
-        ByteArrayOutputStream response = new ByteArrayOutputStream();        
-        byte[] buffer = new byte[1024];
-        int length = 0;
-        while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
-        }
-        response.close();
-        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());   		
-        // Check that the request and response matches
-        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
-        // Close the connection
-        clientSocket.close();
-
-        // Connect to the http server, and do a simple http post, with
-        // a pause after transmitting the headers
-        clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
-        outputStream = clientSocket.getOutputStream();
-        inputStream = clientSocket.getInputStream();
-        
-        // Write to the socket
-        bos = new ByteArrayOutputStream();
-        // Headers
-        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write("Host: localhost".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(("Content-type: text/plain; charset=" + ISO_8859_1).getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(("Content-length: " + postBody.length).getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(CRLF);
-        bos.close();
-        // Write the headers, and then sleep
-        bos.close();
-        byte[] firstChunk = bos.toByteArray(); 
-        outputStream.write(firstChunk);
-        Thread.sleep(300);
-        
-        // Write the body
-        byte[] secondChunk = postBody;         
-        outputStream.write(secondChunk);
-        // Read the response
-        response = new ByteArrayOutputStream();        
-        buffer = new byte[1024];
-        length = 0;
-        while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
-        }
-        response.close();
-        mirroredResponse = getMirroredResponse(response.toByteArray());
-        // The content sent
-        bos = new ByteArrayOutputStream();
-        bos.write(firstChunk);
-        bos.write(secondChunk);
-        bos.close();        
-        // Check that the request and response matches
-        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
-        // Close the connection
-        clientSocket.close();
-        
-        // Connect to the http server, and do a simple http post with utf-8
-        // encoding of the body, which caused problems when reader/writer
-        // classes were used in the HttpMirrorThread
-        clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
-        outputStream = clientSocket.getOutputStream();
-        inputStream = clientSocket.getInputStream();
-        // Construct body
-        postBodyBuffer = new StringBuffer();
-        for(int i = 0; i < 1000; i++) {
-        	postBodyBuffer.append("\u0364\u00c5\u2052");
-        }
-        postBody = postBodyBuffer.toString().getBytes(UTF_8);
-        
-        // Write to the socket
-        bos = new ByteArrayOutputStream();
-        // Headers
-        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write("Host: localhost".getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(("Content-type: text/plain; charset=" + UTF_8).getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(("Content-length: " + postBody.length).getBytes(ISO_8859_1));
-        bos.write(CRLF);
-        bos.write(CRLF);
-        bos.close();
-        // Write the headers, and then sleep
-        bos.close();
-        firstChunk = bos.toByteArray(); 
-        outputStream.write(firstChunk);
-        Thread.sleep(300);
-        
-        // Write the body
-        secondChunk = postBody;         
-        outputStream.write(secondChunk);
-        // Read the response
-        response = new ByteArrayOutputStream();        
-        buffer = new byte[1024];
-        length = 0;
-        while((length = inputStream.read(buffer)) != -1) {
-        	response.write(buffer, 0, length);
-        }
-        response.close();
-        mirroredResponse = getMirroredResponse(response.toByteArray());
-        // The content sent
-        bos = new ByteArrayOutputStream();
-        bos.write(firstChunk);
-        bos.write(secondChunk);
-        bos.close();
-        // Check that the request and response matches       
-        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
-        // Close the connection
-        clientSocket.close();
-    }
-/*
-    public void testPostRequestChunked() throws Exception {
-        // TODO - implement testing of chunked post request
-    }
-*/    
-
-    /**
-     * Check that the the two byte arrays have identical content
-     * 
-     * @param expected
-     * @param actual
-     * @throws UnsupportedEncodingException 
-     */
-    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("<<<<<<<<<<<<<<<<<<<<");
-                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("<<<<<<<<<<<<<<<<<<<<");
-/*
-                     	// 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]);
-                    }
-                }
-            }
-        }
-        else {
-            fail("expected or actual byte arrays were null");
-        }
-    }
-    
-    private byte[] getMirroredResponse(byte[] allResponse) {
-    	// 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;
-   			}
-   		}
-        byte[] mirrorResponse = new byte[allResponse.length - startOfMirrorResponse]; 
-        System.arraycopy(allResponse, startOfMirrorResponse, mirrorResponse, 0, mirrorResponse.length);
-        return mirrorResponse;    	
-    }
-}
+/*
+ * 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.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.Socket;
+/*
+import org.apache.jmeter.engine.util.ValueReplacer;
+import org.apache.jmeter.protocol.http.control.HttpMirrorControl;
+import org.apache.jmeter.protocol.http.sampler.HTTPSampler2;
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.protocol.http.util.EncoderCache;
+import org.apache.jmeter.protocol.http.util.HTTPArgument;
+import org.apache.jmeter.testelement.TestPlan;
+import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterVariables;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternMatcherInput;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
+*/
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.extensions.TestSetup;
+
+/**
+ * Class for testing the HTTPMirrorThread, which is handling the
+ * incoming requests for the HTTPMirrorServer
+ */
+public class TestHTTPMirrorThread extends TestCase {
+    /** The encodings used for http headers and control information */
+    private final static String ISO_8859_1 = "ISO-8859-1"; // $NON-NLS-1$
+    private final static String UTF_8 = "UTF-8"; // $NON-NLS-1$
+
+    private static final byte[] CRLF = { 0x0d, 0x0a };
+    private final static int HTTP_SERVER_PORT = 8080;
+
+    public TestHTTPMirrorThread(String arg0) {
+        super(arg0);
+    }
+    
+    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;
+    };
+
+    /**
+     * Utility method to handle starting the HttpMirrorServer for testing.
+     * Also used by TestHTTPSamplersAgainstHttpMirrorServer
+     */
+    public static HttpMirrorServer startHttpMirror(int port) throws Exception {
+    	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
+        }
+        
+        if (!server.isAlive()){
+        	throw new Exception("Could not start mirror server on port: "+port);
+        }
+    	return server;
+    }
+
+    public void testGetRequest() throws Exception {        
+        // Connect to the http server, and do a simple http get
+        Socket clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
+        OutputStream outputStream = clientSocket.getOutputStream();
+        InputStream inputStream = clientSocket.getInputStream();
+        
+        // Write to the socket
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        // Headers
+        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write("Host: localhost".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(CRLF);
+        bos.close();
+        outputStream.write(bos.toByteArray());
+        
+        // Read the response
+        ByteArrayOutputStream response = new ByteArrayOutputStream();        
+        byte[] buffer = new byte[1024];
+        int length = 0;
+        while(( length = inputStream.read(buffer)) != -1) {
+        	response.write(buffer, 0, length);
+        }
+        response.close();
+        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());   		
+        // Check that the request and response matches
+        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
+        // Close the connection
+        clientSocket.close();
+
+        // Connect to the http server, and do a simple http get, with
+        // a pause in the middle of transmitting the header
+        clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
+        outputStream = clientSocket.getOutputStream();
+        inputStream = clientSocket.getInputStream();
+        
+        // Write to the socket
+        bos = new ByteArrayOutputStream();
+        // Headers
+        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        // Write the start of the headers, and then sleep, so that the mirror
+        // thread will have to block to wait for more data to appear
+        bos.close();
+        byte[] firstChunk = bos.toByteArray(); 
+        outputStream.write(firstChunk);
+        Thread.sleep(300);
+        // Write the rest of the headers
+        bos = new ByteArrayOutputStream();
+        bos.write("Host: localhost".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(CRLF);
+        bos.close();
+        byte[] secondChunk = bos.toByteArray(); 
+        outputStream.write(secondChunk);
+        // Read the response
+        response = new ByteArrayOutputStream();        
+        buffer = new byte[1024];
+        length = 0;
+        while((length = inputStream.read(buffer)) != -1) {
+        	response.write(buffer, 0, length);
+        }
+        response.close();
+        mirroredResponse = getMirroredResponse(response.toByteArray());
+        // The content sent
+        bos = new ByteArrayOutputStream();
+        bos.write(firstChunk);
+        bos.write(secondChunk);
+        bos.close();        
+        // Check that the request and response matches
+        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
+        // Close the connection
+        clientSocket.close();        
+    }
+
+    public void testPostRequest() throws Exception {
+        // Connect to the http server, and do a simple http post
+        Socket clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
+        OutputStream outputStream = clientSocket.getOutputStream();
+        InputStream inputStream = clientSocket.getInputStream();
+        // Construct body
+        StringBuffer postBodyBuffer = new StringBuffer();
+        for(int i = 0; i < 1000; i++) {
+        	postBodyBuffer.append("abc");
+        }
+        byte[] postBody = postBodyBuffer.toString().getBytes(ISO_8859_1);
+        
+        // Write to the socket
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        // Headers
+        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write("Host: localhost".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(("Content-type: text/plain; charset=" + ISO_8859_1).getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(("Content-length: " + postBody.length).getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(CRLF);
+        bos.write(postBody);
+        bos.close();
+        // Write the headers and body
+        outputStream.write(bos.toByteArray());
+        // Read the response
+        ByteArrayOutputStream response = new ByteArrayOutputStream();        
+        byte[] buffer = new byte[1024];
+        int length = 0;
+        while((length = inputStream.read(buffer)) != -1) {
+        	response.write(buffer, 0, length);
+        }
+        response.close();
+        byte[] mirroredResponse = getMirroredResponse(response.toByteArray());   		
+        // Check that the request and response matches
+        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
+        // Close the connection
+        clientSocket.close();
+
+        // Connect to the http server, and do a simple http post, with
+        // a pause after transmitting the headers
+        clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
+        outputStream = clientSocket.getOutputStream();
+        inputStream = clientSocket.getInputStream();
+        
+        // Write to the socket
+        bos = new ByteArrayOutputStream();
+        // Headers
+        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write("Host: localhost".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(("Content-type: text/plain; charset=" + ISO_8859_1).getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(("Content-length: " + postBody.length).getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(CRLF);
+        bos.close();
+        // Write the headers, and then sleep
+        bos.close();
+        byte[] firstChunk = bos.toByteArray(); 
+        outputStream.write(firstChunk);
+        Thread.sleep(300);
+        
+        // Write the body
+        byte[] secondChunk = postBody;         
+        outputStream.write(secondChunk);
+        // Read the response
+        response = new ByteArrayOutputStream();        
+        buffer = new byte[1024];
+        length = 0;
+        while((length = inputStream.read(buffer)) != -1) {
+        	response.write(buffer, 0, length);
+        }
+        response.close();
+        mirroredResponse = getMirroredResponse(response.toByteArray());
+        // The content sent
+        bos = new ByteArrayOutputStream();
+        bos.write(firstChunk);
+        bos.write(secondChunk);
+        bos.close();        
+        // Check that the request and response matches
+        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
+        // Close the connection
+        clientSocket.close();
+        
+        // Connect to the http server, and do a simple http post with utf-8
+        // encoding of the body, which caused problems when reader/writer
+        // classes were used in the HttpMirrorThread
+        clientSocket = new Socket("localhost", HTTP_SERVER_PORT);
+        outputStream = clientSocket.getOutputStream();
+        inputStream = clientSocket.getInputStream();
+        // Construct body
+        postBodyBuffer = new StringBuffer();
+        for(int i = 0; i < 1000; i++) {
+        	postBodyBuffer.append("\u0364\u00c5\u2052");
+        }
+        postBody = postBodyBuffer.toString().getBytes(UTF_8);
+        
+        // Write to the socket
+        bos = new ByteArrayOutputStream();
+        // Headers
+        bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write("Host: localhost".getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(("Content-type: text/plain; charset=" + UTF_8).getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(("Content-length: " + postBody.length).getBytes(ISO_8859_1));
+        bos.write(CRLF);
+        bos.write(CRLF);
+        bos.close();
+        // Write the headers, and then sleep
+        bos.close();
+        firstChunk = bos.toByteArray(); 
+        outputStream.write(firstChunk);
+        Thread.sleep(300);
+        
+        // Write the body
+        secondChunk = postBody;         
+        outputStream.write(secondChunk);
+        // Read the response
+        response = new ByteArrayOutputStream();        
+        buffer = new byte[1024];
+        length = 0;
+        while((length = inputStream.read(buffer)) != -1) {
+        	response.write(buffer, 0, length);
+        }
+        response.close();
+        mirroredResponse = getMirroredResponse(response.toByteArray());
+        // The content sent
+        bos = new ByteArrayOutputStream();
+        bos.write(firstChunk);
+        bos.write(secondChunk);
+        bos.close();
+        // Check that the request and response matches       
+        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
+        // Close the connection
+        clientSocket.close();
+    }
+/*
+    public void testPostRequestChunked() throws Exception {
+        // TODO - implement testing of chunked post request
+    }
+*/    
+
+    /**
+     * Check that the the two byte arrays have identical content
+     * 
+     * @param expected
+     * @param actual
+     * @throws UnsupportedEncodingException 
+     */
+    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("<<<<<<<<<<<<<<<<<<<<");
+                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("<<<<<<<<<<<<<<<<<<<<");
+/*
+                     	// 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]);
+                    }
+                }
+            }
+        }
+        else {
+            fail("expected or actual byte arrays were null");
+        }
+    }
+    
+    private byte[] getMirroredResponse(byte[] allResponse) {
+    	// 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;
+   			}
+   		}
+        byte[] mirrorResponse = new byte[allResponse.length - startOfMirrorResponse]; 
+        System.arraycopy(allResponse, startOfMirrorResponse, mirrorResponse, 0, mirrorResponse.length);
+        return mirrorResponse;    	
+    }
+}

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

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java Mon Feb  4 11:55:48 2008
@@ -1,301 +1,301 @@
-/*
- * 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.parser;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.TreeSet;
-import java.util.Vector;
-
-import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
-import junit.framework.TestSuite;
-
-public class TestHTMLParser extends JMeterTestCase {
-    private static final Logger log = LoggingManager.getLoggerForClass();
-
-    public TestHTMLParser(String arg0) {
-        super(arg0);
-    }
-        private String parserName;
-
-        private int testNumber = 0;
-
-        public TestHTMLParser(String name, int test) {
-            super(name);
-            testNumber = test;
-        }
-
-        public TestHTMLParser(String name, String parser, int test) {
-            super(name);
-            testNumber = test;
-            parserName = parser;
-        }
-
-        private static class StaticTestClass // Can't instantiate
-        {
-            private StaticTestClass() {
-            };
-        }
-
-        private class TestClass // Can't instantiate
-        {
-            private TestClass() {
-            };
-        }
-
-        private static class TestData {
-            private String fileName;
-
-            private String baseURL;
-
-            private String expectedSet;
-
-            private String expectedList;
-
-            private TestData(String f, String b, String s, String l) {
-                fileName = f;
-                baseURL = b;
-                expectedSet = s;
-                expectedList = l;
-            }
-
-//            private TestData(String f, String b, String s) {
-//                this(f, b, s, null);
-//            }
-        }
-
-        // List of parsers to test. Should probably be derived automatically
-        private static final String[] PARSERS = { 
-            "org.apache.jmeter.protocol.http.parser.HtmlParserHTMLParser",
-            "org.apache.jmeter.protocol.http.parser.JTidyHTMLParser",
-            "org.apache.jmeter.protocol.http.parser.RegexpHTMLParser" 
-            };
-
-        private static final TestData[] TESTS = new TestData[] {
-                new TestData("testfiles/HTMLParserTestCase.html",
-                        "http://localhost/mydir/myfile.html",
-                        "testfiles/HTMLParserTestCase.set",
-                        "testfiles/HTMLParserTestCase.all"),
-                new TestData("testfiles/HTMLParserTestCaseWithBaseHRef.html", 
-                        "http://localhost/mydir/myfile.html",
-                        "testfiles/HTMLParserTestCaseBase.set", 
-                        "testfiles/HTMLParserTestCaseBase.all"),
-                new TestData("testfiles/HTMLParserTestCaseWithBaseHRef2.html", 
-                        "http://localhost/mydir/myfile.html",
-                         "testfiles/HTMLParserTestCaseBase.set", 
-                         "testfiles/HTMLParserTestCaseBase.all"),
-                new TestData("testfiles/HTMLParserTestCaseWithMissingBaseHRef.html",
-                        "http://localhost/mydir/images/myfile.html", 
-                        "testfiles/HTMLParserTestCaseBase.set",
-                        "testfiles/HTMLParserTestCaseBase.all"),
-                new TestData("testfiles/HTMLParserTestCase2.html",
-                        "http:", "", ""), // Dummy as the file has no entries
-                new TestData("testfiles/HTMLParserTestCase3.html",
-                        "http:", "", ""), // Dummy as the file has no entries
-                new TestData("testfiles/HTMLParserTestCaseWithComments.html",
-                        "http://localhost/mydir/myfile.html",
-                        "testfiles/HTMLParserTestCaseBase.set",
-                        "testfiles/HTMLParserTestCaseBase.all"),
-                new TestData("testfiles/HTMLScript.html",
-                        "http://localhost/",
-                        "testfiles/HTMLScript.set",
-                        "testfiles/HTMLScript.all"),
-                new TestData("testfiles/HTMLParserTestFrames.html",
-                        "http://localhost/",
-                        "testfiles/HTMLParserTestFrames.all",
-                        "testfiles/HTMLParserTestFrames.all"), 
-                         };
-
-        public static junit.framework.Test suite() {
-            TestSuite suite = new TestSuite("TestHTMLParser");
-            suite.addTest(new TestHTMLParser("testDefaultParser"));
-            suite.addTest(new TestHTMLParser("testParserDefault"));
-            suite.addTest(new TestHTMLParser("testParserMissing"));
-            suite.addTest(new TestHTMLParser("testNotParser"));
-            suite.addTest(new TestHTMLParser("testNotCreatable"));
-            suite.addTest(new TestHTMLParser("testNotCreatableStatic"));
-            for (int i = 0; i < PARSERS.length; i++) {
-                TestSuite ps = new TestSuite(PARSERS[i]);// Identify subtests
-                ps.addTest(new TestHTMLParser("testParserProperty", PARSERS[i], 0));
-                for (int j = 0; j < TESTS.length; j++) {
-                    TestSuite ts = new TestSuite(TESTS[j].fileName);
-                    ts.addTest(new TestHTMLParser("testParserSet", PARSERS[i], j));
-                    ts.addTest(new TestHTMLParser("testParserList", PARSERS[i], j));
-                    ps.addTest(ts);
-                }
-                suite.addTest(ps);
-            }
-            return suite;
-        }
-
-        // Test if can instantiate parser using property name
-        public void testParserProperty() throws Exception {
-            Properties p = JMeterUtils.getJMeterProperties();
-            if (p == null) {
-                p = JMeterUtils.getProperties("jmeter.properties");
-            }
-            p.setProperty(HTMLParser.PARSER_CLASSNAME, parserName);
-            HTMLParser.getParser();
-        }
-
-        public void testDefaultParser() throws Exception {
-            HTMLParser.getParser();
-        }
-
-        public void testParserDefault() throws Exception {
-            HTMLParser.getParser(HTMLParser.DEFAULT_PARSER);
-        }
-
-        public void testParserMissing() throws Exception {
-            try {
-                HTMLParser.getParser("no.such.parser");
-                fail("Should not have been able to create the parser");
-            } catch (HTMLParseError e) {
-                if (e.getCause() instanceof ClassNotFoundException) {
-                    // This is OK
-                } else {
-                    throw e;
-                }
-            }
-        }
-
-        public void testNotParser() throws Exception {
-            try {
-                HTMLParser.getParser("java.lang.String");
-                fail("Should not have been able to create the parser");
-            } catch (HTMLParseError e) {
-                if (e.getCause() instanceof ClassCastException)
-                    return;
-                throw e;
-            }
-        }
-
-        public void testNotCreatable() throws Exception {
-            try {
-                HTMLParser.getParser(TestClass.class.getName());
-                fail("Should not have been able to create the parser");
-            } catch (HTMLParseError e) {
-                if (e.getCause() instanceof InstantiationException)
-                    return;
-                throw e;
-            }
-        }
-
-        public void testNotCreatableStatic() throws Exception {
-            try {
-                HTMLParser.getParser(StaticTestClass.class.getName());
-                fail("Should not have been able to create the parser");
-            } catch (HTMLParseError e) {
-                if (e.getCause() instanceof ClassCastException)
-                    return;
-                if (e.getCause() instanceof IllegalAccessException)
-                    return;
-                throw e;
-            }
-        }
-
-        public void testParserSet() throws Exception {
-            HTMLParser p = HTMLParser.getParser(parserName);
-            filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseURL, TESTS[testNumber].expectedSet, null,
-                    false);
-        }
-
-        public void testParserList() throws Exception {
-            HTMLParser p = HTMLParser.getParser(parserName);
-            filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseURL, TESTS[testNumber].expectedList,
-                    new Vector(), true);
-        }
-
-        private static void filetest(HTMLParser p, String file, String url, String resultFile, Collection c,
-                boolean orderMatters) // Does the order matter?
-                throws Exception {
-            String parserName = p.getClass().getName().substring("org.apache.jmeter.protocol.http.parser.".length());
-            String fname = file.substring(file.indexOf("/")+1);
-            log.debug("file   " + file);
-            File f = findTestFile(file);
-            byte[] buffer = new byte[(int) f.length()];
-            int len = new FileInputStream(f).read(buffer);
-            assertEquals(len, buffer.length);
-            Iterator result;
-            if (c == null) {
-                result = p.getEmbeddedResourceURLs(buffer, new URL(url));
-            } else {
-                result = p.getEmbeddedResourceURLs(buffer, new URL(url), c);
-            }
-            /*
-             * TODO: Exact ordering is only required for some tests; change the
-             * comparison to do a set compare where necessary.
-             */
-            Iterator expected;
-            if (orderMatters) {
-                expected = getFile(resultFile).iterator();
-            } else {
-                // Convert both to Sets
-                expected = new TreeSet(getFile(resultFile)).iterator();
-                TreeSet temp = new TreeSet(new Comparator() {
-                    public int compare(Object o1, Object o2) {
-                        return (o1.toString().compareTo(o2.toString()));
-                    }
-                });
-                while (result.hasNext()) {
-                    temp.add(result.next());
-                }
-                result = temp.iterator();
-            }
-
-            while (expected.hasNext()) {
-                Object next = expected.next();
-                assertTrue(fname+"::"+parserName + "::Expecting another result " + next, result.hasNext());
-                try {
-                    assertEquals(fname+"::"+parserName + "(next)", next, ((URL) result.next()).toString());
-                } catch (ClassCastException e) {
-                    fail(fname+"::"+parserName + "::Expected URL, but got " + e.toString());
-                }
-            }
-            assertFalse(fname+"::"+parserName + "::Should have reached the end of the results", result.hasNext());
-        }
-
-        // Get expected results as a List
-        private static List getFile(String file) throws Exception {
-            ArrayList al = new ArrayList();
-            if (file != null && file.length() > 0) {
-                BufferedReader br = new BufferedReader(new FileReader(findTestFile(file)));
-                String line = br.readLine();
-                while (line != null) {
-                    al.add(line);
-                    line = br.readLine();
-                }
-                br.close();
-            }
-            return al;
-        }
-}
+/*
+ * 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.parser;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.TreeSet;
+import java.util.Vector;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+import junit.framework.TestSuite;
+
+public class TestHTMLParser extends JMeterTestCase {
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    public TestHTMLParser(String arg0) {
+        super(arg0);
+    }
+        private String parserName;
+
+        private int testNumber = 0;
+
+        public TestHTMLParser(String name, int test) {
+            super(name);
+            testNumber = test;
+        }
+
+        public TestHTMLParser(String name, String parser, int test) {
+            super(name);
+            testNumber = test;
+            parserName = parser;
+        }
+
+        private static class StaticTestClass // Can't instantiate
+        {
+            private StaticTestClass() {
+            };
+        }
+
+        private class TestClass // Can't instantiate
+        {
+            private TestClass() {
+            };
+        }
+
+        private static class TestData {
+            private String fileName;
+
+            private String baseURL;
+
+            private String expectedSet;
+
+            private String expectedList;
+
+            private TestData(String f, String b, String s, String l) {
+                fileName = f;
+                baseURL = b;
+                expectedSet = s;
+                expectedList = l;
+            }
+
+//            private TestData(String f, String b, String s) {
+//                this(f, b, s, null);
+//            }
+        }
+
+        // List of parsers to test. Should probably be derived automatically
+        private static final String[] PARSERS = { 
+            "org.apache.jmeter.protocol.http.parser.HtmlParserHTMLParser",
+            "org.apache.jmeter.protocol.http.parser.JTidyHTMLParser",
+            "org.apache.jmeter.protocol.http.parser.RegexpHTMLParser" 
+            };
+
+        private static final TestData[] TESTS = new TestData[] {
+                new TestData("testfiles/HTMLParserTestCase.html",
+                        "http://localhost/mydir/myfile.html",
+                        "testfiles/HTMLParserTestCase.set",
+                        "testfiles/HTMLParserTestCase.all"),
+                new TestData("testfiles/HTMLParserTestCaseWithBaseHRef.html", 
+                        "http://localhost/mydir/myfile.html",
+                        "testfiles/HTMLParserTestCaseBase.set", 
+                        "testfiles/HTMLParserTestCaseBase.all"),
+                new TestData("testfiles/HTMLParserTestCaseWithBaseHRef2.html", 
+                        "http://localhost/mydir/myfile.html",
+                         "testfiles/HTMLParserTestCaseBase.set", 
+                         "testfiles/HTMLParserTestCaseBase.all"),
+                new TestData("testfiles/HTMLParserTestCaseWithMissingBaseHRef.html",
+                        "http://localhost/mydir/images/myfile.html", 
+                        "testfiles/HTMLParserTestCaseBase.set",
+                        "testfiles/HTMLParserTestCaseBase.all"),
+                new TestData("testfiles/HTMLParserTestCase2.html",
+                        "http:", "", ""), // Dummy as the file has no entries
+                new TestData("testfiles/HTMLParserTestCase3.html",
+                        "http:", "", ""), // Dummy as the file has no entries
+                new TestData("testfiles/HTMLParserTestCaseWithComments.html",
+                        "http://localhost/mydir/myfile.html",
+                        "testfiles/HTMLParserTestCaseBase.set",
+                        "testfiles/HTMLParserTestCaseBase.all"),
+                new TestData("testfiles/HTMLScript.html",
+                        "http://localhost/",
+                        "testfiles/HTMLScript.set",
+                        "testfiles/HTMLScript.all"),
+                new TestData("testfiles/HTMLParserTestFrames.html",
+                        "http://localhost/",
+                        "testfiles/HTMLParserTestFrames.all",
+                        "testfiles/HTMLParserTestFrames.all"), 
+                         };
+
+        public static junit.framework.Test suite() {
+            TestSuite suite = new TestSuite("TestHTMLParser");
+            suite.addTest(new TestHTMLParser("testDefaultParser"));
+            suite.addTest(new TestHTMLParser("testParserDefault"));
+            suite.addTest(new TestHTMLParser("testParserMissing"));
+            suite.addTest(new TestHTMLParser("testNotParser"));
+            suite.addTest(new TestHTMLParser("testNotCreatable"));
+            suite.addTest(new TestHTMLParser("testNotCreatableStatic"));
+            for (int i = 0; i < PARSERS.length; i++) {
+                TestSuite ps = new TestSuite(PARSERS[i]);// Identify subtests
+                ps.addTest(new TestHTMLParser("testParserProperty", PARSERS[i], 0));
+                for (int j = 0; j < TESTS.length; j++) {
+                    TestSuite ts = new TestSuite(TESTS[j].fileName);
+                    ts.addTest(new TestHTMLParser("testParserSet", PARSERS[i], j));
+                    ts.addTest(new TestHTMLParser("testParserList", PARSERS[i], j));
+                    ps.addTest(ts);
+                }
+                suite.addTest(ps);
+            }
+            return suite;
+        }
+
+        // Test if can instantiate parser using property name
+        public void testParserProperty() throws Exception {
+            Properties p = JMeterUtils.getJMeterProperties();
+            if (p == null) {
+                p = JMeterUtils.getProperties("jmeter.properties");
+            }
+            p.setProperty(HTMLParser.PARSER_CLASSNAME, parserName);
+            HTMLParser.getParser();
+        }
+
+        public void testDefaultParser() throws Exception {
+            HTMLParser.getParser();
+        }
+
+        public void testParserDefault() throws Exception {
+            HTMLParser.getParser(HTMLParser.DEFAULT_PARSER);
+        }
+
+        public void testParserMissing() throws Exception {
+            try {
+                HTMLParser.getParser("no.such.parser");
+                fail("Should not have been able to create the parser");
+            } catch (HTMLParseError e) {
+                if (e.getCause() instanceof ClassNotFoundException) {
+                    // This is OK
+                } else {
+                    throw e;
+                }
+            }
+        }
+
+        public void testNotParser() throws Exception {
+            try {
+                HTMLParser.getParser("java.lang.String");
+                fail("Should not have been able to create the parser");
+            } catch (HTMLParseError e) {
+                if (e.getCause() instanceof ClassCastException)
+                    return;
+                throw e;
+            }
+        }
+
+        public void testNotCreatable() throws Exception {
+            try {
+                HTMLParser.getParser(TestClass.class.getName());
+                fail("Should not have been able to create the parser");
+            } catch (HTMLParseError e) {
+                if (e.getCause() instanceof InstantiationException)
+                    return;
+                throw e;
+            }
+        }
+
+        public void testNotCreatableStatic() throws Exception {
+            try {
+                HTMLParser.getParser(StaticTestClass.class.getName());
+                fail("Should not have been able to create the parser");
+            } catch (HTMLParseError e) {
+                if (e.getCause() instanceof ClassCastException)
+                    return;
+                if (e.getCause() instanceof IllegalAccessException)
+                    return;
+                throw e;
+            }
+        }
+
+        public void testParserSet() throws Exception {
+            HTMLParser p = HTMLParser.getParser(parserName);
+            filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseURL, TESTS[testNumber].expectedSet, null,
+                    false);
+        }
+
+        public void testParserList() throws Exception {
+            HTMLParser p = HTMLParser.getParser(parserName);
+            filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseURL, TESTS[testNumber].expectedList,
+                    new Vector(), true);
+        }
+
+        private static void filetest(HTMLParser p, String file, String url, String resultFile, Collection c,
+                boolean orderMatters) // Does the order matter?
+                throws Exception {
+            String parserName = p.getClass().getName().substring("org.apache.jmeter.protocol.http.parser.".length());
+            String fname = file.substring(file.indexOf("/")+1);
+            log.debug("file   " + file);
+            File f = findTestFile(file);
+            byte[] buffer = new byte[(int) f.length()];
+            int len = new FileInputStream(f).read(buffer);
+            assertEquals(len, buffer.length);
+            Iterator result;
+            if (c == null) {
+                result = p.getEmbeddedResourceURLs(buffer, new URL(url));
+            } else {
+                result = p.getEmbeddedResourceURLs(buffer, new URL(url), c);
+            }
+            /*
+             * TODO: Exact ordering is only required for some tests; change the
+             * comparison to do a set compare where necessary.
+             */
+            Iterator expected;
+            if (orderMatters) {
+                expected = getFile(resultFile).iterator();
+            } else {
+                // Convert both to Sets
+                expected = new TreeSet(getFile(resultFile)).iterator();
+                TreeSet temp = new TreeSet(new Comparator() {
+                    public int compare(Object o1, Object o2) {
+                        return (o1.toString().compareTo(o2.toString()));
+                    }
+                });
+                while (result.hasNext()) {
+                    temp.add(result.next());
+                }
+                result = temp.iterator();
+            }
+
+            while (expected.hasNext()) {
+                Object next = expected.next();
+                assertTrue(fname+"::"+parserName + "::Expecting another result " + next, result.hasNext());
+                try {
+                    assertEquals(fname+"::"+parserName + "(next)", next, ((URL) result.next()).toString());
+                } catch (ClassCastException e) {
+                    fail(fname+"::"+parserName + "::Expected URL, but got " + e.toString());
+                }
+            }
+            assertFalse(fname+"::"+parserName + "::Should have reached the end of the results", result.hasNext());
+        }
+
+        // Get expected results as a List
+        private static List getFile(String file) throws Exception {
+            ArrayList al = new ArrayList();
+            if (file != null && file.length() > 0) {
+                BufferedReader br = new BufferedReader(new FileReader(findTestFile(file)));
+                String line = br.readLine();
+                while (line != null) {
+                    al.add(line);
+                    line = br.readLine();
+                }
+                br.close();
+            }
+            return al;
+        }
+}

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

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java Mon Feb  4 11:55:48 2008
@@ -1,215 +1,215 @@
-/*
- * 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 org.apache.jmeter.config.Argument;
-import org.apache.jmeter.config.Arguments;
-
-import junit.framework.TestCase;
-
-public class TestHTTPSamplers extends TestCase {
-
-    public TestHTTPSamplers(String arg0) {
-        super(arg0);
-    }
-
-    // Parse arguments singly
-    public void testParseArguments(){
-        HTTPSamplerBase sampler = new HTTPNullSampler();
-        Arguments args;
-        Argument arg;
-        
-        args = sampler.getArguments();
-        assertEquals(0,args.getArgumentCount());
-        
-        sampler.parseArguments("");
-        args = sampler.getArguments();
-        assertEquals(0,args.getArgumentCount());
-        
-        sampler.parseArguments("name1");
-        args = sampler.getArguments();
-        assertEquals(1,args.getArgumentCount());
-        arg=args.getArgument(0);
-        assertEquals("name1",arg.getName());
-        assertEquals("",arg.getMetaData());
-        assertEquals("",arg.getValue());
-        
-        sampler.parseArguments("name2=");
-        args = sampler.getArguments();
-        assertEquals(2,args.getArgumentCount());
-        arg=args.getArgument(1);
-        assertEquals("name2",arg.getName());
-        assertEquals("=",arg.getMetaData());
-        assertEquals("",arg.getValue());
-        
-        sampler.parseArguments("name3=value3");
-        args = sampler.getArguments();
-        assertEquals(3,args.getArgumentCount());
-        arg=args.getArgument(2);
-        assertEquals("name3",arg.getName());
-        assertEquals("=",arg.getMetaData());
-        assertEquals("value3",arg.getValue());
-        
-    }
-
-    // Parse arguments all at once
-    public void testParseArguments2(){
-        HTTPSamplerBase sampler = new HTTPNullSampler();
-        Arguments args;
-        Argument arg;
-        
-        args = sampler.getArguments();
-        assertEquals(0,args.getArgumentCount());
-        
-        sampler.parseArguments("&name1&name2=&name3=value3");
-        args = sampler.getArguments();
-        assertEquals(3,args.getArgumentCount());
-        
-        arg=args.getArgument(0);
-        assertEquals("name1",arg.getName());
-        assertEquals("",arg.getMetaData());
-        assertEquals("",arg.getValue());
-        
-        arg=args.getArgument(1);
-        assertEquals("name2",arg.getName());
-        assertEquals("=",arg.getMetaData());
-        assertEquals("",arg.getValue());
-        
-        arg=args.getArgument(2);
-        assertEquals("name3",arg.getName());
-        assertEquals("=",arg.getMetaData());
-        assertEquals("value3",arg.getValue());
-        
-    }
-
-        public void testArgumentWithoutEquals() throws Exception {
-            HTTPSamplerBase sampler = new HTTPNullSampler();
-            sampler.setProtocol("http");
-            sampler.setMethod(HTTPSamplerBase.GET);
-            sampler.setPath("/index.html?pear");
-            sampler.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?pear", sampler.getUrl().toString());
-        }
-
-        public void testMakingUrl() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.addArgument("param1", "value1");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1=value1", config.getUrl().toString());
-        }
-
-        public void testMakingUrl2() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.addArgument("param1", "value1");
-            config.setPath("/index.html?p1=p2");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1=value1&p1=p2", config.getUrl().toString());
-        }
-
-        public void testMakingUrl3() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.POST);
-            config.addArgument("param1", "value1");
-            config.setPath("/index.html?p1=p2");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?p1=p2", config.getUrl().toString());
-        }
-
-        // test cases for making Url, and exercise method
-        // addArgument(String name,String value,String metadata)
-
-        public void testMakingUrl4() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.addArgument("param1", "value1", "=");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1=value1", config.getUrl().toString());
-        }
-
-        public void testMakingUrl5() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.addArgument("param1", "", "=");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1=", config.getUrl().toString());
-        }
-
-        public void testMakingUrl6() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.addArgument("param1", "", "");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1", config.getUrl().toString());
-        }
-
-        // test cases for making Url, and exercise method
-        // parseArguments(String queryString)
-
-        public void testMakingUrl7() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.parseArguments("param1=value1");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1=value1", config.getUrl().toString());
-        }
-
-        public void testMakingUrl8() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.parseArguments("param1=");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1=", config.getUrl().toString());
-        }
-
-        public void testMakingUrl9() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.parseArguments("param1");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html?param1", config.getUrl().toString());
-        }
-
-        public void testMakingUrl10() throws Exception {
-            HTTPSamplerBase config = new HTTPNullSampler();
-            config.setProtocol("http");
-            config.setMethod(HTTPSamplerBase.GET);
-            config.parseArguments("");
-            config.setPath("/index.html");
-            config.setDomain("www.apache.org");
-            assertEquals("http://www.apache.org/index.html", config.getUrl().toString());
-        }
-}
+/*
+ * 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 org.apache.jmeter.config.Argument;
+import org.apache.jmeter.config.Arguments;
+
+import junit.framework.TestCase;
+
+public class TestHTTPSamplers extends TestCase {
+
+    public TestHTTPSamplers(String arg0) {
+        super(arg0);
+    }
+
+    // Parse arguments singly
+    public void testParseArguments(){
+        HTTPSamplerBase sampler = new HTTPNullSampler();
+        Arguments args;
+        Argument arg;
+        
+        args = sampler.getArguments();
+        assertEquals(0,args.getArgumentCount());
+        
+        sampler.parseArguments("");
+        args = sampler.getArguments();
+        assertEquals(0,args.getArgumentCount());
+        
+        sampler.parseArguments("name1");
+        args = sampler.getArguments();
+        assertEquals(1,args.getArgumentCount());
+        arg=args.getArgument(0);
+        assertEquals("name1",arg.getName());
+        assertEquals("",arg.getMetaData());
+        assertEquals("",arg.getValue());
+        
+        sampler.parseArguments("name2=");
+        args = sampler.getArguments();
+        assertEquals(2,args.getArgumentCount());
+        arg=args.getArgument(1);
+        assertEquals("name2",arg.getName());
+        assertEquals("=",arg.getMetaData());
+        assertEquals("",arg.getValue());
+        
+        sampler.parseArguments("name3=value3");
+        args = sampler.getArguments();
+        assertEquals(3,args.getArgumentCount());
+        arg=args.getArgument(2);
+        assertEquals("name3",arg.getName());
+        assertEquals("=",arg.getMetaData());
+        assertEquals("value3",arg.getValue());
+        
+    }
+
+    // Parse arguments all at once
+    public void testParseArguments2(){
+        HTTPSamplerBase sampler = new HTTPNullSampler();
+        Arguments args;
+        Argument arg;
+        
+        args = sampler.getArguments();
+        assertEquals(0,args.getArgumentCount());
+        
+        sampler.parseArguments("&name1&name2=&name3=value3");
+        args = sampler.getArguments();
+        assertEquals(3,args.getArgumentCount());
+        
+        arg=args.getArgument(0);
+        assertEquals("name1",arg.getName());
+        assertEquals("",arg.getMetaData());
+        assertEquals("",arg.getValue());
+        
+        arg=args.getArgument(1);
+        assertEquals("name2",arg.getName());
+        assertEquals("=",arg.getMetaData());
+        assertEquals("",arg.getValue());
+        
+        arg=args.getArgument(2);
+        assertEquals("name3",arg.getName());
+        assertEquals("=",arg.getMetaData());
+        assertEquals("value3",arg.getValue());
+        
+    }
+
+        public void testArgumentWithoutEquals() throws Exception {
+            HTTPSamplerBase sampler = new HTTPNullSampler();
+            sampler.setProtocol("http");
+            sampler.setMethod(HTTPSamplerBase.GET);
+            sampler.setPath("/index.html?pear");
+            sampler.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?pear", sampler.getUrl().toString());
+        }
+
+        public void testMakingUrl() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.addArgument("param1", "value1");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1=value1", config.getUrl().toString());
+        }
+
+        public void testMakingUrl2() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.addArgument("param1", "value1");
+            config.setPath("/index.html?p1=p2");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1=value1&p1=p2", config.getUrl().toString());
+        }
+
+        public void testMakingUrl3() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.POST);
+            config.addArgument("param1", "value1");
+            config.setPath("/index.html?p1=p2");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?p1=p2", config.getUrl().toString());
+        }
+
+        // test cases for making Url, and exercise method
+        // addArgument(String name,String value,String metadata)
+
+        public void testMakingUrl4() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.addArgument("param1", "value1", "=");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1=value1", config.getUrl().toString());
+        }
+
+        public void testMakingUrl5() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.addArgument("param1", "", "=");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1=", config.getUrl().toString());
+        }
+
+        public void testMakingUrl6() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.addArgument("param1", "", "");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1", config.getUrl().toString());
+        }
+
+        // test cases for making Url, and exercise method
+        // parseArguments(String queryString)
+
+        public void testMakingUrl7() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.parseArguments("param1=value1");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1=value1", config.getUrl().toString());
+        }
+
+        public void testMakingUrl8() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.parseArguments("param1=");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1=", config.getUrl().toString());
+        }
+
+        public void testMakingUrl9() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.parseArguments("param1");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html?param1", config.getUrl().toString());
+        }
+
+        public void testMakingUrl10() throws Exception {
+            HTTPSamplerBase config = new HTTPNullSampler();
+            config.setProtocol("http");
+            config.setMethod(HTTPSamplerBase.GET);
+            config.parseArguments("");
+            config.setPath("/index.html");
+            config.setDomain("www.apache.org");
+            assertEquals("http://www.apache.org/index.html", config.getUrl().toString());
+        }
+}

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

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java Mon Feb  4 11:55:48 2008
@@ -1,51 +1,51 @@
-/*
- * 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.ldap.config.gui;
-
-import junit.framework.TestCase;
-
-public class PackageTest extends TestCase {
-		/**
-		 * Create a new test.
-		 * 
-		 * @param name
-		 *            the name of the test
-		 */
-		public PackageTest(String name) {
-			super(name);
-		}
-
-		/**
-		 * Test that adding an argument to the table results in an appropriate
-		 * TestElement being created.
-		 * 
-		 * @throws Exception
-		 *             if an exception occurred during the test
-		 */
-		public void testLDAPArgumentCreation() throws Exception {
-			LDAPArgumentsPanel gui = new LDAPArgumentsPanel();
-			gui.tableModel.addRow(new LDAPArgument());
-			gui.tableModel.setValueAt("howdy", 0, 0);
-			gui.tableModel.addRow(new LDAPArgument());
-			gui.tableModel.setValueAt("doody", 0, 1);
-
-			assertEquals("=", ((LDAPArgument) ((LDAPArguments) gui.createTestElement()).getArguments().get(0)
-					.getObjectValue()).getMetaData());
-		}
-}
+/*
+ * 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.ldap.config.gui;
+
+import junit.framework.TestCase;
+
+public class PackageTest extends TestCase {
+		/**
+		 * Create a new test.
+		 * 
+		 * @param name
+		 *            the name of the test
+		 */
+		public PackageTest(String name) {
+			super(name);
+		}
+
+		/**
+		 * Test that adding an argument to the table results in an appropriate
+		 * TestElement being created.
+		 * 
+		 * @throws Exception
+		 *             if an exception occurred during the test
+		 */
+		public void testLDAPArgumentCreation() throws Exception {
+			LDAPArgumentsPanel gui = new LDAPArgumentsPanel();
+			gui.tableModel.addRow(new LDAPArgument());
+			gui.tableModel.setValueAt("howdy", 0, 0);
+			gui.tableModel.addRow(new LDAPArgument());
+			gui.tableModel.setValueAt("doody", 0, 1);
+
+			assertEquals("=", ((LDAPArgument) ((LDAPArguments) gui.createTestElement()).getArguments().get(0)
+					.getObjectValue()).getMetaData());
+		}
+}

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

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java?rev=618404&r1=618403&r2=618404&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java Mon Feb  4 11:55:48 2008
@@ -1,55 +1,55 @@
-/*
- * 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.testbeans.gui;
-
-public class TestComboStringEditor extends junit.framework.TestCase {
-		public TestComboStringEditor(String name) {
-			super(name);
-		}
-
-		private void testSetGet(ComboStringEditor e, Object value) throws Exception {
-			e.setValue(value);
-			assertEquals(value, e.getValue());
-		}
-
-		private void testSetGetAsText(ComboStringEditor e, String text) throws Exception {
-			e.setAsText(text);
-			assertEquals(text, e.getAsText());
-		}
-
-		public void testSetGet() throws Exception {
-			ComboStringEditor e = new ComboStringEditor();
-
-			testSetGet(e, "any string");
-			testSetGet(e, "");
-			testSetGet(e, null);
-			testSetGet(e, "${var}");
-		}
-
-		public void testSetGetAsText() throws Exception {
-			ComboStringEditor e = new ComboStringEditor();
-
-			testSetGetAsText(e, "any string");
-			testSetGetAsText(e, "");
-			testSetGetAsText(e, null);
-			testSetGetAsText(e, "${var}");
-
-			// Check "Undefined" does not become a "reserved word":
-			e.setAsText(ComboStringEditor.UNDEFINED.toString());
-			assertNotNull(e.getAsText());
-		}
+/*
+ * 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.testbeans.gui;
+
+public class TestComboStringEditor extends junit.framework.TestCase {
+		public TestComboStringEditor(String name) {
+			super(name);
+		}
+
+		private void testSetGet(ComboStringEditor e, Object value) throws Exception {
+			e.setValue(value);
+			assertEquals(value, e.getValue());
+		}
+
+		private void testSetGetAsText(ComboStringEditor e, String text) throws Exception {
+			e.setAsText(text);
+			assertEquals(text, e.getAsText());
+		}
+
+		public void testSetGet() throws Exception {
+			ComboStringEditor e = new ComboStringEditor();
+
+			testSetGet(e, "any string");
+			testSetGet(e, "");
+			testSetGet(e, null);
+			testSetGet(e, "${var}");
+		}
+
+		public void testSetGetAsText() throws Exception {
+			ComboStringEditor e = new ComboStringEditor();
+
+			testSetGetAsText(e, "any string");
+			testSetGetAsText(e, "");
+			testSetGetAsText(e, null);
+			testSetGetAsText(e, "${var}");
+
+			// Check "Undefined" does not become a "reserved word":
+			e.setAsText(ComboStringEditor.UNDEFINED.toString());
+			assertNotNull(e.getAsText());
+		}
 }

Propchange: jakarta/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestComboStringEditor.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