Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLSchemaAssertionGUI.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLSchemaAssertionGUI.java?rev=674342&r1=674341&r2=674342&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLSchemaAssertionGUI.java (original) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLSchemaAssertionGUI.java Sun Jul 6 13:28:49 2008 @@ -40,46 +40,46 @@ */ public class XMLSchemaAssertionGUI extends AbstractAssertionGui { - // class attributes - private static final Logger log = LoggingManager.getLoggerForClass(); + // class attributes + private static final Logger log = LoggingManager.getLoggerForClass(); - private JTextField xmlSchema; + private JTextField xmlSchema; - /** - * The constructor. - */ - public XMLSchemaAssertionGUI() { - init(); - } - - /** - * Returns the label to be shown within the JTree-Component. - */ - public String getLabelResource() { - return "xmlschema_assertion_title"; //$NON-NLS-1$ - } - - /** - * create Test Element - */ - public TestElement createTestElement() { - log.debug("XMLSchemaAssertionGui.createTestElement() called"); - XMLSchemaAssertion el = new XMLSchemaAssertion(); - modifyTestElement(el); - return el; - } - - /** - * Modifies a given TestElement to mirror the data in the gui components. - * - * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) - */ - public void modifyTestElement(TestElement inElement) { - - log.debug("XMLSchemaAssertionGui.modifyTestElement() called"); - configureTestElement(inElement); - ((XMLSchemaAssertion) inElement).setXsdFileName(xmlSchema.getText()); - } + /** + * The constructor. + */ + public XMLSchemaAssertionGUI() { + init(); + } + + /** + * Returns the label to be shown within the JTree-Component. + */ + public String getLabelResource() { + return "xmlschema_assertion_title"; //$NON-NLS-1$ + } + + /** + * create Test Element + */ + public TestElement createTestElement() { + log.debug("XMLSchemaAssertionGui.createTestElement() called"); + XMLSchemaAssertion el = new XMLSchemaAssertion(); + modifyTestElement(el); + return el; + } + + /** + * Modifies a given TestElement to mirror the data in the gui components. + * + * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) + */ + public void modifyTestElement(TestElement inElement) { + + log.debug("XMLSchemaAssertionGui.modifyTestElement() called"); + configureTestElement(inElement); + ((XMLSchemaAssertion) inElement).setXsdFileName(xmlSchema.getText()); + } /** * Implements JMeterGUIComponent.clearGui @@ -90,49 +90,49 @@ xmlSchema.setText(""); //$NON-NLS-1$ } - /** - * Configures the GUI from the associated test element. - * - * @param el - - * the test element (should be XMLSchemaAssertion) - */ - public void configure(TestElement el) { - super.configure(el); - XMLSchemaAssertion assertion = (XMLSchemaAssertion) el; - xmlSchema.setText(assertion.getXsdFileName()); - } - - /** - * Inits the GUI. - */ - private void init() { - setLayout(new BorderLayout(0, 10)); - setBorder(makeBorder()); - - add(makeTitlePanel(), BorderLayout.NORTH); - - JPanel mainPanel = new JPanel(new BorderLayout()); - - // USER_INPUT - VerticalPanel assertionPanel = new VerticalPanel(); - assertionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "XML Schema")); - - // doctype - HorizontalPanel xmlSchemaPanel = new HorizontalPanel(); - - xmlSchemaPanel.add(new JLabel(JMeterUtils.getResString("xmlschema_assertion_label"))); //$NON-NLS-1$ - - xmlSchema = new JTextField(26); - xmlSchemaPanel.add(xmlSchema); - - assertionPanel.add(xmlSchemaPanel); - - mainPanel.add(assertionPanel, BorderLayout.NORTH); - add(mainPanel, BorderLayout.CENTER); - } - - // public void stateChanged(ChangeEvent e) { - // log.debug("XMLSchemaAssertionGui.stateChanged() called"); - // } + /** + * Configures the GUI from the associated test element. + * + * @param el - + * the test element (should be XMLSchemaAssertion) + */ + public void configure(TestElement el) { + super.configure(el); + XMLSchemaAssertion assertion = (XMLSchemaAssertion) el; + xmlSchema.setText(assertion.getXsdFileName()); + } + + /** + * Inits the GUI. + */ + private void init() { + setLayout(new BorderLayout(0, 10)); + setBorder(makeBorder()); + + add(makeTitlePanel(), BorderLayout.NORTH); + + JPanel mainPanel = new JPanel(new BorderLayout()); + + // USER_INPUT + VerticalPanel assertionPanel = new VerticalPanel(); + assertionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "XML Schema")); + + // doctype + HorizontalPanel xmlSchemaPanel = new HorizontalPanel(); + + xmlSchemaPanel.add(new JLabel(JMeterUtils.getResString("xmlschema_assertion_label"))); //$NON-NLS-1$ + + xmlSchema = new JTextField(26); + xmlSchemaPanel.add(xmlSchema); + + assertionPanel.add(xmlSchemaPanel); + + mainPanel.add(assertionPanel, BorderLayout.NORTH); + add(mainPanel, BorderLayout.CENTER); + } + + // public void stateChanged(ChangeEvent e) { + // log.debug("XMLSchemaAssertionGui.stateChanged() called"); + // } -} \ No newline at end of file +}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java?rev=674342&r1=674341&r2=674342&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java (original) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java Sun Jul 6 13:28:49 2008 @@ -30,79 +30,79 @@ public class XPathAssertionGui extends AbstractAssertionGui { - private XPathPanel xpath; + private XPathPanel xpath; - private XMLConfPanel xml; + private XMLConfPanel xml; - public XPathAssertionGui() { - init(); - } - - /** - * Returns the label to be shown within the JTree-Component. - */ - public String getLabelResource() { - return "xpath_assertion_title"; //$NON-NLS-1$ - } - - /** - * Create test element - */ - public TestElement createTestElement() { - XPathAssertion el = new XPathAssertion(); - modifyTestElement(el); - return el; - } - - public String getXPathAttributesTitle() { - return JMeterUtils.getResString("xpath_assertion_test"); //$NON-NLS-1$ - } - - public void configure(TestElement el) { - super.configure(el); - XPathAssertion assertion = (XPathAssertion) el; - xpath.setXPath(assertion.getXPathString()); - xpath.setNegated(assertion.isNegated()); - - xml.configure(assertion); - } - - private void init() { - setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP)); - setBorder(makeBorder()); - - add(makeTitlePanel()); - - // USER_INPUT - JPanel sizePanel = new JPanel(new BorderLayout()); - sizePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); - sizePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), - getXPathAttributesTitle())); - xpath = new XPathPanel(); - sizePanel.add(xpath); - - xml = new XMLConfPanel(); - xml.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils - .getResString("xpath_assertion_option"))); //$NON-NLS-1$ - add(xml); - - add(sizePanel); - } - - /** - * Modifies a given TestElement to mirror the data in the gui components. - * - * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) - */ - public void modifyTestElement(TestElement el) { - super.configureTestElement(el); - if (el instanceof XPathAssertion) { - XPathAssertion assertion = (XPathAssertion) el; - assertion.setNegated(xpath.isNegated()); - assertion.setXPathString(xpath.getXPath()); - xml.modifyTestElement(assertion); - } - } + public XPathAssertionGui() { + init(); + } + + /** + * Returns the label to be shown within the JTree-Component. + */ + public String getLabelResource() { + return "xpath_assertion_title"; //$NON-NLS-1$ + } + + /** + * Create test element + */ + public TestElement createTestElement() { + XPathAssertion el = new XPathAssertion(); + modifyTestElement(el); + return el; + } + + public String getXPathAttributesTitle() { + return JMeterUtils.getResString("xpath_assertion_test"); //$NON-NLS-1$ + } + + public void configure(TestElement el) { + super.configure(el); + XPathAssertion assertion = (XPathAssertion) el; + xpath.setXPath(assertion.getXPathString()); + xpath.setNegated(assertion.isNegated()); + + xml.configure(assertion); + } + + private void init() { + setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP)); + setBorder(makeBorder()); + + add(makeTitlePanel()); + + // USER_INPUT + JPanel sizePanel = new JPanel(new BorderLayout()); + sizePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); + sizePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), + getXPathAttributesTitle())); + xpath = new XPathPanel(); + sizePanel.add(xpath); + + xml = new XMLConfPanel(); + xml.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils + .getResString("xpath_assertion_option"))); //$NON-NLS-1$ + add(xml); + + add(sizePanel); + } + + /** + * Modifies a given TestElement to mirror the data in the gui components. + * + * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) + */ + public void modifyTestElement(TestElement el) { + super.configureTestElement(el); + if (el instanceof XPathAssertion) { + XPathAssertion assertion = (XPathAssertion) el; + assertion.setNegated(xpath.isNegated()); + assertion.setXPathString(xpath.getXPath()); + xml.modifyTestElement(assertion); + } + } /** * Implements JMeterGUIComponent.clearGui Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java?rev=674342&r1=674341&r2=674342&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java (original) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java Sun Jul 6 13:28:49 2008 @@ -42,202 +42,202 @@ public class XPathPanel extends JPanel { private static final Logger log = LoggingManager.getLoggerForClass(); - private static Document testDoc; + private static Document testDoc; - private JCheckBox negated; + private JCheckBox negated; - private JTextField xpath; + private JTextField xpath; - private JButton checkXPath; + private JButton checkXPath; - /** - * - */ - public XPathPanel() { - super(); - init(); - } - - /** - * @param isDoubleBuffered - */ - public XPathPanel(boolean isDoubleBuffered) { - super(isDoubleBuffered); - init(); - } - - /** - * @param layout - */ - public XPathPanel(LayoutManager layout) { - super(layout); - init(); - } - - /** - * @param layout - * @param isDoubleBuffered - */ - public XPathPanel(LayoutManager layout, boolean isDoubleBuffered) { - super(layout, isDoubleBuffered); - init(); - } - - private void init() { - Box hbox = Box.createHorizontalBox(); - hbox.add(Box.createHorizontalGlue()); - hbox.add(getXPathTextField()); - hbox.add(Box.createHorizontalGlue()); - hbox.add(getCheckXPathButton()); - - Box vbox = Box.createVerticalBox(); - vbox.add(hbox); - vbox.add(Box.createVerticalGlue()); - vbox.add(getNegatedCheckBox()); + /** + * + */ + public XPathPanel() { + super(); + init(); + } + + /** + * @param isDoubleBuffered + */ + public XPathPanel(boolean isDoubleBuffered) { + super(isDoubleBuffered); + init(); + } + + /** + * @param layout + */ + public XPathPanel(LayoutManager layout) { + super(layout); + init(); + } + + /** + * @param layout + * @param isDoubleBuffered + */ + public XPathPanel(LayoutManager layout, boolean isDoubleBuffered) { + super(layout, isDoubleBuffered); + init(); + } - add(vbox); + private void init() { + Box hbox = Box.createHorizontalBox(); + hbox.add(Box.createHorizontalGlue()); + hbox.add(getXPathTextField()); + hbox.add(Box.createHorizontalGlue()); + hbox.add(getCheckXPathButton()); + + Box vbox = Box.createVerticalBox(); + vbox.add(hbox); + vbox.add(Box.createVerticalGlue()); + vbox.add(getNegatedCheckBox()); - setDefaultValues(); - } + add(vbox); + + setDefaultValues(); + } public void setDefaultValues() { setXPath("/"); //$NON-NLS-1$ setNegated(false); } - /** - * Get the XPath String - * - * @return String - */ - public String getXPath() { - return this.xpath.getText(); - } - - /** - * Set the string that will be used in the xpath evaluation - * - * @param xpath - */ - public void setXPath(String xpath) { - this.xpath.setText(xpath); - } - - /** - * Does this negate the xpath results - * - * @return boolean - */ - public boolean isNegated() { - return this.negated.isSelected(); - } - - /** - * Set this to true, if you want success when the xpath does not match. - * - * @param negated - */ - public void setNegated(boolean negated) { - this.negated.setSelected(negated); - } - - /** - * Negated chechbox - * - * @return JCheckBox - */ - public JCheckBox getNegatedCheckBox() { - if (negated == null) { - negated = new JCheckBox(JMeterUtils.getResString("xpath_assertion_negate"), false); //$NON-NLS-1$ - } - - return negated; - } - - /** - * Check XPath button - * - * @return JButton - */ - public JButton getCheckXPathButton() { - if (checkXPath == null) { - checkXPath = new JButton(JMeterUtils.getResString("xpath_assertion_button")); //$NON-NLS-1$ - checkXPath.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - validXPath(xpath.getText(), true); - } - }); - } - return checkXPath; - } - - public JTextField getXPathTextField() { - if (xpath == null) { - xpath = new JTextField(50); - } - return xpath; - } - - /** - * @return Returns the showNegate. - */ - public boolean isShowNegated() { - return this.getNegatedCheckBox().isVisible(); - } - - /** - * @param showNegate - * The showNegate to set. - */ - public void setShowNegated(boolean showNegate) { - getNegatedCheckBox().setVisible(showNegate); - } - - /** - * Test weather an XPath is valid. It seems the Xalan has no easy way to - * check, so this creates a test document, then tries to evaluate the xpath. - * - * @param xpathString - * XPath String to validate - * @param showDialog - * weather to show a dialog - * @return returns true if valid, valse otherwise. - */ - public static boolean validXPath(String xpathString, boolean showDialog) { - String ret = null; - boolean success = true; - try { - if (testDoc == null) { - testDoc = XPathUtil.makeDocumentBuilder(false, false, false).newDocument(); - Element el = testDoc.createElement("root"); //$NON-NLS-1$ - testDoc.appendChild(el); - - } - if (XPathAPI.eval(testDoc, xpathString) == null) { - // We really should never get here - // because eval will throw an exception - // if xpath is invalid, but whatever, better - // safe - log.warn("xpath eval was null "); - ret = "xpath eval was null"; - success = false; - } - - } catch (ParserConfigurationException e) { - success = false; - ret = e.getLocalizedMessage(); - } catch (TransformerException e) { - success = false; - ret = e.getLocalizedMessage(); - } - - if (showDialog) { - JOptionPane.showMessageDialog(null, (success) ? JMeterUtils.getResString("xpath_assertion_valid") : ret, //$NON-NLS-1$ - (success) ? JMeterUtils.getResString("xpath_assertion_valid") : JMeterUtils //$NON-NLS-1$ - .getResString("xpath_assertion_failed"), (success) ? JOptionPane.INFORMATION_MESSAGE //$NON-NLS-1$ - : JOptionPane.ERROR_MESSAGE); - } - return success; + /** + * Get the XPath String + * + * @return String + */ + public String getXPath() { + return this.xpath.getText(); + } + + /** + * Set the string that will be used in the xpath evaluation + * + * @param xpath + */ + public void setXPath(String xpath) { + this.xpath.setText(xpath); + } - } -} \ No newline at end of file + /** + * Does this negate the xpath results + * + * @return boolean + */ + public boolean isNegated() { + return this.negated.isSelected(); + } + + /** + * Set this to true, if you want success when the xpath does not match. + * + * @param negated + */ + public void setNegated(boolean negated) { + this.negated.setSelected(negated); + } + + /** + * Negated chechbox + * + * @return JCheckBox + */ + public JCheckBox getNegatedCheckBox() { + if (negated == null) { + negated = new JCheckBox(JMeterUtils.getResString("xpath_assertion_negate"), false); //$NON-NLS-1$ + } + + return negated; + } + + /** + * Check XPath button + * + * @return JButton + */ + public JButton getCheckXPathButton() { + if (checkXPath == null) { + checkXPath = new JButton(JMeterUtils.getResString("xpath_assertion_button")); //$NON-NLS-1$ + checkXPath.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + validXPath(xpath.getText(), true); + } + }); + } + return checkXPath; + } + + public JTextField getXPathTextField() { + if (xpath == null) { + xpath = new JTextField(50); + } + return xpath; + } + + /** + * @return Returns the showNegate. + */ + public boolean isShowNegated() { + return this.getNegatedCheckBox().isVisible(); + } + + /** + * @param showNegate + * The showNegate to set. + */ + public void setShowNegated(boolean showNegate) { + getNegatedCheckBox().setVisible(showNegate); + } + + /** + * Test weather an XPath is valid. It seems the Xalan has no easy way to + * check, so this creates a test document, then tries to evaluate the xpath. + * + * @param xpathString + * XPath String to validate + * @param showDialog + * weather to show a dialog + * @return returns true if valid, valse otherwise. + */ + public static boolean validXPath(String xpathString, boolean showDialog) { + String ret = null; + boolean success = true; + try { + if (testDoc == null) { + testDoc = XPathUtil.makeDocumentBuilder(false, false, false).newDocument(); + Element el = testDoc.createElement("root"); //$NON-NLS-1$ + testDoc.appendChild(el); + + } + if (XPathAPI.eval(testDoc, xpathString) == null) { + // We really should never get here + // because eval will throw an exception + // if xpath is invalid, but whatever, better + // safe + log.warn("xpath eval was null "); + ret = "xpath eval was null"; + success = false; + } + + } catch (ParserConfigurationException e) { + success = false; + ret = e.getLocalizedMessage(); + } catch (TransformerException e) { + success = false; + ret = e.getLocalizedMessage(); + } + + if (showDialog) { + JOptionPane.showMessageDialog(null, (success) ? JMeterUtils.getResString("xpath_assertion_valid") : ret, //$NON-NLS-1$ + (success) ? JMeterUtils.getResString("xpath_assertion_valid") : JMeterUtils //$NON-NLS-1$ + .getResString("xpath_assertion_failed"), (success) ? JOptionPane.INFORMATION_MESSAGE //$NON-NLS-1$ + : JOptionPane.ERROR_MESSAGE); + } + return success; + + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]