@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_load:
       menuItem = item;
       menuItem.setActionView(R.layout.progressbar);
       menuItem.expandActionView();
       TestTask task = new TestTask();
       task.execute("test");
       break;
     default:
       break;
   }
   return true;
 }
 /** True if the clients have all thrown a stop scheduling order on the task. */
 private boolean receivedStopSchedulingTaskOnClientOrder(TestTask task, Vector clients) {
   for (Iterator i = clients.iterator(); i.hasNext(); ) {
     ClientRecord client = (ClientRecord) i.next();
     if (!task.receivedStopSchedulingTaskOnClientOrder(client)) {
       return false;
     }
   }
   return true;
 }
Beispiel #3
0
  /**
   * @param testTask the testTask to be executed
   * @param testSuite the TestSuite wrapper for the testTask
   * @param environment the environment configuration
   */
  public void runTestTask(TestTask testTask, TestSuite testSuite, Environment environment) {

    /*
     * check if all mandatory fields are set
     */
    ProcessStatus notNullCheck =
        NullCheckWrapperUtil.checkIfNotNull(testTask, "id", "method", "resource");
    if (notNullCheck.isPassed()) {
      /*
       Run the http calls
      */ try {

        resourceInvocationHandler.executeResourceCalls(testTask, testSuite);

        /*
        Run the status check assertions if set
        */
        if (testTask.getStatusCheck() != null) {
          assertionExecutor.executeStatusAssertion(testTask, testSuite);
        }
        /*
        Run the value assertions if set
         */
        if (testTask.getAssertions() != null && testTask.getAssertions().size() > 0) {
          for (ValueAssertion assertion : testTask.getAssertions()) {
            assertionExecutor.executeAssertion(assertion, testSuite.getTestContext());
            if (!assertion.isPassed()) {
              testSuite.setFailureCount(testSuite.getFailureCount() + 1);
              testTask.setPassed(false);
            }
          }
        }
      } catch (IOException e) {
        LOGGER.error("IO Exception when executing testSuiteId " + testSuite.getId(), e);
        testTask.setError(e.getMessage());
      } catch (JsonPathException e) {
        LOGGER.error("Json path Exception when executing testSuiteId " + testSuite.getId(), e);
        testTask.setError(e.getMessage());

      } catch (InvalidExpressionException e) {
        LOGGER.error("InvalidExpression  when executing testSuiteId" + testSuite.getId(), e);
        testTask.setError(e.getMessage());
      }
    } else {
      testTask.setError(notNullCheck.getMessage());
    }
  }
  /**
   * Schedules the client with the task, if it is in the proper threadgroup and has not thrown a
   * stop scheduling order for it.
   */
  protected boolean schedule(ClientRecord client, TestTask task, long now) {
    if (task.usesThreadGroup(client.getThreadGroupName())
        && !task.receivedStopSchedulingTaskOnClientOrder(client)) {
      ClientVmRecord vm = client.vm();
      synchronized (vm) {
        if (vm.isLive()) {
          synchronized (client) {
            client.setBusy(true);
            client.setTask(task);
            client.setStartTime(now);

            synchronized (task) {
              task.incrementNumTimesInUse();
            }
            assignTask(client, task);
          }
        }
      }
      return true;

    } else {
      return false;
    }
  }
 @Override
 protected UnblockTestTaskResponse taskOperation(UnblockTestTasksRequest request, Task task) {
   ((TestTask) task).unblock();
   return new UnblockTestTaskResponse();
 }
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    if (e.getSource() == backButton) {
      CardLayout cl = (CardLayout) (this.card.getLayout());
      cl.show(this.card, "Menu");
    }

    // browse for source folder in preprocessing
    else if (e.getSource() == selectFolder1) {
      int a = srcFolder.showOpenDialog(this);
      if (a == JFileChooser.APPROVE_OPTION) {
        File file = srcFolder.getSelectedFile();
        folder1.setText(file.getAbsolutePath());
      }
    }
    // browse for destination folder in preprocessing
    else if (e.getSource() == selectDest) {
      int a = destFolder.showOpenDialog(this);
      if (a == JFileChooser.APPROVE_OPTION) {
        File file = destFolder.getSelectedFile();
        destination.setText(file.getAbsolutePath());
      }
    }
    // browse for source folder in train/test
    else if (e.getSource() == selectFolder2) {
      int a = tFolder.showOpenDialog(this);
      if (a == JFileChooser.APPROVE_OPTION) {
        File file = tFolder.getSelectedFile();
        folder2.setText(file.getAbsolutePath());
      }
    }
    // run test/train
    else if (e.getSource() == run) {
      String path = folder2.getText();
      if (train.isSelected()) {

        // reset graph and summary table
        resetResults();
        TrainTask trainTask = new TrainTask(this, path);
        // task.addPropertyChangeListener(this);
        trainTask.execute();
        run.setEnabled(false);

      } else if (test.isSelected()) {
        TestTask testTask = new TestTask(this, path);
        testTask.execute();
        run.setEnabled(false);

      } else if (eval.isSelected()) {
        // read the images
        // p.getAllFeatures2(path, "cross_validation_data");
        task = new Task(this);
        // task.addPropertyChangeListener(this);
        task.execute();
        run.setEnabled(false);
      }
    }
    // crop datasets
    else if (e.getSource() == crop) {
      String sourcePath = folder1.getText().replace("\\", "/") + "/";
      String destinationPath = destination.getText().replace("\\", "/") + "/";
      p.cropImages(setList.getSelectedIndex() + 1, sourcePath, destinationPath);
    } else if (e.getSource() == viewResults) {
      resultsDialog.setVisible(true);
    } else if (e.getSource() == viewConfButton) {
      d.setVisible(true);
    }

    // show confusion matrix
    else if (e.getSource() == viewANN) {
      // change color of button
      viewANN.setColor("orange");
      viewSVM.setColor("blue");
      viewBN.setColor("blue");

      this.fillConfTable(evalANN.confusionMatrix());
    } else if (e.getSource() == viewSVM) {

      viewSVM.setColor("orange");
      viewBN.setColor("blue");
      viewANN.setColor("blue");
      this.fillConfTable(evalSVM.confusionMatrix());
    } else if (e.getSource() == viewBN) {
      viewBN.setColor("orange");
      viewANN.setColor("blue");
      viewSVM.setColor("blue");
      this.fillConfTable(evalNB.confusionMatrix());
    }
  }
 /** True if the client has thrown a stop scheduling order on the task. */
 private boolean receivedStopSchedulingTaskOnClientOrder(TestTask task, ClientRecord client) {
   return task.receivedStopSchedulingTaskOnClientOrder(client);
 }