Ejemplo n.º 1
0
  public PropertiesTreeNode(
      T modelItem, ModelItem parentItem, TestPropertyHolder holder, SoapUITreeModel treeModel) {
    super(modelItem, parentItem, treeModel);
    this.holder = holder;

    for (String name : holder.getPropertyNames()) {
      PropertyTreeNode propertyTreeNode =
          new PropertyTreeNode(holder.getProperty(name), getModelItem(), holder, treeModel);
      propertyNodes.add(propertyTreeNode);
      propertyMap.put(name, propertyTreeNode);
      getTreeModel().mapModelItem(propertyTreeNode);
    }

    testPropertyListener = new InternalTestPropertyListener();
    holder.addTestPropertyListener(testPropertyListener);
  }
Ejemplo n.º 2
0
 @Override
 protected String internalAssertProperty(
     TestPropertyHolder source,
     String propertyName,
     MessageExchange messageExchange,
     SubmitContext context)
     throws AssertionException {
   assertContent(context, source.getPropertyValue(propertyName), propertyName);
   return "OK";
 }
Ejemplo n.º 3
0
  public void release() {
    super.release();

    holder.removeTestPropertyListener(testPropertyListener);

    for (PropertyTreeNode node : propertyNodes) getTreeModel().unmapModelItem(node.getModelItem());

    propertyNodes.clear();
    propertyMap.clear();
  }
Ejemplo n.º 4
0
  public static int saveTo(TestPropertyHolder propertyHolder, String fileName) throws IOException {
    PrintWriter writer = new PrintWriter(new FileWriter(fileName));

    for (TestProperty prop : propertyHolder.getPropertyList()) {
      writer.print(prop.getName());
      writer.print('=');
      String value = prop.getValue();
      if (value == null) value = "";

      String[] lines = value.split("\n");
      for (int c = 0; c < lines.length; c++) {
        if (c > 0) writer.println("\\");
        writer.print(lines[c]);
      }

      writer.println();
    }

    writer.close();
    return propertyHolder.getPropertyCount();
  }
  // TODO check if this should be applicable to properties after all, it's not mapped for properties
  // currently
  protected String internalAssertProperty(
      TestPropertyHolder source,
      String propertyName,
      MessageExchange messageExchange,
      SubmitContext context)
      throws AssertionException {

    Map<String, String> checkMap = createCheckMap(context);
    List<AssertionError> assertionErrorList = new ArrayList<AssertionError>();
    String propertyValue = source.getPropertyValue(propertyName);
    Set<String> messages = new HashSet<String>();

    try {
      for (String token : checkMap.keySet()) {
        boolean useRegexp = token.trim().startsWith(PREFIX);
        String description = !checkMap.get(token).equals("") ? checkMap.get(token) : token;
        if (useRegexp) {
          token = token.substring(token.indexOf(PREFIX) + 1);
        }

        String match = SecurityScanUtil.contains(context, propertyValue, token, useRegexp);
        if (match != null) {
          String message =
              description
                  + " - Token ["
                  + token
                  + "] found ["
                  + match
                  + "] in property "
                  + propertyName;
          if (!messages.contains(message)) {
            assertionErrorList.add(new AssertionError(message));
            messages.add(message);
          }
        }
      }
    } catch (Throwable e) {
      SoapUI.logError(e);
    }

    if (!messages.isEmpty()) {
      throw new AssertionException(
          assertionErrorList.toArray(new AssertionError[assertionErrorList.size()]));
    }

    return "OK";
  }
Ejemplo n.º 6
0
 @Override
 public boolean canAssert(TestPropertyHolder modelItem, String property) {
   String content = modelItem.getPropertyValue(property);
   //			return !StringUtils.isNullOrEmpty( content );
   return true;
 }
Ejemplo n.º 7
0
 public void updateName() {
   setName("Properties (" + holder.getPropertyNames().length + ")");
 }
Ejemplo n.º 8
0
 public PropertiesModelItem(TestPropertyHolder holder) {
   super(
       "Properties (" + holder.getPropertyNames().length + ")",
       UISupport.createImageIcon("/properties_step.gif"));
   this.holder = holder;
 }