686 /**
687 * List all the tests in the tree.
688 *
689 * @return An iterator which returns all tests in the tree.
690 * @since 3.0
691 */
692 public TreeIterator getIterator() {
693 if (root == null)
694 return NullEnum.getInstance();
695 else
696 return getIterator(root);
697 }
698
699 /**
700 * List all the tests in the tree.
701 *
702 * @return An enumerator which returns all tests in the tree.
703 * @see #getIterator()
704 * @since 3.0
705 */
706 public Enumeration elements() {
707 return getIterator();
708 }
709
710 /**
711 * List all the tests in the tree subject to the given filters.
712 *
713 * @param filters The Filters to run tests through before "selecting"
714 * them for iteration. May be null.
715 * @return An iterator which returns all tests in the tree after removing
716 * those filtered out by the filters.
717 * @since 3.0
718 */
719 public TreeIterator getIterator(TestFilter[] filters) {
720 if (root == null)
721 return NullEnum.getInstance();
722 else
723 return getIterator(root, filters);
724 }
725
726 /**
727 * Same description as getIterator() method with same args.
728 *
729 * @param filters The Filters to run tests through before "selecting"
730 * them for iteration. May be null.
731 * @return An enumerator which returns all tests in the tree after removing
732 * those filtered out by the filters.
733 * @since 3.0
734 * @see #getIterator()
735 */
736 public Enumeration elements(TestFilter[] filters) {
737 return getIterator(filters);
738 }
739
740 /**
741 * List all the tests under this node.
742 *
743 * @param node The tree node to being the iteration at.
744 * @return An iterator which return all the tests below the given node.
745 * @since 3.0
746 */
747 public static TreeIterator getIterator(TreeNode node) {
748 if (node == null)
749 return NullEnum.getInstance();
750 else
751 return new TRT_Iterator(node);
752 }
753
754 /**
755 * List all the tests under this node.
756 *
757 * @param node The tree node to being the iteration at.
758 * @return An enumerator which return all the tests below the given node.
759 * @see #getIterator()
760 * @since 3.0
761 */
762 public static Enumeration elements(TreeNode node) {
763 return getIterator(node);
764 }
765
766 /**
767 * Get an iterator capable of producing a filtered view of the test suite.
768 * If the node parameter is null, an iterator with no items will be returned.
769 * An empty or null set of filters is acceptable and will result in unfiltered
770 * iteration.
771 *
772 * @param node The tree node to being the iteration at. May be null.
773 * @param filter The filter to run tests through before "selecting"
774 * them for iteration.
775 * @return An iterator which returns test below the given node after
776 * removing any tests which the filter rejects.
777 * @since 3.0
778 */
779 public static TreeIterator getIterator(TreeNode node, TestFilter filter) {
780 if (node == null)
781 return NullEnum.getInstance();
782 else {
783 TestFilter[] filters = new TestFilter[] {filter};
784 return new TRT_Iterator(node, filters);
785 }
786 }
787
788 /**
789 * Same description as getIterator() method with same args.
790 *
791 * @param node The tree node to being the enumeration at. May be null.
792 * @param filter The filter to run tests through before "selecting"
793 * them for enumeration. May be null.
794 * @return An enumerator which returns test below the given node after
795 * removing any tests which the filter rejects.
796 * @see #getIterator()
797 * @since 3.0
798 */
799 public static Enumeration elements(TreeNode node, TestFilter filter) {
800 return getIterator(node, filter);
801 }
802
803 /**
804 * Get an iterator capable of producing a filtered view of the test suite.
805 * If the node parameter is null, an iterator with no items will be returned.
806 * An empty or null set of filters is acceptable and will result in unfiltered
807 * iteration.
808 *
809 * @param node The tree node to begin enumerating at. May be null.
810 * @param filters The test filters to apply to any tests found.
811 * @return An iterator which returns test below the given node after
812 * removing any tests which the filters reject.
813 * @since 3.0
814 */
815 public static TreeIterator getIterator(TreeNode node, TestFilter[] filters) {
816 if (node == null)
817 return NullEnum.getInstance();
818 else
819 return new TRT_Iterator(node, filters);
820 }
821
822 /**
823 * Same description as getIterator() method with same args.
824 *
825 * @param node The tree node to begin enumerating at. May be null.
826 * @param filters The test filters to apply to any tests found.
827 * @return An enumerator which returns test below the given node after
828 * removing any tests which the filters reject.
829 * @see #getIterator()
830 * @since 3.0
831 */
832 public static Enumeration elements(TreeNode node, TestFilter[] filters) {
833 return getIterator(node, filters);
834 }
835
836 /**
837 * Get an enumerator capable of producing a filtered view of the test
838 * suite. This can be used to obtain a view of the test suite based on an
839 * initial URL selection. The URL can specify a folder/directory, a
840 * specific test, or a file which contains one or more tests. If the given
841 * URL parameter is null, an iterator with no elements will be returned.
842 * An empty or null set of filters is acceptable and will result in
843 * unfiltered iteration.
844 *
845 * @param url The test URL to scan. This value should have already be
846 * normalized to a '/' file separator. May be null.
847 * @param filters The test filters to apply to any tests found. May be null.
848 * @return An enumerator which returns test below the given location after
849 * removing any tests which the filters reject.
850 * @see #getIterator()
851 * @since 3.0
852 */
853 public Enumeration elements(String url, TestFilter[] filters) {
854 if (url == null)
855 return NullEnum.getInstance();
856 else {
857 String[] urls = {url};
858 return elements(urls, filters);
859 }
860 }
861
862 /**
863 * Get an iterator capable of producing a filtered view of the test suite.
864 * This can be used to obtain a view of the test suite based on an initial
865 * URL selection. The URL can specify a folder/directory, a specific test,
866 * or a file which contains one or more tests. If the initial urls are
867 * null or zero length, a filtered iterator of the root will be returned.
868 * An empty or null set of filters is acceptable and will result in
869 * unfiltered iteration.
870 *
871 * @param tests The set of files base the iterator on. May be null.
872 * If this set is not empty, the contents should have already been
873 * validated using the validatePath() method.
881 public TreeIterator getIterator(File[] tests, TestFilter[] filters) throws Fault {
882 String[] urls = preProcessInitFiles(tests);
883
884 if (urls != null && urls.length > 0)
885 return getIterator(urls, filters);
886 else
887 return getIterator(filters);
888 }
889
890 /**
891 * Same as getIterator() with the same args.
892 *
893 * @param tests The set of files base the enumerator on. May be null.
894 * @param filters The test filters to apply to any tests found. May be null.
895 * @return An enumerator which return the union of tests specified by the
896 * initial files but not removed by the filters.
897 * @throws TestResultTable.Fault Thrown if the given initialUrls are invalid.
898 * @see #getIterator()
899 * @since 3.0
900 */
901 public Enumeration elements(File[] tests, TestFilter[] filters) throws Fault {
902 return getIterator(tests, filters);
903 }
904
905 /**
906 * Get an iterator capable of producing a filtered view of the test suite.
907 * This can be used to obtain a view of the test suite based on an initial
908 * URL selection. An empty or null set of filters is acceptable and will
909 * result in unfiltered iteration.
910 *
911 * @param paths The test URLs to scan. Values should have already be normalized to a
912 * '/' file separator. May not be null.
913 * @param filters The test filters to apply to any tests found. May be null.
914 * @return An iterator which return the union of tests specified by the
915 * URLs but not removed by the filters.
916 * @since 3.0
917 */
918 public TreeIterator getIterator(String[] paths, TestFilter[] filters) {
919 LinkedList<TreeNode> initNodes = new LinkedList<TreeNode>();
920 LinkedList<TestResult> initTests = new LinkedList<TestResult>();
921
968 if (debug == 1 || debug == 99)
969 Debug.println("Using combo TreeIterator, " + initTests.size() +
970 " tests, " + initNodes.size() + " nodes.");
971 return new TRT_Iterator(initNodes.toArray(new TreeNode[0]), initTests.toArray(new TestResult[0]), filters);
972 }
973 else
974 return new TRT_Iterator(initNodes.toArray(new TreeNode[0]), filters);
975 }
976
977 /**
978 * This method is the same as getIterator() with the same params.
979 *
980 * @param urls The test URLs to scan. Values should have already be normalized to a
981 * '/' file separator.
982 * @param filters The test filters to apply to any tests found.
983 * @return An enumerator which return the union of tests specified by the
984 * URLs but not removed by the filters.
985 * @see #getIterator()
986 * @since 3.0
987 */
988 public Enumeration elements(String[] urls, TestFilter[] filters) {
989 return getIterator(urls, filters);
990 }
991
992 /**
993 * Find out the size of the entire tree. This is a high overhead call, use
994 * with caution.
995 *
996 * @return The number of tests in the tree.
997 */
998 public int size() {
999 if (root == null)
1000 return 0;
1001 else
1002 return root.getSize();
1003 }
1004
1005 /**
1006 * Insert the given test into the tree.
1007 *
1008 * @param tr The test to insert. A null value is ignored.
|
686 /**
687 * List all the tests in the tree.
688 *
689 * @return An iterator which returns all tests in the tree.
690 * @since 3.0
691 */
692 public TreeIterator getIterator() {
693 if (root == null)
694 return NullEnum.getInstance();
695 else
696 return getIterator(root);
697 }
698
699 /**
700 * List all the tests in the tree.
701 *
702 * @return An enumerator which returns all tests in the tree.
703 * @see #getIterator()
704 * @since 3.0
705 */
706 public Enumeration<TestResult> elements() {
707 return getIterator();
708 }
709
710 /**
711 * List all the tests in the tree subject to the given filters.
712 *
713 * @param filters The Filters to run tests through before "selecting"
714 * them for iteration. May be null.
715 * @return An iterator which returns all tests in the tree after removing
716 * those filtered out by the filters.
717 * @since 3.0
718 */
719 public TreeIterator getIterator(TestFilter[] filters) {
720 if (root == null)
721 return NullEnum.getInstance();
722 else
723 return getIterator(root, filters);
724 }
725
726 /**
727 * Same description as getIterator() method with same args.
728 *
729 * @param filters The Filters to run tests through before "selecting"
730 * them for iteration. May be null.
731 * @return An enumerator which returns all tests in the tree after removing
732 * those filtered out by the filters.
733 * @since 3.0
734 * @see #getIterator()
735 */
736 public Enumeration<TestResult> elements(TestFilter[] filters) {
737 return getIterator(filters);
738 }
739
740 /**
741 * List all the tests under this node.
742 *
743 * @param node The tree node to being the iteration at.
744 * @return An iterator which return all the tests below the given node.
745 * @since 3.0
746 */
747 public static TreeIterator getIterator(TreeNode node) {
748 if (node == null)
749 return NullEnum.getInstance();
750 else
751 return new TRT_Iterator(node);
752 }
753
754 /**
755 * List all the tests under this node.
756 *
757 * @param node The tree node to being the iteration at.
758 * @return An enumerator which return all the tests below the given node.
759 * @see #getIterator()
760 * @since 3.0
761 */
762 public static Enumeration<TestResult> elements(TreeNode node) {
763 return getIterator(node);
764 }
765
766 /**
767 * Get an iterator capable of producing a filtered view of the test suite.
768 * If the node parameter is null, an iterator with no items will be returned.
769 * An empty or null set of filters is acceptable and will result in unfiltered
770 * iteration.
771 *
772 * @param node The tree node to being the iteration at. May be null.
773 * @param filter The filter to run tests through before "selecting"
774 * them for iteration.
775 * @return An iterator which returns test below the given node after
776 * removing any tests which the filter rejects.
777 * @since 3.0
778 */
779 public static TreeIterator getIterator(TreeNode node, TestFilter filter) {
780 if (node == null)
781 return NullEnum.getInstance();
782 else {
783 TestFilter[] filters = new TestFilter[] {filter};
784 return new TRT_Iterator(node, filters);
785 }
786 }
787
788 /**
789 * Same description as getIterator() method with same args.
790 *
791 * @param node The tree node to being the enumeration at. May be null.
792 * @param filter The filter to run tests through before "selecting"
793 * them for enumeration. May be null.
794 * @return An enumerator which returns test below the given node after
795 * removing any tests which the filter rejects.
796 * @see #getIterator()
797 * @since 3.0
798 */
799 public static Enumeration<TestResult> elements(TreeNode node, TestFilter filter) {
800 return getIterator(node, filter);
801 }
802
803 /**
804 * Get an iterator capable of producing a filtered view of the test suite.
805 * If the node parameter is null, an iterator with no items will be returned.
806 * An empty or null set of filters is acceptable and will result in unfiltered
807 * iteration.
808 *
809 * @param node The tree node to begin enumerating at. May be null.
810 * @param filters The test filters to apply to any tests found.
811 * @return An iterator which returns test below the given node after
812 * removing any tests which the filters reject.
813 * @since 3.0
814 */
815 public static TreeIterator getIterator(TreeNode node, TestFilter[] filters) {
816 if (node == null)
817 return NullEnum.getInstance();
818 else
819 return new TRT_Iterator(node, filters);
820 }
821
822 /**
823 * Same description as getIterator() method with same args.
824 *
825 * @param node The tree node to begin enumerating at. May be null.
826 * @param filters The test filters to apply to any tests found.
827 * @return An enumerator which returns test below the given node after
828 * removing any tests which the filters reject.
829 * @see #getIterator()
830 * @since 3.0
831 */
832 public static Enumeration<TestResult> elements(TreeNode node, TestFilter[] filters) {
833 return getIterator(node, filters);
834 }
835
836 /**
837 * Get an enumerator capable of producing a filtered view of the test
838 * suite. This can be used to obtain a view of the test suite based on an
839 * initial URL selection. The URL can specify a folder/directory, a
840 * specific test, or a file which contains one or more tests. If the given
841 * URL parameter is null, an iterator with no elements will be returned.
842 * An empty or null set of filters is acceptable and will result in
843 * unfiltered iteration.
844 *
845 * @param url The test URL to scan. This value should have already be
846 * normalized to a '/' file separator. May be null.
847 * @param filters The test filters to apply to any tests found. May be null.
848 * @return An enumerator which returns test below the given location after
849 * removing any tests which the filters reject.
850 * @see #getIterator()
851 * @since 3.0
852 */
853 public Enumeration<TestResult> elements(String url, TestFilter[] filters) {
854 if (url == null)
855 return NullEnum.getInstance();
856 else {
857 String[] urls = {url};
858 return elements(urls, filters);
859 }
860 }
861
862 /**
863 * Get an iterator capable of producing a filtered view of the test suite.
864 * This can be used to obtain a view of the test suite based on an initial
865 * URL selection. The URL can specify a folder/directory, a specific test,
866 * or a file which contains one or more tests. If the initial urls are
867 * null or zero length, a filtered iterator of the root will be returned.
868 * An empty or null set of filters is acceptable and will result in
869 * unfiltered iteration.
870 *
871 * @param tests The set of files base the iterator on. May be null.
872 * If this set is not empty, the contents should have already been
873 * validated using the validatePath() method.
881 public TreeIterator getIterator(File[] tests, TestFilter[] filters) throws Fault {
882 String[] urls = preProcessInitFiles(tests);
883
884 if (urls != null && urls.length > 0)
885 return getIterator(urls, filters);
886 else
887 return getIterator(filters);
888 }
889
890 /**
891 * Same as getIterator() with the same args.
892 *
893 * @param tests The set of files base the enumerator on. May be null.
894 * @param filters The test filters to apply to any tests found. May be null.
895 * @return An enumerator which return the union of tests specified by the
896 * initial files but not removed by the filters.
897 * @throws TestResultTable.Fault Thrown if the given initialUrls are invalid.
898 * @see #getIterator()
899 * @since 3.0
900 */
901 public Enumeration<TestResult> elements(File[] tests, TestFilter[] filters) throws Fault {
902 return getIterator(tests, filters);
903 }
904
905 /**
906 * Get an iterator capable of producing a filtered view of the test suite.
907 * This can be used to obtain a view of the test suite based on an initial
908 * URL selection. An empty or null set of filters is acceptable and will
909 * result in unfiltered iteration.
910 *
911 * @param paths The test URLs to scan. Values should have already be normalized to a
912 * '/' file separator. May not be null.
913 * @param filters The test filters to apply to any tests found. May be null.
914 * @return An iterator which return the union of tests specified by the
915 * URLs but not removed by the filters.
916 * @since 3.0
917 */
918 public TreeIterator getIterator(String[] paths, TestFilter[] filters) {
919 LinkedList<TreeNode> initNodes = new LinkedList<TreeNode>();
920 LinkedList<TestResult> initTests = new LinkedList<TestResult>();
921
968 if (debug == 1 || debug == 99)
969 Debug.println("Using combo TreeIterator, " + initTests.size() +
970 " tests, " + initNodes.size() + " nodes.");
971 return new TRT_Iterator(initNodes.toArray(new TreeNode[0]), initTests.toArray(new TestResult[0]), filters);
972 }
973 else
974 return new TRT_Iterator(initNodes.toArray(new TreeNode[0]), filters);
975 }
976
977 /**
978 * This method is the same as getIterator() with the same params.
979 *
980 * @param urls The test URLs to scan. Values should have already be normalized to a
981 * '/' file separator.
982 * @param filters The test filters to apply to any tests found.
983 * @return An enumerator which return the union of tests specified by the
984 * URLs but not removed by the filters.
985 * @see #getIterator()
986 * @since 3.0
987 */
988 public Enumeration<TestResult> elements(String[] urls, TestFilter[] filters) {
989 return getIterator(urls, filters);
990 }
991
992 /**
993 * Find out the size of the entire tree. This is a high overhead call, use
994 * with caution.
995 *
996 * @return The number of tests in the tree.
997 */
998 public int size() {
999 if (root == null)
1000 return 0;
1001 else
1002 return root.getSize();
1003 }
1004
1005 /**
1006 * Insert the given test into the tree.
1007 *
1008 * @param tr The test to insert. A null value is ignored.
|