|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2013, 2022, 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
|
@@ -671,68 +671,68 @@ public OutputAnalyzer stdoutShouldMatchByLine(String pattern) {
|
671 | 671 | /**
|
672 | 672 | * @see #shouldMatchByLine(String, String, String)
|
673 | 673 | */
|
674 |
| - public OutputAnalyzer shouldMatchByLineFrom(String from, String pattern) { |
675 |
| - return shouldMatchByLine(from, null, pattern); |
| 674 | + public OutputAnalyzer shouldMatchByLineFrom(String fromPattern, String pattern) { |
| 675 | + return shouldMatchByLine(fromPattern, null, pattern); |
676 | 676 | }
|
677 | 677 |
|
678 | 678 | /**
|
679 | 679 | * @see #shouldMatchByLine(String, String, String)
|
680 | 680 | */
|
681 |
| - public OutputAnalyzer shouldMatchByLineTo(String to, String pattern) { |
682 |
| - return shouldMatchByLine(null, to, pattern); |
| 681 | + public OutputAnalyzer shouldMatchByLineTo(String toPattern, String pattern) { |
| 682 | + return shouldMatchByLine(null, toPattern, pattern); |
683 | 683 | }
|
684 | 684 |
|
685 | 685 | /**
|
686 | 686 | * Verify that the stdout and stderr contents of output buffer match the
|
687 | 687 | * {@code pattern} line by line. The whole output could be matched or
|
688 | 688 | * just a subset of it.
|
689 | 689 | *
|
690 |
| - * @param from |
691 |
| - * The line (excluded) from where output will be matched. |
692 |
| - * Set {@code from} to null for matching from the first line. |
693 |
| - * @param to |
694 |
| - * The line (excluded) until where output will be matched. |
695 |
| - * Set {@code to} to null for matching until the last line. |
| 690 | + * @param fromPattern |
| 691 | + * The pattern of line (excluded) from where output will be matched. |
| 692 | + * Set {@code fromPattern} to null for matching from the first line. |
| 693 | + * @param toPattern |
| 694 | + * The pattern of line (excluded) until where output will be matched. |
| 695 | + * Set {@code toPattern} to null for matching until the last line. |
696 | 696 | * @param pattern
|
697 | 697 | * Matching pattern
|
698 | 698 | */
|
699 |
| - public OutputAnalyzer shouldMatchByLine(String from, String to, String pattern) { |
700 |
| - return shouldMatchByLine(getOutput(), from, to, pattern); |
| 699 | + public OutputAnalyzer shouldMatchByLine(String fromPattern, String toPattern, String pattern) { |
| 700 | + return shouldMatchByLine(getOutput(), fromPattern, toPattern, pattern); |
701 | 701 | }
|
702 | 702 |
|
703 | 703 | /**
|
704 | 704 | * Verify that the stdout contents of output buffer matches the
|
705 | 705 | * {@code pattern} line by line. The whole stdout could be matched or
|
706 | 706 | * just a subset of it.
|
707 | 707 | *
|
708 |
| - * @param from |
709 |
| - * The line (excluded) from where stdout will be matched. |
710 |
| - * Set {@code from} to null for matching from the first line. |
711 |
| - * @param to |
712 |
| - * The line (excluded) until where stdout will be matched. |
713 |
| - * Set {@code to} to null for matching until the last line. |
| 708 | + * @param fromPattern |
| 709 | + * The pattern of line (excluded) from where stdout will be matched. |
| 710 | + * Set {@code fromPattern} to null for matching from the first line. |
| 711 | + * @param toPattern |
| 712 | + * The pattern of line (excluded) until where stdout will be matched. |
| 713 | + * Set {@code toPattern} to null for matching until the last line. |
714 | 714 | * @param pattern
|
715 | 715 | * Matching pattern
|
716 | 716 | */
|
717 |
| - public OutputAnalyzer stdoutShouldMatchByLine(String from, String to, String pattern) { |
718 |
| - return shouldMatchByLine(getStdout(), from, to, pattern); |
| 717 | + public OutputAnalyzer stdoutShouldMatchByLine(String fromPattern, String toPattern, String pattern) { |
| 718 | + return shouldMatchByLine(getStdout(), fromPattern, toPattern, pattern); |
719 | 719 | }
|
720 | 720 |
|
721 |
| - private OutputAnalyzer shouldMatchByLine(String buffer, String from, String to, String pattern) { |
| 721 | + private OutputAnalyzer shouldMatchByLine(String buffer, String fromPattern, String toPattern, String pattern) { |
722 | 722 | List<String> lines = asLines(buffer);
|
723 | 723 |
|
724 | 724 | int fromIndex = 0;
|
725 |
| - if (from != null) { |
726 |
| - fromIndex = indexOf(lines, from, 0) + 1; // + 1 -> apply 'pattern' to lines after 'from' match |
| 725 | + if (fromPattern != null) { |
| 726 | + fromIndex = indexOf(lines, fromPattern, 0) + 1; // + 1 -> apply 'pattern' to lines after 'from' match |
727 | 727 | Asserts.assertGreaterThan(fromIndex, 0,
|
728 |
| - "The line/pattern '" + from + "' from where the output should match can not be found"); |
| 728 | + "The line matched with pattern '" + fromPattern + "' from where the output should match can not be found"); |
729 | 729 | }
|
730 | 730 |
|
731 | 731 | int toIndex = lines.size();
|
732 |
| - if (to != null) { |
733 |
| - toIndex = indexOf(lines, to, fromIndex); |
| 732 | + if (toPattern != null) { |
| 733 | + toIndex = indexOf(lines, toPattern, fromIndex); |
734 | 734 | Asserts.assertGreaterThan(toIndex, fromIndex,
|
735 |
| - "The line/pattern '" + to + "' until where the output should match can not be found"); |
| 735 | + "The line matched with pattern '" + toPattern + "' until where the output should match can not be found"); |
736 | 736 | }
|
737 | 737 |
|
738 | 738 | List<String> subList = lines.subList(fromIndex, toIndex);
|
|
0 commit comments