private String firstTag(List<String> listTags) { return elementPattern(toRegex(CollectionUtil.first(listTags))); }
/** * Most regex implementations today do not build a DFA / NFA -- especially * those that offer backreferences (which are not "regular" at all). * * And because they do NOT build DFAs and NFAs, it's very simple to * construct pathological cases - e.g., "((a*)(a*))+b" can take * exponentially long to decide that aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac is * not in the language using the matching techniques commonly in use. * * Ori Berger * * @param text The text to check * @return boolean true, if the text matches pathological case, else false */ private boolean pathologicalCase(String text) { String tag = toRegex(CollectionUtil.first(tags)); String regex = String.format("(?is)(<\\s*(%s)\\s*.*?>)", tag); Matcher match = compile(regex).matcher(text); if (match.find()) { regex = String.format("(?is)(.*?)(<\\s*/\\s*(%s)\\s*.*?>)", tag); return ! compile(regex).matcher(text).find(match.end()); } return true; }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example anchor = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.will(Annotate.ignored(anchor.addSibling())); call.execute(); } catch (InvocationTargetException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } catch (IllegalAccessException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example reject = row.firstChild(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(ShouldBe.either(FALSE).or(instanceOf(Exception.class))); call.will(Annotate.right(reject)).when(ResultIs.right()); call.will(Annotate.wrong(reject)).when(ResultIs.wrong()); call.will(Annotate.exception(CollectionUtil.first(keywordCells(row)))).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (InvocationTargetException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } catch (IllegalAccessException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example expectedCell = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(expectedCell.getContent()); call.will(Annotate.right(expectedCell)).when(ResultIs.right()); call.will(Annotate.wrongWithDetails(expectedCell)).when(ResultIs.wrong()); call.will(Annotate.exception(CollectionUtil.first(keywordCells(row)))).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (InvocationTargetException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } catch (IllegalAccessException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example anchor = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.will(Annotate.ignored(anchor.addSibling())); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.will(Do.both(Annotate.right(Group.composedOf(keywordCells(row)))).and(countRowOf(table).right())).when( ResultIs.equalTo(true)); call.will(Do.both(Annotate.wrong(Group.composedOf(keywordCells(row)))).and(countRowOf(table).wrong())).when( ResultIs.equalTo(false)); call.will(Do.both(Annotate.exception(CollectionUtil.first(keywordCells(row)))).and(countRowOf(table) .exception())).when(ResultIs.exception()); call.execute(); } catch (InvocationTargetException e) { LOG.error(LOG_ERROR, e); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); reportException(table); } catch (IllegalAccessException e) { LOG.error(LOG_ERROR, e); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); reportException(table); } catch (NoSuchMessageException e) { LOG.error(LOG_ERROR, e); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); reportException(table); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example accept = row.firstChild(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(ShouldBe.TRUE); call.will(Annotate.right(accept)).when(ResultIs.right()); call.will(Annotate.wrong(accept)).when(ResultIs.wrong()); call.will(Annotate.exception(accept)).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (InvocationTargetException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } catch (IllegalAccessException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example expectedCell = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(expectedCell.getContent()); call.will(Annotate.right(expectedCell)).when(ResultIs.right()); call.will(Annotate.wrongWithDetails(expectedCell)).when(ResultIs.wrong()); call.will(Annotate.exception(CollectionUtil.first(keywordCells(row)))).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example reject = row.firstChild(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(ShouldBe.either(FALSE).or(instanceOf(Exception.class))); call.will(Annotate.right(reject)).when(ResultIs.right()); call.will(Annotate.wrong(reject)).when(ResultIs.wrong()); call.will(Annotate.exception(CollectionUtil.first(keywordCells(row)))).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example accept = row.firstChild(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(ShouldBe.TRUE); call.will(Annotate.right(accept)).when(ResultIs.right()); call.will(Annotate.wrong(accept)).when(ResultIs.wrong()); call.will(Annotate.exception(accept)).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }