1 17 18 package org.apache.jmeter.assertions.gui; 19 20 import java.awt.BorderLayout ; 21 22 import javax.swing.BorderFactory ; 23 import javax.swing.JPanel ; 24 25 import org.apache.jmeter.assertions.XPathAssertion; 26 import org.apache.jmeter.testelement.TestElement; 27 import org.apache.jmeter.util.JMeterUtils; 28 import org.apache.jorphan.gui.layout.VerticalLayout; 29 30 import org.apache.jorphan.logging.LoggingManager; 31 import org.apache.log.Logger; 32 33 38 39 public class XPathAssertionGui extends AbstractAssertionGui 40 { 41 42 private static transient Logger log = LoggingManager.getLoggerForClass(); 43 private static final String OPERATOR_KEY = null; 44 45 private int execState; 46 private XPathPanel xpath; 47 private XMLConfPanel xml; 48 49 public XPathAssertionGui() { 50 init(); 51 } 52 53 56 public String getLabelResource() 57 { 58 return "xpath_assertion_title"; 59 } 60 61 64 public TestElement createTestElement() 65 { 66 XPathAssertion el = new XPathAssertion(); 67 modifyTestElement(el); 68 return el; 69 } 70 71 public String getXPathAttributesTitle() 72 { 73 return JMeterUtils.getResString("xpath_assertion_test"); 74 } 75 76 public void configure(TestElement el) 77 { 78 super.configure(el); 79 XPathAssertion assertion = (XPathAssertion) el; 80 xpath.setXPath(assertion.getXPathString()); 81 xpath.setNegated(assertion.isNegated()); 82 83 xml.setWhitespace(assertion.isWhitespace()); 84 xml.setValidate(assertion.isValidating()); 85 xml.setTolerant(assertion.isTolerant()); 86 xml.setNamespace(assertion.isNamespace()); 87 88 } 89 90 private void init() 91 { 92 setLayout( 93 new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP)); 94 setBorder(makeBorder()); 95 96 add(makeTitlePanel()); 97 98 JPanel sizePanel = new JPanel (new BorderLayout ()); 100 sizePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); 101 sizePanel.setBorder( 102 BorderFactory.createTitledBorder( 103 BorderFactory.createEtchedBorder(), 104 getXPathAttributesTitle())); 105 xpath = new XPathPanel(); 106 sizePanel.add(xpath); 107 108 xml = new XMLConfPanel(); 109 xpath = new XPathPanel(); 110 111 xml.setBorder( 112 BorderFactory.createTitledBorder( 113 BorderFactory.createEtchedBorder(), 114 JMeterUtils.getResString("xpath_assertion_option"))); 115 add(xml); 116 117 add(sizePanel); 118 } 119 120 124 public void modifyTestElement(TestElement el) 125 { 126 super.configureTestElement(el); 127 if (el instanceof XPathAssertion ) { 128 XPathAssertion assertion = (XPathAssertion) el; 129 assertion.setValidating(xml.isValidate()); 130 assertion.setWhitespace(xml.isWhitespace()); 131 assertion.setTolerant(xml.isTolerant()); 132 assertion.setNamespace(xml.isNamespace()); 133 assertion.setNegated(xpath.isNegated()); 134 assertion.setXPathString(xpath.getXPath()); 135 } 136 } 137 } 138 | Popular Tags |