Exemplo n.º 1
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

      boldFont = getFont().deriveFont(Font.BOLD);

      AssertionListEntry entry = (AssertionListEntry) value;
      String type = TestAssertionRegistry.getInstance().getAssertionTypeForName(entry.getName());
      boolean canAssert = false;
      boolean disable = true;
      JLabel label;
      JTextArea descText;
      JLabel disabledInfo;
      if (type != null && assertable != null && assertable.getModelItem() != null) {
        canAssert =
            isAssertionApplicable(type, assertable.getModelItem(), getSelectedPropertyName());
        disable = !categoriesListTable.isEnabled() || !canAssert;
      }
      String str = entry.getName();
      label = new JLabel(str);
      label.setFont(boldFont);
      descText = new JTextArea(((AssertionListEntry) value).getDescription());
      descText.setSize(new Dimension(80, 20));
      descText.setLineWrap(true);
      descText.setWrapStyleWord(true);
      disabledInfo = new JLabel("Not applicable with selected Source and Property");
      descText.setFont(disabledInfo.getFont());
      if (disable) {
        label.setForeground(Color.LIGHT_GRAY);
        descText.setForeground(Color.LIGHT_GRAY);
        disabledInfo.setForeground(Color.LIGHT_GRAY);
      }
      SimpleForm form = new SimpleForm();
      form.addComponent(label);
      if (!isHideDescriptionSelected()) {
        form.addComponent(descText);
        //				if( disable )
        //				{
        //					form.addComponent( disabledInfo );
        //				}
        getAssertionsTable().setRowHeight(70);
      } else {
        if (disable) {
          form.addComponent(disabledInfo);
        }
        getAssertionsTable().setRowHeight(40);
      }
      if (isSelected) {
        descText.setBackground(Color.LIGHT_GRAY);
        form.getPanel().setBackground(Color.LIGHT_GRAY);
      } else {
        descText.setBackground(Color.WHITE);
        form.getPanel().setBackground(Color.WHITE);
      }
      return form.getPanel();
    }
Exemplo n.º 2
0
 public AddAssertionPanel(Assertable assertable) {
   super(
       "Add Assertion",
       "Select the source property and which assertion to apply below ",
       HelpUrls.ADD_ASSERTION_PANEL);
   this.assertable = assertable;
   assertionEntryRenderer.setAssertable(assertable);
   categoriesListRenderer.setAssertable(assertable);
   selectionListener = new InternalListSelectionListener();
   categoriesAssertionsMap =
       AssertionCategoryMapping.getCategoriesAssertionsMap(assertable, recentAssertionHandler);
   // load interfaces or have a issue with table and cell renderer
   WsdlProject project = (WsdlProject) ModelSupport.getModelItemProject(assertable.getModelItem());
   for (Interface inf : project.getInterfaceList()) {
     try {
       // There seems to be no good reason to load the definitions for rest interfaces
       // hence that call has been removed for the time being.
       if (inf instanceof WsdlInterface) {
         ((WsdlInterface) inf).getWsdlContext().loadIfNecessary();
       }
     } catch (Exception e) {
       // TODO Improve this
       e.printStackTrace();
     }
   }
 }
Exemplo n.º 3
0
  protected void throwFailureException() throws Exception {
    StringBuffer buf = new StringBuffer();

    for (int c = 0; c < assertions.size(); c++) {
      TestAssertion assertion = assertions.get(c);
      Assertable assertable = assertion.getAssertable();
      if (assertable instanceof WsdlTestStep) {
        failedTests.remove(((WsdlTestStep) assertable).getTestCase());
      }

      buf.append(
          assertion.getName() + " in [" + assertable.getModelItem().getName() + "] failed;\n");
      buf.append(Arrays.toString(assertion.getErrors()) + "\n");

      WsdlTestStepResult result = assertionResults.get(assertion);
      StringWriter stringWriter = new StringWriter();
      PrintWriter writer = new PrintWriter(stringWriter);
      result.writeTo(writer);
      buf.append(stringWriter.toString());
    }

    while (!failedTests.isEmpty()) {
      buf.append("TestCase [" + failedTests.remove(0).getName() + "] failed without assertions\n");
    }

    throw new Exception(buf.toString());
  }