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 2006/04/23 20:31:40 UTC

svn commit: r396302 - in /jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler: LDAPExtSampler.java LdapExtClient.java

Author: sebb
Date: Sun Apr 23 11:31:38 2006
New Revision: 396302

URL: http://svn.apache.org/viewcvs?rev=396302&view=rev
Log:
Replace package variables with method returns

Modified:
    jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
    jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java

Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java?rev=396302&r1=396301&r2=396302&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java Sun Apr 23 11:31:38 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 The Apache Software Foundation.
+ * Copyright 2003-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,23 +21,22 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.SearchResult;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.InitialDirContext;
 import javax.naming.directory.ModificationItem;
-import javax.naming.NamingEnumeration;
+import javax.naming.directory.SearchResult;
 
 import org.apache.jmeter.config.Argument;
 import org.apache.jmeter.config.Arguments;
 import org.apache.jmeter.engine.event.LoopIterationEvent;
 import org.apache.jmeter.protocol.ldap.config.gui.LDAPArgument;
 import org.apache.jmeter.protocol.ldap.config.gui.LDAPArguments;
-import org.apache.jmeter.protocol.ldap.sampler.LdapExtClient;
 import org.apache.jmeter.samplers.AbstractSampler;
 import org.apache.jmeter.samplers.Entry;
 import org.apache.jmeter.samplers.SampleResult;
@@ -123,6 +122,7 @@
 	// create the new entry in the server
 	// private static int counter=0;
 
+    // TODO replace these with ThreadLocal
 	private static Hashtable ldapConnections = new Hashtable();
 
 	private static Hashtable ldapContexts = new Hashtable();
@@ -589,6 +589,7 @@
 	private void addTest(LdapExtClient ldap, DirContext dirContext, SampleResult res) throws NamingException {
 		res.sampleStart();
 		ldap.createTest(dirContext, getUserAttributes(), getPropertyAsString(BASE_ENTRY_DN));
+        // Returned DirContext is not currently used
 		res.sampleEnd();
 	}
 
@@ -604,20 +605,6 @@
 	}
 
 	/***************************************************************************
-	 * This will do the search test for the User defined TestCase
-	 * 
-	 * @return executed time for the give test case
-	 **************************************************************************/
-	private void searchTest(LdapExtClient ldap, DirContext dirContext, SampleResult res) throws NamingException {
-		res.sampleStart();
-		ldap.searchTest(dirContext, getPropertyAsString(SEARCHBASE), getPropertyAsString(SEARCHFILTER),
-				getPropertyAsInt(SCOPE), getPropertyAsLong(COUNTLIM), getPropertyAsInt(TIMELIM),
-				getRequestAttributes(getPropertyAsString(ATTRIBS)), getPropertyAsBoolean(RETOBJ),
-				getPropertyAsBoolean(DEREF));
-		res.sampleEnd();
-	}
-
-	/***************************************************************************
 	 * This will do the modify test for the User defined TestCase
 	 * 
 	 * @return executed time for the give test case
@@ -661,17 +648,6 @@
 	}
 
 	/***************************************************************************
-	 * This will do a compare Opp for the User and attribute/value pair defined
-	 * 
-	 * @return executed time for the compare op
-	 **************************************************************************/
-	private void compareOp(LdapExtClient ldap, DirContext dirContext, SampleResult res) throws NamingException {
-		res.sampleStart();
-		ldap.compare(dirContext, getPropertyAsString(COMPAREFILT), getPropertyAsString(COMPAREDN));
-		res.sampleEnd();
-	}
-
-	/***************************************************************************
 	 * This will do a moddn Opp for the User new DN defined
 	 * 
 	 * @return executed time for the moddn op
@@ -751,8 +727,10 @@
 				responseData = responseData + "<comparedn>" + getPropertyAsString(COMPAREDN) + "</comparedn>";
 				responseData = responseData + "<comparefilter>" + getPropertyAsString(COMPAREFILT)
 						+ "</comparefilter></operation>";
-				compareOp(temp_client, dirContext, res);
-				if (temp_client.compareAnswer.hasMore()) {
+                res.sampleStart();
+                NamingEnumeration cmp = temp_client.compare(dirContext, getPropertyAsString(COMPAREFILT), getPropertyAsString(COMPAREDN));
+                res.sampleEnd();
+				if (cmp.hasMore()) {
 				} else {
 					res.setResponseCode("49");
 					res.setResponseMessage("compareFalse");
@@ -792,9 +770,14 @@
 				responseData = responseData + "<countlimit>" + getPropertyAsString(COUNTLIM) + "</countlimit>";
 				responseData = responseData + "<timelimit>" + getPropertyAsString(TIMELIM) + "</timelimit>";
 				responseData = responseData + "</operation><searchresult>";
-				searchTest(temp_client, dirContext, res);
-				while (temp_client.answer.hasMore()) {
-                    SearchResult sr = (SearchResult) temp_client.answer.next();
+                res.sampleStart();
+                NamingEnumeration srch = temp_client.searchTest(dirContext, getPropertyAsString(SEARCHBASE), getPropertyAsString(SEARCHFILTER),
+                        getPropertyAsInt(SCOPE), getPropertyAsLong(COUNTLIM), getPropertyAsInt(TIMELIM),
+                        getRequestAttributes(getPropertyAsString(ATTRIBS)), getPropertyAsBoolean(RETOBJ),
+                        getPropertyAsBoolean(DEREF));
+                res.sampleEnd();
+				while (srch.hasMore()) {
+                    SearchResult sr = (SearchResult) srch.next();
 					responseData = responseData + "<dn>" + sr.getName() + "," + getPropertyAsString(SEARCHBASE) + ","
 							+ getRootdn() + "</dn>";
 					responseData = responseData + "<returnedattr>" + sr.getAttributes().size() + "</returnedattr>";

Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java?rev=396302&r1=396301&r2=396302&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java Sun Apr 23 11:31:38 2006
@@ -1,6 +1,5 @@
-//$Header$
 /*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2004,2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,12 +46,7 @@
  * LDAP functionality available
  ******************************************************************************/
 public class LdapExtClient {
-	transient private static Logger log = LoggingManager.getLoggerForClass();
-
-	// Used by Sampler
-	NamingEnumeration answer;
-
-	NamingEnumeration compareAnswer;
+	private static final Logger log = LoggingManager.getLoggerForClass();
 
 	/**
 	 * Constructor for the LdapClient object
@@ -111,13 +105,13 @@
 	 * @param search
 	 *            filter filter this value from the base
 	 **************************************************************************/
-	public void searchTest(DirContext dirContext, String searchBase, String searchFilter, int scope, long countlim,
+	public NamingEnumeration searchTest(DirContext dirContext, String searchBase, String searchFilter, int scope, long countlim,
 			int timelim, String[] attrs, boolean retobj, boolean deref) throws NamingException {
 		SearchControls searchcontrols = null;
 		searchcontrols = new SearchControls(scope, countlim, timelim, attrs, retobj, deref);
 		log.debug("scope, countlim, timelim, attrs, retobj, deref= " + searchFilter + scope + countlim + timelim
 				+ attrs + retobj + deref);
-		answer = dirContext.search(searchBase, searchFilter, searchcontrols);
+		return dirContext.search(searchBase, searchFilter, searchcontrols);
 	}
 
 	/***************************************************************************
@@ -128,9 +122,9 @@
 	 * @param search
 	 *            filter filter this value from the base
 	 **************************************************************************/
-	public void compare(DirContext dirContext, String filter, String entrydn) throws NamingException {
+	public NamingEnumeration compare(DirContext dirContext, String filter, String entrydn) throws NamingException {
 		SearchControls searchcontrols = new SearchControls(0, 1, 0, new String[0], false, false);
-		compareAnswer = dirContext.search(entrydn, filter, searchcontrols);
+		return dirContext.search(entrydn, filter, searchcontrols);
 	}
 
 	/***************************************************************************
@@ -167,9 +161,9 @@
 	 * @param string
 	 *            The string (dn) value
 	 **************************************************************************/
-    public void createTest(DirContext dirContext, Attributes attributes, String string)
+    public DirContext createTest(DirContext dirContext, Attributes attributes, String string)
 			throws NamingException {
-		dirContext.createSubcontext(string, attributes);
+		return dirContext.createSubcontext(string, attributes);
 	}
 
 	/***************************************************************************



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