sebb 2005/07/09 15:08:43
Modified: src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler
LDAPExtSampler.java
Log:
Fix singleBind so it disconnects as well
Replace generic Exception by NamingException
Provide more detail if non-standard message returned
Revision Changes Path
1.7 +18 -20
jakarta-jmeter/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
Index: LDAPExtSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- LDAPExtSampler.java 19 May 2005 23:22:25 -0000 1.6
+++ LDAPExtSampler.java 9 Jul 2005 22:08:43 -0000 1.7
@@ -602,7 +602,7 @@
* TestCase
[EMAIL PROTECTED] executed time for the give test case
***********************************************************/
- public void addTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws Exception{
+ public void addTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws NamingException{
res.sampleStart();
ldap.createTest(dirContext, getUserAttributes(),
getPropertyAsString(BASE_ENTRY_DN));
res.sampleEnd();
@@ -614,7 +614,7 @@
* TestCase
[EMAIL PROTECTED] executed time for the give test case
***********************************************************/
- public void deleteTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res)throws Exception {
+ public void deleteTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res)throws NamingException {
res.sampleStart();
ldap.deleteTest(dirContext, getPropertyAsString(DELETE));
res.sampleEnd();
@@ -625,7 +625,7 @@
* TestCase
[EMAIL PROTECTED] executed time for the give test case
***********************************************************/
- public void searchTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res)throws Exception {
+ public 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)
@@ -638,7 +638,7 @@
* TestCase
[EMAIL PROTECTED] executed time for the give test case
***********************************************************/
- public void modifyTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res)throws Exception{
+ public void modifyTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res)throws NamingException{
res.sampleStart();
ldap.modifyTest(dirContext, getUserModAttributes(),
getPropertyAsString(BASE_ENTRY_DN));
res.sampleEnd();
@@ -649,7 +649,7 @@
* Thread, this bind is used for the whole context
[EMAIL PROTECTED] executed time for the bind op
***********************************************************/
- public void bindOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws Exception{
+ public void bindOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws NamingException{
res.sampleStart();
dirContext=ldap.connect(getServername(),getPort(),getRootdn(),getUserDN(),getUserPw());
res.sampleEnd();
@@ -657,15 +657,17 @@
}
/************************************************************
- * This will do the bind for the User defined
+ * This will do the bind and unbind for the User defined
* TestCase
[EMAIL PROTECTED] executed time for the bind op
***********************************************************/
- public void singleBindOp(SampleResult res) throws Exception{
+ public void singleBindOp(SampleResult res) throws NamingException{
LdapExtClient ldap_temp;
ldap_temp=new LdapExtClient();
res.sampleStart();
-
ldap_temp.sbind(getServername(),getPort(),getRootdn(),getSuserDN(),getSuserPw());
+ DirContext ctx =
+
ldap_temp.connect(getServername(),getPort(),getRootdn(),getSuserDN(),getSuserPw());
+ ldap_temp.disconnect(ctx);
res.sampleEnd();
}
@@ -673,7 +675,7 @@
* This will do a compare Opp for the User and attribute/value pair
defined
[EMAIL PROTECTED] executed time for the compare op
***********************************************************/
- public void compareOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws Exception{
+ public void compareOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws NamingException{
res.sampleStart();
ldap.compare(dirContext, getPropertyAsString(COMPAREFILT),
getPropertyAsString(COMPAREDN));
res.sampleEnd();
@@ -683,7 +685,7 @@
* This will do a moddn Opp for the User new DN defined
[EMAIL PROTECTED] executed time for the moddn op
***********************************************************/
- public void renameTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws Exception{
+ public void renameTest(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws NamingException{
res.sampleStart();
ldap.moddnOp(dirContext, getPropertyAsString(MODDDN),
getPropertyAsString(NEWDN));
res.sampleEnd();
@@ -694,7 +696,7 @@
* TestCase as well as inbuilt test case
[EMAIL PROTECTED] executed time for the bind op
***********************************************************/
- public void unbindOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws Exception{
+ public void unbindOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws NamingException{
res.sampleStart();
ldap.disconnect(dirContext);
res.sampleEnd();
@@ -725,7 +727,7 @@
temp_client =new LdapExtClient();
try {
dirContext=new InitialDirContext();
- } catch (Exception err) {
+ } catch (NamingException err) {
log.error("Ldap client context creation - ",err);
}
ldapConnections.put(Thread.currentThread().getName(),
temp_client);
@@ -816,16 +818,12 @@
if (returnData.indexOf("LDAP: error code") >=0) {
res.setResponseMessage(returnData.substring(returnData.indexOf("LDAP: error
code")+22,returnData.indexOf("]")));
res.setResponseCode(returnData.substring(returnData.indexOf("LDAP: error
code")+17,returnData.indexOf("LDAP: error code")+19));
+ } else {
+ res.setResponseMessage(returnData);
+ res.setResponseCode("800");
}
isSuccessful = false;
}
- catch (Exception ex) {
- res.setResponseData(ex.toString().getBytes());
- log.error("Ldap client - ",ex);
- isSuccessful = false;
- res.setResponseMessage("internal error");
- res.setResponseCode("800");
- }
finally {
responseData=responseData + "<responsecode>" +
res.getResponseCode() + "</responsecode>";
responseData=responseData + "<responsemessage>" +
res.getResponseMessage() + "</responsemessage>";
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]