Method from org.apache.jmeter.protocol.ldap.sampler.LDAPExtSampler Detail: |
public Arguments getArguments() {
return (Arguments) getProperty(ARGUMENTS).getObjectValue();
}
Gets the Arguments attribute of the LdapConfig object |
public String getAttrs() {
return getPropertyAsString(ATTRIBS);
}
Gets the attributes of the LDAPSampler object |
public String getBaseEntryDN() {
return getPropertyAsString(BASE_ENTRY_DN);
}
Gets the BaseEntryDN attribute of the LDAPSampler object |
public String getConnTimeOut() {
return getPropertyAsString(CONNTO);
}
|
public String getCountlim() {
return getPropertyAsString(COUNTLIM);
}
Gets the size limit attribute of the LDAPSampler object |
public long getCountlimAsLong() {
return getPropertyAsLong(COUNTLIM);
}
|
public LDAPArguments getLDAPArguments() {
return (LDAPArguments) getProperty(LDAPARGUMENTS).getObjectValue();
}
Gets the LDAPArguments attribute of the LdapConfig object |
public String getLabel() {
return ("ldap://" + this.getServername() //$NON-NLS-1$
+ ":" + getPort() //$NON-NLS-1$
+ "/" + this.getRootdn()); //$NON-NLS-1$
}
Returns a formatted string label describing this sampler Example output: |
public String getPort() {
return getPropertyAsString(PORT);
}
Gets the Port attribute of the LDAPSampler object |
public String getRootdn() {
return getPropertyAsString(ROOTDN);
}
Gets the Rootdn attribute of the LDAPSampler object |
public String getScope() {
return getPropertyAsString(SCOPE);
}
Gets the search scope attribute of the LDAPSampler object |
public int getScopeAsInt() {
return getPropertyAsInt(SCOPE);
}
|
public String getServername() {
return getPropertyAsString(SERVERNAME);
}
Gets the servername attribute of the LDAPSampler object |
public String getTest() {
return getPropertyAsString(TEST);
}
Gets the test attribute of the LDAPSampler object |
public String getTimelim() {
return getPropertyAsString(TIMELIM);
}
Gets the time limit attribute of the LDAPSampler object |
public int getTimelimAsInt() {
return getPropertyAsInt(TIMELIM);
}
|
public String getUserDN() {
return getPropertyAsString(USERDN);
}
Gets the username attribute of the LDAP object |
public String getUserPw() {
return getPropertyAsString(USERPW);
}
Gets the password attribute of the LDAP object |
public boolean isDeref() {
return getPropertyAsBoolean(DEREF);
}
Gets the deref attribute of the LDAPSampler object |
public boolean isParseFlag() {
return getPropertyAsBoolean(PARSEFLAG);
}
|
public boolean isRetobj() {
return getPropertyAsBoolean(RETOBJ);
}
Gets the return objects attribute of the LDAPSampler object |
public boolean isSecure() {
return getPropertyAsBoolean(SECURE);
}
|
public SampleResult sample(Entry e) {
XMLBuffer xmlBuffer = new XMLBuffer();
xmlBuffer.openTag("ldapanswer"); // $NON-NLS-1$
SampleResult res = new SampleResult();
res.setResponseData("successfull".getBytes());
res.setResponseMessage("Success"); // $NON-NLS-1$
res.setResponseCode("0"); // $NON-NLS-1$
res.setContentType("text/xml");// $NON-NLS-1$
boolean isSuccessful = true;
res.setSampleLabel(getName());
LdapExtClient temp_client = (LdapExtClient) ldapConnections.get(getThreadName());
DirContext dirContext = (DirContext) ldapContexts.get(getThreadName());
if (temp_client == null) {
temp_client = new LdapExtClient();
try {
dirContext = new InitialDirContext();
} catch (NamingException err) {
log.error("Ldap client context creation - ", err);
}
ldapConnections.put(getThreadName(), temp_client);
}
try {
xmlBuffer.openTag("operation"); // $NON-NLS-1$
final String testType = getTest();
xmlBuffer.tag("opertype", testType); // $NON-NLS-1$
log.debug("performing test: " + testType);
if (testType.equals(UNBIND)) {
res.setSamplerData("Unbind");
xmlBuffer.tag("baseobj",getRootdn()); // $NON-NLS-1$
xmlBuffer.tag("binddn",getUserDN()); // $NON-NLS-1$
unbindOp(temp_client, dirContext, res);
} else if (testType.equals(BIND)) {
res.setSamplerData("Bind as "+getUserDN());
xmlBuffer.tag("baseobj",getRootdn()); // $NON-NLS-1$
xmlBuffer.tag("binddn",getUserDN()); // $NON-NLS-1$
xmlBuffer.tag("connectionTO",getConnTimeOut()); // $NON-NLS-1$
bindOp(temp_client, dirContext, res);
} else if (testType.equals(SBIND)) {
res.setSamplerData("SingleBind as "+getUserDN());
xmlBuffer.tag("baseobj",getRootdn()); // $NON-NLS-1$
xmlBuffer.tag("binddn",getUserDN()); // $NON-NLS-1$
xmlBuffer.tag("connectionTO",getConnTimeOut()); // $NON-NLS-1$
singleBindOp(res);
} else if (testType.equals(COMPARE)) {
res.setSamplerData("Compare "+getPropertyAsString(COMPAREFILT) + " "
+ getPropertyAsString(COMPAREDN));
xmlBuffer.tag("comparedn",getPropertyAsString(COMPAREDN)); // $NON-NLS-1$
xmlBuffer.tag("comparefilter",getPropertyAsString(COMPAREFILT)); // $NON-NLS-1$
NamingEnumeration cmp=null;
try {
res.sampleStart();
cmp = temp_client.compare(dirContext, getPropertyAsString(COMPAREFILT),
getPropertyAsString(COMPAREDN));
if (!cmp.hasMore()) {
res.setResponseCode("5"); // $NON-NLS-1$
res.setResponseMessage("compareFalse");
isSuccessful = false;
}
} finally {
res.sampleEnd();
if (cmp != null) {
cmp.close();
}
}
} else if (testType.equals(ADD)) {
res.setSamplerData("Add object " + getBaseEntryDN());
xmlBuffer.tag("attributes",getArguments().toString()); // $NON-NLS-1$
xmlBuffer.tag("dn",getBaseEntryDN()); // $NON-NLS-1$
addTest(temp_client, dirContext, res);
} else if (testType.equals(DELETE)) {
res.setSamplerData("Delete object " + getBaseEntryDN());
xmlBuffer.tag("dn",getBaseEntryDN()); // $NON-NLS-1$
deleteTest(temp_client, dirContext, res);
} else if (testType.equals(MODIFY)) {
res.setSamplerData("Modify object " + getBaseEntryDN());
xmlBuffer.tag("dn",getBaseEntryDN()); // $NON-NLS-1$
xmlBuffer.tag("attributes",getLDAPArguments().toString()); // $NON-NLS-1$
modifyTest(temp_client, dirContext, res);
} else if (testType.equals(RENAME)) {
res.setSamplerData("ModDN object " + getPropertyAsString(MODDDN) + " to " + getPropertyAsString(NEWDN));
xmlBuffer.tag("dn",getPropertyAsString(MODDDN)); // $NON-NLS-1$
xmlBuffer.tag("newdn",getPropertyAsString(NEWDN)); // $NON-NLS-1$
renameTest(temp_client, dirContext, res);
} else if (testType.equals(SEARCH)) {
final String scopeStr = getScope();
final int scope = getScopeAsInt();
final String searchFilter = getPropertyAsString(SEARCHFILTER);
final String searchBase = getPropertyAsString(SEARCHBASE);
final String timeLimit = getTimelim();
final String countLimit = getCountlim();
res.setSamplerData("Search with filter " + searchFilter);
xmlBuffer.tag("searchfilter",searchFilter); // $NON-NLS-1$
xmlBuffer.tag("baseobj",getRootdn()); // $NON-NLS-1$
xmlBuffer.tag("searchbase",searchBase);// $NON-NLS-1$
xmlBuffer.tag("scope" , scopeStr); // $NON-NLS-1$
xmlBuffer.tag("countlimit",countLimit); // $NON-NLS-1$
xmlBuffer.tag("timelimit",timeLimit); // $NON-NLS-1$
NamingEnumeration srch=null;
try {
res.sampleStart();
srch = temp_client.searchTest(
dirContext, searchBase, searchFilter,
scope, getCountlimAsLong(),
getTimelimAsInt(),
getRequestAttributes(getAttrs()),
isRetobj(),
isDeref());
if (isParseFlag()) {
try {
xmlBuffer.openTag("searchresults"); // $NON-NLS-1$
writeSearchResults(xmlBuffer, srch);
} finally {
xmlBuffer.closeTag("searchresults"); // $NON-NLS-1$
}
} else {
xmlBuffer.tag("searchresults", // $NON-NLS-1$
"hasElements="+srch.hasMoreElements()); // $NON-NLS-1$
}
} finally {
if (srch != null){
srch.close();
}
res.sampleEnd();
}
}
} catch (NamingException ex) {
//log.warn("DEBUG",ex);
// e.g. javax.naming.SizeLimitExceededException: [LDAP: error code 4 - Sizelimit Exceeded]; remaining name ''
// 123456789012345678901
// TODO: tidy this up
String returnData = ex.toString();
final int indexOfLDAPErrCode = returnData.indexOf("LDAP: error code");
if (indexOfLDAPErrCode >= 0) {
res.setResponseMessage(returnData.substring(indexOfLDAPErrCode + 21, returnData
.indexOf("]"))); // $NON-NLS-1$
res.setResponseCode(returnData.substring(indexOfLDAPErrCode + 17, indexOfLDAPErrCode + 19));
} else {
res.setResponseMessage(returnData);
res.setResponseCode("800"); // $NON-NLS-1$
}
isSuccessful = false;
} finally {
xmlBuffer.closeTag("operation"); // $NON-NLS-1$
xmlBuffer.tag("responsecode",res.getResponseCode()); // $NON-NLS-1$
xmlBuffer.tag("responsemessage",res.getResponseMessage()); // $NON-NLS-1$
res.setResponseData(xmlBuffer.toString().getBytes());
res.setDataType(SampleResult.TEXT);
res.setSuccessful(isSuccessful);
}
return res;
}
!ToDo (Method description) |
public void setArguments(Arguments value) {
setProperty(new TestElementProperty(ARGUMENTS, value));
}
Sets the Arguments attribute of the LdapConfig object This will collect
values from the table for user defined test case |
public void setAttrs(String newAttrs) {
this.setProperty(ATTRIBS, newAttrs);
}
Sets the attributes of the LdapConfig object |
public void setBaseEntryDN(String newbaseentry) {
setProperty(new StringProperty(BASE_ENTRY_DN, newbaseentry));
}
Sets the Base Entry DN attribute of the LDAPSampler object |
public void setConnTimeOut(String connto) {
setProperty(new StringProperty(CONNTO, connto));
}
|
public void setCountlim(String newClim) {
this.setProperty(COUNTLIM, newClim);
}
Sets the size limit attribute of the LDAPSampler object |
public void setDeref(String newDref) {
this.setProperty(DEREF, newDref);
}
Sets the deref attribute of the LDAPSampler object |
public void setLDAPArguments(LDAPArguments value) {
setProperty(new TestElementProperty(LDAPARGUMENTS, value));
}
Sets the Arguments attribute of the LdapConfig object This will collect
values from the table for user defined test case |
public void setParseFlag(String parseFlag) {
setProperty(new StringProperty(PARSEFLAG, parseFlag));
}
|
public void setPort(String port) {
setProperty(new StringProperty(PORT, port));
}
Sets the Port attribute of the ServerConfig object |
public void setRetobj(String newRobj) {
this.setProperty(RETOBJ, newRobj);
}
Sets the return objects attribute of the LDAPSampler object
************************************************************** |
public void setRootdn(String newRootdn) {
this.setProperty(ROOTDN, newRootdn);
}
Sets the Rootdn attribute of the LDAPSampler object |
public void setScope(String newScope) {
this.setProperty(SCOPE, newScope);
}
Sets the search scope attribute of the LDAPSampler object |
public void setSecure(String sec) {
setProperty(new StringProperty(SECURE, sec));
}
|
public void setServername(String servername) {
setProperty(new StringProperty(SERVERNAME, servername));
}
Sets the Servername attribute of the ServerConfig object |
public void setTest(String newTest) {
this.setProperty(TEST, newTest);
}
Sets the Test attribute of the LdapConfig object |
public void setTimelim(String newTlim) {
this.setProperty(TIMELIM, newTlim);
}
Sets the time limit attribute of the LDAPSampler object |
public void setUserDN(String newUserDN) {
setProperty(new StringProperty(USERDN, newUserDN));
}
Sets the username attribute of the LDAP object
******************************************************* |
public void setUserPw(String newUserPw) {
setProperty(new StringProperty(USERPW, newUserPw));
}
Sets the password attribute of the LDAP object
******************************************************* |
public void testEnded() {
testEnded(""); // $NON-NLS-1$
}
|
public void testEnded(String host) {
Iterator it = ldapContexts.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String key = (String) entry.getKey();
DirContext dc = (DirContext) entry.getValue();
try {
log.warn("Tidying old Context for thread: " + key);
dc.close();
} catch (NamingException ignored) {
// ignored
}
it.remove();// Make sure the entry is not left around for the next run
}
}
|
public void testIterationStart(LoopIterationEvent event) {
// ignored
}
|
public void testStarted() {
testStarted(""); // $NON-NLS-1$
}
|
public void testStarted(String host) {
// ignored
}
|