Author: sebb
Date: Sun Mar 11 10:50:57 2007
New Revision: 516970
URL: http://svn.apache.org/viewvc?view=rev&rev=516970
Log:
Bug 40103 - various LDAP enhancements
Modified:
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapExtConfigGui.java
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java
jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml
jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml
Modified:
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties?view=diff&rev=516970&r1=516969&r2=516970
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
Sun Mar 11 10:50:57 2007
@@ -362,10 +362,16 @@
junit_test_method=Test Method
junit_test_config=JUnit Test Parameters
ldap_argument_list=LDAPArgument List
+ldap_connto=Connection timeout (in milliseconds)
+ldap_parse_results=Parse the search results ?
ldap_sample_title=LDAP Request Defaults
+ldap_search_baseobject=Perform baseobject search
+ldap_search_onelevel=Perform onelevel search
+ldap_search_subtree=Perform subtree search
ldap_testing_title=LDAP Request
ldapext_sample_title=LDAP Extended Request Defaults
ldapext_testing_title= LDAP Extended Request
+ldap_secure=Use Secure LDAP Protocol ?
load=Load
load_wsdl=Load WSDL
log_errors_only=Log Errors Only
Modified:
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapExtConfigGui.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapExtConfigGui.java?view=diff&rev=516970&r1=516969&r2=516970
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapExtConfigGui.java
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapExtConfigGui.java
Sun Mar 11 10:50:57 2007
@@ -1,4 +1,3 @@
-//$Header$
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -26,6 +25,7 @@
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
+import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
@@ -42,6 +42,7 @@
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.JLabeledChoice;
/*******************************************************************************
* author Dolf Smits([EMAIL PROTECTED]) created Aug 09 2003 11:00 AM
@@ -77,7 +78,20 @@
private JTextField port = new JTextField(20);
- private JTextField scope = new JTextField(20);
+ /*
+ * N.B. These entries MUST agree with the LDAP SearchControls
SCOPE_LEVELS
+ * These have the values 0,1,2 so can be used as indexes in the array
+ * as well as the value for the search itself.
+ */
+ private static final String[] SCOPE_STRINGS = new String[]{
+ JMeterUtils.getResString("ldap_search_baseobject"),//
$NON-NLS-1$
+ JMeterUtils.getResString("ldap_search_onelevel"),// $NON-NLS-1$
+ JMeterUtils.getResString("ldap_search_subtree"),// $NON-NLS-1$
+ };
+
+ private JLabeledChoice scope =
+ new JLabeledChoice(JMeterUtils.getResString("scope"), //
$NON-NLS-1$
+ SCOPE_STRINGS);
private JTextField countlim = new JTextField(20);
@@ -85,10 +99,10 @@
private JTextField attribs = new JTextField(20);
- private JTextField retobj = new JTextField(20);
-
- private JTextField deref = new JTextField(20);
+ private JCheckBox retobj = new
JCheckBox(JMeterUtils.getResString("retobj")); // $NON-NLS-1$
+ private JCheckBox deref = new
JCheckBox(JMeterUtils.getResString("deref")); // $NON-NLS-1$
+
private JTextField userdn = new JTextField(20);
private JTextField userpw = new JPasswordField(20);
@@ -97,39 +111,41 @@
private JTextField comparefilt = new JTextField(20);
- private JTextField suserdn = new JTextField(20);
-
- private JTextField suserpw = new JPasswordField(20);
-
private JTextField modddn = new JTextField(20);
private JTextField newdn = new JTextField(20);
- private JRadioButton addTest = new
JRadioButton(JMeterUtils.getResString("addTest"));
+ private JTextField connto = new JTextField(20);
- private JRadioButton modifyTest = new
JRadioButton(JMeterUtils.getResString("modTest"));
+ private JCheckBox parseflag = new
JCheckBox(JMeterUtils.getResString("ldap_parse_results")); // $NON-NLS-1$
+
+ private JCheckBox secure = new
JCheckBox(JMeterUtils.getResString("ldap_secure")); // $NON-NLS-1$
+
+ private JRadioButton addTest = new
JRadioButton(JMeterUtils.getResString("addTest")); // $NON-NLS-1$
- private JRadioButton deleteTest = new
JRadioButton(JMeterUtils.getResString("delTest"));
+ private JRadioButton modifyTest = new
JRadioButton(JMeterUtils.getResString("modTest")); // $NON-NLS-1$
- private JRadioButton searchTest = new
JRadioButton(JMeterUtils.getResString("searchTest"));
+ private JRadioButton deleteTest = new
JRadioButton(JMeterUtils.getResString("delTest")); // $NON-NLS-1$
- private JRadioButton bind = new
JRadioButton(JMeterUtils.getResString("bind"));
+ private JRadioButton searchTest = new
JRadioButton(JMeterUtils.getResString("searchTest")); // $NON-NLS-1$
- private JRadioButton rename = new
JRadioButton(JMeterUtils.getResString("rename"));
+ private JRadioButton bind = new
JRadioButton(JMeterUtils.getResString("bind")); // $NON-NLS-1$
- private JRadioButton unbind = new
JRadioButton(JMeterUtils.getResString("unbind"));
+ private JRadioButton rename = new
JRadioButton(JMeterUtils.getResString("rename")); // $NON-NLS-1$
- private JRadioButton sbind = new
JRadioButton(JMeterUtils.getResString("sbind"));
+ private JRadioButton unbind = new
JRadioButton(JMeterUtils.getResString("unbind")); // $NON-NLS-1$
- private JRadioButton compare = new
JRadioButton(JMeterUtils.getResString("compare"));
+ private JRadioButton sbind = new
JRadioButton(JMeterUtils.getResString("sbind")); // $NON-NLS-1$
+
+ private JRadioButton compare = new
JRadioButton(JMeterUtils.getResString("compare")); // $NON-NLS-1$
private ButtonGroup bGroup = new ButtonGroup();
private boolean displayName = true;
- ArgumentsPanel tableAddPanel = new
ArgumentsPanel(JMeterUtils.getResString("addTest"));
+ ArgumentsPanel tableAddPanel = new
ArgumentsPanel(JMeterUtils.getResString("addTest")); // $NON-NLS-1$
- LDAPArgumentsPanel tableModifyPanel = new
LDAPArgumentsPanel(JMeterUtils.getResString("modTest"));
+ LDAPArgumentsPanel tableModifyPanel = new
LDAPArgumentsPanel(JMeterUtils.getResString("modTest")); // $NON-NLS-1$
private JPanel cards;
@@ -152,12 +168,7 @@
}
public String getLabelResource() {
- return "ldapext_sample_title";
- }
-
- // Remove this when status changes (and update component_reference)
- public String getStaticLabel() {
- return super.getStaticLabel() + " (ALPHA)";
+ return "ldapext_sample_title"; // $NON-NLS-1$
}
/**
@@ -174,56 +185,57 @@
servername.setText(element.getPropertyAsString(LDAPExtSampler.SERVERNAME));
port.setText(element.getPropertyAsString(LDAPExtSampler.PORT));
rootdn.setText(element.getPropertyAsString(LDAPExtSampler.ROOTDN));
-
scope.setText(element.getPropertyAsString(LDAPExtSampler.SCOPE));
+
scope.setSelectedIndex(element.getPropertyAsInt(LDAPExtSampler.SCOPE));
countlim.setText(element.getPropertyAsString(LDAPExtSampler.COUNTLIM));
timelim.setText(element.getPropertyAsString(LDAPExtSampler.TIMELIM));
attribs.setText(element.getPropertyAsString(LDAPExtSampler.ATTRIBS));
-
retobj.setText(element.getPropertyAsString(LDAPExtSampler.RETOBJ));
-
deref.setText(element.getPropertyAsString(LDAPExtSampler.DEREF));
+
retobj.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.RETOBJ));
+
deref.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.DEREF));
+ connto.setText(element.getPropertyAsString(LDAPExtSampler.CONNTO));
+
parseflag.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.PARSEFLAG));
+
secure.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.SECURE));
userpw.setText(element.getPropertyAsString(LDAPExtSampler.USERPW));
userdn.setText(element.getPropertyAsString(LDAPExtSampler.USERDN));
comparedn.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREDN));
comparefilt.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREFILT));
-
suserpw.setText(element.getPropertyAsString(LDAPExtSampler.SUSERPW));
-
suserdn.setText(element.getPropertyAsString(LDAPExtSampler.SUSERDN));
modddn.setText(element.getPropertyAsString(LDAPExtSampler.MODDDN));
newdn.setText(element.getPropertyAsString(LDAPExtSampler.NEWDN));
CardLayout cl = (CardLayout) (cards.getLayout());
- if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("unbind")) {
+ if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("unbind")) { //
$NON-NLS-1$
unbind.setSelected(true);
cl.show(cards, "unbind");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("bind")) {
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("bind")) { //
$NON-NLS-1$
bind.setSelected(true);
cl.show(cards, "bind");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("sbind")) {
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("sbind")) { //
$NON-NLS-1$
sbind.setSelected(true);
cl.show(cards, "sbind");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("compare")) {
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("compare")) { //
$NON-NLS-1$
compare.setSelected(true);
cl.show(cards, "compare");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("add")) {
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("add")) { //
$NON-NLS-1$
addTest.setSelected(true);
add.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
tableAddPanel.configure((TestElement)
element.getProperty(LDAPExtSampler.ARGUMENTS).getObjectValue());
- cl.show(cards, "Add");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("modify")) {
+ cl.show(cards, "Add"); // $NON-NLS-1$
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("modify")) { //
$NON-NLS-1$
modifyTest.setSelected(true);
modify.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
tableModifyPanel
.configure((TestElement)
element.getProperty(LDAPExtSampler.LDAPARGUMENTS).getObjectValue());
- cl.show(cards, "Modify");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("delete")) {
+ cl.show(cards, "Modify"); // $NON-NLS-1$
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("delete")) { //
$NON-NLS-1$
deleteTest.setSelected(true);
delete.setText(element.getPropertyAsString(LDAPExtSampler.DELETE));
- cl.show(cards, "Delete");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("rename")) {
+ cl.show(cards, "Delete"); // $NON-NLS-1$
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("rename")) { //
$NON-NLS-1$
rename.setSelected(true);
- cl.show(cards, "rename");
- } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("search")) {
+ cl.show(cards, "rename"); // $NON-NLS-1$
+ } else if
(element.getPropertyAsString(LDAPExtSampler.TEST).equals("search")) { //
$NON-NLS-1$
searchTest.setSelected(true);
searchbase.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHBASE));
searchfilter.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHFILTER));
- cl.show(cards, "Search");
+ cl.show(cards, "Search"); // $NON-NLS-1$
}
}
@@ -245,18 +257,19 @@
element.setProperty(LDAPExtSampler.SERVERNAME,
servername.getText());
element.setProperty(LDAPExtSampler.PORT, port.getText());
element.setProperty(LDAPExtSampler.ROOTDN, rootdn.getText());
- element.setProperty(LDAPExtSampler.SCOPE, scope.getText());
+
element.setProperty(LDAPExtSampler.SCOPE,String.valueOf(scope.getSelectedIndex()));
element.setProperty(LDAPExtSampler.COUNTLIM,
countlim.getText());
element.setProperty(LDAPExtSampler.TIMELIM, timelim.getText());
element.setProperty(LDAPExtSampler.ATTRIBS, attribs.getText());
- element.setProperty(LDAPExtSampler.RETOBJ, retobj.getText());
- element.setProperty(LDAPExtSampler.DEREF, deref.getText());
+
element.setProperty(LDAPExtSampler.RETOBJ,Boolean.toString(retobj.isSelected()));
+
element.setProperty(LDAPExtSampler.DEREF,Boolean.toString(deref.isSelected()));
+ element.setProperty(LDAPExtSampler.CONNTO, connto.getText());
+
element.setProperty(LDAPExtSampler.PARSEFLAG,Boolean.toString(parseflag.isSelected()));
+
element.setProperty(LDAPExtSampler.SECURE,Boolean.toString(secure.isSelected()));
element.setProperty(LDAPExtSampler.USERDN, userdn.getText());
element.setProperty(LDAPExtSampler.USERPW, userpw.getText());
element.setProperty(LDAPExtSampler.COMPAREDN,
comparedn.getText());
element.setProperty(LDAPExtSampler.COMPAREFILT,
comparefilt.getText());
- element.setProperty(LDAPExtSampler.SUSERDN, suserdn.getText());
- element.setProperty(LDAPExtSampler.SUSERPW, suserpw.getText());
element.setProperty(LDAPExtSampler.MODDDN, modddn.getText());
element.setProperty(LDAPExtSampler.NEWDN, newdn.getText());
if (addTest.isSelected()) {
@@ -275,7 +288,7 @@
element.setProperty(new
StringProperty(LDAPExtSampler.DELETE, delete.getText()));
}
if (searchTest.isSelected()) {
- element.setProperty(new
StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.SEARCHBASE));
+ element.setProperty(new
StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.SEARCH));
element.setProperty(new
StringProperty(LDAPExtSampler.SEARCHBASE, searchbase.getText()));
element.setProperty(new
StringProperty(LDAPExtSampler.SEARCHFILTER, searchfilter.getText()));
}
@@ -303,23 +316,23 @@
public void itemStateChanged(ItemEvent ie) {
CardLayout cl = (CardLayout) (cards.getLayout());
if (addTest.isSelected()) {
- cl.show(cards, "Add");
+ cl.show(cards, "Add"); // $NON-NLS-1$
} else if (deleteTest.isSelected()) {
- cl.show(cards, "Delete");
+ cl.show(cards, "Delete"); // $NON-NLS-1$
} else if (bind.isSelected()) {
- cl.show(cards, "Bind");
+ cl.show(cards, "Bind"); // $NON-NLS-1$
} else if (sbind.isSelected()) {
- cl.show(cards, "Sbind");
+ cl.show(cards, "Bind"); // $NON-NLS-1$
} else if (rename.isSelected()) {
- cl.show(cards, "Rename");
+ cl.show(cards, "Rename"); // $NON-NLS-1$
} else if (compare.isSelected()) {
- cl.show(cards, "Compare");
+ cl.show(cards, "Compare"); // $NON-NLS-1$
} else if (searchTest.isSelected()) {
- cl.show(cards, "Search");
+ cl.show(cards, "Search"); // $NON-NLS-1$
} else if (modifyTest.isSelected()) {
- cl.show(cards, "Modify");
- } else {
- cl.show(cards, "");
+ cl.show(cards, "Modify"); // $NON-NLS-1$
+ } else { // e.g unbind
+ cl.show(cards, ""); // $NON-NLS-1$
}
}
@@ -328,7 +341,7 @@
**************************************************************************/
private JPanel createServernamePanel() {
JPanel serverPanel = new JPanel(new BorderLayout(5, 0));
- JLabel label = new
JLabel(JMeterUtils.getResString("servername"));
+ JLabel label = new
JLabel(JMeterUtils.getResString("servername")); // $NON-NLS-1$
label.setLabelFor(servername);
serverPanel.add(label, BorderLayout.WEST);
serverPanel.add(servername, BorderLayout.CENTER);
@@ -340,7 +353,7 @@
**************************************************************************/
private JPanel createPortPanel() {
JPanel portPanel = new JPanel(new BorderLayout(5, 0));
- JLabel label = new JLabel(JMeterUtils.getResString("port"));
+ JLabel label = new JLabel(JMeterUtils.getResString("port")); //
$NON-NLS-1$
label.setLabelFor(port);
portPanel.add(label, BorderLayout.WEST);
portPanel.add(port, BorderLayout.CENTER);
@@ -352,7 +365,7 @@
**************************************************************************/
private JPanel createRootdnPanel() {
JPanel rootdnPanel = new JPanel(new BorderLayout(5, 0));
- JLabel label = new JLabel(JMeterUtils.getResString("ddn"));
+ JLabel label = new JLabel(JMeterUtils.getResString("ddn")); //
$NON-NLS-1$
label.setLabelFor(rootdn);
rootdnPanel.add(label, BorderLayout.WEST);
rootdnPanel.add(rootdn, BorderLayout.CENTER);
@@ -360,28 +373,7 @@
}
/***************************************************************************
- * This will create the bind panel in the LdapConfigGui
-
**************************************************************************/
- private JPanel createSbindPanel() {
- VerticalPanel sbindPanel = new VerticalPanel();
- JPanel sBPanel = new JPanel(new BorderLayout(5, 0));
- JLabel sBlabel0 = new
JLabel(JMeterUtils.getResString("userdn"));
- sBlabel0.setLabelFor(suserdn);
- sBPanel.add(sBlabel0, BorderLayout.WEST);
- sBPanel.add(suserdn, BorderLayout.CENTER);
- sbindPanel.add(sBPanel);
-
- JPanel sB1Panel = new JPanel(new BorderLayout(5, 0));
- JLabel sBlabel1 = new
JLabel(JMeterUtils.getResString("userpw"));
- sBlabel1.setLabelFor(suserpw);
- sB1Panel.add(sBlabel1, BorderLayout.WEST);
- sB1Panel.add(suserpw, BorderLayout.CENTER);
- sbindPanel.add(sB1Panel);
- return sbindPanel;
- }
-
-
/***************************************************************************
- * This will create the bind panel in the LdapConfigGui
+ * This will create the bind/sbind panel in the LdapConfigGui
**************************************************************************/
private JPanel createBindPanel() {
VerticalPanel bindPanel = new VerticalPanel();
@@ -390,18 +382,27 @@
bindPanel.add(createRootdnPanel());
JPanel BPanel = new JPanel(new BorderLayout(5, 0));
- JLabel Blabel0 = new JLabel(JMeterUtils.getResString("userdn"));
- Blabel0.setLabelFor(scope);
+ JLabel Blabel0 = new
JLabel(JMeterUtils.getResString("userdn")); // $NON-NLS-1$
+ Blabel0.setLabelFor(userdn);
BPanel.add(Blabel0, BorderLayout.WEST);
BPanel.add(userdn, BorderLayout.CENTER);
bindPanel.add(BPanel);
JPanel B1Panel = new JPanel(new BorderLayout(5, 0));
- JLabel Blabel1 = new JLabel(JMeterUtils.getResString("userpw"));
- Blabel1.setLabelFor(countlim);
+ JLabel Blabel1 = new
JLabel(JMeterUtils.getResString("userpw")); // $NON-NLS-1$
+ Blabel1.setLabelFor(userpw);
B1Panel.add(Blabel1, BorderLayout.WEST);
B1Panel.add(userpw, BorderLayout.CENTER);
bindPanel.add(B1Panel);
+
+ JPanel B2Panel = new JPanel(new BorderLayout(5, 0));
+ JLabel Blabel2 = new JLabel(JMeterUtils.getResString("ldap_connto"));
// $NON-NLS-1$
+ Blabel2.setLabelFor(connto);
+ B2Panel.add(Blabel2, BorderLayout.WEST);
+ B2Panel.add(connto, BorderLayout.CENTER);
+ bindPanel.add(B2Panel);
+
+ bindPanel.add(secure);
return bindPanel;
}
@@ -411,14 +412,14 @@
private JPanel createComparePanel() {
VerticalPanel cbindPanel = new VerticalPanel();
JPanel cBPanel = new JPanel(new BorderLayout(5, 0));
- JLabel cBlabel0 = new
JLabel(JMeterUtils.getResString("entrydn"));
+ JLabel cBlabel0 = new
JLabel(JMeterUtils.getResString("entrydn")); // $NON-NLS-1$
cBlabel0.setLabelFor(comparedn);
cBPanel.add(cBlabel0, BorderLayout.WEST);
cBPanel.add(comparedn, BorderLayout.CENTER);
cbindPanel.add(cBPanel);
JPanel cBPanel1 = new JPanel(new BorderLayout(5, 0));
- JLabel cBlabel1 = new
JLabel(JMeterUtils.getResString("comparefilt"));
+ JLabel cBlabel1 = new
JLabel(JMeterUtils.getResString("comparefilt")); // $NON-NLS-1$
cBlabel1.setLabelFor(comparefilt);
cBPanel1.add(cBlabel1, BorderLayout.WEST);
cBPanel1.add(comparefilt, BorderLayout.CENTER);
@@ -434,46 +435,36 @@
VerticalPanel SCPanel = new VerticalPanel();
JPanel SC0Panel = new JPanel(new BorderLayout(5, 0));
- JLabel label0 = new JLabel(JMeterUtils.getResString("scope"));
+ JLabel label0 = new JLabel(JMeterUtils.getResString("scope"));
// $NON-NLS-1$
label0.setLabelFor(scope);
SC0Panel.add(label0, BorderLayout.WEST);
SC0Panel.add(scope, BorderLayout.CENTER);
SCPanel.add(SC0Panel);
JPanel SC1Panel = new JPanel(new BorderLayout(5, 0));
- JLabel label1 = new
JLabel(JMeterUtils.getResString("countlim"));
+ JLabel label1 = new
JLabel(JMeterUtils.getResString("countlim")); // $NON-NLS-1$
label1.setLabelFor(countlim);
SC1Panel.add(label1, BorderLayout.WEST);
SC1Panel.add(countlim, BorderLayout.CENTER);
SCPanel.add(SC1Panel);
JPanel SC2Panel = new JPanel(new BorderLayout(5, 0));
- JLabel label2 = new JLabel(JMeterUtils.getResString("timelim"));
+ JLabel label2 = new
JLabel(JMeterUtils.getResString("timelim")); // $NON-NLS-1$
label2.setLabelFor(timelim);
SC2Panel.add(label2, BorderLayout.WEST);
SC2Panel.add(timelim, BorderLayout.CENTER);
SCPanel.add(SC2Panel);
JPanel SC3Panel = new JPanel(new BorderLayout(5, 0));
- JLabel label3 = new JLabel(JMeterUtils.getResString("attrs"));
+ JLabel label3 = new JLabel(JMeterUtils.getResString("attrs"));
// $NON-NLS-1$
label3.setLabelFor(attribs);
SC3Panel.add(label3, BorderLayout.WEST);
SC3Panel.add(attribs, BorderLayout.CENTER);
SCPanel.add(SC3Panel);
- JPanel SC4Panel = new JPanel(new BorderLayout(5, 0));
- JLabel label4 = new JLabel(JMeterUtils.getResString("retobj"));
- label4.setLabelFor(retobj);
- SC4Panel.add(label4, BorderLayout.WEST);
- SC4Panel.add(retobj, BorderLayout.CENTER);
- SCPanel.add(SC4Panel);
-
- JPanel SC5Panel = new JPanel(new BorderLayout(5, 0));
- JLabel label5 = new JLabel(JMeterUtils.getResString("deref"));
- label5.setLabelFor(deref);
- SC5Panel.add(label5, BorderLayout.WEST);
- SC5Panel.add(deref, BorderLayout.CENTER);
- SCPanel.add(SC5Panel);
+ SCPanel.add(retobj);
+ SCPanel.add(deref);
+ SCPanel.add(parseflag);
return SCPanel;
}
@@ -486,13 +477,13 @@
VerticalPanel searchPanel = new VerticalPanel();
JPanel searchBPanel = new JPanel(new BorderLayout(5, 0));
- JLabel label = new
JLabel(JMeterUtils.getResString("searchbase"));
+ JLabel label = new
JLabel(JMeterUtils.getResString("searchbase")); // $NON-NLS-1$
label.setLabelFor(searchbase);
searchBPanel.add(label, BorderLayout.WEST);
searchBPanel.add(searchbase, BorderLayout.CENTER);
JPanel searchFPanel = new JPanel(new BorderLayout(5, 0));
- JLabel label20 = new
JLabel(JMeterUtils.getResString("searchfilter"));
+ JLabel label20 = new
JLabel(JMeterUtils.getResString("searchfilter")); // $NON-NLS-1$
label20.setLabelFor(searchfilter);
searchFPanel.add(label20, BorderLayout.WEST);
searchFPanel.add(searchfilter, BorderLayout.CENTER);
@@ -500,6 +491,7 @@
searchPanel.add(searchBPanel);
searchPanel.add(searchFPanel);
searchPanel.add(createSCPanel());
+
return searchPanel;
}
@@ -511,13 +503,13 @@
VerticalPanel modPanel = new VerticalPanel();
JPanel renamePanel = new JPanel(new BorderLayout(5, 0));
- JLabel labelmod = new
JLabel(JMeterUtils.getResString("modddn"));
+ JLabel labelmod = new
JLabel(JMeterUtils.getResString("modddn")); // $NON-NLS-1$
labelmod.setLabelFor(modddn);
renamePanel.add(labelmod, BorderLayout.WEST);
renamePanel.add(modddn, BorderLayout.CENTER);
JPanel rename2Panel = new JPanel(new BorderLayout(5, 0));
- JLabel labelmod2 = new
JLabel(JMeterUtils.getResString("newdn"));
+ JLabel labelmod2 = new
JLabel(JMeterUtils.getResString("newdn")); // $NON-NLS-1$
labelmod2.setLabelFor(newdn);
rename2Panel.add(labelmod2, BorderLayout.WEST);
rename2Panel.add(newdn, BorderLayout.CENTER);
@@ -533,7 +525,7 @@
private JPanel createDeletePanel() {
VerticalPanel panel = new VerticalPanel();
JPanel deletePanel = new JPanel(new BorderLayout(5, 0));
- JLabel label = new JLabel(JMeterUtils.getResString("delete"));
+ JLabel label = new JLabel(JMeterUtils.getResString("delete"));
// $NON-NLS-1$
label.setLabelFor(delete);
deletePanel.add(label, BorderLayout.WEST);
deletePanel.add(delete, BorderLayout.CENTER);
@@ -547,7 +539,7 @@
private JPanel createAddPanel() {
JPanel addPanel = new JPanel(new BorderLayout(5, 0));
JPanel addInnerPanel = new JPanel(new BorderLayout(5, 0));
- JLabel label = new JLabel(JMeterUtils.getResString("entrydn"));
+ JLabel label = new JLabel(JMeterUtils.getResString("entrydn"));
// $NON-NLS-1$
label.setLabelFor(add);
addInnerPanel.add(label, BorderLayout.WEST);
addInnerPanel.add(add, BorderLayout.CENTER);
@@ -562,7 +554,7 @@
private JPanel createModifyPanel() {
JPanel modifyPanel = new JPanel(new BorderLayout(5, 0));
JPanel modifyInnerPanel = new JPanel(new BorderLayout(5, 0));
- JLabel label = new JLabel(JMeterUtils.getResString("entrydn"));
+ JLabel label = new JLabel(JMeterUtils.getResString("entrydn"));
// $NON-NLS-1$
label.setLabelFor(modify);
modifyInnerPanel.add(label, BorderLayout.WEST);
modifyInnerPanel.add(modify, BorderLayout.CENTER);
@@ -578,15 +570,14 @@
**************************************************************************/
private JPanel testPanel() {
cards = new JPanel(new CardLayout());
- cards.add(new JPanel(), "");
- cards.add(createAddPanel(), "Add");
- cards.add(createModifyPanel(), "Modify");
- cards.add(createModdnPanel(), "Rename");
- cards.add(createDeletePanel(), "Delete");
- cards.add(createSearchPanel(), "Search");
- cards.add(createBindPanel(), "Bind");
- cards.add(createComparePanel(), "Compare");
- cards.add(createSbindPanel(), "Sbind");
+ cards.add(new JPanel(), ""); // $NON-NLS-1$
+ cards.add(createAddPanel(), "Add"); // $NON-NLS-1$
+ cards.add(createModifyPanel(), "Modify"); // $NON-NLS-1$
+ cards.add(createModdnPanel(), "Rename"); // $NON-NLS-1$
+ cards.add(createDeletePanel(), "Delete"); // $NON-NLS-1$
+ cards.add(createSearchPanel(), "Search"); // $NON-NLS-1$
+ cards.add(createBindPanel(), "Bind"); // $NON-NLS-1$
+ cards.add(createComparePanel(), "Compare"); // $NON-NLS-1$
return cards;
}
@@ -595,9 +586,9 @@
**************************************************************************/
private JPanel createTestPanel() {
JPanel testPanel = new JPanel(new BorderLayout());
-
testPanel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("test_configuration")));
+
testPanel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("test_configuration")));
// $NON-NLS-1$
- testPanel.add(new JLabel(JMeterUtils.getResString("testt")));
+ testPanel.add(new JLabel(JMeterUtils.getResString("testt")));
// $NON-NLS-1$
JPanel rowPanel = new JPanel();
JPanel row2Panel = new JPanel();
@@ -637,6 +628,7 @@
mainPanel.add(createTestPanel());
mainPanel.add(testPanel());
add(mainPanel, BorderLayout.CENTER);
+ // Take note of when buttong are changed so can change panel
bind.addItemListener(this);
sbind.addItemListener(this);
unbind.addItemListener(this);
Modified:
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java?view=diff&rev=516970&r1=516969&r2=516970
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
Sun Mar 11 10:50:57 2007
@@ -31,7 +31,6 @@
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import org.apache.jmeter.config.Argument;
@@ -47,6 +46,7 @@
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;
import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.util.XMLBuffer;
import org.apache.log.Logger;
/*******************************************************************************
@@ -58,14 +58,21 @@
private static final Logger log = LoggingManager.getLoggerForClass();
+ /*
+ * The following strings are used in the test plan, and the values must
not be changed
+ * if test plans are to be upwardly compatible.
+ */
public final static String SERVERNAME = "servername"; // $NON-NLS-1$
public final static String PORT = "port"; // $NON-NLS-1$
+
+ public final static String SECURE = "secure"; // $NON-NLS-1$
public final static String ROOTDN = "rootdn"; // $NON-NLS-1$
public final static String TEST = "test"; // $NON-NLS-1$
+ // These are values for the TEST attribute above
public final static String ADD = "add"; // $NON-NLS-1$
public final static String MODIFY = "modify"; // $NON-NLS-1$
@@ -76,6 +83,9 @@
public final static String DELETE = "delete"; // $NON-NLS-1$
+ public final static String SEARCH = "search"; // $NON-NLS-1$
+ // end of TEST values
+
public final static String SEARCHBASE = "search"; // $NON-NLS-1$
public final static String SEARCHFILTER = "searchfilter"; // $NON-NLS-1$
@@ -105,15 +115,15 @@
public final static String SBIND = "sbind"; // $NON-NLS-1$
public final static String COMPARE = "compare"; // $NON-NLS-1$
-
- public final static String SUSERDN = "suser_dn"; // $NON-NLS-1$
-
- public final static String SUSERPW = "suser_pw"; // $NON-NLS-1$
+
+ public final static String CONNTO = "connection_timeout"; // $NON-NLS-1$
public final static String COMPAREDN = "comparedn"; // $NON-NLS-1$
public final static String COMPAREFILT = "comparefilt"; // $NON-NLS-1$
+ public final static String PARSEFLAG = "parseflag"; // $NON-NLS-1$
+
public final static String RENAME = "rename"; // $NON-NLS-1$
public final static String MODDDN = "modddn"; // $NON-NLS-1$
@@ -135,6 +145,31 @@
public LDAPExtSampler() {
}
+ public void setConnTimeOut(String connto) {
+ setProperty(new StringProperty(CONNTO, connto));
+ }
+
+ public String getConnTimeOut() {
+ return getPropertyAsString(CONNTO);
+ }
+
+ public void setSecure(String sec) {
+ setProperty(new StringProperty(SECURE, sec));
+ }
+
+ public boolean isSecure() {
+ return getPropertyAsBoolean(SECURE);
+ }
+
+
+ public boolean isParseFlag() {
+ return getPropertyAsBoolean(PARSEFLAG);
+ }
+
+ public void setParseFlag(String parseFlag) {
+ setProperty(new StringProperty(PARSEFLAG, parseFlag));
+ }
+
/***************************************************************************
* Gets the username attribute of the LDAP object
*
@@ -176,46 +211,6 @@
}
/***************************************************************************
- * Gets the username attribute of the LDAP object
- *
- * @return The username
-
**************************************************************************/
-
- public String getSuserDN() {
- return getPropertyAsString(SUSERDN);
- }
-
-
/***************************************************************************
- * Sets the username attribute of the LDAP object
- *
- * @return The username
-
**************************************************************************/
-
- public void setSuserDN(String newUserDN) {
- setProperty(new StringProperty(SUSERDN, newUserDN));
- }
-
-
/***************************************************************************
- * Gets the password attribute of the LDAP object
- *
- * @return The password
-
**************************************************************************/
-
- public String getSuserPw() {
- return getPropertyAsString(SUSERPW);
- }
-
-
/***************************************************************************
- * Gets the password attribute of the LDAP object
- *
- * @return The password
-
**************************************************************************/
-
- public void setSuserPw(String newUserPw) {
- setProperty(new StringProperty(SUSERPW, newUserPw));
- }
-
-
/***************************************************************************
* Sets the Servername attribute of the ServerConfig object
*
* @param servername
@@ -632,7 +627,7 @@
ctx.close();
}
res.sampleStart();
- ctx = ldap.connect(getServername(), getPort(), getRootdn(),
getUserDN(), getUserPw());
+ ctx = ldap.connect(getServername(), getPort(), getRootdn(),
getUserDN(), getUserPw(),getConnTimeOut(),isSecure());
res.sampleEnd();
ldapContexts.put(getThreadName(), ctx);
}
@@ -646,7 +641,7 @@
LdapExtClient ldap_temp;
ldap_temp = new LdapExtClient();
res.sampleStart();
- DirContext ctx = ldap_temp.connect(getServername(), getPort(),
getRootdn(), getSuserDN(), getSuserPw());
+ DirContext ctx = ldap_temp.connect(getServername(), getPort(),
getRootdn(), getUserDN(), getUserPw(),getConnTimeOut(),isSecure());
ldap_temp.disconnect(ctx);
res.sampleEnd();
}
@@ -668,7 +663,7 @@
*
* @return executed time for the bind op
**************************************************************************/
- private void unbindOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) throws NamingException {
+ private void unbindOp(LdapExtClient ldap, DirContext dirContext,
SampleResult res) {
res.sampleStart();
ldap.disconnect(dirContext);
res.sampleEnd();
@@ -685,7 +680,8 @@
* @return !ToDo (Return description)
**************************************************************************/
public SampleResult sample(Entry e) {
- String responseData = "<ldapanswer>";
+ XMLBuffer xmlBuffer = new XMLBuffer();
+ xmlBuffer.openTag("ldapanswer");
SampleResult res = new SampleResult();
res.setResponseData("successfull".getBytes());
res.setResponseMessage("Success");
@@ -705,131 +701,121 @@
}
try {
- log.debug("performing test: " +
getPropertyAsString(TEST));
- if (getPropertyAsString(TEST).equals("unbind")) {
+ xmlBuffer.openTag("operation");
+ final String testType = getPropertyAsString(TEST);
+ xmlBuffer.tag("opertype", testType);
+ log.debug("performing test: " + testType);
+ if (testType.equals("unbind")) {
res.setSamplerData("Unbind");
- responseData = responseData +
"<operation><opertype>unbind</opertype>";
- responseData = responseData + "<baseobj>" +
getRootdn() + "</baseobj>";
- responseData = responseData + "<binddn>" +
getUserDN() + "</binddn></operation>";
+ xmlBuffer.tag("baseobj",getRootdn());
+ xmlBuffer.tag("binddn",getUserDN());
unbindOp(temp_client, dirContext, res);
- } else if (getPropertyAsString(TEST).equals(BIND)) {
- res.setSamplerData("Bind as " + getUserDN());
- responseData = responseData +
"<operation><opertype>bind</opertype>";
- responseData = responseData + "<baseobj>" +
getRootdn() + "</baseobj>";
- responseData = responseData + "<binddn>" +
getUserDN() + "</binddn></operation>";
+ } else if (testType.equals(BIND)) {
+ res.setSamplerData("Bind as "+getUserDN());
+ xmlBuffer.tag("baseobj",getRootdn());
+ xmlBuffer.tag("binddn",getUserDN());
+ xmlBuffer.tag("connectionTO",getConnTimeOut());
bindOp(temp_client, dirContext, res);
- } else if (getPropertyAsString(TEST).equals(SBIND)) {
- res.setSamplerData("SingleBind as " +
getSuserDN());
- responseData = responseData +
"<operation><opertype>bind</opertype>";
- responseData = responseData + "<binddn>" +
getSuserDN() + "</binddn></operation>";
+ } else if (testType.equals(SBIND)) {
+ res.setSamplerData("SingleBind as
"+getUserDN());
+ xmlBuffer.tag("baseobj",getRootdn());
+ xmlBuffer.tag("binddn",getUserDN());
+ xmlBuffer.tag("connectionTO",getConnTimeOut());
singleBindOp(res);
- } else if (getPropertyAsString(TEST).equals(COMPARE)) {
- res.setSamplerData("Compare " +
getPropertyAsString(COMPAREFILT) + " "
+ } else if (testType.equals(COMPARE)) {
+ res.setSamplerData("Compare
"+getPropertyAsString(COMPAREFILT) + " "
+
getPropertyAsString(COMPAREDN));
- responseData = responseData +
"<operation><opertype>compare</opertype>";
- responseData = responseData + "<comparedn>" +
getPropertyAsString(COMPAREDN) + "</comparedn>";
- responseData = responseData + "<comparefilter>"
+ getPropertyAsString(COMPAREFILT)
- +
"</comparefilter></operation>";
+
xmlBuffer.tag("comparedn",getPropertyAsString(COMPAREDN));
+
xmlBuffer.tag("comparefilter",getPropertyAsString(COMPAREFILT));
res.sampleStart();
NamingEnumeration cmp = temp_client.compare(dirContext,
getPropertyAsString(COMPAREFILT), getPropertyAsString(COMPAREDN));
res.sampleEnd();
if (cmp.hasMore()) {
} else {
- res.setResponseCode("49");
+ res.setResponseCode("5");
res.setResponseMessage("compareFalse");
isSuccessful = false;
}
- } else if (getPropertyAsString(TEST).equals(ADD)) {
+ } else if (testType.equals(ADD)) {
res.setSamplerData("Add object " +
getPropertyAsString(BASE_ENTRY_DN));
- responseData = responseData +
"<operation><opertype>add</opertype>";
- responseData = responseData + "<attributes>" +
getArguments().toString() + "</attributes>";
- responseData = responseData + "<dn>" +
getPropertyAsString(BASE_ENTRY_DN) + "</dn></operation>";
+
xmlBuffer.tag("attributes",getArguments().toString());
+
xmlBuffer.tag("dn",getPropertyAsString(BASE_ENTRY_DN));
addTest(temp_client, dirContext, res);
- } else if (getPropertyAsString(TEST).equals(DELETE)) {
+ } else if (testType.equals(DELETE)) {
res.setSamplerData("Delete object " +
getPropertyAsString(DELETE));
- responseData = responseData +
"<operation><opertype>delete</opertype>";
- responseData = responseData + "<dn>" +
getPropertyAsString(DELETE) + "</dn></operation>";
+ xmlBuffer.tag("dn",getPropertyAsString(DELETE));
deleteTest(temp_client, dirContext, res);
- } else if (getPropertyAsString(TEST).equals(MODIFY)) {
+ } else if (testType.equals(MODIFY)) {
res.setSamplerData("Modify object " +
getPropertyAsString(BASE_ENTRY_DN));
- responseData = responseData +
"<operation><opertype>modify</opertype>";
- responseData = responseData + "<dn>" +
getPropertyAsString(BASE_ENTRY_DN) + "</dn>";
- responseData = responseData + "<attributes>" +
getLDAPArguments().toString()
- + "</attributes></operation>";
+
xmlBuffer.tag("dn",getPropertyAsString(BASE_ENTRY_DN));
+
xmlBuffer.tag("attributes",getLDAPArguments().toString());
modifyTest(temp_client, dirContext, res);
- } else if (getPropertyAsString(TEST).equals(RENAME)) {
+ } else if (testType.equals(RENAME)) {
res.setSamplerData("ModDN object " +
getPropertyAsString(MODDDN) + " to " + getPropertyAsString(NEWDN));
- responseData = responseData +
"<operation><opertype>moddn</opertype>";
- responseData = responseData + "<dn>" +
getPropertyAsString(MODDDN) + "</dn>";
- responseData = responseData + "<newdn>" +
getPropertyAsString(NEWDN) + "</newdn></operation>";
+ xmlBuffer.tag("dn",getPropertyAsString(MODDDN));
+
xmlBuffer.tag("newdn",getPropertyAsString(NEWDN));
renameTest(temp_client, dirContext, res);
- } else if
(getPropertyAsString(TEST).equals(SEARCHBASE)) {
+ } else if (testType.equals(SEARCH)) {
final String scopeStr = getPropertyAsString(SCOPE);
- final int scope;
+ final int scope = getPropertyAsInt(SCOPE);
+ final String searchFilter = getPropertyAsString(SEARCHFILTER);
+ final String searchBase =
getPropertyAsString(SEARCHBASE);
+ final String timeLimit =
getPropertyAsString(TIMELIM);
+ final String countLimit =
getPropertyAsString(COUNTLIM);
+
+ res.setSamplerData("Search with filter " +
searchFilter);
+ xmlBuffer.tag("searchfilter",searchFilter);
+ xmlBuffer.tag("searchbase",searchBase + "," +
getPropertyAsString(ROOTDN));
+ xmlBuffer.tag("scope" , scopeStr);
+ xmlBuffer.tag("countlimit",countLimit);
+ xmlBuffer.tag("timelimit",timeLimit);
- res.setSamplerData("Search with filter " +
getPropertyAsString(SEARCHFILTER));
- responseData = responseData +
"<operation><opertype>search</opertype>";
- responseData = responseData + "<searchfilter>"
+ getPropertyAsString(SEARCHFILTER) + "</searchfilter>";
- responseData = responseData + "<searchbase>" +
getPropertyAsString(SEARCHBASE) + ","
- + getPropertyAsString(ROOTDN) +
"</searchbase>";
- responseData = responseData + "<scope>" +
getPropertyAsString(SCOPE) + "</scope>";
- responseData = responseData + "<countlimit>" +
getPropertyAsString(COUNTLIM) + "</countlimit>";
- responseData = responseData + "<timelimit>" +
getPropertyAsString(TIMELIM) + "</timelimit>";
- responseData = responseData +
"</operation><searchresult>";
res.sampleStart();
-
- if ("object".equals(scopeStr)) { // $NON-NLS-1$
- scope = SearchControls.OBJECT_SCOPE;
- } else if ("onelevel".equals(scopeStr)) { // $NON-NLS-1$
- scope = SearchControls.ONELEVEL_SCOPE;
- } else if ("subtree".equals(scopeStr)) { // $NON-NLS-1$
- scope = SearchControls.SUBTREE_SCOPE;
- } else {
- // for backwards compatibility
- scope = getPropertyAsInt(SCOPE);
- }
-
- NamingEnumeration srch = temp_client.searchTest(dirContext,
getPropertyAsString(SEARCHBASE), getPropertyAsString(SEARCHFILTER),
- scope, getPropertyAsLong(COUNTLIM),
getPropertyAsInt(TIMELIM),
- getRequestAttributes(getPropertyAsString(ATTRIBS)),
getPropertyAsBoolean(RETOBJ),
+ NamingEnumeration srch = temp_client.searchTest(
+ dirContext, searchBase, searchFilter,
+ 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>";
- NamingEnumeration attrlist = sr.getAttributes().getIDs();
- while (attrlist.hasMore()) {
- String iets = (String)
attrlist.next();
- responseData = responseData +
"<attribute><attributename>" + iets
- +
"</attributename>";
- responseData = responseData
- +
"<attributevalue>"
- +
sr.getAttributes().get(iets).toString().substring(
-
iets.length() + 2) + "</attributevalue></attribute>";
+
+ if (isParseFlag()) {
+ xmlBuffer.openTag("searchresult");
+ while (srch.hasMore()) {
+ SearchResult sr =
(SearchResult) srch.next();
+ xmlBuffer.tag("dn",sr.getName()
+ "," +searchBase + "," + getRootdn());
+
xmlBuffer.tag("returnedattr",String.valueOf(sr.getAttributes().size()));
+ NamingEnumeration attrlist =
sr.getAttributes().getIDs();
+ while (attrlist.hasMore()) {
+ String iets = (String)
attrlist.next();
+
xmlBuffer.openTag("attribute");
+ xmlBuffer.tag("attributename", iets);
+
xmlBuffer.tag("attributevalue",
+
sr.getAttributes().get(iets).toString().substring(iets.length() + 2));
+
xmlBuffer.closeTag("attribute");
+ }
}
- }
- responseData = responseData + "</searchresult>";
+ }
}
} catch (NamingException ex) {
+ // TODO: tidy this up
String returnData = ex.toString();
- if (returnData.indexOf("LDAP: error code") >= 0) {
-
res.setResponseMessage(returnData.substring(returnData.indexOf("LDAP: error
code") + 22, returnData
+ final int indexOfLDAPErrCode =
returnData.indexOf("LDAP: error code");
+ if (indexOfLDAPErrCode >= 0) {
+
res.setResponseMessage(returnData.substring(indexOfLDAPErrCode + 21, returnData
.indexOf("]")));
-
res.setResponseCode(returnData.substring(returnData.indexOf("LDAP: error code")
+ 17, returnData
- .indexOf("LDAP: error code") +
19));
+
res.setResponseCode(returnData.substring(indexOfLDAPErrCode + 17,
indexOfLDAPErrCode + 19));
} else {
res.setResponseMessage(returnData);
res.setResponseCode("800"); // $NON-NLS-1$
}
isSuccessful = false;
} finally {
- responseData = responseData + "<responsecode>" +
res.getResponseCode() + "</responsecode>";
- responseData = responseData + "<responsemessage>" +
res.getResponseMessage() + "</responsemessage>";
- responseData = responseData + "</ldapanswer>";
- res.setResponseData(responseData.getBytes());
+ xmlBuffer.tag("responsecode",res.getResponseCode());
+
xmlBuffer.tag("responsemessage",res.getResponseMessage());
+ res.setResponseData(xmlBuffer.toString().getBytes());
res.setDataType(SampleResult.TEXT);
res.setSuccessful(isSuccessful);
}
Modified:
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java?view=diff&rev=516970&r1=516969&r2=516970
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LdapExtClient.java
Sun Mar 11 10:50:57 2007
@@ -67,15 +67,31 @@
* @exception NamingException
* Description of Exception
*/
- public DirContext connect(String host, String port, String rootdn,
String username, String password)
+ public DirContext connect(String host, String port, String rootdn,
String username, String password, String connTimeOut, boolean secure)
throws NamingException {
DirContext dirContext;
Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
- env.put(Context.PROVIDER_URL, "ldap://" + host + ":" + port +
"/" + rootdn);
- log.info("prov_url= " + env.get(Context.PROVIDER_URL));
- env.put(Context.REFERRAL, "throw");
- env.put("java.naming.batchsize", "0");
+ env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory"); // $NON-NLS-1$
+ StringBuffer sb = new StringBuffer(80);
+ if (secure) {
+ sb.append("ldaps://"); // $NON-NLS-1$
+ } else {
+ sb.append("ldap://"); // $NON-NLS-1$
+ }
+ sb.append(host);
+ if (port.length()>0){
+ sb.append(":"); // $NON-NLS-1$
+ sb.append(port);
+ }
+ sb.append("/"); // $NON-NLS-1$
+ sb.append(rootdn);
+ env.put(Context.PROVIDER_URL,sb.toString());
+ log.info("prov_url= " + env.get(Context.PROVIDER_URL)); //
$NON-NLS-1$
+ if (connTimeOut.length()> 0) {
+ env.put("com.sun.jndi.ldap.connect.timeout", connTimeOut); //
$NON-NLS-1$
+ }
+ env.put(Context.REFERRAL, "throw"); // $NON-NLS-1$
+ env.put("java.naming.batchsize", "0"); // $NON-NLS-1$ //
$NON-NLS-2$
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.SECURITY_PRINCIPAL, username);
dirContext = new InitialDirContext(env);
@@ -108,6 +124,9 @@
**************************************************************************/
public NamingEnumeration searchTest(DirContext dirContext, String
searchBase, String searchFilter, int scope, long countlim,
int timelim, String[] attrs, boolean retobj, boolean
deref) throws NamingException {
+ if (dirContext == null) {
+ throw new NamingException("Context is null");
+ }
SearchControls searchcontrols = null;
searchcontrols = new SearchControls(scope, countlim, timelim,
attrs, retobj, deref);
log.debug("scope, countlim, timelim, attrs, retobj, deref= " +
searchFilter + scope + countlim + timelim
@@ -124,6 +143,9 @@
* filter filter this value from the base
**************************************************************************/
public NamingEnumeration compare(DirContext dirContext, String filter,
String entrydn) throws NamingException {
+ if (dirContext == null) {
+ throw new NamingException("Context is null");
+ }
SearchControls searchcontrols = new SearchControls(0, 1, 0, new
String[0], false, false);
return dirContext.search(entrydn, filter, searchcontrols);
}
@@ -138,6 +160,9 @@
**************************************************************************/
public void moddnOp(DirContext dirContext, String ddn, String newdn)
throws NamingException {
log.debug("ddn and newDn= " + ddn + "@@@@" + newdn);
+ if (dirContext == null) {
+ throw new NamingException("Context is null");
+ }
dirContext.rename(ddn, newdn);
}
@@ -150,6 +175,9 @@
* The string (dn) value
**************************************************************************/
public void modifyTest(DirContext dirContext, ModificationItem[] mods,
String string) throws NamingException {
+ if (dirContext == null) {
+ throw new NamingException("Context is null");
+ }
dirContext.modifyAttributes(string, mods);
}
@@ -164,6 +192,9 @@
**************************************************************************/
public DirContext createTest(DirContext dirContext, Attributes attributes,
String string)
throws NamingException {
+ if (dirContext == null) {
+ throw new NamingException("Context is null");
+ }
return dirContext.createSubcontext(string, attributes);
}
@@ -174,6 +205,9 @@
* The string (dn) value
**************************************************************************/
public void deleteTest(DirContext dirContext, String string) throws
NamingException {
+ if (dirContext == null) {
+ throw new NamingException("Context is null");
+ }
dirContext.destroySubcontext(string);
}
}
Modified: jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml?view=diff&rev=516970&r1=516969&r2=516970
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml Sun Mar 11 10:50:57 2007
@@ -110,6 +110,7 @@
<li>Bug 41705 - add content-encoding option to HTTP samplers for POST
requests</li>
<li>Bug 40933, 40945 - optional matching of embedded resource URLs</li>
<li>Bug 41704 - Allow charset encoding to be specified for CSV DataSet</li>
+<li>Bug 40103 - various LDAP enhancements</li>
</ul>
<h4>Non-functional improvements:</h4>
Modified:
jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml?view=diff&rev=516970&r1=516969&r2=516970
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml
(original)
+++ jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml
Sun Mar 11 10:50:57 2007
@@ -452,11 +452,11 @@
</component>
-<component name="LDAP Extended Request (ALPHA)" index="§-num;.1.8"
width="595" height="542" screenshot="ldapext_request.png">
+<component name="LDAP Extended Request" index="§-num;.1.8" width="595"
height="542" screenshot="ldapext_request.png">
<description>This Sampler can send all 8 different LDAP request to an LDAP
server. It is an extended version of the LDAP sampler,
therefore it is harder to configure, but can be made much closer resembling
a real LDAP session.
<p>If you are going to send multiple requests to the same LDAP server,
consider
- using an <complink name="LDAP Extended Request Defaults (ALPHA)"/>
+ using an <complink name="LDAP Extended Request Defaults"/>
Configuration Element so you do not have to enter the same information
for each
LDAP Request.</p> </description>
@@ -575,7 +575,7 @@
<links>
<link href="build-ldapext-test-plan.html">Building an LDAP Test
Plan</link>
- <complink name="LDAP Extended Request Defaults (ALPHA)"/>
+ <complink name="LDAP Extended Request Defaults"/>
</links>
</component>
@@ -2249,8 +2249,8 @@
</component>
-<component name="LDAP Extended Request Defaults (ALPHA)"
index="§-num;.4.13" width="597" height="545"
screenshot="ldapext_defaults.png">
-<description><p>The LDAP Extended Request Defaults component lets you set
default values for extended LDAP testing. See the <complink name="LDAP
Extended Request (ALPHA)"/>.</p>
+<component name="LDAP Extended Request Defaults" index="§-num;.4.13"
width="597" height="545" screenshot="ldapext_defaults.png">
+<description><p>The LDAP Extended Request Defaults component lets you set
default values for extended LDAP testing. See the <complink name="LDAP
Extended Request"/>.</p>
</description>
</component>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]