Ejemplo n.º 1
0
  public String assertResult(
      LoadTestRunner loadTestRunner,
      LoadTestRunContext context,
      TestStepResult result,
      TestCaseRunner testRunner,
      TestCaseRunContext runContext) {
    WsdlLoadTest loadTest = (WsdlLoadTest) loadTestRunner.getLoadTest();
    LoadTestStatistics statisticsModel = loadTest.getStatisticsModel();

    TestStep step = result.getTestStep();
    if (targetStepMatches(step)) {
      int index = step.getTestCase().getIndexOfTestStep(step);

      long average = statisticsModel.getStatistic(index, Statistic.AVERAGE);
      long count = statisticsModel.getStatistic(index, Statistic.AVERAGE);
      if (count > minRequests && (count % sampleInterval == 0) && average >= maxAverage) {
        return returnErrorOrFail(
            "Average [" + average + "] exceeds limit [" + maxAverage + "]",
            maxErrors,
            loadTestRunner,
            context);
      }
    } else if (ALL_TEST_STEPS.equals(getTargetStep())) {
      long average = statisticsModel.getStatistic(LoadTestStatistics.TOTAL, Statistic.AVERAGE);
      long count = statisticsModel.getStatistic(LoadTestStatistics.TOTAL, Statistic.COUNT);
      if (count > minRequests && (count % sampleInterval == 0) && average >= maxAverage) {
        return returnErrorOrFail(
            "Average [" + average + "] exceeds limit [" + maxAverage + "]",
            maxErrors,
            loadTestRunner,
            context);
      }
    }

    return null;
  }
Ejemplo n.º 2
0
  public JLoadTestAssertionsTable(WsdlLoadTest wsdlLoadTest) {
    super(new BorderLayout());
    this.loadTest = wsdlLoadTest;

    loadTest.addLoadTestListener(internalLoadTestListener);

    tableModel = new LoadTestAssertionsTableModel();
    table = new JXTable(tableModel);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    TableColumnModel columnModel = table.getColumnModel();
    columnModel.getColumn(0).setMaxWidth(16);
    columnModel.getColumn(0).setCellRenderer(new IconTableCellRenderer());
    columnModel.getColumn(1).setPreferredWidth(100);
    columnModel.getColumn(2).setPreferredWidth(100);
    columnModel.getColumn(3).setPreferredWidth(200);

    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane, BorderLayout.CENTER);

    table.addMouseListener(
        new MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() < 2) return;

            int ix = table.getSelectedRow();
            if (ix == -1) return;
            ix = table.convertRowIndexToModel(ix);

            Object obj = loadTest.getAssertionAt(ix);
            if (obj instanceof Configurable) {
              ((Configurable) obj).configure();
            } else Toolkit.getDefaultToolkit().beep();
          }
        });

    add(buildToolbar(), BorderLayout.NORTH);

    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              public void valueChanged(ListSelectionEvent e) {
                int ix = table.getSelectedRow();

                configureAssertionAction.setEnabled(ix >= 0);
                removeAssertionAction.setEnabled(ix >= 0);

                if (ix == -1) return;

                ix = table.convertRowIndexToModel(ix);
                configureAssertionAction.setEnabled(
                    loadTest.getAssertionAt(ix) instanceof Configurable);
              }
            });

    assertionPopup = new JPopupMenu();
    assertionPopup.add(configureAssertionAction);
    assertionPopup.addSeparator();
    assertionPopup.add(addLoadTestAssertionAction);
    assertionPopup.add(removeAssertionAction);

    setComponentPopupMenu(assertionPopup);

    scrollPane.setInheritsPopupMenu(true);
    table.setComponentPopupMenu(assertionPopup);
  }
Ejemplo n.º 3
0
 public void release() {
   tableModel.release();
   loadTest.removeLoadTestListener(internalLoadTestListener);
 }