@Override protected String internalAssertProperty( TestPropertyHolder source, String propertyName, MessageExchange messageExchange, SubmitContext context) throws AssertionException { assertContent(context, source.getPropertyValue(propertyName), propertyName); return "OK"; }
// 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"; }
@Override public boolean canAssert(TestPropertyHolder modelItem, String property) { String content = modelItem.getPropertyValue(property); // return !StringUtils.isNullOrEmpty( content ); return true; }