|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -607,68 +607,68 @@ public OutputAnalyzer stdoutShouldMatchByLine(String pattern) {
|
607 | 607 | /**
|
608 | 608 | * @see #shouldMatchByLine(String, String, String)
|
609 | 609 | */
|
610 |
| - public OutputAnalyzer shouldMatchByLineFrom(String from, String pattern) { |
611 |
| - return shouldMatchByLine(from, null, pattern); |
| 610 | + public OutputAnalyzer shouldMatchByLineFrom(String fromPattern, String pattern) { |
| 611 | + return shouldMatchByLine(fromPattern, null, pattern); |
612 | 612 | }
|
613 | 613 |
|
614 | 614 | /**
|
615 | 615 | * @see #shouldMatchByLine(String, String, String)
|
616 | 616 | */
|
617 |
| - public OutputAnalyzer shouldMatchByLineTo(String to, String pattern) { |
618 |
| - return shouldMatchByLine(null, to, pattern); |
| 617 | + public OutputAnalyzer shouldMatchByLineTo(String toPattern, String pattern) { |
| 618 | + return shouldMatchByLine(null, toPattern, pattern); |
619 | 619 | }
|
620 | 620 |
|
621 | 621 | /**
|
622 | 622 | * Verify that the stdout and stderr contents of output buffer match the
|
623 | 623 | * {@code pattern} line by line. The whole output could be matched or
|
624 | 624 | * just a subset of it.
|
625 | 625 | *
|
626 |
| - * @param from |
627 |
| - * The line (excluded) from where output will be matched. |
628 |
| - * Set {@code from} to null for matching from the first line. |
629 |
| - * @param to |
630 |
| - * The line (excluded) until where output will be matched. |
631 |
| - * Set {@code to} to null for matching until the last line. |
| 626 | + * @param fromPattern |
| 627 | + * The pattern of line (excluded) from where output will be matched. |
| 628 | + * Set {@code fromPattern} to null for matching from the first line. |
| 629 | + * @param toPattern |
| 630 | + * The pattern of line (excluded) until where output will be matched. |
| 631 | + * Set {@code toPattern} to null for matching until the last line. |
632 | 632 | * @param pattern
|
633 | 633 | * Matching pattern
|
634 | 634 | */
|
635 |
| - public OutputAnalyzer shouldMatchByLine(String from, String to, String pattern) { |
636 |
| - return shouldMatchByLine(getOutput(), from, to, pattern); |
| 635 | + public OutputAnalyzer shouldMatchByLine(String fromPattern, String toPattern, String pattern) { |
| 636 | + return shouldMatchByLine(getOutput(), fromPattern, toPattern, pattern); |
637 | 637 | }
|
638 | 638 |
|
639 | 639 | /**
|
640 | 640 | * Verify that the stdout contents of output buffer matches the
|
641 | 641 | * {@code pattern} line by line. The whole stdout could be matched or
|
642 | 642 | * just a subset of it.
|
643 | 643 | *
|
644 |
| - * @param from |
645 |
| - * The line (excluded) from where stdout will be matched. |
646 |
| - * Set {@code from} to null for matching from the first line. |
647 |
| - * @param to |
648 |
| - * The line (excluded) until where stdout will be matched. |
649 |
| - * Set {@code to} to null for matching until the last line. |
| 644 | + * @param fromPattern |
| 645 | + * The pattern of line (excluded) from where stdout will be matched. |
| 646 | + * Set {@code fromPattern} to null for matching from the first line. |
| 647 | + * @param toPattern |
| 648 | + * The pattern of line (excluded) until where stdout will be matched. |
| 649 | + * Set {@code toPattern} to null for matching until the last line. |
650 | 650 | * @param pattern
|
651 | 651 | * Matching pattern
|
652 | 652 | */
|
653 |
| - public OutputAnalyzer stdoutShouldMatchByLine(String from, String to, String pattern) { |
654 |
| - return shouldMatchByLine(getStdout(), from, to, pattern); |
| 653 | + public OutputAnalyzer stdoutShouldMatchByLine(String fromPattern, String toPattern, String pattern) { |
| 654 | + return shouldMatchByLine(getStdout(), fromPattern, toPattern, pattern); |
655 | 655 | }
|
656 | 656 |
|
657 |
| - private OutputAnalyzer shouldMatchByLine(String buffer, String from, String to, String pattern) { |
| 657 | + private OutputAnalyzer shouldMatchByLine(String buffer, String fromPattern, String toPattern, String pattern) { |
658 | 658 | List<String> lines = asLines(buffer);
|
659 | 659 |
|
660 | 660 | int fromIndex = 0;
|
661 |
| - if (from != null) { |
662 |
| - fromIndex = indexOf(lines, from, 0) + 1; // + 1 -> apply 'pattern' to lines after 'from' match |
| 661 | + if (fromPattern != null) { |
| 662 | + fromIndex = indexOf(lines, fromPattern, 0) + 1; // + 1 -> apply 'pattern' to lines after 'from' match |
663 | 663 | Asserts.assertGreaterThan(fromIndex, 0,
|
664 |
| - "The line/pattern '" + from + "' from where the output should match can not be found"); |
| 664 | + "The line matched with pattern '" + fromPattern + "' from where the output should match can not be found"); |
665 | 665 | }
|
666 | 666 |
|
667 | 667 | int toIndex = lines.size();
|
668 |
| - if (to != null) { |
669 |
| - toIndex = indexOf(lines, to, fromIndex); |
| 668 | + if (toPattern != null) { |
| 669 | + toIndex = indexOf(lines, toPattern, fromIndex); |
670 | 670 | Asserts.assertGreaterThan(toIndex, fromIndex,
|
671 |
| - "The line/pattern '" + to + "' until where the output should match can not be found"); |
| 671 | + "The line matched with pattern '" + toPattern + "' until where the output should match can not be found"); |
672 | 672 | }
|
673 | 673 |
|
674 | 674 | List<String> subList = lines.subList(fromIndex, toIndex);
|
|
0 commit comments