sebb 2003/12/19 09:07:27
Modified: src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler
LDAPSampler.java
Log:
Use sampleStart() and SampleEnd(); Make fields and methods private if poss
Revision Changes Path
1.9 +30 -44
jakarta-jmeter/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPSampler.java
Index: LDAPSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPSampler.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- LDAPSampler.java 22 Nov 2003 03:25:54 -0000 1.8
+++ LDAPSampler.java 19 Dec 2003 17:07:27 -0000 1.9
@@ -106,7 +106,7 @@
//For In build test case using this counter
//create the new entry in the server
- public static int counter=0;
+ private static int counter=0;
private boolean searchFoundEntries;//TODO turn into parameter?
@@ -294,7 +294,7 @@
*
* @return the BasicAttributes
*/
- public BasicAttributes getUserAttributes()
+ private BasicAttributes getUserAttributes()
{
BasicAttribute basicattribute = new BasicAttribute("objectclass");
basicattribute.add("top");
@@ -323,7 +323,7 @@
*
* @return the BasicAttributes
*/
- public ModificationItem[] getUserModAttributes()
+ private ModificationItem[] getUserModAttributes()
{
ModificationItem[] mods =
new ModificationItem[getArguments().getArguments().size()];
@@ -348,7 +348,7 @@
*
* @return the BasicAttributes
*/
- public ModificationItem[] getModificationItem()
+ private ModificationItem[] getModificationItem()
{
ModificationItem[] mods = new ModificationItem[2];
// replace (update) attribute
@@ -370,7 +370,7 @@
*
* @return the BasicAttributes
*/
- public BasicAttributes getBasicAttributes()
+ private BasicAttributes getBasicAttributes()
{
BasicAttributes basicattributes = new BasicAttributes();
BasicAttribute basicattribute = new BasicAttribute("objectclass");
@@ -398,7 +398,7 @@
*
* @return the BasicAttribute
*/
- public BasicAttribute getBasicAttribute(String name, String value)
+ private BasicAttribute getBasicAttribute(String name, String value)
{
BasicAttribute attr = new BasicAttribute(name,value);
return attr;
@@ -427,27 +427,24 @@
*
* @return executed time for the give test case
*/
- public long addTest(LdapClient ldap)
+ private void addTest(LdapClient ldap, SampleResult res)
throws NamingException
{
- long start = 0L;
- long end = 0L;
if (getPropertyAsBoolean(USER_DEFINED))
{
- start = System.currentTimeMillis();
+ res.sampleStart();
ldap.createTest(
getUserAttributes(),
getPropertyAsString(BASE_ENTRY_DN));
- end = System.currentTimeMillis();
+ res.sampleEnd();
}
else
{
- start = System.currentTimeMillis();
+ res.sampleStart();
ldap.createTest(getBasicAttributes(), getPropertyAsString(ADD));
- end = System.currentTimeMillis();
+ res.sampleEnd();
ldap.deleteTest(getPropertyAsString(ADD));
}
- return (end - start);
}
@@ -457,20 +454,17 @@
*
* @return executed time for the give test case
*/
- public long deleteTest(LdapClient ldap)
+ private void deleteTest(LdapClient ldap, SampleResult res)
throws NamingException
{
- long start = 0L;
- long end = 0L;
if (!getPropertyAsBoolean(USER_DEFINED))
{
ldap.createTest(getBasicAttributes(), getPropertyAsString(ADD));
setProperty(new StringProperty(DELETE, getPropertyAsString(ADD)));
}
- start = System.currentTimeMillis();
+ res.sampleStart();
ldap.deleteTest(getPropertyAsString(DELETE));
- end = System.currentTimeMillis();
- return (end - start);
+ res.sampleEnd();
}
/**
@@ -479,12 +473,9 @@
*
* @return executed time for the give test case
*/
- public long searchTest(LdapClient ldap)
+ private void searchTest(LdapClient ldap, SampleResult res)
throws NamingException
{
- long start = 0L;
- long end = 0L;
-
if (!getPropertyAsBoolean(USER_DEFINED))
{
ldap.createTest(getBasicAttributes(), getPropertyAsString(ADD));
@@ -493,16 +484,15 @@
setProperty(
new StringProperty(SEARCHFILTER, getPropertyAsString(ADD)));
}
- start = System.currentTimeMillis();
+ res.sampleStart();
searchFoundEntries = ldap.searchTest(
getPropertyAsString(SEARCHBASE),
getPropertyAsString(SEARCHFILTER));
- end = System.currentTimeMillis();
+ res.sampleEnd();
if (!getPropertyAsBoolean(USER_DEFINED))
{
ldap.deleteTest(getPropertyAsString(ADD));
}
- return (end - start);
}
/**
@@ -511,29 +501,26 @@
*
* @return executed time for the give test case
*/
- public long modifyTest(LdapClient ldap)
+ private void modifyTest(LdapClient ldap, SampleResult res)
throws NamingException
{
- long start = 0L;
- long end = 0L;
if (getPropertyAsBoolean(USER_DEFINED))
{
- start = System.currentTimeMillis();
+ res.sampleStart();
ldap.modifyTest(
getUserModAttributes(),
getPropertyAsString(BASE_ENTRY_DN));
- end = System.currentTimeMillis();
+ res.sampleEnd();
}
else
{
ldap.createTest(getBasicAttributes(), getPropertyAsString(ADD));
setProperty(new StringProperty(MODIFY, getPropertyAsString(ADD)));
- start = System.currentTimeMillis();
+ res.sampleStart();
ldap.modifyTest(getModificationItem(), getPropertyAsString(MODIFY));
- end = System.currentTimeMillis();
+ res.sampleEnd();
ldap.deleteTest(getPropertyAsString(ADD));
}
- return (end - start);
}
public SampleResult sample(Entry e)
@@ -542,7 +529,6 @@
boolean isSuccessful = false;
res.setSampleLabel(getLabel());
res.setSamplerData(getPropertyAsString(TEST));//TODO improve this
- long time=0L;
LdapClient ldap = new LdapClient();
try
@@ -556,19 +542,19 @@
if (getPropertyAsString(TEST).equals("add"))
{
- time = addTest(ldap);
+ addTest(ldap,res);
}
else if (getPropertyAsString(TEST).equals("delete"))
{
- time = deleteTest(ldap);
+ deleteTest(ldap,res);
}
else if (getPropertyAsString(TEST).equals("modify"))
{
- time = modifyTest(ldap);
+ modifyTest(ldap,res);
}
else if (getPropertyAsString(TEST).equals("search"))
{
- time = searchTest(ldap);
+ searchTest(ldap,res);
}
//TODO - needs more work ...
@@ -590,15 +576,15 @@
catch (Exception ex)
{
log.error("Ldap client - ",ex);
+ // Could time this
+ // res.sampleEnd();
+ // if sampleEnd() is not called, elapsed time will remain zero
res.setResponseCode("500");//TODO distinguish errors better
res.setResponseMessage(ex.toString());
ldap.disconnect();
isSuccessful = false;
- time = 0L;
}
- // Calculate response time
- res.setTime(time);
// Set if we were successful or not
res.setSuccessful(isSuccessful);
return res;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]