Package org.apache.jmeter.assertions

Examples of org.apache.jmeter.assertions.ResponseAssertion


    /*
     * Helper method to add a Response Assertion
     */
    private void addAssertion(JMeterTreeModel model, JMeterTreeNode node) throws IllegalUserActionException {
        ResponseAssertion ra = new ResponseAssertion();
        ra.setProperty(TestElement.GUI_CLASS, ASSERTION_GUI);
        ra.setName(JMeterUtils.getResString("assertion_title")); // $NON-NLS-1$
        ra.setTestFieldResponseData();
        model.addComponent(ra, node);
    }
View Full Code Here


        return "assertion_title"; // $NON-NLS-1$
    }

    /* Implements JMeterGUIComponent.createTestElement() */
    public TestElement createTestElement() {
        ResponseAssertion el = new ResponseAssertion();
        modifyTestElement(el);
        return el;
    }
View Full Code Here

    /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
    public void modifyTestElement(TestElement el) {
        configureTestElement(el);
        if (el instanceof ResponseAssertion) {
            ResponseAssertion ra = (ResponseAssertion) el;

            saveScopeSettings(ra);

            ra.clearTestStrings();
            String[] testStrings = tableModel.getData().getColumn(COL_RESOURCE_NAME);
            for (int i = 0; i < testStrings.length; i++) {
                ra.addTestString(testStrings[i]);
            }

            if (responseStringButton.isSelected()) {
                ra.setTestFieldResponseData();
            } else if (responseCodeButton.isSelected()) {
                ra.setTestFieldResponseCode();
            } else if (responseMessageButton.isSelected()) {
                ra.setTestFieldResponseMessage();
            } else if (responseHeadersButton.isSelected()) {
                ra.setTestFieldResponseHeaders();
            } else { // Assume URL
                ra.setTestFieldURL();
            }

            ra.setAssumeSuccess(assumeSuccess.isSelected());

            if (containsBox.isSelected()) {
                ra.setToContainsType();
            } else if (equalsBox.isSelected()) {
                ra.setToEqualsType();
            } else if (substringBox.isSelected()) {
                ra.setToSubstringType();
            } else {
                ra.setToMatchType();
            }

            if (notBox.isSelected()) {
                ra.setToNotType();
            } else {
                ra.unsetNotType();
            }
        }
    }
View Full Code Here

     *            the TestElement to configure
     */
    @Override
    public void configure(TestElement el) {
        super.configure(el);
        ResponseAssertion model = (ResponseAssertion) el;

        showScopeSettings(model, true);

        if (model.isContainsType()) {
            containsBox.setSelected(true);
        } else if (model.isEqualsType()) {
            equalsBox.setSelected(true);
        } else if (model.isSubstringType()) {
            substringBox.setSelected(true);
        } else {
            matchesBox.setSelected(true);
        }

        notBox.setSelected(model.isNotType());

        if (model.isTestFieldResponseData()) {
            responseStringButton.setSelected(true);
        } else if (model.isTestFieldResponseCode()) {
            responseCodeButton.setSelected(true);
        } else if (model.isTestFieldResponseMessage()) {
            responseMessageButton.setSelected(true);
        } else if (model.isTestFieldResponseHeaders()) {
            responseHeadersButton.setSelected(true);
        } else // Assume it is the URL
        {
            urlButton.setSelected(true);
        }

        assumeSuccess.setSelected(model.getAssumeSuccess());

        tableModel.clearData();
        PropertyIterator tests = model.getTestStrings().iterator();
        while (tests.hasNext()) {
            tableModel.addRow(new Object[] { tests.next().getStringValue() });
        }

        if (model.getTestStrings().size() == 0) {
            deletePattern.setEnabled(false);
        } else {
            deletePattern.setEnabled(true);
        }

View Full Code Here

     * Helper method to add a Response Assertion
     */
    private void addAssertion(JMeterTreeModel model,JMeterTreeNode node)
        throws IllegalUserActionException
    {
        ResponseAssertion ra = new ResponseAssertion();
        ra.setProperty(TestElement.GUI_CLASS,
            "org.apache.jmeter.assertions.gui.AssertionGui");
        ra.setName("Check response");
        ra.setTestField(ResponseAssertion.RESPONSE_DATA);
        model.addComponent(ra,node);
    }
View Full Code Here

    }

    /* Implements JMeterGUIComponent.createTestElement() */
    public TestElement createTestElement()
    {
        ResponseAssertion el = new ResponseAssertion();
        modifyTestElement(el);
        return el;
    }
View Full Code Here

    public void modifyTestElement(TestElement el)
    {
        configureTestElement(el);
        if (el instanceof ResponseAssertion)
        {
            ResponseAssertion ra = (ResponseAssertion) el;

            ra.clearTestStrings();
            String[] testStrings = tableModel.getData().getColumn(COL_NAME);
            for (int i = 0; i < testStrings.length; i++)
            {
                ra.addTestString(testStrings[i]);
            }

            if (labelButton.isSelected())
            {
                ra.setTestField(ResponseAssertion.SAMPLE_LABEL);
            }
            else if (responseCodeButton.isSelected())
            {
        ra.setTestField(ResponseAssertion.RESPONSE_CODE);
            }
      else if (responseMessageButton.isSelected())
      {
        ra.setTestField(ResponseAssertion.RESPONSE_MESSAGE);
      }
            else
            {
                ra.setTestField(ResponseAssertion.RESPONSE_DATA);
            }

             ra.setAssumeSuccess(assumeSuccess.isSelected());

             if (containsBox.isSelected())
            {
                ra.setToContainsType();
            }
            else
            {
                ra.setToMatchType();
            }

            if (notBox.isSelected())
            {
                ra.setToNotType();
            }
            else
            {
                ra.unsetNotType();
            }
        }
    }
View Full Code Here

     * @param el the TestElement to configure
     */
    public void configure(TestElement el)
    {
        super.configure(el);
        ResponseAssertion model = (ResponseAssertion) el;

        if (model.isContainsType())
        {
            containsBox.setSelected(true);
            matchesBox.setSelected(false);
        }
        else
        {
            containsBox.setSelected(false);
            matchesBox.setSelected(true);
        }

        if (model.isNotType())
        {
            notBox.setSelected(true);
        }
        else
        {
            notBox.setSelected(false);
        }

        if (ResponseAssertion.RESPONSE_DATA.equals(model.getTestField()))
        {
            responseStringButton.setSelected(true);
        }
    else if (ResponseAssertion.RESPONSE_CODE.equals(model.getTestField()))
    {
      responseCodeButton.setSelected(true);
    }
    else if (ResponseAssertion.RESPONSE_MESSAGE.equals(model.getTestField()))
    {
      responseMessageButton.setSelected(true);
    }
        else // Assume it is the URL
        {
            labelButton.setSelected(true);
        }

        assumeSuccess.setSelected(model.getAssumeSuccess());
       
        tableModel.clearData();
        PropertyIterator tests = model.getTestStrings().iterator();
        while (tests.hasNext())
        {
            tableModel.addRow(new Object[] { tests.next().getStringValue()});
        }

        if(model.getTestStrings().size() == 0)
        {
            deletePattern.setEnabled(false);
        }
        else
        {
View Full Code Here

     * Helper method to add a Response Assertion
     */
    private void addAssertion(JMeterTreeModel model,JMeterTreeNode node)
        throws IllegalUserActionException
    {
        ResponseAssertion ra = new ResponseAssertion();
        ra.setProperty(TestElement.GUI_CLASS,
            "org.apache.jmeter.assertions.gui.AssertionGui");
        ra.setName("Check response");
        ra.setTestField(ResponseAssertion.RESPONSE_DATA);
        model.addComponent(ra,node);
    }
View Full Code Here

    return JMeterUtils.getResString("assertion_title");
  }

  public TestElement createTestElement()
  {
    ResponseAssertion el = new ResponseAssertion();
    String[] testStrings = tableModel.getData().getColumn(COL_NAME);
    for(int i = 0;i < testStrings.length;i++)
    {
      el.addTestString(testStrings[i]);
    }
    configureTestElement(el);
    if(labelButton.isSelected())
    {
      el.setTestField(ResponseAssertion.SAMPLE_LABEL);
    }
    else
    {
      el.setTestField(ResponseAssertion.RESPONSE_DATA);
    }
    if(containsBox.isSelected())
    {
      el.setToContainsType();
    }
    else
    {
      el.setToMatchType();
    }
    if(notBox.isSelected())
    {
      el.setToNotType();
    }
    else
    {
      el.unsetNotType();
    }
    return el;
  }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.assertions.ResponseAssertion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.