[
  {
    "path": ".gitattributes",
    "content": "* text eol=lf\n*.gif binary\n*.GIF binary\n*.jar binary\n*.png binary\n*.jpg binary\n*.svg text eol=lf\n\n# These files do not have unix line endings. Do not normalize them for now.\n# Will fix these right before we cut JUnit 4.13.\n/src/main/java/org/junit/experimental/categories/CategoryFilterFactory.java -text\n/src/main/java/org/junit/experimental/categories/ExcludeCategories.java -text\n/src/main/java/org/junit/experimental/categories/IncludeCategories.java -text\n/src/main/java/org/junit/internal/Classes.java -text\n/src/main/java/org/junit/runner/FilterFactories.java -text\n/src/main/java/org/junit/runner/FilterFactory.java -text\n/src/main/java/org/junit/runner/FilterFactoryParams.java -text\n/src/main/java/org/junit/runner/JUnitCommandLineParseResult.java -text\n/src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java -text\n/src/test/java/org/junit/runner/FilterFactoriesTest.java -text\n/src/test/java/org/junit/runner/JUnitCommandLineParseResultTest.java -text\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: Report a critical bug\nabout: Please only report critical bugs since the project is in maintenance mode\ntype: Bug\n---\n\n> [!IMPORTANT]  \n> **JUnit 4 is in maintenance mode.**\n>\n> At this point, only critical bugs and security issues will be fixed.<br>\n> All other issues and PRs will therefore be declined.<br>\n> For ongoing development, please check out the [junit-framework](https://github.com/junit-team/junit-framework/) repository.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "> [!IMPORTANT]  \n> **JUnit 4 is in maintenance mode.**\n>\n> At this point, only critical bugs and security issues will be fixed.<br>\n> All other issues and PRs will therefore be declined.<br>\n> For ongoing development, please check out the [junit-framework](https://github.com/junit-team/junit-framework/) repository.\n\n## Overview\n\n<!-- Please describe your changes here and list any open questions you might have. -->\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: CI\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - '*'\n\npermissions:\n  contents: read #  to fetch code (actions/checkout)\n\njobs:\n\n  build-and-verify:\n    name: Build and verify (JDK ${{ matrix.java }})\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        java: ['8', '11', '17', '21']\n    steps:\n      - uses: actions/checkout@v2\n      - name: Download Maven # Download with default JDK because OpenJDK 6 does not support TLS 1.2\n        run: ./mvnw --version\n      - name: Set up JDK 6\n        if: ${{ matrix.java == '6'}}\n        uses: actions/setup-java@v4\n        with:\n          java-version: ${{ matrix.java }}\n          distribution: temurin\n      - name: Set up JDK\n        if: ${{ matrix.java != '6'}}\n        uses: actions/setup-java@v4\n        with:\n          java-version: ${{ matrix.java }}\n          distribution: temurin\n          cache: maven\n      - name: Build and verify\n        run: ./mvnw verify javadoc:javadoc site:site --batch-mode --errors --settings .github/workflows/settings.xml\n\n  publish-snapshots:\n    name: Publish snapshot artifacts\n    if: github.event_name == 'push' && github.repository == 'junit-team/junit4' && github.ref == 'refs/heads/main'\n    needs: build-and-verify\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n      - name: Download Maven # Download with default JDK because OpenJDK 6 does not support TLS 1.2\n        run: ./mvnw --version\n      - name: Set up JDK\n        uses: actions/setup-java@v4\n        with:\n          java-version: 8\n          distribution: temurin\n      - name: Publish snapshot artifacts\n        env:\n          MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}\n          MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}\n        run: ./mvnw deploy --batch-mode --errors --activate-profiles generate-docs --settings .github/workflows/settings.xml\n"
  },
  {
    "path": ".github/workflows/settings.xml",
    "content": "<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n          xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd\">\n    <servers>\n        <server>\n            <id>central-portal</id>\n            <username>${env.MAVEN_CENTRAL_USERNAME}</username>\n            <password>${env.MAVEN_CENTRAL_PASSWORD}</password>\n        </server>\n    </servers>\n</settings>\n"
  },
  {
    "path": ".gitignore",
    "content": "MaxCore.ser\nbin\njunit4.*\ntarget\nMaxCore.max\n# IntelliJ\n.idea\n*.ipr\n*.iml\n*.iws\nout\njava.hprof.txt\n.DS_Store\n"
  },
  {
    "path": ".mvn/wrapper/maven-wrapper.properties",
    "content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\nwrapperVersion=3.3.1\ndistributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip\n"
  },
  {
    "path": ".settings/org.eclipse.jdt.core.prefs",
    "content": "#Mon Oct 12 21:57:10 EDT 2009\neclipse.preferences.version=1\norg.eclipse.jdt.core.codeComplete.argumentPrefixes=\norg.eclipse.jdt.core.codeComplete.argumentSuffixes=\norg.eclipse.jdt.core.codeComplete.fieldPrefixes=f\norg.eclipse.jdt.core.codeComplete.fieldSuffixes=\norg.eclipse.jdt.core.codeComplete.localPrefixes=\norg.eclipse.jdt.core.codeComplete.localSuffixes=\norg.eclipse.jdt.core.codeComplete.staticFieldPrefixes=\norg.eclipse.jdt.core.codeComplete.staticFieldSuffixes=\norg.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5\norg.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\norg.eclipse.jdt.core.compiler.compliance=1.5\norg.eclipse.jdt.core.compiler.debug.lineNumber=generate\norg.eclipse.jdt.core.compiler.debug.localVariable=generate\norg.eclipse.jdt.core.compiler.debug.sourceFile=generate\norg.eclipse.jdt.core.compiler.doc.comment.support=enabled\norg.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning\norg.eclipse.jdt.core.compiler.problem.assertIdentifier=error\norg.eclipse.jdt.core.compiler.problem.autoboxing=ignore\norg.eclipse.jdt.core.compiler.problem.comparingIdentical=warning\norg.eclipse.jdt.core.compiler.problem.deadCode=warning\norg.eclipse.jdt.core.compiler.problem.deprecation=warning\norg.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled\norg.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled\norg.eclipse.jdt.core.compiler.problem.discouragedReference=ignore\norg.eclipse.jdt.core.compiler.problem.emptyStatement=ignore\norg.eclipse.jdt.core.compiler.problem.enumIdentifier=error\norg.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore\norg.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled\norg.eclipse.jdt.core.compiler.problem.fieldHiding=ignore\norg.eclipse.jdt.core.compiler.problem.finalParameterBound=warning\norg.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning\norg.eclipse.jdt.core.compiler.problem.forbiddenReference=error\norg.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning\norg.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning\norg.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore\norg.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore\norg.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning\norg.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled\norg.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled\norg.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled\norg.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected\norg.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore\norg.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning\norg.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning\norg.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore\norg.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore\norg.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled\norg.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected\norg.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag\norg.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore\norg.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled\norg.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected\norg.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning\norg.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning\norg.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore\norg.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning\norg.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning\norg.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore\norg.eclipse.jdt.core.compiler.problem.nullReference=warning\norg.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning\norg.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore\norg.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore\norg.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore\norg.eclipse.jdt.core.compiler.problem.rawTypeReference=warning\norg.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore\norg.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning\norg.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled\norg.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning\norg.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled\norg.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore\norg.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning\norg.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning\norg.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore\norg.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning\norg.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore\norg.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning\norg.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore\norg.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning\norg.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled\norg.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled\norg.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled\norg.eclipse.jdt.core.compiler.problem.unusedImport=warning\norg.eclipse.jdt.core.compiler.problem.unusedLabel=warning\norg.eclipse.jdt.core.compiler.problem.unusedLocal=warning\norg.eclipse.jdt.core.compiler.problem.unusedParameter=ignore\norg.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled\norg.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled\norg.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled\norg.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning\norg.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning\norg.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning\norg.eclipse.jdt.core.compiler.source=1.5\norg.eclipse.jdt.core.compiler.taskCaseSensitive=enabled\norg.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL,HIGH,NORMAL\norg.eclipse.jdt.core.compiler.taskTags=TODO,REVISIT,HACK,QUESTION\norg.eclipse.jdt.core.formatter.align_type_members_on_columns=false\norg.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16\norg.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16\norg.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16\norg.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16\norg.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16\norg.eclipse.jdt.core.formatter.alignment_for_assignment=0\norg.eclipse.jdt.core.formatter.alignment_for_binary_expression=16\norg.eclipse.jdt.core.formatter.alignment_for_compact_if=16\norg.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80\norg.eclipse.jdt.core.formatter.alignment_for_enum_constants=0\norg.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16\norg.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16\norg.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16\norg.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16\norg.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16\norg.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16\norg.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16\norg.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16\norg.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16\norg.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16\norg.eclipse.jdt.core.formatter.blank_lines_after_imports=1\norg.eclipse.jdt.core.formatter.blank_lines_after_package=1\norg.eclipse.jdt.core.formatter.blank_lines_before_field=1\norg.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0\norg.eclipse.jdt.core.formatter.blank_lines_before_imports=1\norg.eclipse.jdt.core.formatter.blank_lines_before_member_type=1\norg.eclipse.jdt.core.formatter.blank_lines_before_method=1\norg.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1\norg.eclipse.jdt.core.formatter.blank_lines_before_package=0\norg.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1\norg.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1\norg.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line\norg.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line\norg.eclipse.jdt.core.formatter.comment.clear_blank_lines=false\norg.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false\norg.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false\norg.eclipse.jdt.core.formatter.comment.format_block_comments=true\norg.eclipse.jdt.core.formatter.comment.format_comments=true\norg.eclipse.jdt.core.formatter.comment.format_header=false\norg.eclipse.jdt.core.formatter.comment.format_html=true\norg.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true\norg.eclipse.jdt.core.formatter.comment.format_line_comments=true\norg.eclipse.jdt.core.formatter.comment.format_source_code=true\norg.eclipse.jdt.core.formatter.comment.indent_parameter_description=true\norg.eclipse.jdt.core.formatter.comment.indent_root_tags=true\norg.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert\norg.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert\norg.eclipse.jdt.core.formatter.comment.line_length=80\norg.eclipse.jdt.core.formatter.compact_else_if=true\norg.eclipse.jdt.core.formatter.continuation_indentation=2\norg.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2\norg.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false\norg.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true\norg.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true\norg.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true\norg.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true\norg.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true\norg.eclipse.jdt.core.formatter.indent_empty_lines=false\norg.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true\norg.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true\norg.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true\norg.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false\norg.eclipse.jdt.core.formatter.indentation.size=4\norg.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert\norg.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert\norg.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert\norg.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert\norg.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert\norg.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert\norg.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert\norg.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert\norg.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert\norg.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert\norg.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert\norg.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert\norg.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert\norg.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert\norg.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert\norg.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert\norg.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert\norg.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert\norg.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert\norg.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert\norg.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert\norg.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert\norg.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert\norg.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert\norg.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert\norg.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert\norg.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert\norg.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert\norg.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert\norg.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert\norg.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert\norg.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert\norg.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert\norg.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert\norg.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert\norg.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert\norg.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert\norg.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert\norg.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert\norg.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false\norg.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false\norg.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false\norg.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false\norg.eclipse.jdt.core.formatter.lineSplit=80\norg.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false\norg.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false\norg.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0\norg.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1\norg.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true\norg.eclipse.jdt.core.formatter.tabulation.char=space\norg.eclipse.jdt.core.formatter.tabulation.size=4\norg.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false\norg.eclipse.jdt.core.formatter.wrap_before_binary_operator=true\n"
  },
  {
    "path": ".settings/org.eclipse.jdt.ui.prefs",
    "content": "#Tue Jul 22 09:31:38 PDT 2008\neclipse.preferences.version=1\nformatter_profile=_junit\nformatter_settings_version=11\ninternal.default.compliance=default\norg.eclipse.jdt.ui.exception.name=e\norg.eclipse.jdt.ui.gettersetter.use.is=true\norg.eclipse.jdt.ui.ignorelowercasenames=true\norg.eclipse.jdt.ui.importorder=java;javax;com;\norg.eclipse.jdt.ui.keywordthis=false\norg.eclipse.jdt.ui.ondemandthreshold=99\norg.eclipse.jdt.ui.overrideannotation=true\norg.eclipse.jdt.ui.text.custom_code_templates=<?xml version\\=\"1.0\" encoding\\=\"UTF-8\" standalone\\=\"no\"?><templates/>\n"
  },
  {
    "path": "BUILDING",
    "content": "BUILDING FROM GITHUB:\n=====================\n\ngit clone https://github.com/junit-team/junit4.git\ncd junit4\nmvn install\n\nBUILDING FROM JARS OR ZIPS:\n===========================\n\nThe contents of the zip and jar files are largely maintained for historical\nreasons.  We do not at this time have an official way to build from the src\njar or zip.  If this is an important missing feature, please let us know\nat http://github.com/junit-team/junit4/issues\n"
  },
  {
    "path": "CODING_STYLE.txt",
    "content": "JUnit project uses the Google Java Style (https://github.com/google/styleguide) for all new\ncode (under org.junit.*). Deviating from this, indentation is 4 spaces instead of 2.\n\nBe sure to set text file encoding to UTF-8 and line delimiters to UNIX style.\n\nSince not all code has been formatted yet, please format only code lines you changed to avoid extraneous changes.\n\nLegacy code (under junit.*) used the legacy guide specified in LEGACY_CODING_STYLE.txt in the\nproject root.\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "## Project License:  Eclipse Public License v1.0\n\n- You will only Submit Contributions where You have authored 100% of the content.\n- You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the Contributions.\n- Whatever content You Contribute will be provided under the Project License(s).\n\n## Building\n\n### Command line\n\nYou need to have Maven and a JDK (at least version 1.5) installed.\n\nRun `./mvnw verify` to build the code and run the tests\n\n### Eclipse\n\nMaven can generate project files for Eclipse. See [these instructions](https://mkyong.com/maven/how-to-convert-maven-java-project-to-support-eclipse-ide/) for details.\n\n## Coding Conventions\n\n### Formatting\n\nSee [CODING_STYLE.txt](CODING_STYLE.txt) for how we format our code.\n\n## How to submit a pull request\n\nWe love pull requests. Here is a quick guide:\n\n1. You need to have Maven and a JDK (at least version 1.5) installed.\n2. [Fork the repo](https://help.github.com/articles/fork-a-repo).\n3. [Create a new branch](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/) from `main`.\n4. Ensure that you have a clean state by running `./mvnw verify`.\n5. Add your change together with a test (tests are not needed for refactorings and documentation changes).\n6. Format your code: Import the JUnit project in Eclipse and use its formatter or apply the rules in the `CODING_STYLE` file manually. Only format the code you've changed; reformatting unrelated code makes it harder for us to review your changes.\n7. Run `./mvnw verify` again and ensure all tests are passing.\n8. Push to your fork and [submit a pull request](https://help.github.com/articles/creating-a-pull-request/).\n\nNow you are waiting on us. We review your pull request and at least leave some comments.\n\n\nNote that if you are thinking of providing a fix for one of the bugs or feature requests, it's usually\na good idea to add a comment to the bug to make sure that there's agreement on how we should proceed.\n\n## Limitations\n\nThe JUnit team is not accepting changes to the code under the following paths:\n\n* `src/main/java/junit`\n* `test/java/junit/tests/framework`\n* `test/java/junit/tests/extensions`\n\nThe reasoning is that the JUnit team feels that our users should focus on using either the JUnit4 or JUnit5 APIs.\n\nThe team is also reluctant to accept changes that only update code from one code style to another.\nGenerally the code in JUnit was approved by at least one person, so two people agreed that the style was reasonable.\n\nTo find other places where you can have an impact, please see the [Issues tagged \"up-for-grabs\"](https://github.com/junit-team/junit4/issues?q=is%3Aissue+is%3Aopen+label%3Aup-for-grabs).\n"
  },
  {
    "path": "KEYS",
    "content": "This file contains the PGP key that is used to sign releases.\n\nImporting: `pgp < KEYS` or `gpg --import KEYS`\n\nAdding a key:\n`pgp -kxa <your name> >> KEYS`,\nor `(pgpk -ll <your name> && pgpk -xa <your name>) >> KEYS`,\nor `(gpg --list-sigs <your name> && gpg --armor --export <your name>) >> KEYS`\n\n================================\n\npub   rsa4096 2018-04-08 [SC]\n      FF6E2C001948C5F2F38B0CC385911F425EC61B51\nuid           [ unknown] Open Source Development <mail@marcphilipp.de>\nsig 3        85911F425EC61B51 2018-04-08  Open Source Development <mail@marcphilipp.de>\nsub   rsa4096 2018-04-08 [E]\nsig          85911F425EC61B51 2018-04-08  Open Source Development <mail@marcphilipp.de>\n\n-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFrKW9IBEACkqUvM7hU1WqOOeb1gZ7pUsRliHuoUvYIrd+hdp+qhPmJ0NG0W\nYhZK5UtJBmqvtHKRkbwYxUuya9zlBmCfQFf0GpFKJ65JSrPSkZADI3aZ4aUkxIUw\nnIRoUHucmr10Xftpebr/zaJk5oR8RdaL5FapapmcZmAaHR9CDWB8XtI318u314jq\nM5rKatnAZMERoPugOvvuAOz4bfZKwdfCmZKfYUM/TMSrSinXrGExSW6z4RhtqmpC\nE5M/7OoVfvDynVJKqNazqgigpmMNhOyzAhQsiKh1K0akyxTZbjeZKsdYfhCXvq0q\nk9+KM/cTllQ54MPnFWiObLkHeK0Waw8bI/vAJ4h4x/XM9iGYpkXv7F2/FVsHQdPe\nYJcwD/CkD8KHyiPaRKMeApiUtZsdAHU0L4X/lNmcooea/7ipskruUgwcm+RdLhRZ\nP949t1e7nqDZfpEHy90NiFxmlRAPSNqBLwefxY/hwBgog2jabDALJVcLCMosFWPj\nMQhFlGSIODiVcW8folGIjzkyNZbNMWkwnl2QnWp/h2TAwYQJOMqcv2MG9o5pyzpx\n97Iz1ngq1FlM/gJnGnNUydP2tAjT2L2U3MP1uX/EdRChdgPqdolqYhdFfwCr0Fpf\nW527bUZpReHCEiQ29ABSnQ711mO+d9+qM6edRyHUoBWz89IHt8sCunuvNwARAQAB\ntC1PcGVuIFNvdXJjZSBEZXZlbG9wbWVudCA8bWFpbEBtYXJjcGhpbGlwcC5kZT6J\nAk4EEwEIADgWIQT/biwAGUjF8vOLDMOFkR9CXsYbUQUCWspb0gIbAwULCQgHAgYV\nCAkKCwIEFgIDAQIeAQIXgAAKCRCFkR9CXsYbUQyRD/9xm3BqdpWcRCE5UyB6nbwV\n8TgzMmbOhpFhhcjzobly/pKAbcofKsjhreENJkfBVUo+zAFx21ToC5tbH20wRtIE\nvQVCP6sAIzhYWU1ohafqVFP4+PztNBuYTnS6vGvSwzp0IXLIIoxSxo0IOED9uUS9\nDTxh1n9NnDLDe2pfjrXBblQtLSW3W5ISDoUvcoyO7Hk1OByW6MNsSoLvXIUNeVhB\nju9TfYxFACJSWBhUxJfgip9Y2GrNBJaYGLZrTAoW1Lh1H1DfLV3wHDClQ1+H+oyx\nIOZULEGYY3MgZTd6Ner2yNAUCB7gVa50NiCZXCS74m+XzMrTEsdWjSMUaOe+dL0I\n9MCrgi4ycUHWIfTKx9gGlIOo3hSDMN+8Nj33XPjLT8kcfoFeUX8jTOvC1HFfTuQJ\nx2t/dKHizdrS3F6A/JQa7v8GNTrZFnEXkwgRTf3ccLoo3gPwzNJeCm2xNjvne1VH\nfvxzwNmq8M05oicEigvEed2VMStMhvT7dSiMAf66rEJHjjaHAoNqbLDEATYrWUP2\nI52txHSSxSJohxVP6Ec6dERnqqYi0mVyzBPo7mmFFBisq74w8RvZXyzvXE3BTiDL\nwe1E/Z/AXbtJye9DickQ/G6RFtVLbUHQfzyRS/65JPtlH8rqJr58YWlylGImVLwE\nOsKNQrwLZ0UkfaWV7wqr3rkCDQRaylvSARAAnQG636wliEOLkXN662OZS6Qz2+cF\nltCWboq9oX9FnA1PHnTY2cAtwS214RfWZxkjg6Stau+d1Wb8TsF/SUN3eKRSyrkA\nxlX0v552vj3xmmfNsslQX47e6aEWZ0du0M8jw7/f7Qxp0InkBfpQwjSg4ECoH4cA\n6dOFJIdxBv8dgS4K90HNuIHa+QYfVSVMjGwOjD9St6Pwkbg1sLedITRo59Bbv0J1\n4nE9LdWbCiwNrkDr24jTewdgrDaCpN6msUwcH1E0nYxuKAetHEi2OpgBhaY3RQ6Q\nPQB6NywvmD0xRllMqu4hSp70pHFtm8LvJdWOsJ5we3KijHuZzEbBVTTl+2DhNMI0\nKMoh+P/OmyNOfWD8DL4NO3pVv+mPDZn82/eZ3XY1/oSQrpyJaCBjRKasVTtfiA/F\ngYqTml6qZMjy6iywg84rLezELgcxHHvjhAKd4CfxyuCCgnGT0iRLFZKw44ZmOUqP\nDkyvGRddIyHag1K7UaM/2UMn6iPMy7XWcaFiH5Huhz43SiOdsWGuwNk4dDxHdxmz\nSjps0H5dkfCciOFhEc54AFcGEXCWHXuxVqIq/hwqTmVl1RY+PTcQUIOfx36WW1ix\nJQf8TpVxUbooK8vr1jOFF6khorDXoZDJNhI2VKomWp8Y38EPGyiUPZNcnmSiezx+\nMoQwAbeqjFMKG7UAEQEAAYkCNgQYAQgAIBYhBP9uLAAZSMXy84sMw4WRH0JexhtR\nBQJaylvSAhsMAAoJEIWRH0JexhtR0LEP/RvYGlaokoosAYI5vNORAiYEc1Ow2McP\nI1ZafHhcVxZhlwF48dAC2bYcasDX/PbEdcD6pwo8ZU8eI8Ht0VpRQxeV/sP01m2Y\nEpAuyZ6jI7IQQCGcwQdN4qzQJxMAASl9JlplH2NniXV1/994FOtesT59ePMyexm5\n7lzhYXP1PGcdt8dH37r6z3XQu0lHRG/KBn7YhyA3zwJcno324KdBRJiynlc7uqQq\n+ZptU9fR1+Nx0uoWZoFMsrQUmY34aAOPJu7jGMTG+VseMH6vDdNhhZs9JOlD/e/V\naF7NyadjOUD4j/ud7c0z2EwqjDKMFTHGbIdawT/7jartT+9yGUO+EmScBMiMuJUT\ndCP4YDh3ExRdqefEBff3uE/rAP73ndNYdIVq9U0gY0uSNCD9JPfj4aCN52y9a2pS\n7Dg7KB/Z8SH1R9IWP+t0HvVtAILdsLExNFTedJGHRh7uaC7pwRz01iivmtAKYICz\nruqlJie/IdEFFK/sus6fZek29odTrQxx42HGHO5GCNyEdK9jKVAeuZ10vcaNbuBp\niP7sf8/BsiEU4wHE8gjFeUPRiSjnERgXQwfJosLgf/K/SShQn2dCkYZRNF+SWJ6Z\n2tQxcW5rpUjtclV/bRVkUX21EYfwA6SMB811mI7AVy8WPXCe8La72ukmaxEGbpJ8\nmdzS2PJko7mm\n=l0XA\n-----END PGP PUBLIC KEY BLOCK-----\n"
  },
  {
    "path": "LEGACY_CODING_STYLE.txt",
    "content": "==================================\nCoding style\n==================================\n\n----------------------------------\nTabs and Indents\n----------------------------------\n* Tab size : 4\n* Indent : 4\n* Continuation indent : 8\n* Label indent : 0\n\n> Don't use tab characters.\n\n----------------------------------\nSpaces\n----------------------------------\nBefore Parentheses\n* if parentheses\n* for parentheses\n* while parentheses\n* switch parentheses\n* try parentheses\n* catch parentheses\n* synchronized parentheses\n\nAround Operators\n* Assignment operators (=, +=, …)\n* Logical operators (&&, ||)\n* Equality operators (==, !=)\n* Relational operators (<, >, <=, >=)\n* Bitwise operators (&, |, ^)\n* Additive operators (+, -)\n* Multiplicative operators (*, /, %)\n* Shift operators (<<, >>, >>>)\n\nBefore Left Brace\n* Class left brace\n* Method left brace\n* if left brace\n* else left brace\n* for left brace\n* while left brace\n* do left brace\n* switch left brace\n* try left brace\n* catch left brace\n* finally left brace\n* synchronized left brace\n\nBefore Keywords\n* else keyword\n* while keyword\n* catch keyword\n* finally keyword\n\nIn Ternary Operator (?:)\n* Before ?\n* After ?\n* Before :\n* After :\n\nWithin Type Arguments\n* After comma\n\nOther\n* After comma\n* After semicolon\n* After type cast\n\n----------------------------------\nWrapping and Braces\n----------------------------------\nBraces placement\n* In class declaration : End of line\n* In method declaration : End of line\n* Other : End of line\n\nUse Of Braces\n* if() statement : When multiline\n* for() statement : When multiline\n* while() statement : When multiline\n* do .. while() statement : When multiline\n\nAnnotations\n* Class annotations : Wrap always\n* Method annotations : Wrap always\n* Field annotations : Wrap always\n* Parameter annotations : Do not wrap\n* Local variable annotations : Do not wrap\n\n----------------------------------\nBlank Lines\n----------------------------------\nMinimum Blank Lines\n* Before package statement : 0\n* After package statement : 1\n* Before imports : 1\n* After imports : 1\n* Around class : 1\n* After class header : 0\n* After anonymous class header : 0\n* Around field in interface : 0\n* Around field : 0\n* Around method in interface : 1\n* Around method : 1\n* Before method body : 0 \n\n----------------------------------\nJavaDoc\n----------------------------------\nAlignment\n* Align thrown exception descriptions\n\nBlank Lines\n* After description\n\nOther\n* Enable leading asterisks\n* Use @throws rather than @exception\n* Keep empty lines\n\n----------------------------------\nImports\n----------------------------------\nimport static (all other imports)\n<blank line>\nimport java.*\nimport javax.*\nimport com.*\n<blank line> \nimport (all other imports)\n"
  },
  {
    "path": "LICENSE-junit.txt",
    "content": "JUnit\n\nEclipse Public License - v 1.0\n\nTHE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC\nLICENSE (\"AGREEMENT\"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM\nCONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.\n\n1. DEFINITIONS\n\n\"Contribution\" means:\n\n      a) in the case of the initial Contributor, the initial code and\n         documentation distributed under this Agreement, and\n      b) in the case of each subsequent Contributor:\n\n      i) changes to the Program, and\n\n      ii) additions to the Program;\n\n      where such changes and/or additions to the Program originate from and are\ndistributed by that particular Contributor. A Contribution 'originates' from a\nContributor if it was added to the Program by such Contributor itself or anyone\nacting on such Contributor's behalf. Contributions do not include additions to\nthe Program which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii) are\nnot derivative works of the Program. \n\n\"Contributor\" means any person or entity that distributes the Program.\n\n\"Licensed Patents \" mean patent claims licensable by a Contributor which are\nnecessarily infringed by the use or sale of its Contribution alone or when\ncombined with the Program.\n\n\"Program\" means the Contributions distributed in accordance with this Agreement.\n\n\"Recipient\" means anyone who receives the Program under this Agreement,\nincluding all Contributors.\n\n2. GRANT OF RIGHTS\n\n      a) Subject to the terms of this Agreement, each Contributor hereby grants\nRecipient a non-exclusive, worldwide, royalty-free copyright license to\nreproduce, prepare derivative works of, publicly display, publicly perform,\ndistribute and sublicense the Contribution of such Contributor, if any, and\nsuch derivative works, in source code and object code form.\n\n      b) Subject to the terms of this Agreement, each Contributor hereby grants\nRecipient a non-exclusive, worldwide, royalty-free patent license under\nLicensed Patents to make, use, sell, offer to sell, import and otherwise\ntransfer the Contribution of such Contributor, if any, in source code and\nobject code form. This patent license shall apply to the combination of the\nContribution and the Program if, at the time the Contribution is added by the\nContributor, such addition of the Contribution causes such combination to be\ncovered by the Licensed Patents. The patent license shall not apply to any\nother combinations which include the Contribution. No hardware per se is\nlicensed hereunder. \n\n      c) Recipient understands that although each Contributor grants the\nlicenses to its Contributions set forth herein, no assurances are provided by\nany Contributor that the Program does not infringe the patent or other\nintellectual property rights of any other entity. Each Contributor disclaims\nany liability to Recipient for claims brought by any other entity based on\ninfringement of intellectual property rights or otherwise. As a condition to\nexercising the rights and licenses granted hereunder, each Recipient hereby\nassumes sole responsibility to secure any other intellectual property rights\nneeded, if any. For example, if a third party patent license is required to\nallow Recipient to distribute the Program, it is Recipient's responsibility to\nacquire that license before distributing the Program.\n\n      d) Each Contributor represents that to its knowledge it has sufficient\ncopyright rights in its Contribution, if any, to grant the copyright license\nset forth in this Agreement. \n\n3. REQUIREMENTS\n\nA Contributor may choose to distribute the Program in object code form under\nits own license agreement, provided that:\n\n      a) it complies with the terms and conditions of this Agreement; and\n\n      b) its license agreement:\n\n      i) effectively disclaims on behalf of all Contributors all warranties and\nconditions, express and implied, including warranties or conditions of title\nand non-infringement, and implied warranties or conditions of merchantability\nand fitness for a particular purpose; \n\n      ii) effectively excludes on behalf of all Contributors all liability for\ndamages, including direct, indirect, special, incidental and consequential\ndamages, such as lost profits; \n\n      iii) states that any provisions which differ from this Agreement are\noffered by that Contributor alone and not by any other party; and\n\n      iv) states that source code for the Program is available from such\nContributor, and informs licensees how to obtain it in a reasonable manner on\nor through a medium customarily used for software exchange. \n\nWhen the Program is made available in source code form:\n\n      a) it must be made available under this Agreement; and \n\n      b) a copy of this Agreement must be included with each copy of the\nProgram. \n\nContributors may not remove or alter any copyright notices contained within the\nProgram.\n\nEach Contributor must identify itself as the originator of its Contribution, if\nany, in a manner that reasonably allows subsequent Recipients to identify the\noriginator of the Contribution.\n\n4. COMMERCIAL DISTRIBUTION\n\nCommercial distributors of software may accept certain responsibilities with\nrespect to end users, business partners and the like. While this license is\nintended to facilitate the commercial use of the Program, the Contributor who\nincludes the Program in a commercial product offering should do so in a manner\nwhich does not create potential liability for other Contributors. Therefore, if\na Contributor includes the Program in a commercial product offering, such\nContributor (\"Commercial Contributor\") hereby agrees to defend and indemnify\nevery other Contributor (\"Indemnified Contributor\") against any losses, damages\nand costs (collectively \"Losses\") arising from claims, lawsuits and other legal\nactions brought by a third party against the Indemnified Contributor to the\nextent caused by the acts or omissions of such Commercial Contributor in\nconnection with its distribution of the Program in a commercial product\noffering. The obligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In order\nto qualify, an Indemnified Contributor must: a) promptly notify the Commercial\nContributor in writing of such claim, and b) allow the Commercial Contributor\nto control, and cooperate with the Commercial Contributor in, the defense and\nany related settlement negotiations. The Indemnified Contributor may\nparticipate in any such claim at its own expense.\n\nFor example, a Contributor might include the Program in a commercial product\noffering, Product X. That Contributor is then a Commercial Contributor. If that\nCommercial Contributor then makes performance claims, or offers warranties\nrelated to Product X, those performance claims and warranties are such\nCommercial Contributor's responsibility alone. Under this section, the\nCommercial Contributor would have to defend claims against the other\nContributors related to those performance claims and warranties, and if a court\nrequires any other Contributor to pay any damages as a result, the Commercial\nContributor must pay those damages.\n\n5. NO WARRANTY\n\nEXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR\nIMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,\nNON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each\nRecipient is solely responsible for determining the appropriateness of using\nand distributing the Program and assumes all risks associated with its exercise\nof rights under this Agreement, including but not limited to the risks and\ncosts of program errors, compliance with applicable laws, damage to or loss of\ndata, programs or equipment, and unavailability or interruption of operations.\n\n6. DISCLAIMER OF LIABILITY\n\nEXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY\nCONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST\nPROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\nSTRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY\nWAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS\nGRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n\n7. GENERAL\n\nIf any provision of this Agreement is invalid or unenforceable under applicable\nlaw, it shall not affect the validity or enforceability of the remainder of the\nterms of this Agreement, and without further action by the parties hereto, such\nprovision shall be reformed to the minimum extent necessary to make such\nprovision valid and enforceable.\n\nIf Recipient institutes patent litigation against any\nentity (including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other software or\nhardware) infringes such Recipient's patent(s), then such Recipient's rights\ngranted under Section 2(b) shall terminate as of the date such litigation is\nfiled.\n\nAll Recipient's rights under this Agreement shall terminate if it fails to\ncomply with any of the material terms or conditions of this Agreement and does\nnot cure such failure in a reasonable period of time after becoming aware of\nsuch noncompliance. If all Recipient's rights under this Agreement terminate,\nRecipient agrees to cease use and distribution of the Program as soon as\nreasonably practicable. However, Recipient's obligations under this Agreement\nand any licenses granted by Recipient relating to the Program shall continue\nand survive.\n\nEveryone is permitted to copy and distribute copies of this Agreement, but in\norder to avoid inconsistency the Agreement is copyrighted and may only be\nmodified in the following manner. The Agreement Steward reserves the right to\npublish new versions (including revisions) of this Agreement from time to time.\nNo one other than the Agreement Steward has the right to modify this Agreement.\nThe Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to\nserve as the Agreement Steward to a suitable separate entity. Each new version\nof the Agreement will be given a distinguishing version number. The Program\n(including Contributions) may always be distributed subject to the version of\nthe Agreement under which it was received. In addition, after a new version of\nthe Agreement is published, Contributor may elect to distribute the Program\n(including its Contributions) under the new version. Except as expressly stated\nin Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to\nthe intellectual property of any Contributor under this Agreement, whether\nexpressly, by implication, estoppel or otherwise. All rights in the Program not\nexpressly granted under this Agreement are reserved.\n\nThis Agreement is governed by the laws of the State of New York and the\nintellectual property laws of the United States of America. No party to this\nAgreement will bring a legal action under this Agreement more than one year\nafter the cause of action arose. Each party waives its rights to a jury trial\nin any resulting litigation. \n\n"
  },
  {
    "path": "NOTICE.txt",
    "content": "   ===================================================================================\n   ==  Notices and attributions required by libraries that the project depends on   ==\n   ===================================================================================\n\n The JUnit depends on Java Hamcrest (http://hamcrest.org/JavaHamcrest/).\n"
  },
  {
    "path": "README.md",
    "content": "# JUnit 4\nJUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.\n\n> [!IMPORTANT]  \n> **JUnit 4 is in maintenance mode.**\n>\n> At this point, only critical bugs and security issues will be fixed.<br>\n> All other issues and PRs will therefore be declined.<br>\n> For ongoing development, please check out the [junit-framework](https://github.com/junit-team/junit-framework/) repository.\n\nFor more information, please visit:\n* [Wiki](https://github.com/junit-team/junit4/wiki)\n* [Download and Install guide](https://github.com/junit-team/junit4/wiki/Download-and-Install)\n* [Getting Started](https://github.com/junit-team/junit4/wiki/Getting-started)\n\n[![CI Status](https://github.com/junit-team/junit4/workflows/CI/badge.svg)](https://github.com/junit-team/junit4/actions)\n"
  },
  {
    "path": "SECURITY.md",
    "content": "# Security Policy\n\n## Supported Versions\n\n| Version | Supported          |\n| ------- | ------------------ |\n| 4.13.x  | :white_check_mark: |\n| < 4.13  | :x:                |\n\n## Reporting a Vulnerability\n\nTo report a security vulnerability, please send an email to security@junit.org.\n"
  },
  {
    "path": "acknowledgements.txt",
    "content": "2006 March 9\n\tMatthias Schmidt: improved org.junit package javadoc\n\t\n2006 August 3\n\tgiovanni: better test for TestCase without a name.\n\tMatthias Pfau: better error message when test case constructor fails\n\t\n2006 November 21\n\tdakcalouro: Found defect with comparing ints and longs (1555161)\n\tBen Maurer: Found defect with timeouts taking twice as long as specified (1536198)\n\t\n2007 February 08\n\tKazimierz Pogoda: Found defect with null array elements (1438163)\n\t\n2007 July 09\n\twangqq: Found defect with @After not running after a timeout (1745048)\n\n2007 July 18\n    Andrew Dick: Found defect with assertEquals comparing non-Integer Numbers (1715326)\n\tMichael Schechter: Found defect with Filters and suite() methods (1739095)\n\n2008 February 5\n\tWalter Gildersleeve: Found assertEquals(null, \"null\") defect (1857283)\n\t\n2008 July 1\n\tJohannes Link: Submitted test for running subclasses of Suite\n\t\n2008 July 23\n\tDaniel Brolund: Submitted patch for build.xml, fixing 1.5 compatibility (2021396)\n\t\n2008 Aug 1\n\tNat Pryce: Found defect in treatment of validation errors from custom \n\t           subclasses of the legacy JUnit4ClassRunner.\n\t           \n2008 Aug 18\n\tNir Soffer: Suggested adding to the cookbook information about running\n\t\t\t\trunning JUnit from the command line.\n\t\t\t\t           \n2008 Aug 19\n\tJack Woehr: Discovered build.xml was missing from junit-4.x.zip\n\t\n2009 Jan 5\n\tAmanda Robinson: Fixed overly permissive @DataPoint processing.\n\t\n2009 Feb 9\n\tMark Shapiro: Discovered bug in test counting after an ignored method (2106324)\n\t\n2009 Apr 20\n\tChris Felaco: Discovered regression in handling suite() methods with JUnit 3 runner (1812200)\n\tToby Byron: Suggested updating linking in javadoc (2090230)\n\tRaphael Parree: Improved docs on Parameterized (2186792)\n\tRobin de Silva Jayasinghe: Fixed Javadoc code sample for AfterClass (2126279)\n\t\n2009 May 04\n\tJames Abbley: Submitted a patch that fixed the 2-second limit on Parallel execution.\n\n2009 Nov 16\n    Kristian Rosenvold: Submitted a patch (github#16) that improves thread-safety of\n                        result counting\n2010 Feb 08\n    Paul Holser: Submitted additional test for TestName rule.\n    \n2010 May 03\n    jonas22@github: Found bug (github#98) with assumptions and expected exceptions.\n\n2011 Jan 03\n    jens.schauder@freenet.de: Found bug (github#74) with Categories and \n                              Parameterized.\n\n2011 Jan 18\n    Markus Keller: Reported bug (github#163): \n           Bad comparison failure message when using assertEquals(String, String)\n    \n    Kevin Cooney (kcooney@github):\n           Patches for runLeaf, public multiple failure exception,\n           assertion messages and null.\n\n2011 Mar 04\n    Jerome Lacoste (lacostej@github) for initial patch for GH-191.\n\n2011 Apr 15\n     reinholdfuereder@github For initial test for GH-39\n\n2011 Apr 15\n     ububenheimer@github for bug report https://github.com/junit-team/junit4/issues/208\n\n2011 Apr 29\n     reinholdfuereder@github: bug report, test, and fix for GH-38:\n                              ParentRunner filtering\n2011 Apr 29\n     Markus Keller (mkeller@github): Report for GH-187:\n            Unintentional dependency on Java 6\n\n2011 May 31\n     Kevin Cooney (kcooney@github): Patches for filtering test suites:\n         copy List returned by getChildren() before mutating it;\n         optimize ParentRunner.filter for nested suites;\n         optimize Filter.intersect for common cases\n\n2011 Jun 06\n     Vampire@github: Report for GH-235: 4.7 release notes incorrect.\n\n2011 Jun 24\n     Samuel Le Berrigaud (sleberrigaud@github): Report for GH-248:\n            protected BlockJUnit4ClassRunner#rules method removed from 4.8.2\n\n2011 Jun 24\n    Daniel Rothmaler (drothmaler@github):\n        #299: random temp file/folder creation \n        #300: ErrorCollector.checkThat overload\n        \n2011 Jun 25\n     Juan Cortez (jcortez@github): Fixed issue #219 where floats were being \n\t printed and represented as doubles in error messages.\n\n2011 Jul 06\n     Stefan Birkner: Fixed wrong documentation of ClassRule (github#254).\n\n2011 Jul 08\n     Paul Holser (pholser@alumni.rice.edu): Beginnings of fix for GH-64:\n            Theories doesn't honor parameterized types\n\n2011 Jul 09\n     Nigel Charman: Reported Rules bugs github#257 and gihub#258.\n\n2011 Jul 09\n     Stefan Birkner: Fixed rules bugs (github#257, gihub#258, github#260).\n\n2011 Jul 09\n     Stefan Birkner: Fixed rules bugs (github#257, gihub#258, github#260).\n\n2011 Jul 16\n\tRob Dawson: Submitted a patch that makes Results serlializable.\n\n2011 Jul 20\n     Asaf Ary, Stefan Birkner: Fixed FailOnTimeout class (github#265).\n\n2011 Jul 22\n     Andreas Köhler, Stefan Birkner: Fixed wrong documentation of Parameterized (github#89).\n\n2011 Jul 28\n     electrickery, Stefan Birkner: Fixed typo in JavaDoc (github#134).\n\n2011 Aug 07\n\tEsko Luontola: Fixed TemporaryFolder creating files in the current working directory (github#278).\n\n2011 Aug 09\n     Stefan Birkner: Fixed JavaDoc links.\n\n2011 Aug 10\n     rodolfoliviero@github and JoseRibeiro@github: feature to create recursive temporary folders.\n\n2011 Aug 12\n\tEsko Luontola: Fixed syntax error in Parameterized's usage example (github#285).\n\n2011 Sep 09\n     Robert Munteanu, Stefan Birkner:\n            TestWatcher and TestWatchman don't call failed when assumption is violated (github#296).\n     digulla@github, Stefan Birkner: Removed useless code (github#289).\n\n== NOTE: as of September 2011, we have stopped recording contributions here.\n   For a full list of everyone who has contributed great bug reports and code, please see\n   http://github.com/junit-team/junit4\n"
  },
  {
    "path": "doc/ReleaseNotes4.10.html",
    "content": "<h2>Summary of Changes in version 4.10</h2>\n\n<p>A full summary of commits between 4.9 and 4.10 is on <a href=\"https://github.com/junit-team/junit4/compare/r4.9...r4.10\">github</a></p>\n\n<h3>junit-dep has correct contents</h3>\n\n<p>junit-dep-4.9.jar incorrectly contained hamcrest classes, which could lead to version conflicts in projects that depend on hamcrest directly.  This is fixed in 4.10 [@dsaff, closing gh-309]</p>\n\n<h3>RuleChain</h3>\n\n<p>The RuleChain rule allows ordering of TestRules:</p>\n\n<pre><code>public static class UseRuleChain {\n    @Rule\n    public TestRule chain= RuleChain\n                           .outerRule(new LoggingRule(\"outer rule\")\n                           .around(new LoggingRule(\"middle rule\")\n                           .around(new LoggingRule(\"inner rule\");\n\n    @Test\n    public void example() {\n        assertTrue(true);\n    }\n}\n</code></pre>\n\n<p>writes the log</p>\n\n<pre><code>starting outer rule\nstarting middle rule\nstarting inner rule\nfinished inner rule\nfinished middle rule\nfinished outer rule\n</code></pre>\n\n<h3>TemporaryFolder</h3>\n\n<ul>\n<li><code>TemporaryFolder#newFolder(String... folderNames)</code> creates recursively deep temporary folders \n[@rodolfoliviero, closing gh-283]</li>\n<li><code>TemporaryFolder#newFile()</code> creates a randomly named new file, and <code>#newFolder()</code> creates a randomly named new folder\n[@Daniel Rothmaler, closing gh-299]</li>\n</ul>\n\n<h3>Theories</h3>\n\n<p>The <code>Theories</code> runner does not anticipate theory parameters that have generic\ntypes, as reported by github#64.  Fixing this won't happen until <code>Theories</code> is\nmoved to junit-contrib. In anticipation of this, 4.9.1 adds some of the\nnecessary machinery to the runner classes, and deprecates a method that only\nthe <code>Theories</code> runner uses, <code>FrameworkMethod</code>#producesType(). \nThe Common Public License that JUnit is released under is now included\nin the source repository.</p>\n\n<p>Thanks to <code>@pholser</code> for identifying a potential resolution for github#64\nand initiating work on it.</p>\n\n<h3>Bug fixes</h3>\n\n<ul>\n<li>Built-in Rules implementations\n<ul>\n<li>TemporaryFolder should not create files in the current working directory if applying the rule fails \n[@orfjackal, fixing gh-278]</li>\n<li>TestWatcher and TestWatchman should not call failed for AssumptionViolatedExceptions\n[@stefanbirkner, fixing gh-296]</li>\n</ul></li>\n<li>Javadoc bugs\n<ul>\n<li>Assert documentation [@stefanbirkner, fixing gh-134]</li>\n<li>ClassRule [@stefanbirkner, fixing gh-254]</li>\n<li>Parameterized  [@stefanbirkner, fixing gh-89]</li>\n<li>Parameterized, again [@orfjackal, fixing gh-285]</li>\n</ul></li>\n<li>Miscellaneous\n<ul>\n<li>Useless code in RunAfters [@stefanbirkner, fixing gh-289]</li>\n<li>Parameterized test classes should be able to have <code>@Category</code> annotations\n[@dsaff, fixing gh-291]</li>\n<li>Error count should be initialized in junit.tests.framework.TestListenerTest [@stefanbirkner, fixing gh-225]</li>\n<li>AssertionFailedError constructor shouldn't call super with null message [@stefanbirkner, fixing gh-318]</li>\n<li>Clearer error message for non-static inner test classes  [@stefanbirkner, fixing gh-42]</li>\n</ul></li>\n</ul>\n\n<h3>Minor changes</h3>\n\n<ul>\n<li>Description, Result and Failure are Serializable [@ephox-rob, closing gh-101]</li>\n<li>FailOnTimeout is reusable, allowing for retrying Rules [@stefanbirkner, closing gh-265]</li>\n<li>New <code>ErrorCollector.checkThat</code> overload, that allows you to specify a reason [@drothmaler, closing gh-300]</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.10.md",
    "content": "## Summary of Changes in version 4.10 ##\n\nThanks to a full cast of contributors of bug fixes and new features.\n\nA full summary of commits between 4.9 and 4.10 is on [github](https://github.com/junit-team/junit4/compare/r4.9...r4.10)\n\n### junit-dep has correct contents ###\n\njunit-dep-4.9.jar incorrectly contained hamcrest classes, which could lead to version conflicts in projects that depend on hamcrest directly.  This is fixed in 4.10 [@dsaff, closing gh-309]\n\n### RuleChain ###\n\nThe RuleChain rule allows ordering of TestRules:\n\n```java\npublic static class UseRuleChain {\n\t@Rule\n\tpublic TestRule chain= RuleChain\n\t                       .outerRule(new LoggingRule(\"outer rule\")\n\t                       .around(new LoggingRule(\"middle rule\")\n\t                       .around(new LoggingRule(\"inner rule\");\n\n\t@Test\n\tpublic void example() {\n\t\tassertTrue(true);\n\t}\n}\n```\n\nwrites the log\n\n    starting outer rule\n    starting middle rule\n    starting inner rule\n    finished inner rule\n    finished middle rule\n    finished outer rule\n\n### TemporaryFolder ###\n\n- `TemporaryFolder#newFolder(String... folderNames)` creates recursively deep temporary folders \n  [@rodolfoliviero, closing gh-283]\n- `TemporaryFolder#newFile()` creates a randomly named new file, and `#newFolder()` creates a randomly named new folder\n  [@Daniel Rothmaler, closing gh-299]\n\n### Theories ###\n\nThe `Theories` runner does not anticipate theory parameters that have generic\ntypes, as reported by github#64.  Fixing this won't happen until `Theories` is\nmoved to junit-contrib. In anticipation of this, 4.9.1 adds some of the\nnecessary machinery to the runner classes, and deprecates a method that only\nthe `Theories` runner uses, `FrameworkMethod`#producesType(). \nThe Common Public License that JUnit is released under is now included\nin the source repository.\n\nThanks to `@pholser` for identifying a potential resolution for github#64\nand initiating work on it.\n\n### Bug fixes ###\n\n- Built-in Rules implementations\n  - TemporaryFolder should not create files in the current working directory if applying the rule fails \n    [@orfjackal, fixing gh-278]\n  - TestWatcher and TestWatchman should not call failed for AssumptionViolatedExceptions\n    [@stefanbirkner, fixing gh-296]\n- Javadoc bugs\n  - Assert documentation [@stefanbirkner, fixing gh-134]\n  - ClassRule [@stefanbirkner, fixing gh-254]\n  - Parameterized  [@stefanbirkner, fixing gh-89]\n  - Parameterized, again [@orfjackal, fixing gh-285]\n- Miscellaneous\n  - Useless code in RunAfters [@stefanbirkner, fixing gh-289]\n  - Parameterized test classes should be able to have `@Category` annotations\n    [@dsaff, fixing gh-291]\n  - Error count should be initialized in junit.tests.framework.TestListenerTest [@stefanbirkner, fixing gh-225]\n  - AssertionFailedError constructor shouldn't call super with null message [@stefanbirkner, fixing gh-318]\n  - Clearer error message for non-static inner test classes  [@stefanbirkner, fixing gh-42]\n\n### Minor changes ###\n\n- Description, Result and Failure are Serializable [@ephox-rob, closing gh-101]\n- FailOnTimeout is reusable, allowing for retrying Rules [@stefanbirkner, closing gh-265]\n- New `ErrorCollector.checkThat` overload, that allows you to specify a reason [@drothmaler, closing gh-300]\n\n\n\n"
  },
  {
    "path": "doc/ReleaseNotes4.10.txt",
    "content": "Please see ReleaseNotes4.10.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.11.html",
    "content": "<h2>Summary of changes in version 4.11</h2>\n\n<h3>Matchers: Upgrade to Hamcrest 1.3</h3>\n\n<p>JUnit now uses the latest version of Hamcrest. Thus, you can use all the available matchers and benefit from an improved <code>assertThat</code> which will now print the mismatch description from the matcher when an assertion fails.</p>\n\n<h4>Example</h4>\n\n<pre><code>assertThat(Long.valueOf(1), instanceOf(Integer.class));\n</code></pre>\n\n<p>Old error message:</p>\n\n<pre><code>Expected: an instance of java.lang.Integer\n     got: &lt;1L&gt;\n</code></pre>\n\n<p>New error message:</p>\n\n<pre><code>Expected: an instance of java.lang.Integer\n     but: &lt;1L&gt; is a java.lang.Long\n</code></pre>\n\n<p>Hamcrest's new <code>FeatureMatcher</code> makes writing custom matchers that make use of custom mismatch descriptions quite easy:</p>\n\n<pre><code>@Test\npublic void featureMatcher() throws Exception {\n    assertThat(\"Hello World!\", length(is(0)));\n}\n\nprivate Matcher&lt;String&gt; length(Matcher&lt;? super Integer&gt; matcher) {\n    return new FeatureMatcher&lt;String, Integer&gt;(matcher, \"a String of length that\", \"length\") {\n        @Override\n        protected Integer featureValueOf(String actual) {\n            return actual.length();\n        }\n    };\n}\n</code></pre>\n\n<p>Running this test will return the following failure message:</p>\n\n<pre><code>Expected: a String of length that is &lt;0&gt;\n     but: length was &lt;12&gt;\n</code></pre>\n\n<p>Most of the matchers in <code>JUnitMatchers</code> have been deprecated. Please use <code>org.hamcrest.CoreMatchers</code> directly.</p>\n\n<h3>Parameterized Tests</h3>\n\n<p>In order to easily identify the individual test cases in a Parameterized test, you may provide a name using the <code>@Parameters</code> annotation. This name is allowed to contain placeholders that are replaced at runtime:</p>\n\n<ul>\n<li><code>{index}</code>: the current parameter index</li>\n<li><code>{0}</code>, <code>{1}</code>, …: the first, second, and so on, parameter value</li>\n</ul>\n\n<h4>Example</h4>\n\n<pre><code>@RunWith(Parameterized.class)\npublic class FibonacciTest {\n\n    @Parameters(name = \"{index}: fib({0})={1}\")\n    public static Iterable&lt;Object[]&gt; data() {\n        return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 1 }, { 2, 1 },\n                { 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 } });\n    }\n\n    private int input;\n    private int expected;\n\n    public FibonacciTest(int input, int expected) {\n        this.input = input;\n        this.expected = expected;\n    }\n\n    @Test\n    public void test() {\n        assertEquals(expected, Fibonacci.compute(input));\n    }\n}\n</code></pre>\n\n<p>In the example given above, the <code>Parameterized</code> runner creates names like <code>[1: fib(3)=2]</code>. If you don't specify a name, the current parameter index will be used by default.</p>\n\n<h3>Test execution order</h3>\n\n<p>By design, JUnit does not specify the execution order of test method invocations. Until now, the methods were simply invoked in the order returned by the reflection API. However, using the JVM order is unwise since the Java platform does not specify any particular order, and in fact JDK 7 returns a more or less random order. Of course, well-written test code would not assume any order, but some does, and a predictable failure is better than a random failure on certain platforms.</p>\n\n<p>From now on, JUnit will by default use a deterministic, but not predictable, order (<code>MethodSorters.DEFAULT</code>). To change the test execution order simply annotate your test class using <code>@FixMethodOrder</code> and specify one of the available <code>MethodSorters</code>:</p>\n\n<ul>\n<li><p><code>@FixMethodOrder(MethodSorters.JVM)</code>: Leaves the test methods in the order returned by the JVM. This order may vary from run to run.</p></li>\n<li><p><code>@FixMethodOrder(MethodSorters.NAME_ASCENDING)</code>: Sorts the test methods by method name, in lexicographic order.</p></li>\n</ul>\n\n<h3>Maven artifacts</h3>\n\n<p>Up until now there were two Maven artifacts for JUnit: <code>junit:junit-dep</code> and <code>junit:junit</code>. From a Maven point-of-view only the former made sense because it did not contain the Hamcrest classes but declared a dependency to the Hamcrest Maven artifact. The latter included the Hamcrest classes which was very un-Maven-like.</p>\n\n<p>From this release on, you should use <code>junit:junit</code> which will be what <code>junit:junit-dep</code> used to. If you still reference <code>junit:junit-dep</code>, Maven will automatically relocate you to the new <code>junit:junit</code> and issue a warning for you to fix.</p>\n\n<h3>Rules</h3>\n\n<p>A number of improvements have been made to Rules:</p>\n\n<ul>\n<li><code>MethodRule</code> is no longer deprecated.</li>\n<li>Both <code>@Rule</code> and <code>@ClassRule</code> can now be used on methods that return a <code>TestRule</code>.</li>\n<li><code>ExpectedException</code> now always prints the stacktrace of the actual exception in case of failure.</li>\n<li>A parent folder can be specified for <code>TemporaryFolder</code>. In addition, the <code>newFile</code>/<code>newFolder</code> methods will now fail when the file or folder could not be created.</li>\n<li><code>TestWatcher</code> has a new template method called <code>skipped</code> that is invoked when a test is skipped due to a failed assumption.</li>\n</ul>\n\n<h3>Improvements to Assert and Assume</h3>\n\n<ul>\n<li><code>assertNotEquals</code> has been added to <code>Assert</code>.</li>\n<li><code>assertEquals</code> has been overloaded in order to check whether two floats are equal given a certain float delta.</li>\n<li>Most methods in <code>Assume</code> now allow to pass a custom message.</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.11.md",
    "content": "## Summary of changes in version 4.11\n\n### Matchers: Upgrade to Hamcrest 1.3\n\nJUnit now uses the latest version of Hamcrest. Thus, you can use all the available matchers and benefit from an improved `assertThat` which will now print the mismatch description from the matcher when an assertion fails.\n\n#### Example\n\n```java\nassertThat(Long.valueOf(1), instanceOf(Integer.class));\n```\n\nOld error message:\n\n    Expected: an instance of java.lang.Integer\n         got: <1L>\n\nNew error message:\n\n    Expected: an instance of java.lang.Integer\n         but: <1L> is a java.lang.Long\n\nHamcrest's new `FeatureMatcher` makes writing custom matchers that make use of custom mismatch descriptions quite easy:\n\n```java\n@Test\npublic void featureMatcher() throws Exception {\n    assertThat(\"Hello World!\", length(is(0)));\n}\n\nprivate Matcher<String> length(Matcher<? super Integer> matcher) {\n    return new FeatureMatcher<String, Integer>(matcher, \"a String of length that\", \"length\") {\n        @Override\n        protected Integer featureValueOf(String actual) {\n            return actual.length();\n        }\n    };\n}\n```\n\nRunning this test will return the following failure message:\n\n    Expected: a String of length that is <0>\n         but: length was <12>\n\n\nMost of the matchers in `JUnitMatchers` have been deprecated. Please use `org.hamcrest.CoreMatchers` directly.\n\n### Parameterized Tests\n\nIn order to easily identify the individual test cases in a Parameterized test, you may provide a name using the `@Parameters` annotation. This name is allowed to contain placeholders that are replaced at runtime:\n\n* `{index}`: the current parameter index\n* `{0}`, `{1}`, …: the first, second, and so on, parameter value\n\n#### Example\n\n```java\n@RunWith(Parameterized.class)\npublic class FibonacciTest {\n    \n    @Parameters(name = \"{index}: fib({0})={1}\")\n    public static Iterable<Object[]> data() {\n        return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 1 }, { 2, 1 },\n    \t\t{ 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 } });\n    }\n    \n    private int input;\n    private int expected;\n    \n    public FibonacciTest(int input, int expected) {\n        this.input = input;\n    \tthis.expected = expected;\n    }\n    \n    @Test\n    public void test() {\n        assertEquals(expected, Fibonacci.compute(input));\n    }\n}\n```\n\nIn the example given above, the `Parameterized` runner creates names like `[1: fib(3)=2]`. If you don't specify a name, the current parameter index will be used by default.\n\n### Test execution order\n\nBy design, JUnit does not specify the execution order of test method invocations. Until now, the methods were simply invoked in the order returned by the reflection API. However, using the JVM order is unwise since the Java platform does not specify any particular order, and in fact JDK 7 returns a more or less random order. Of course, well-written test code would not assume any order, but some does, and a predictable failure is better than a random failure on certain platforms.\n\nFrom now on, JUnit will by default use a deterministic, but not predictable, order (`MethodSorters.DEFAULT`). To change the test execution order simply annotate your test class using `@FixMethodOrder` and specify one of the available `MethodSorters`:\n\n* `@FixMethodOrder(MethodSorters.JVM)`: Leaves the test methods in the order returned by the JVM. This order may vary from run to run.\n\n* `@FixMethodOrder(MethodSorters.NAME_ASCENDING)`: Sorts the test methods by method name, in lexicographic order.\n\n### Maven artifacts\n\nUp until now there were two Maven artifacts for JUnit: `junit:junit-dep` and `junit:junit`. From a Maven point-of-view only the former made sense because it did not contain the Hamcrest classes but declared a dependency to the Hamcrest Maven artifact. The latter included the Hamcrest classes which was very un-Maven-like.\n\nFrom this release on, you should use `junit:junit` which will be what `junit:junit-dep` used to. If you still reference `junit:junit-dep`, Maven will automatically relocate you to the new `junit:junit` and issue a warning for you to fix.\n\n### Rules\n\nA number of improvements have been made to Rules:\n\n* `MethodRule` is no longer deprecated.\n* Both `@Rule` and `@ClassRule` can now be used on methods that return a `TestRule`.\n* `ExpectedException` now always prints the stacktrace of the actual exception in case of failure.\n* A parent folder can be specified for `TemporaryFolder`. In addition, the `newFile`/`newFolder` methods will now fail when the file or folder could not be created.\n* `TestWatcher` has a new template method called `skipped` that is invoked when a test is skipped due to a failed assumption.\n\n### Improvements to Assert and Assume\n\n* `assertNotEquals` has been added to `Assert`.\n* `assertEquals` has been overloaded in order to check whether two floats are equal given a certain float delta.\n* Most methods in `Assume` now allow to pass a custom message.\n\n"
  },
  {
    "path": "doc/ReleaseNotes4.11.txt",
    "content": "Please see ReleaseNotes4.11.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.12.md",
    "content": "## Summary of changes in version 4.12\n\n# Assertions\n\n### [Pull request #611:](https://github.com/junit-team/junit4/pull/611) Assert.assertNotEquals() for `float` parameters\n\nVersion 4.11 added `Assert.assertEquals()` for `float` parameters with a delta, and `Assert.assertNotEquals()`. This is the combination of those two features.\n\n\n### [Pull request #632:](https://github.com/junit-team/junit4/pull/632) Assert.assertArrayEquals() for `boolean[]` parameters.\n\n`Assert.assertArrayEquals()` previously existed for all primitive array types, except `boolean[]`. This has now been added for `boolean[]`.\n\n\n### [Pull request #918:](https://github.com/junit-team/junit4/pull/918) Avoid potentially expensive reflection-based loop in Assert.assertArrayEquals()\n\nIn the usual case, where the array elements are in fact exactly equal, the potentially expensive reflection-based loop to compare them is avoided by using `Arrays.deepEquals()` first. The exact comparison is only executed when `deepEquals()` returns `false`.\n\n\n# Command-line options\n### [Pull request #647:](https://github.com/junit-team/junit4/pull/647) Support command-line `--filter` param.\n\nWhen running JUnit from the command line, a command-line parameter can be supplied using `--filter`, which supplies a filter that will restrict which tests and subtests from the rest of the command will be run.  For example, this will run only the tests in ExampleTestSuite that are in categories Cat1 or Cat2:\n\n```\njava org.junit.runner.JUnitCore \\\n  --filter=org.junit.experimental.categories.IncludeCategories=pkg.of.Cat1,pkg.of.Cat2 \\\n  com.example.ExampleTestSuite\n```\n\nIn general, the argument to `--filter` should be `ClassName=param`, where `ClassName` names an implementation of `FilterFactory`, whose `createFilter` method will be called with an instance of `FilterFactoryParams` that contains `\"param\"`, in order to return the filter to be applied.\n\n# Test Runners\n\n\n### [Pull request #763:](https://github.com/junit-team/junit4/pull/763) Allow custom test runners to create their own TestClasses and customize the scanning of annotations.\n\nThis introduces some extension points to `ParentRunner` to allow subclasses to control creation\nof the `TestClass` instance and to scan for annotations.\n\n### [Pull request #817:](https://github.com/junit-team/junit4/pull/817) Support for context hierarchies\n\nThe `AnnotatedBuilder` is a strategy for constructing runners for test classes that have been annotated with the `@RunWith` annotation. All tests within such a class will be executed using the runner that was specified within the annotation.\n\nPrior to JUnit 4.12, this covered only the tests within the annotated test class. With 4.12, the `AnnotationBuilder` will also support inner member classes. If a custom test runner supports inner member classes (which JUnit does not support out-of-the-box), the member classes will inherit the runner from the enclosing class, e.g.:\n\n```java\n@RunWith(MyRunner.class)\npublic class MyTest {\n    // some tests might go here\n\n    public class MyMemberClass {\n        @Test\n        public void thisTestRunsWith_MyRunner() {\n            // some test logic\n        }\n\n        // some more tests might go here\n    }\n\n    @RunWith(AnotherRunner.class)\n    public class AnotherMemberClass {\n        // some tests might go here\n\n        public class DeepInnerClass {\n            @Test\n            public void thisTestRunsWith_AnotherRunner() {\n                // some test logic\n            }\n        }\n\n        public class DeepInheritedClass extends SuperTest {\n            @Test\n            public void thisTestRunsWith_SuperRunner() {\n                // some test logic\n            }\n        }\n    }\n}\n\n@RunWith(SuperRunner.class)\npublic class SuperTest {\n    // some tests might go here\n}\n```\n\nThe key points to note here are:\n\n* If there is no `@RunWith` annotation, no runner will be created.\n* The resolve step is inside-out, e.g. the closest `@RunWith` annotation wins.\n* `@RunWith` annotations are inherited and work as if the class was annotated itself.\n* The default JUnit runner does not support inner member classes, so this is only valid for custom runners that support inner member classes.\n* Custom runners with support for inner classes may or may not support `@RunWith` annotations for member classes. Please refer to the custom runner documentation.\n\nOne example of a runner that makes use of this extension is the Hierarchical Context Runner (see https://github.com/bechte/junit-hierarchicalcontextrunner/wiki).\n\n\n### [Pull request #716:](https://github.com/junit-team/junit4/pull/716) Fix annotation collection from superclasses of JUnit3 tests.\n\nPreviously `Description.getAnnotations()` would always return an empty list for _test*_ methods derived from superclasses. \n\n\n### [Pull request #625 (commit 72af03c49f):](https://github.com/junit-team/junit4/commit/72af03c49fdad5f10e36c7eb4e7045feb971d253) Make `RunNotifier` code concurrent.\n\nWhen running tests from multiple threads, JUnit will now call `RunListener` methods from multiple threads if the listener class is annotated with `@RunListener.ThreadSafe`. In addition, the code in `RunNotifier` has been modified to not use locks.\n\n\n### [Pull request #684:](https://github.com/junit-team/junit4/pull/684) Adding `AnnotationValidator` framework and validation checks for `@Category`.\n\nThis allows for validation to be added to annotations. Validators should extend `AnnotationValidator` and be attached to annotations with the `@ValidateWith` annotation. `CategoryValidator` extends `AnnotationValidator` and ensures that incompatible annotations (`@BeforeClass`, `@AfterClass`, `@Before`, `@After`) are not used in conjunction with `@Category`.\n\n\n# Exception Testing\n\n\n### [Pull request #583:](https://github.com/junit-team/junit4/pull/583) [Pull request #720:](https://github.com/junit-team/junit4/pull/720) Fix handling of `AssertionError` and `AssumptionViolatedException` in `ExpectedException` rule.\n\n`ExpectedException` didn't handle `AssertionError`s and `AssumptionViolatedException` well. This has been fixed. The new documentation explains the usage of `ExpectedException` for testing these exceptions. The two methods `handleAssertionErrors()` and `handleAssumptionViolatedExceptions()` are not needed anymore. If you have used them, just remove it and read `ExpectedException`'s documentation.\n\n\n### [Pull request #818:](https://github.com/junit-team/junit4/pull/818) [Pull request #993:](https://github.com/junit-team/junit4/pull/993) External version of AssumptionViolatedException\n\nIn JUnit 4.11 and earlier, if you wanted to write a custom runner that handled\n`AssumptionViolatedException` or you needed to create an instance of `AssumptionViolatedException`\ndirectly, you needed to import an internal class (`org.junit.internal.AssumptionViolatedException`).\nNow you can import `org.junit.AssumptionViolatedException` (which extends\n`org.junit.internal.AssumptionViolatedException`).\n\nThe classes in `Assume` have been modified to throw `org.junit.AssumptionViolatedException`.\n\nThe constructors in the external `AssumptionViolatedException` are also\nsimpler than the ones in the internal version. That being said,\nit's recommended that you create `AssumptionViolatedException` via the methods in `Assume`.\n\n\n### [Pull request #985:](https://github.com/junit-team/junit4/pull/985) Change AssumptionViolatedException to not set the cause to null; fixes issue #494\n\nPreviously, the `AssumptionViolatedException` constructors would explicitly set the cause to `null`\n(unless you use a constructor where you provide a `Throwable`, in which case it would set that as\nthe cause). This prevented code directly creating the exception from setting a cause.\n\nWith this change, the cause is only set if you pass in a `Throwable`.\n\nIt's recommended that you create `AssumptionViolatedException` via the methods in `Assume`.\n\n\n### [Pull request #542:](https://github.com/junit-team/junit4/pull/542) Customized failure message for `ExpectedException`\n\n`ExpectedException` now allows customization of the failure message when the test does not throw the expected exception. For example:\n\n```java\nthrown.reportMissingExceptionWithMessage(\"FAIL: Expected exception to be thrown\");\n```\n\nIf a custom failure message is not provided, a default message is used.\n\n\n### [Pull request #1013:](https://github.com/junit-team/junit4/pull/1013) Make ErrorCollector#checkSucceeds generic\n\nThe method `ErrorCollector.checkSucceeds()` is now generic. Previously, you could only pass\nin a `Callable<Object>` and it returned `Object`. You can now pass any `Callable` and the\nreturn type will match the type of the callable.\n\n\n# Timeout for Tests\n*See also [Timeout for tests](https://github.com/junit-team/junit4/wiki/Timeout-for-tests)*\n\n### [Pull request #823:](https://github.com/junit-team/junit4/pull/823) Throw `TestFailedOnTimeoutException` instead of plain `Exception` on timeout\n\nWhen a test times out, a `org.junit.runners.model.TestTimedOutException` is now thrown instead of a plain `java.lang.Exception`.\n\n\n### [Pull request #742:](https://github.com/junit-team/junit4/pull/742) [Pull request #986:](https://github.com/junit-team/junit4/pull/986) `Timeout` exceptions now include stack trace from stuck thread (experimental)\n\n`Timeout` exceptions try to determine if there is a child thread causing the problem, and if so its stack trace is included in the exception in addition to the one of the main thread. This feature must be enabled with the timeout rule by creating it through the new `Timeout.builder()` method:\n\n```java\npublic class HasGlobalTimeout {\n    @Rule public final TestRule timeout = Timeout.builder()\n            .withTimeout(10, TimeUnit.SECONDS)\n            .withLookingForStuckThread(true)\n            .build();\n\n    @Test\n    public void testInfiniteLoop() {\n        for (;;) {\n        }\n    }\n}\n```\n\n\n### [Pull request #544:](https://github.com/junit-team/junit4/pull/544) New constructor and factories in `Timeout`\n\n`Timeout` deprecated the old constructor `Timeout(int millis)`.\nA new constructor is available: `Timeout(long timeout, TimeUnit unit)`. It enables you to use different granularities of time units like `NANOSECONDS`, `MICROSECONDS`, `MILLISECONDS`, and `SECONDS`. Examples:\n\n```java\n@Rule public final TestRule globalTimeout = new Timeout(50, TimeUnit.MILLISECONDS);\n```\n\n```java\n@Rule public final TestRule globalTimeout = new Timeout(10, TimeUnit.SECONDS);\n```\n\nand factory methods in `Timeout`:\n\n```java\n@Rule public final TestRule globalTimeout = Timeout.millis(50);\n```\n\n```java\n@Rule public final TestRule globalTimeout = Timeout.seconds(10);\n```\n\nThis usage avoids the truncation, which was the problem in the deprecated constructor `Timeout(int millis)` when casting `long` to `int`.\n\n\n### [Pull request #549:](https://github.com/junit-team/junit4/pull/549) fixes for #544 and #545\n\nThe `Timeout` rule applies the same timeout to all test methods in a class:\n\n```java\npublic class HasGlobalTimeout {\n    @Rule\n    public Timeout globalTimeout = new Timeout(10, TimeUnit.SECONDS);\n\n    @Test\n    public void testInfiniteLoop() {\n        for (;;) {\n        }\n    }\n\n    @Test\n    public synchronized void testInterruptableLock() throws InterruptedException {\n        wait();\n    }\n\n    @Test\n    public void testInterruptableIO() throws IOException {\n        for (;;) {\n            FileChannel channel = new RandomAccessFile(file, \"rw\").getChannel();\n\n            // Interrupted thread closes channel and throws ClosedByInterruptException.\n            channel.write(buffer);\n            channel.close();\n        }\n    }\n}\n```\nEach test is run in a new _daemon_ thread. If the specified timeout elapses before the test completes, its execution is interrupted via `Thread#interrupt()`. This happens in interruptable I/O (operations throwing `java.io.InterruptedIOException` and `java.nio.channels.ClosedByInterruptException`), locks (package `java.util.concurrent`) and methods in `java.lang.Object` and `java.lang.Thread` throwing `java.lang.InterruptedException`.\n\n### [Pull request #876:](https://github.com/junit-team/junit4/pull/876) The timeout rule never times out if you pass in a timeout of zero.\n\nA specified timeout of 0 will be interpreted as not set, however tests still launch from separate threads. This can be useful for disabling timeouts in environments where they are dynamically set based on some property.\n\n\n# Parameterized Tests\n\n\n### [Pull request #702:](https://github.com/junit-team/junit4/pull/702) Support more return types for the `@Parameters` method of the `Parameterized` runner\n\nThe return types `Iterator<? extends Object>`, `Object[]` and `Object[][]` are now supported on methods annotated with `@Parameters`. You don't have to wrap arrays with `Iterable`s and single parameters with `Object` arrays.\n\n\n### [Pull request #773:](https://github.com/junit-team/junit4/pull/773) Allow configurable creation of child runners of parameterized suites\n\nThe factory for creating the `Runner` instance of a single set of parameters is now configurable. It can be specified by the `@UseParametersRunnerFactory` annotation.\n\n\n# Rules\n\n\n### [Pull request #552:](https://github.com/junit-team/junit4/pull/552) [Pull request #937:](https://github.com/junit-team/junit4/pull/937) `Stopwatch` rule\n\nThe `Stopwatch` Rule notifies one of its own protected methods of the time spent by a test. Override them to get the time in nanoseconds. For example, this class will keep logging the time spent by each passed, failed, skipped, and finished test:\n\n```java\npublic static class StopwatchTest {\n    private static final Logger logger = Logger.getLogger(\"\");\n\n    private static void logInfo(String testName, String status, long nanos) {\n        logger.info(String.format(\"Test %s %s, spent %d microseconds\",\n            testName, status, Stopwatch.toMicros(nanos)));\n    }\n\n    @Rule\n    public Stopwatch stopwatch = new Stopwatch() {\n        @Override\n        protected void succeeded(long nanos, Description description) {\n            logInfo(description.getMethodName(), \"succeeded\", nanos);\n        }\n\n        @Override\n        protected void failed(long nanos, Throwable e, Description description) {\n            logInfo(description.getMethodName(), \"failed\", nanos);\n        }\n\n        @Override\n        protected void skipped(long nanos, AssumptionViolatedException e, Description description) {\n            logInfo(description.getMethodName(), \"skipped\", nanos);\n        }\n\n        @Override\n        protected void finished(long nanos, Description description) {\n            logInfo(description.getMethodName(), \"finished\", nanos);\n        }\n    };\n\n    @Test\n    public void succeeds() {\n    }\n\n    @Test\n    public void fails() {\n        fail();\n    }\n\n    @Test\n    public void skips() {\n        assumeTrue(false);\n    }\n}\n```\n\nAn example to assert running time:\n\n```java\n@Test\npublic void performanceTest() throws InterruptedException {\n    long delta = 30;\n    Thread.sleep(300L);\n    assertEquals(300D, stopwatch.runtime(MILLISECONDS), delta);\n    Thread.sleep(500L);\n    assertEquals(800D, stopwatch.runtime(MILLISECONDS), delta);\n}\n```\n\n### [Pull request #932:](https://github.com/junit-team/junit4/pull/932) Allow static `@Rule`s also annotated with `@ClassRule`\n\nJUnit 4.11 introduced restrictions requiring `@Rule` members to be non-static and `@ClassRule` members to be static. These restrictions have been relaxed slightly, in that a static member annotated with both `@Rule` and `@ClassRule` is now considered valid. This means a single rule may be used to perform actions both before/after a class (e.g. setup/tear down an external resource) and between tests (e.g. reset the external resource), without the need for any workarounds mentioned in issue [#793](https://github.com/junit-team/junit4/issues/793).\n\nNote that a non-static `@ClassRule` annotated member is still considered invalid, even if annotated with `@Rule`.\n\n```java\npublic class CommonRuleTest {\n    @Rule\n    @ClassRule\n    public static MySetupResetAndTearDownRule rule = new MySetupResetAndTearDownRule();\n}\n```\n\nBe warned that if you have static methods or fields annotated with `@Rule` you will not be able to run your test methods in parallel.\n\n### [Pull request #956:](https://github.com/junit-team/junit4/pull/956) `DisableOnDebug` rule\n\nThe `DisableOnDebug` rule allows users to disable other rules when the JVM is launched in debug mode. Prior to this feature the common approach to disable rules that make debugging difficult was to comment them out and remember to revert the change. When using this feature users no longer have to modify their test code nor do they need to remember to revert changes.\n\nThis rule is particularly useful in combination with the `Timeout` rule. \n\n```\n@Rule\npublic DisableOnDebug timeout = new DisableOnDebug(Timeout.seconds(1));\n```\n\nSee the Javadoc for more detail and limitations. Related to https://github.com/junit-team/junit4/issues/738\n\n### [Pull request #974:](https://github.com/junit-team/junit4/pull/974) Updated `TemporaryFolder.newFolder()` to give an error message if a path contains a slash.\n\nIf you call `TemporaryFolder.newFolder(\"foo/bar\")` in JUnit 4.10 the method returns a `File` object for the new folder but actually fails to create it. That is contrary to the expected behaviour of the method which is to actually create the folder. In JUnit 4.11 the same call throws an exception. Nowhere in the documentation does it explain that the String(s) passed to that method can only be single path components.\n\nWith this fix, folder names are validated to contain single path name. If the folder name consists of multiple path names, an exception is thrown stating that usage of multiple path components in a string containing folder name is disallowed.\n\n### [Pull request #1015:](https://github.com/junit-team/junit4/pull/1015) Methods annotated with `Rule` can return a `MethodRule`.\n\nMethods annotated with `@Rule` can now return either a `TestRule` (or subclass) or a\n`MethodRule` (or subclass).\n\nPrior to this change, all public methods annotated with `@Rule` were called, but the\nreturn value was ignored if it could not be assigned to a `TestRule`. After this change,\nthe method is only called if the return type could be assigned to `TestRule` or\n`MethodRule`. For methods annotated with `@Rule` that return other values, see the notes\nfor pull request #1020.\n\n### [Pull request #1020:](https://github.com/junit-team/junit4/pull/1020) Added validation that @ClassRule should only be implementation of TestRule.\n\nPrior to this change, fields annotated with `@ClassRule` that did not have a type of `TestRule`\n(or a class that implements `TestRule`) were ignored. With this change, the test will fail\nwith a validation error.\n\nPrior to this change, methods annotated with `@ClassRule` that did specify a return type\nof `TestRule`(or a class that implements `TestRule`) were ignored. With this change, the test\nwill fail with a validation error.\n\n### [Pull request #1021:](https://github.com/junit-team/junit4/pull/1021) JavaDoc of TemporaryFolder: folder not guaranteed to be deleted.\n\nAdjusted JavaDoc of TemporaryFolder to reflect that temporary folders are not guaranteed to be\ndeleted.\n\n# Theories\n\n\n### [Pull request #529:](https://github.com/junit-team/junit4/pull/529) `@DataPoints`-annotated methods can now yield `null` values\n\nUp until JUnit 4.11 a `@DataPoints`-annotated array field could contain `null` values, but the array returned by a `@DataPoints`-annotated method could not. This asymmetry has been resolved: _both_ can now provide a `null` data point. \n\n\n### [Pull request #572:](https://github.com/junit-team/junit4/pull/572) Ensuring no-generic-type-parms validator called/tested for theories\n\nThe `Theories` runner now disallows `Theory` methods with parameters that have \"unresolved\" generic type parameters (e.g. `List<T>` where `T` is a type variable). It is exceedingly difficult for the `DataPoint(s)` scraper or other `ParameterSupplier`s to correctly decide values that can legitimately be assigned to such parameters in a type-safe way, so JUnit now disallows them altogether. Theory parameters such as `List<String>` and `Iterable<? extends Number>` are still allowed.\n\nThe machinery to perform this validation was in the code base for some time, but not used. It now is used.\n\n[junit.contrib](https://github.com/junit-team/junit.contrib)'s rendition of theories performs the same validation.\n\n\n### [Pull request #607:](https://github.com/junit-team/junit4/pull/607) Improving theory failure messages\n\nTheory failure messages previously were of the form: `ParameterizedAssertionError: theoryTest(badDatapoint, allValues[1], otherVar)`, where allValues, badDatapoint and otherVar were the variables the datapoints was sourced from. These messages are now of the form: \n\n```java\nParameterizedAssertionError: theoryTest(null <from badDatapoint>, \"good value\" <from allValues[1]>, \n                                  [toString() threw RuntimeException: Error message] <from otherVar>)\n```\n\n\n### [Pull request #601:](https://github.com/junit-team/junit4/pull/601) Allow use of `Assume` in tests run by `Theories` runner\n\nIf, in a theory, all parameters were \"assumed\" away, the `Theories` runner would properly fail, informing you that no parameters were found to actually test something. However, if you had another method in that same class, that was not a theory (annotated with `@Test` only,) you could not use Assume in that test. Now, the `Theories` runner will verify the method is annotated with `@Theory` before failing due to no parameters being found.\n\n```java\n@RunWith(Theories.class)\npublic class TheoriesAndTestsTogether {\n    @DataPoint\n    public static Object o;\n\n    @Theory\n    public void theory(Object o) {\n        // this will still fail: java.lang.AssertionError: Never found parameters that satisfied method assumptions.\n        Assume.assumeTrue(false);\n    }\n\n    @Test\n    public void test() {\n        // this will no longer fail\n        Assume.assumeTrue(false);\n    }\n}\n```\n\n\n### [Pull request #623:](https://github.com/junit-team/junit4/pull/623) Ensure data points array fields and methods are `public` and `static` in Theory classes.\n\nPreviously if a data points array field or method was non-`static` or non-`public` it would be silently ignored and the data points not used. Now the `Theories` runner verifies that all `@DataPoint` or `@DataPoints` annotated fields or methods in classes are both `public` and `static`, and such classes will fail to run with `InitializationError`s if they are not.\n\n\n### [Pull request #621:](https://github.com/junit-team/junit4/pull/621) Added mechanism for matching specific data points in theories to specific parameters, by naming data points.\n\n`@DataPoints` fields or methods can now be given (one or more) names in the annotation, and `@Theory` method parameters can be annotated with `@FromDataPoints(name)`, to limit the data points considered for that parameter to only the data points with that name:\n\n```java\n@DataPoints\npublic static String[] unnamed = new String[] { ... };\n\n@DataPoints(\"regexes\")\npublic static String[] regexStrings = new String[] { ... };\n  \n@DataPoints({\"forMatching\", \"alphanumeric\"})\npublic static String[] testStrings = new String[] { ... }; \n  \n@Theory\npublic void stringTheory(String param) {\n    // This will be called with every value in 'regexStrings',\n    // 'testStrings' and 'unnamed'.\n}\n  \n@Theory\npublic void regexTheory(@FromDataPoints(\"regexes\") String regex,\n                        @FromDataPoints(\"forMatching\") String value) {\n    // This will be called with only the values in 'regexStrings' as \n    // regex, only the values in 'testStrings' as value, and none \n    // of the values in 'unnamed'.\n}\n```\n\n\n### [Pull request #654:](https://github.com/junit-team/junit4/pull/654) Auto-generation of `enum` and `boolean` data points\n\nAny theory method parameters with `boolean` or `enum` types that cannot be supplied with values by any other sources will be automatically supplied with default values: `true` and `false`, or every value of the given `enum`. If other explicitly defined values are available (e.g. from a specified `ParameterSupplier` or some `DataPoints` method in the theory class), only those explicitly defined values will be used.\n\n\n### [Pull request #651:](https://github.com/junit-team/junit4/pull/651) Improvements to Theory parameter and DataPoint type matching\n\n * Validity of `DataPoints` for theory parameters for all field data points and multi-valued method data points (i.e. not single-valued method data points) is now done on runtime type, not field/method return type (previously this was the case for multi-valued array methods only).\n\n * Validity of `DataPoints` for theory parameters for all data points now correctly handles boxing and unboxing for primitive and wrapper types; e.g. `int` values will be considered for theory parameters that are `Integer` assignable, and vice versa.\n\n\n### [Pull request #639:](https://github.com/junit-team/junit4/pull/639) Failing theory datapoint methods now cause theory test failures\n\nPreviously `@DataPoint(s)` methods that threw exceptions were quietly ignored and if another `DataPoint` source was available then those values alone were used, leaving the theory passing using only a subset of the (presumably) intended input values. Now, any data point method failures during invocation of a theory will cause the theory being tested to fail immediately.\n\n*This is a non-backward-compatible change*, and could potentially break theory tests that depended on failing methods. If that was desired behavior, then the expected exceptions can instead be specifically ignored using the new `ignoredExceptions` array attribute on `@DataPoint` and `@DataPoints` methods. Adding an exception to this `ignoredExceptions` array will stop theory methods from failing if the given exception, or subclasses of it, are thrown in the annotated method. This attribute has no effect on data point fields.\n\n\n### [Pull request #658:](https://github.com/junit-team/junit4/pull/658) `Iterable`s can now be used as data points\n\nPreviously, when building sets of data points for theory parameters, the only valid multi-valued `@DataPoints` types were arrays. This has now been extended to also take parameters from `Iterable` `@DataPoints` methods and fields.\n\n\n# Categories\n\n\n### [Pull request #566:](https://github.com/junit-team/junit4/pull/566) Enables inheritance on `Category` by adding `@Inherited`\n\n`@interface Category` now is annotated with `@Inherited` itself. This enables inheritance of categories from ancestors (e.g. abstract test-classes). Note that you are able to \"overwrite\" `@Category` on inheritors and that this has no effect on method-level categories (see [@Inherited](http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Inherited.html)).\n\n\n### [Pull request #503:](https://github.com/junit-team/junit4/pull/503) Configurable Categories\n\nFrom a given set of test classes, the `Categories` runner runs only the classes and methods\nthat are annotated with either the category given with the `@IncludeCategory` annotation, or a subtype of that category. Either classes or interfaces can be used as categories. Subtyping works, so if you say `@IncludeCategory(SuperClass.class)`, a test marked `@Category({SubClass.class})` will be run.\n\nYou can also exclude categories by using the `@ExcludeCategory` annotation; see `SlowTestSuiteWithoutFast`.\n\nThe suite `FastOrSmokeTestSuite` is an example to run multiple categories.\n\nTo execute tests which match all categories, use `matchAny = false` in annotations. See `FastAndSmokeTestSuite`.\n \nExample:\n\n```java\npublic static interface FastTests { /* category marker */ }\npublic static interface SlowTests { /* category marker */ }\npublic static interface SmokeTests { /* category marker */ }\n\npublic static class A {\n    public void a() {\n        fail();\n    }\n\n    @Category(SlowTests.class)\n    @Test\n    public void b() {\n    }\n\n    @Category({FastTests.class, SmokeTests.class})\n    @Test\n    public void c() {\n    }\n}\n\n@Category({SlowTests.class, FastTests.class})\npublic static class B {\n    @Test\n    public void d() {\n    }\n}\n\n@RunWith(Categories.class)\n@Categories.IncludeCategory(SlowTests.class)\n@Suite.SuiteClasses({A.class, B.class})\npublic static class SlowTestSuite {\n    // Will run A.b and B.d, but not A.a and A.c\n}\n\n@RunWith(Categories.class)\n@Categories.IncludeCategory({FastTests.class, SmokeTests.class})\n@Suite.SuiteClasses({A.class, B.class})\npublic static class FastOrSmokeTestSuite {\n    // Will run A.c and B.d, but not A.b because it is not any of FastTests or SmokeTests\n}\n\n@RunWith(Categories.class)\n@Categories.IncludeCategory(value = {FastTests.class, SmokeTests.class}, matchAny = false)\n@Suite.SuiteClasses({A.class, B.class})\npublic static class FastAndSmokeTestSuite {\n    // Will run only A.c => match both FastTests AND SmokeTests\n}\n\n@RunWith(Categories.class)\n@Categories.IncludeCategory(SlowTests.class)\n@Categories.ExcludeCategory(FastTests.class)\n@Suite.SuiteClasses({A.class, B.class}) // Note that Categories is a kind of Suite\npublic class SlowTestSuiteWithoutFast {\n\t// Will run A.b, but not A.a, A.c or B.d\n}\n```\n\n\n# Use with Maven\n\n\n### [Pull request #879:] (https://github.com/junit-team/junit4/pull/879) Add the default 'Implementation-*' headers to the manifest\n\nThe default Maven-style 'Implementation-*' headers are now present in the manifest of `junit.jar`. Example:\n```\nImplementation-Vendor: JUnit\nImplementation-Title: JUnit\nImplementation-Version: 4.12\nImplementation-Vendor-Id: junit\n```\n\n\n### [Pull request #511:](https://github.com/junit-team/junit4/pull/511) Maven project junit:junit:jar\n\n\n#### How to install Maven\n\nDownload the Maven binary [http://www.us.apache.org/dist/maven/maven-3/3.0.4/binaries](http://www.us.apache.org/dist/maven/maven-3/3.0.4/binaries).\n\n(wget http://www.us.apache.org/dist/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.tar.gz)\n\nIf you are in the project root, extract the archive (tar xvzf apache-maven-3.0.4-bin.tar.gz).\nCreate directory _.m2_ in your _user home_. Then the artifacts and plugins are stored in `~/.m2/repository`.\n( _~_ stands for user home)\n\n\n#### How to launch the build from the command line\n\nClone the project (git clone https://github.com/junit-team/junit4.git) and navigate to the project root on your local system (cd junit).\nClean the previous build in _target_ directory, build the project, and install new artifacts in your local repository:\n\n`apache-maven-3.0.4/bin/mvn clean install`\n\nOn Windows type the command `apache-maven-3.0.4\\bin\\mvn clean install`.\n\nSet the environment variables `M2_HOME` and `PATH` when frequently building via command line `mvn clean install`.\n\n[http://maven.apache.org/guides/development/guide-building-m2.html#Building_Maven_Without_Maven_Installed](http://maven.apache.org/guides/development/guide-building-m2.html#Building_Maven_Without_Maven_Installed)\n\n\n#### How to install and build the Maven project in Eclipse\n\nI made a clone of JUnit project from GitHub to local folder `C:\\cygwin\\usr\\local\\etc\\junit`.\n\nIn menu go to _File -> Import..._\n\nIn the popup menu open section _Maven_, click on _Existing Maven Projects_ and click on _Next_. In _Import Maven Projects_ specify the project root, and next proceed further with installing maven support plugin in Eclipse.\n\nYou have created the Maven project, and now build the project.\n\nIn the Package Explorer click on _pom.xml_. In the menu _Run -> Run As -> 2 Maven build..._ open the popup _Edit Configuration_ and specify the build phase _clean install_ in section _Goals_. Click on _Run_ and build the project.\n\n#### How to install and build the Maven project in IntelliJ IDEA\n\nIn IDEA menu create a new project _File -> New Project..._.\n\nSelect _Create Java project from existing sources_, then click on Next and specify _Project file location_.\n\nOn the right-hand side is the _Maven Projects_ tab. Click on + and add _pom.xml_ into the project. Then click on the icon _Maven Settings_, and set _Maven home directory_ as the location of extracted Maven archive on your system. Click on the green triangle and launch the build.\n\nSee the IntelliJ IDEA Web help\n[http://www.jetbrains.com/idea/webhelp/maven-2.html](http://www.jetbrains.com/idea/webhelp/maven-2.html)\n\n#### How to install the Maven project with documentation\nUse the profile `generate-docs` to build _sources.jar_ and _javadoc.jar_. Building Maven site is not yeat supported.\n\nExample: `mvn -Pgenerate-docs install`\n\n#### How to activate and deactivate Maven profiles in Integrated Development Environments:\n\nIn _Eclipse_, from the main menu navigate to Run -> Run As -> 2 Maven build..., open the popup _Edit Configuration_ and specify the profiles.\n\nFollow this link for _IntelliJ IDEA_: [http://www.jetbrains.com/idea/webhelp/activating-and-deactivating-maven-profiles.html](http://www.jetbrains.com/idea/webhelp/activating-and-deactivating-maven-profiles.html)\n\n\n# Miscellaneous\n\n\n### [Pull request #776:](https://github.com/junit-team/junit4/pull/776) Add support for [Travis CI](http://travis-ci.org)\n\nTravis CI is a free CI server for public Github repositories. Every pull request is run by Travis CI and Github's web interface shows the CI result for each pull request. Every user can use Travis CI for testing her branches, too.\n\n### [Pull request #921:](https://github.com/junit-team/junit4/pull/921) Apply Google Code Style\n\nJUnit is now using the well documented [Google Code Style](http://google-styleguide.googlecode.com/svn/trunk/javaguide.html)\n\n### [Pull request #939](https://github.com/junit-team/junit4/pull/939) Renamed license file\n\nWhile using JUnit in Android apps, if any other referenced library has a file named `LICENSE.txt`, the APK generation failed with the following error -\n\n`Error generating final archive: Found duplicate file for APK: LICENSE.txt`\n\nTo avoid this, the license file has been renamed to `LICENSE-junit.txt` \n\n\n### [Pull request #962:](https://github.com/junit-team/junit4/pull/962) Do not include thread start time in test timeout measurements.\n\nThe time it takes to start a thread can be surprisingly large.\nEspecially in virtualized cloud environments where noisy neighbours.\nThis change reduces the probability of non-deterministic failures of\ntests with timeouts (@Test(timeout=…)) by not beginning the timeout\nclock until we have observed the starting of the task thread – the\nthread that runs the actual test. This should make tests with small\ntimeout values more reliable in general, and especially in cloud CI\nenvironments.\n\n# Fixes to issues introduced in JUnit 4.12\n\nThe following section lists fixes to problems introduced in the first\nrelease candidates for JUnit 4.12. You can ignore this section if you are\ntrying to understand the changes between 4.11 and 4.12.\n\n### [Pull request #961:](https://github.com/junit-team/junit4/pull/961) Restore field names with f prefix.\n\nIn order to make the JUnit code more consistent with current coding practices, we changed\na number of field names to not start with the prefix \"f\". Unfortunately, at least one IDE\nreferenced a private field via reflection. This change reverts the field names for fields\nknown to be read via reflection.\n\n### [Pull request #988:](https://github.com/junit-team/junit4/pull/988) Revert \"Delete classes that are deprecated for six years.\"\n\nIn [745ca05](https://github.com/junit-team/junit4/commit/745ca05dccf5cc907e43a58142bb8be97da2b78f)\nwe removed classes that were deprecated for many releases. There was some concern that people\nmight not expect classes to be removed in a 4.x release. Even though we are not aware of any\nproblems from the deletion, we decided to add them back.\n\nThese classes may be removed in JUnit 5.0 or later.\n\n### [Pull request #989:](https://github.com/junit-team/junit4/pull/989) Add JUnitSystem.exit() back.\n\nIn [917a88f](https://github.com/junit-team/junit4/commit/917a88fad06ce108a596a8fdb4607b1a2fbb3f3e)\nthe exit() method in JUnit was removed. This caused problems for at least one user. Even\nthough this class is in an internal package, we decided to add it back, and deprecated it.\n\nThis method may be removed in JUnit 5.0 or later.\n\n### [Pull request #994:](https://github.com/junit-team/junit4/pull/994) [Pull request #1000:](https://github.com/junit-team/junit4/pull/1000) Ensure serialization compatibility where possible.\n\nJUnit 4.12 RC1 introduced serilization incompatibilities with some of the classes. For example,\nthese pre-release versions of JUnit could not read instances of `Result` that were serialized\nin JUnit 4.11 and earlier. These changes fix that problem.\n\n"
  },
  {
    "path": "doc/ReleaseNotes4.13.1.md",
    "content": "## Summary of changes in version 4.13.1\n\n# Rules\n\n### Security fix: `TemporaryFolder` now limits access to temporary folders on Java 1.7 or later\n\nA local information disclosure vulnerability in `TemporaryFolder` has been fixed. See the published [security advisory](https://github.com/junit-team/junit4/security/advisories/GHSA-269g-pwp5-87pp) for details.\n\n# Test Runners\n\n### [Pull request #1669:](https://github.com/junit-team/junit/pull/1669) Make `FrameworkField` constructor public\n\nPrior to this change, custom runners could make `FrameworkMethod` instances, but not `FrameworkField` instances. This small change allows for both now, because `FrameworkField`'s constructor has been promoted from package-private to public.\n"
  },
  {
    "path": "doc/ReleaseNotes4.13.2.md",
    "content": "## Summary of changes in version 4.13.2\n\n# Rules\n\n### [Pull request #1687:](https://github.com/junit-team/junit/pull/1687) Mark ThreadGroups created by FailOnTimeout as daemon groups\n\nIn JUnit 4.13 ([pull request #1517](https://github.com/junit-team/junit4/pull/1517)) an attempt was\nmade to fix leakage of the `ThreadGroup` instances created when a test is run with a timeout. That\nchange explicitly destroyed the `ThreadGroup` that was created for the time-limited test. Numerous\npeople reported problems that were caused by explicitly destroying the `ThreadGroup`.\n\nIn this change, the code was updated to call  `ThreadGroup.setDaemon(true)` instead of destroying the\nThreadGroup.\n\n### [Pull request $1691:](https://github.com/junit-team/junit/pull/1691) Only create ThreadGroups if FailOnTimeout.lookForStuckThread is true.\n\nIn JUnit 4.12 ([pull request #742](https://github.com/junit-team/junit4/pull/742)) the `Timeout`\nRule was updated to optionally display the stacktrace of the thread that appears to be stuck\n(enabled on an opt-in basis by passing `true` to `Timeout.Builder.lookForStuckThread(boolean)`).\nWhen that change was made, time-limited tests were changed to start the new thread in a new\n`ThreadGroup`, even if the test did not call `lookForStuckThread()`. This subtle change in\nbehavior resulted in visible behavior changes to some tests (for example, tests of code that uses\n`java.beans.ThreadGroupContext`).\n\nIn this change, the code is updated to only create a new `ThreadGroup` if the caller calls\n`Timeout.Builder.lookForStuckThread(true)`. Tests with timeouts that do not make this call will\nbehave as they did in JUnit 4.11 (and more similar to tests that do not have a timeout). This\nunfortunately could result in visible changes of tests written or updated since the 4.12\nrelease. If this change adversely affects your tests, you can create the `Timeout` rule via the\nbuilder and call `Timeout.Builder.lookForStuckThread(true)`.\n\n# Exceptions\n\n### [Pull request #1654:](https://github.com/junit-team/junit/pull/1654) Fix for issue #1192: NotSerializableException with AssumptionViolatedException\n\nThis change fixes an issue where `AssumptionViolatedException` instances could not be serialized\nif they were created with a constructor that takes in an `org.hamcrest.Matcher` instance (these\nconstructors are used if you use one of the `assumeThat()` methods in `org.junit.Assume`).\n"
  },
  {
    "path": "doc/ReleaseNotes4.13.md",
    "content": "## Summary of changes in version 4.13\n\n# Assertions\n\n### [Pull request #1054:](https://github.com/junit-team/junit/pull/1054) Improved error message for `assertArrayEquals` when multi-dimensional arrays have different lengths\n\nPreviously, JUnit's assertion error message would indicate only that some array lengths _x_ and _y_ were unequal, without indicating whether this pertained to the outer array or some nested array. Now, in case of a length mismatch between two nested arrays, JUnit will tell at which indices they reside.\n\n### [Pull request #1154](https://github.com/junit-team/junit/pull/1154) and [#1504](https://github.com/junit-team/junit/pull/1504) Add `assertThrows`\n\nThe `Assert` class now includes methods that can assert that a given function call (specified, for instance, as a lambda expression or method reference) results in a particular type of exception being thrown. In addition it returns the exception that was thrown, so that further assertions can be made (e.g. to verify that the message and cause are correct).\n\n### [Pull request #1300:](https://github.com/junit-team/junit/pull/1300) Show contents of actual array when array lengths differ\n\nPreviously, when comparing two arrays which differ in length, `assertArrayEquals()` would only report that they differ in length. Now, it does the usual array comparison even when arrays differ in length, producing a failure message which combines the difference in length and the first difference in content. Where the content is another array, it is described by its type and length.\n\n### [Pull request #1315:](https://github.com/junit-team/junit4/pull/1315) `assertArrayEquals` shouldn't throw an NPE when test suites are compiled/run across versions of junit\n\nA redundant field, `fCause`, was removed on v4.12, and was seemingly harmless because `Throwable#initCause()` could directly initialize `cause` in the constructor. Unfortunately, this backwards incompatible change got aggravated when a test class, compiled with the latest (4.12+), ran with an older version that depended on fCause when building the assertion message<sup>[1](#1315-f1)</sup>.\n\nThis change adds back `fCause`, and overrides `getCause()` to handle forward compatibility<sup>[2](#1315-f2)</sup>.\n\nTo ensure serializability of further changes in `ArrayAssertionFailure` (until excising these fields by a major rev), a unit test now runs against v4.11, v4.12 failures, asserting around `#toString/getCause()`.\n\n<a name=\"1315-f1\">[1]</a> [Issue #1178](https://github.com/junit-team/junit4/issues/1178) details a particular case where gradle v2.2 is packaged with junit v4.11 and is used on running a test, generating test reports, despite specifying a particular version of junit (users would specify v4.12, or v4.+) in the test compile dependencies).\n\n<a name=\"1315-f2\">[2]</a> [Case](https://github.com/junit-team/junit4/pull/1315#issuecomment-222905229) if the test class is compiled with <= v4.11, where only `fCause` is initialized and not `Throwable#cause`, it can now fallback to the field, `fCause`, when building the message.\n\n### [Pull request #1150:](https://github.com/junit-team/junit4/pull/1150) Deprecate `Assert#assertThat`\n\nThe method `assertThat` is used for writing assertions with Hamcrest. Hamcrest is an independent assertion library and contains an own `assertThat` method in the class `org.hamcrest.MatcherAssert`. It is available both in the old Hamcrest 1.3 release and in the current Hamcrest 2.1. Therefore the JUnit team recommends to use Hamcrest's own `assertThat` directly.\n\n# Test Runners\n\n### [Pull request #1037:](https://github.com/junit-team/junit/pull/1037) `BlockJUnit4ClassRunner#createTest` now accepts `FrameworkMethod`\n\nSubclasses of `BlockJUnit4ClassRunner` can now produce a custom test object based on the `FrameworkMethod` test being executed by implementing the new `createTest(FrameworkMethod)` method. The default implementation calls the existing `createTest()` method.\n\n### [Pull request #1082](https://github.com/junit-team/junit/pull/1082): Ensure exceptions from `BlockJUnit4ClassRunner.methodBlock()` don't result in unrooted tests\n\nThe introduction of the `runLeaf()` method in `BlockJUnit4ClassRunner` in JUnit 4.9 introduced a regression with regard to exception handling. Specifically, in JUnit 4.9 through 4.12 the invocation of `methodBlock()` is no longer executed within a try-catch block as was the case in previous versions of JUnit. Custom modifications to `methodBlock()` or the methods it invokes may in fact throw exceptions, and such exceptions cause the current test execution to abort immediately. As a result, the failing test method is unrooted in test reports, and subsequent test methods are never invoked. Furthermore, any `RunListener` registered with JUnit is not notified.\n\nAs of JUnit 4.13, the invocation of `methodBlock()` is once again wrapped within a try-catch block. If an exception is _not_ thrown, the resulting `Statement` is passed to `runLeaf()`. If an exception _is_ thrown, it is wrapped in a `Fail` statement which is passed to `runLeaf()`.\n\n### [Pull request #1286](https://github.com/junit-team/junit/pull/1286): Provide better feedback to the user in case of invalid test classes\n\nOnly one exception per invalid test class is now thrown, rather than one per validation error.\nThe message of the exception includes all of the validation errors.\n\nExample:\n\n    org.junit.runners.InvalidTestClassError: Invalid test class 'com.example.MyTest':\n      1. Method staticAfterMethod() should not be static\n      2. Method staticBeforeMethod() should not be static\n\nis the exception thrown when running the following test class with any kind of `ParentRunner`:\n\n    public class MyTest {\n\n        @Before\n        public static void staticBeforeMethod() { .. }\n\n        @After\n        public static void staticAfterMethod() { .. }\n\n        @Test\n        public void myTest() { .. }\n    }\n\nValidation errors for the same test class now count only once in the failure count. Therefore, in the example above, `Result#getFailureCount` will return 1.\n\n### [Pull request #1252](https://github.com/junit-team/junit4/pull/1252): Restore ability use ParentRunner lost in separate class loader\n\n`ParentRunner.getDescription()` now uses the class instance of the test class to create the description\n(previously the class instance was loaded using the current classloader).\n\n### [Pull request #1377](https://github.com/junit-team/junit4/pull/1377): Description produced by Request.classes() shouldn't be null\n\nWhen obtaining a `Runner` via [Request.classes(Class<?>... classes)](http://junit.org/junit4/javadoc/4.12/org/junit/runner/Request.html#classes(java.lang.Class...)), that Runner's `Description` will now print \"classes\" for the root item. This replaces the misleading output of String \"null\".\n\n### [Issue #1290](https://github.com/junit-team/junit4/issues/1290): Tests expecting AssumptionViolatedException are now correctly marked as passed\n\n    @Test(expected = AssumptionViolatedException.class)\n    public void shouldThrowAssumptionViolatedException() {\n        throw new AssumptionViolatedException(\"expected\");\n    }\n\nThis test would previously be marked as skipped; now will be marked as passed.\n\n\n### [Pull request #1465](https://github.com/junit-team/junit/pull/1465): Provide helpful message if parameter cannot be set.\n\nJUnit throws an exception with a message like\n\n    Cannot set parameter 'name'. Ensure that the the field 'name' is public.\n\nif a field of a parameterized test is annotated `@Parameter`, but its visibility is not public. Before an IllegalAccessException was thrown with a message like \"Class ... can not access a member of class X with modifiers private\".\n\n\n### [Issue #1329](https://github.com/junit-team/junit4/issus/1329): Support assumptions in `@Parameters` method\n\nNo test is run when an assumption in the `@Parameters` method fails. The test result for this test class contains one assumption failure and run count is zero.\n\n\n### [Pull request #1449](https://github.com/junit-team/junit/pull/1449): Parameterized runner reuses TestClass instance\n\nReduce memory consumption of parameterized tests by not creating a new instance of `TestClass` for every test.\n\n### [Pull request #1130](https://github.com/junit-team/junit/pull/1130): Add Ordering, Orderable and @OrderWith\n\nTest classes can now be annotated with `@OrderWith` to specify that the tests should execute in a particular\norder. All runners extending `ParentRunner` support `@OrderWith`. Runners can also be ordered using\n`Request.orderWith(Ordering)`\n\nClasses annotated with `@RunWith(Suite.class)` can also be ordered with `@OrderWith`. Note that if this is done, nested classes annotated with `@FixMethodOrder` will not be reordered (i.e. the `@FixMethodOrder` annotation is\nalways respected). Having a test class annotated with both `@OrderWith` and `@FixMethodOrder` will result in a\nvalidation error (see\n[pull request #1638](https://github.com/junit-team/junit4/pull/1638)).\n\n### [Pull request #1408](https://github.com/junit-team/junit/pull/1408): Suites don't have to be public\n\nClasses annotated with `@RunWith(Suite.class)` do not need to be public. This fixes a regression bug in JUnit 4.12. Suites didn't had to be public before 4.12.\n\n### [Pull request #1638](https://github.com/junit-team/junit4/pull/1638): Never reorder classes annotated with @FixMethodOrder\n\nChanging the order of a test run using `Request.sortWith()` no longer changes the order of test classes annotated\nwith `@FixMethodOrder`. The same holds true when you reorder tests with `Request.orderWith()` (`orderWith()` \nwas introduced in [Pull request #1130](https://github.com/junit-team/junit/pull/1130)).\n\nThis was done because usually `@FixMethodOrder` is added to a class because the tests in the class they only pass\nif run in a specific order. \n\nTest suites annotated with `@OrderWith` will also respect the `@FixMethodOrder` annotation.\n\nHaving a test class annotated with both `@OrderWith` and `@FixMethodOrder` will result in a validation error.\n\n# Rules\n\n### [Pull request #1044:](https://github.com/junit-team/junit/pull/1044) Strict verification of resource deletion in `TemporaryFolder` rule\n\nPreviously `TemporaryFolder` rule did not fail the test if some temporary resources could not be deleted. With this change a new `assuredDeletion` parameter is introduced which will fail the test with an `AssertionError`, if resource deletion fails. The default behavior of `TemporaryFolder` is unchanged.\n\nThis feature must be enabled by creating a `TemporaryFolder` using the `TemporaryFolder.builder()` method:\n```java\n@Rule public TemporaryFolder folder = TemporaryFolder.builder().assureDeletion().build();\n```\n\n### [Issue #1100:](https://github.com/junit-team/junit/issues/1110) StopWatch does not need to be abstract.\n\nPreviously `StopWatch` was an abstract class, which means it cannot be used without extending it or using an anonymous class. The abstract modifier has been removed and StopWatch can be used easily now.\n\n### [Issue #1157:](https://github.com/junit-team/junit/issues/1157) TestName: Make 'name' field volatile\n\nThe `name` field in the `TestName` rule was updated to be volatile. This should ensure that the name\nis published even when tests are running in parallel.\n\n### [Issue #1223:](https://github.com/junit-team/junit/issues/1223) TemporaryFolder doesn't work for parallel test execution in several JVMs\n\nPreviously `TemporaryFolder` rule silently succeeded if it failed to create a fresh temporary directory. With this change it will notice the failure, retry with a new name, and ultimately throw an `IOException` if all such attempts fail.\n\n### [Pull request #1305:](https://github.com/junit-team/junit/pull/1305) Add `ErrorCollector.checkThrows`\n\nThe `ErrorCollector` class now has a `checkThrows` method that can assert that a given function call (specified, for instance, as a lambda expression or method reference) results in a particular type of exception being thrown.\n\n### [Issue #1303:](https://github.com/junit-team/junit/issues/1303) Prevent following symbolic links when deleting temporary directories\n\nPreviously, `TemporaryFolder` would follow symbolic links; now it just deletes them.\n\nFollowing symbolic links when removing files can lead to the removal of files outside the directory structure rooted in the temporary folder, and it can lead to unbounded recursion if a symbolic link points to a directory where the link is directly reachable from.\n\n### [Issue #1295:](https://github.com/junit-team/junit/issues/1295) Javadoc for RuleChain contains errors\n\nRemoved error from RuleChain Javadoc and clarified how it works with existing rules. Removed `static` modifier, added missing closing parenthesis of method calls and added clarification.\n\n### [Pull request #1313](https://github.com/junit-team/junit4/pull/1313): `RuleChain.around()` rejects null arguments\n`RuleChain.around()` now implements a fail-fast strategy which also allows for better feedback to the final user, as the stacktrace will point to the exact line where the null rule is declared.\n\n### [Pull request #1397](https://github.com/junit-team/junit4/pull/1397): Change generics on `ExpectedException.expectCause()`\nThe signature of `ExpectedException.expectCause()` would not allow the caller to pass in a `Matcher<Object>` (which is returned by `CoreMatchers.notNullValue()`). This was fixed by changing the method to take in a\n`Matcher<?>` (ideally, the method should take in `Matcher<? super Throwable>` but there was concern that\nchanging the parameter type to `Matcher<? super Throwable>` would break some callers).  \n\n### [Pull request #1443](https://github.com/junit-team/junit4/pull/1443): `ExpectedException.isAnyExceptionExpected()` is now public\nThe method `ExpectedException.isAnyExceptionExpected()` returns `true` if there is at least one expectation present for the `ExpectedException` rule.\n\n### [Pull request #1395](https://github.com/junit-team/junit4/pull/1395): Wrap assumption violations in ErrorCollector\nBoth `ErrorCollector.addError()` and `ErrorCollector.checkSucceeds()` now wrap `AssumptionViolatedException`.\nIn addition, `ErrorCollector.addError()` will throw a `NullPointerException` if you pass in a `null` value.\n\n### [Pull request #1402](https://github.com/junit-team/junit4/pull/1402): TemporaryFolder.newFolder(String) supports paths with slashes\nThere was a regression in JUnit 4.12 where `TemporaryFolder.newFolder(String)` no longer supported passing\nin strings with separator characters. This has been fixed. he overload of newFolder() that\nsupports passing in multiple strings still does not allow path separators.\n\n### [Pull requests #1406 (part 1)](https://github.com/junit-team/junit4/pull/1406) and [#1568](https://github.com/junit-team/junit4/pull/1568): Improve error message when TemporaryFolder.newFolder(String) fails\nWhen `newFolder(String path)` was not able to create the folder then it always failed with the error message \"a folder with the name '`<path>`' already exists\" although the reason for the failure could be something else. This message is now only used if the folder really exists. The message is \"a file with the path '`<path>`' exists\" if the whole path or a part of the path points to a file. In all other cases it fails now with the message \"could not create a folder with the path '`<path>`'\"\n\n### [Pull request #1406 (part 2)](https://github.com/junit-team/junit4/pull/1406): TemporaryFolder.newFolder(String...) supports path separator\nYou can now pass paths with path separators to `TemporaryFolder.newFolder(String...)`. E.g.\n\n    tempFolder.newFolder(\"temp1\", \"temp2\", \"temp3/temp4\")\n\nIt creates a folder `temp1/temp2/temp3/temp4`.\n\n\n### [Pull request #1406 (part 3)](https://github.com/junit-team/junit4/pull/1406): TemporaryFolder.newFolder(String...) fails for empty array\n\nWhen you call\n\n    tempFolder.newFolder(new String[])\n\nthen it throws an `IllegalArgumentException` instead of returning an already existing folder.\n\n\n### [Pull request #1335](https://github.com/junit-team/junit4/pull/1335): Fix ExternalResource: the test failure could be lost\nWhen both the test failed and closing the resource failed, only the exception coming from the `after()` method was propagated, as per semantics of the try-finally (see also http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.20.2).\n\nThe new behavior is compatible with @After method semantics, as implemented in [RunAfters](https://github.com/junit-team/junit4/blob/HEAD/src/main/java/org/junit/internal/runners/statements/RunAfters.java).\n\n### [Pull request #1435](https://github.com/junit-team/junit4/pull/1435): @BeforeParam/@AfterParam method annotations for Parameterized tests.\nThis allows having preparation and/or cleanup in tests for specific parameter values.\n\n### [Pull request #1460](https://github.com/junit-team/junit4/pull/1460): Handle assumption violations in the @Parameters method for Parameterized tests.\nThis allows skipping the whole test class when its assumptions are not met.\n\n### [Pull request #1445](https://github.com/junit-team/junit4/pull/1445) and [Pull request #1335](https://github.com/junit-team/junit4/pull/1501): Declarative ordering of rules.\nThe order in which rules are executed is specified by the annotation attribute: `@Rule(order = N)`, deprecating `RuleChain`. This may be used for avoiding some common pitfalls with `TestWatcher, `ErrorCollector` and `ExpectedException` for example. The Javadoc of `TestWatcher` was retrofitted accordingly.\n\n### [Pull request #1517](https://github.com/junit-team/junit4/pull/1517): Timeout rule destroys its ThreadGroups at the end\nThe `ThreadGroup` created for handling the timeout of tests is now destroyed, so the main thread group no longer keeps a reference to all timeout groups created during the tests. This caused the `threadGroup` to remain in memory, and all of its context along with it.\n\n### [Pull request #1633](https://github.com/junit-team/junit4/pull/1633): Deprecate ExpectedException.none()\nThe method Assert.assertThrows provides a nicer way for verifying exceptions. In addition the use of ExpectedException is error-prone when used with other rules like TestWatcher because the order of rules is important in that case.\n\n### [Pull request #1413](https://github.com/junit-team/junit4/pull/1413): Ignore bridge methods when scanning for annotated methods\n\nIn a setup with a class hierarchy for test classes the order of rules (from methods), before methods, after methods and others depends on the class that contains these methods. Compilers can add bridge methods to child classes and therefore the order of the aforementioned methods can change in older JUnit releases. This is now fixed because bridge methods are ignored when scanning for annotated methods.\n\n### [Pull request #1612](https://github.com/junit-team/junit4/pull/1612): Make @ValidateWith only applicable to annotation types\n\n`@Target(ANNOTATION_TYPE)` has been added to `@ValidateWith` since it's only designed to be applied to another annotation.\n\n# Run Listener\n\n### [Pull request #1118:](https://github.com/junit-team/junit4/pull/1118) Add suite start/finish events to listener\n\nThe `RunListener` class now has `fireTestSuiteStarted` and `fireTestSuiteFinished` methods that notify when test suites are about to be started/finished.\n\n\n# Exception Testing\n\n### [Pull request #1359:](https://github.com/junit-team/junit4/pull/1359) Fixes how `MultipleFailureException` stack traces are printed\n\nPreviously, calling `MultipleFailureException.printStackTrace()` only printed the stack trace for the `MultipleFailureException` itself. After this change, the stack trace for each exception caught in the `MultipleFailureException` is printed.\n\n### [Pull request #1376:](https://github.com/junit-team/junit4/pull/1376) Initializing MultipleFailureException with an empty list will now fail the test\n\nPreviously, initializing `MultipleFailureException` with an empty list of contained Exceptions and throwing it in a test case wouldn't actually fail the test. Now an `IllegalArgumentException` will be raised in this situation and thus also fail the test.\n\n### [Pull request #1371:](https://github.com/junit-team/junit4/pull/1371) Update MultipleFailureException.assertEmpty() to wrap assumption failure\n\n`MultipleFailureException` will now wrap `MultipleFailureException` with `TestCouldNotBeSkippedException`. Previously, if you passed `MultipleFailureException` one `MultipleFailureException`--and no other exceptions--\nthen the test would be skipped, otherwise it would fail. With the new behavior, it will always fail.\n\n### [Issue #1290:](https://github.com/junit-team/junit4/issues/1290) `@Test(expected = AssumptionViolatedException.class)` passes for AssumptionViolatedException\n\nTests annotated with `@test(expected = AssumptionViolatedException.class)`\nwhich throw AssumptionViolatedException had been marked as skipped. Now the are marked as successful tests.\n\n\n# JUnit 3 Changes\n\n### [Pull request #1227:](https://github.com/junit-team/junit/pull/1227) Behave better if the `SecurityManager` denies access to `junit.properties`\n\nPreviously, running tests with a `SecurityManager` would cause the test runner itself to throw an `AccessControlException` if the security policy didn't want it reading from `~/junit.properties`. This will now be treated the same as if the file does not exist.\n\n# Misc\n\n### [Pull request #1571:](https://github.com/junit-team/junit4/pull/1571) Set \"junit\" as \"Automatic-Module-Name\"\n\nFor existing releases of JUnit the `Automatic-Module-Name` was derived from the name of the jar. In most cases it is already the name \"junit\". JUnit 4.13 explicitly sets the module name to \"junit\" so that it is independent from the jar's name.\n\n\n### [Pull request #1028:](https://github.com/junit-team/junit4/pull/1028) Trim stack trace\n\nJUnit's command-line runner (`JUnitCore`) prints smaller stack traces. It skips all stack trace elements that come before the test method so that it starts at the test method. E.g. the output for the example from [Getting started](https://github.com/junit-team/junit4/wiki/Getting-started) page is now\n\n    .E\n    Time: 0,006\n    There was 1 failure:\n    1) evaluatesExpression(CalculatorTest)\n    java.lang.AssertionError: expected:<6> but was:<-6>\n    \tat org.junit.Assert.fail(Assert.java:89)\n    \tat org.junit.Assert.failNotEquals(Assert.java:835)\n    \tat org.junit.Assert.assertEquals(Assert.java:647)\n    \tat org.junit.Assert.assertEquals(Assert.java:633)\n    \tat CalculatorTest.evaluatesExpression(CalculatorTest.java:9)\n\n    FAILURES!!!\n    Tests run: 1,  Failures: 1\n\n\n### [Pull request #1403:](https://github.com/junit-team/junit4/pull/1403) Restore CategoryFilter constructor\n\nThe constructor `CategoryFilter(Class<?> includedCategory, Class<?> excludedCategory)` has been removed in JUnit 4.12. It is now available again.\n\n\n### [Pull request #1530:](https://github.com/junit-team/junit4/pull/1530) Add Result#getAssumptionFailureCount\n\nAdd method `getAssumptionFailureCount()` to `Result` which returns the number of assumption failures.\n\n### [Pull request #1292:](https://github.com/junit-team/junit4/pull/1292) Fix ResultMatchers#hasFailureContaining\n \n`ResultMatchers.hasFailureContaining()` should return `false` when the given `PrintableResult` has no failures.\n\n### [Pull request #1380:](https://github.com/junit-team/junit4/pull/1380) Fix Assume#assumeNotNull\n\n`Assume.assumeNotNull` should throw AssumptionViolatedException when called with a `null` array.\n\n### [Pull request #1557:](https://github.com/junit-team/junit4/pull/1380) MaxCore always closes stream of history file\n\nMaxCore didn't close the output stream of the history file when write failed. Now it does.\n\n### Signing\n\nThe 4.13 release is signed with a new key (id 5EC61B51):\nhttps://github.com/junit-team/junit4/blob/8c0df64ff17fead54c304a8b189da839084925c2/KEYS\n"
  },
  {
    "path": "doc/ReleaseNotes4.4.html",
    "content": "<h2>Summary of Changes in version 4.5</h2>\n\n<h3>Categories</h3>\n\n<p>Each test method and test class can be annotated as belonging to a <em>category</em>:</p>\n\n<pre><code>public static class SomeUITests {\n    @Category(UserAvailable.class)\n    @Test\n    public void askUserToPressAKey() { }\n\n    @Test\n    public void simulatePressingKey() { }\n}\n\n@Category(InternetConnected.class)\npublic static class InternetTests {\n    @Test\n    public void pingServer() { }\n}\n</code></pre>\n\n<p>To run all of the tests in a particular category, you must currently explicitly create a custom request:</p>\n\n<pre><code>new JUnitCore().run(Request.aClass(SomeUITests.class).inCategories(UserAvailable.class));\n</code></pre>\n\n<p>This feature will very likely be improved before the final release of JUnit 4.5</p>\n\n<h3>Miscellaneous</h3>\n\n<ul>\n<li><p><code>@Before</code> and <code>@After</code> methods are run before and after each set of attempted parameters\non a Theory</p></li>\n<li><p>Refactoring removed duplication that used to exist in classes MethodRoadie and ClassRoadie</p></li>\n<li><p>Exposed API <code>ParameterSignature.getType()</code></p></li>\n</ul>\n\n<h2>Summary of Changes in version 4.4</h2>\n\n<p>JUnit is designed to efficiently capture developers' intentions about\ntheir code, and quickly check their code matches those intentions.\nOver the last year, we've been talking about what things developers\nwould like to say about their code that have been difficult in the\npast, and how we can make them easier.</p>\n\n<p><a href=\"http://sourceforge.net/project/showfiles.php?group_id=15278\">Download</a></p>\n\n<h3>assertThat</h3>\n\n<p>Two years ago, Joe Walnes built a <a href=\"http://joewalnes.com/2005/05/13/flexible-junit-assertions-with-assertthat/\">new assertion mechanism</a> on top of what was \nthen <a href=\"http://www.jmock.org/download.html\">JMock 1</a>.  The method name was <code>assertThat</code>, and the syntax looked like this:</p>\n\n<pre><code>assertThat(x, is(3));\nassertThat(x, is(not(4)));\nassertThat(responseString, either(containsString(\"color\")).or(containsString(\"colour\")));\nassertThat(myList, hasItem(\"3\"));\n</code></pre>\n\n<p>More generally:</p>\n\n<pre><code>assertThat([value], [matcher statement]);\n</code></pre>\n\n<p>Advantages of this assertion syntax include:</p>\n\n<ul>\n<li><p>More readable and typeable: this syntax allows you to think in terms of subject, verb, object\n(assert \"x is 3\") rather than <code>assertEquals</code>, which uses verb, object, subject (assert \"equals 3 x\")</p></li>\n<li><p>Combinations: any matcher statement <code>s</code> can be negated (<code>not(s)</code>), combined (<code>either(s).or(t)</code>),\nmapped to a collection (<code>each(s)</code>), or used in custom combinations (<code>afterFiveSeconds(s)</code>)</p></li>\n<li><p>Readable failure messages.  Compare</p>\n\n<pre><code>assertTrue(responseString.contains(\"color\") || responseString.contains(\"colour\"));\n// ==&gt; failure message: \n// java.lang.AssertionError:\n\n\nassertThat(responseString, anyOf(containsString(\"color\"), containsString(\"colour\")));\n// ==&gt; failure message:\n// java.lang.AssertionError: \n// Expected: (a string containing \"color\" or a string containing \"colour\")\n//      got: \"Please choose a font\"\n</code></pre></li>\n<li><p>Custom Matchers.  By implementing the <code>Matcher</code> interface yourself, you can get all of the\nabove benefits for your own custom assertions.</p></li>\n<li><p>For a more thorough description of these points, see <a href=\"http://joewalnes.com/2005/05/13/flexible-junit-assertions-with-assertthat/\">Joe Walnes's\noriginal post</a>.</p></li>\n</ul>\n\n<p>We have decided to include this API directly in JUnit.\nIt's an extensible and readable syntax, and it enables\nnew features, like <a href=\"#assumptions\">assumptions</a> and <a href=\"#theories\">theories</a>.</p>\n\n<p>Some notes:</p>\n\n<ul>\n<li>The old assert methods are never, ever, going away.  Developers may \ncontinue using the old <code>assertEquals</code>, <code>assertTrue</code>, and so on.</li>\n<li><p>The second parameter of an <code>assertThat</code> statement is a <code>Matcher</code>.\nWe include the Matchers we want as static imports, like this:</p>\n\n<pre><code>import static org.hamcrest.CoreMatchers.is;\n</code></pre>\n\n<p>or:</p>\n\n<pre><code>import static org.hamcrest.CoreMatchers.*;\n</code></pre></li>\n<li><p>Manually importing <code>Matcher</code> methods can be frustrating.  <a href=\"http://www.eclipse.org/downloads/\">Eclipse 3.3</a> includes the ability to \ndefine\n\"Favorite\" classes to import static methods from, which makes it easier \n(Search for \"Favorites\" in the Preferences dialog).\nWe expect that support for static imports will improve in all Java IDEs in the future.</p></li>\n<li><p>To allow compatibility with a wide variety of possible matchers, \nwe have decided to include the classes from hamcrest-core,\nfrom the <a href=\"http://code.google.com/p/hamcrest/\">Hamcrest</a> project.  This is the first time that\nthird-party classes have been included in JUnit.  </p></li>\n<li><p>JUnit currently ships with a few matchers, defined in \n<code>org.hamcrest.CoreMatchers</code> and <code>org.junit.matchers.JUnitMatchers</code>. <br />\nTo use many, many more, consider downloading the <a href=\"http://hamcrest.googlecode.com/files/hamcrest-all-1.1.jar\">full hamcrest package</a>.</p></li>\n<li><p>JUnit contains special support for comparing string and array\nvalues, giving specific information on how they differ.  This is not\nyet available using the <code>assertThat</code> syntax, but we hope to bring\nthe two assert methods into closer alignment in future releases.</p></li>\n</ul>\n\n<p><a name=\"assumptions\" /></p>\n\n<h3>Assumptions</h3>\n\n<p>Ideally, the developer writing a test has control of all of the forces that might cause a test to fail.\nIf this isn't immediately possible, making dependencies explicit can often improve a design. <br />\nFor example, if a test fails when run in a different locale than the developer intended,\nit can be fixed by explicitly passing a locale to the domain code.</p>\n\n<p>However, sometimes this is not desirable or possible. <br />\nIt's good to be able to run a test against the code as it is currently written, \nimplicit assumptions and all, or to write a test that exposes a known bug.\nFor these situations, JUnit now includes the ability to express \"assumptions\":</p>\n\n<pre><code>import static org.junit.Assume.*\n\n@Test public void filenameIncludesUsername() {\n   assumeThat(File.separatorChar, is('/'));\n   assertThat(new User(\"optimus\").configFileName(), is(\"configfiles/optimus.cfg\"));\n}\n\n@Test public void correctBehaviorWhenFilenameIsNull() {\n   assumeTrue(bugFixed(\"13356\"));  // bugFixed is not included in JUnit\n   assertThat(parse(null), is(new NullDocument()));\n}\n</code></pre>\n\n<p>With this release, a failed assumption will lead to the test being marked as passing,\nregardless of what the code below the assumption may assert.\nIn the future, this may change, and a failed assumption may lead to the test being ignored:\nhowever, third-party runners do not currently allow this option.</p>\n\n<p>We have included <code>assumeTrue</code> for convenience, but thanks to the\ninclusion of Hamcrest, we do not need to create <code>assumeEquals</code>,\n<code>assumeSame</code>, and other analogues to the <code>assert*</code> methods.  All of\nthose functionalities are subsumed in <code>assumeThat</code>, with the appropriate\nmatcher.</p>\n\n<p>A failing assumption in a <code>@Before</code> or <code>@BeforeClass</code> method will have the same effect\nas a failing assumption in each <code>@Test</code> method of the class.</p>\n\n<p><a name=\"theories\" /></p>\n\n<h3>Theories</h3>\n\n<p>More flexible and expressive assertions, combined with the ability to\nstate assumptions clearly, lead to a new kind of statement of intent, \nwhich we call a \"Theory\".  A test captures the intended behavior in\none particular scenario.  A theory captures some aspect of the\nintended behavior in possibly\ninfinite numbers of potential scenarios.  For example:</p>\n\n<pre><code>@RunWith(Theories.class)\npublic class UserTest {\n  @DataPoint public static String GOOD_USERNAME = \"optimus\";\n  @DataPoint public static String USERNAME_WITH_SLASH = \"optimus/prime\";\n\n  @Theory public void filenameIncludesUsername(String username) {\n    assumeThat(username, not(containsString(\"/\")));\n    assertThat(new User(username).configFileName(), containsString(username));\n  }\n}\n</code></pre>\n\n<p>This makes it clear that the user's filename should be included in the\nconfig file name, only if it doesn't contain a slash.  Another test\nor theory might define what happens when a username does contain a slash.</p>\n\n<p><code>UserTest</code> will attempt to run <code>filenameIncludesUsername</code> on \nevery compatible <code>DataPoint</code> defined in the class.  If any of the\nassumptions fail, the data point is silently ignored.  If all of the\nassumptions pass, but an assertion fails, the test fails.</p>\n\n<p>The support for Theories has been absorbed from the <a href=\"http://popper.tigris.org\">Popper</a>\nproject, and <a href=\"http://popper.tigris.org/tutorial.html\">more complete documentation</a> can be found\nthere.</p>\n\n<p>Defining general statements in this way can jog the developer's memory\nabout other potential data points and tests, also allows <a href=\"http://www.junitfactory.org\">automated\ntools</a> to <a href=\"http://shareandenjoy.saff.net/2007/04/popper-and-junitfactory.html\">search</a> for new, unexpected data\npoints that expose bugs.</p>\n\n<h3>Other changes</h3>\n\n<p>This release contains other bug fixes and new features.  Among them:</p>\n\n<ul>\n<li><p>Annotated descriptions</p>\n\n<p>Runner UIs, Filters, and Sorters operate on Descriptions of test\nmethods and test classes.  These Descriptions now include the\nannotations on the original Java source element, allowing for richer\ndisplay of test results, and easier development of annotation-based\nfilters.</p></li>\n<li><p>Bug fix (1715326): assertEquals now compares all Numbers using their\nnative implementation of <code>equals</code>.  This assertion, which passed in\n4.3, will now fail:</p>\n\n<pre><code>assertEquals(new Integer(1), new Long(1));\n</code></pre>\n\n<p>Non-integer Numbers (Floats, Doubles, BigDecimals, etc),\nwhich were compared incorrectly in 4.3, are now fixed.</p></li>\n<li><p><code>assertEquals(long, long)</code> and <code>assertEquals(double, double)</code> have\nbeen re-introduced to the <code>Assert</code> class, to take advantage of\nJava's native widening conversions.  Therefore, this still passes:</p>\n\n<pre><code>assertEquals(1, 1L);\n</code></pre></li>\n<li><p>The default runner for JUnit 4 test classes has been refactored.\nThe old version was named <code>TestClassRunner</code>, and the new is named\n<code>JUnit4ClassRunner</code>.  Likewise, <code>OldTestClassRunner</code> is now\n<code>JUnit3ClassRunner</code>.  The new design allows variations in running\nindividual test classes to be expressed with fewer custom classes.\nFor a good example, see the source to\n<code>org.junit.experimental.theories.Theories</code>.</p></li>\n<li><p>The rules for determining which runner is applied by default to a\ntest class have been simplified:</p>\n\n<ol>\n<li><p>If the class has a <code>@RunWith</code> annotation, the annotated runner\nclass is used.</p></li>\n<li><p>If the class can be run with the JUnit 3 test runner (it\nsubclasses <code>TestCase</code>, or contains a <code>public static Test suite()</code>\nmethod), JUnit38ClassRunner is used.</p></li>\n<li><p>Otherwise, JUnit4ClassRunner is used.</p></li>\n</ol>\n\n<p>This default guess can always be overridden by an explicit\n<code>@RunWith(JUnit4ClassRunner.class)</code> or\n<code>@RunWith(JUnit38ClassRunner.class)</code> annotation.</p>\n\n<p>The old class names <code>TestClassRunner</code> and <code>OldTestClassRunner</code>\nremain as deprecated.</p></li>\n<li><p>Bug fix (1739095): Filters and Sorters work correctly on test\nclasses that contain a <code>suite</code> method like:</p>\n\n<pre><code>public static junit.framework.Test suite() {\n  return new JUnit4TestAdapter(MyTest.class);\n}\n</code></pre></li>\n<li><p>Bug fix (1745048): @After methods are now correctly called \nafter a test method times out.</p></li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.4.md",
    "content": "## Summary of Changes in version 4.5 ##\n\n### Categories ###\nEach test method and test class can be annotated as belonging to a _category_:\n\n```java\npublic static class SomeUITests {\n    @Category(UserAvailable.class)\n    @Test\n    public void askUserToPressAKey() { }\n    \n    @Test\n    public void simulatePressingKey() { }\n}\n    \n@Category(InternetConnected.class)\npublic static class InternetTests {\n    @Test\n    public void pingServer() { }\n}\n```\n\nTo run all of the tests in a particular category, you must currently explicitly create a custom request:\n\n```java\nnew JUnitCore().run(Request.aClass(SomeUITests.class).inCategories(UserAvailable.class));\n```\n  \nThis feature will very likely be improved before the final release of JUnit 4.5\n\n### Theories ###\n\n- `@Before` and `@After` methods are run before and after each set of attempted parameters\n  on a Theory, and each set of parameters is run on a new instance of the test class.\n  \n- Exposed API's `ParameterSignature.getType()` and `ParameterSignature.getAnnotations()`\n\n- An array of data points can be introduced by a field or method marked with the new annotation `@DataPoints`\n\n- The Theories custom runner has been refactored to make it easier to extend\n\n### JUnit 4 Runner API ###\n\n- There has been a drastic rewrite of the API for custom Runners in 4.5.  This\n  needs to be written up separately before release.\n  \n- Tests with failed assumptions are now marked as Ignored, rather than silently passing.\n  This may change behavior in some client tests, and also will require some new support \n  on the part of IDE's.\n  \n## Summary of Changes in version 4.4 ##\n\nJUnit is designed to efficiently capture developers' intentions about\ntheir code, and quickly check their code matches those intentions.\nOver the last year, we've been talking about what things developers\nwould like to say about their code that have been difficult in the\npast, and how we can make them easier.\n\n[Download][]\n\n[Download]: http://sourceforge.net/project/showfiles.php?group_id=15278\n\n### assertThat ###\n\nTwo years ago, Joe Walnes built a [new assertion mechanism][walnes] on top of what was \nthen [JMock 1][].  The method name was `assertThat`, and the syntax looked like this:\n\n[walnes]: http://joewalnes.com/2005/05/13/flexible-junit-assertions-with-assertthat/\n[JMock 1]: http://www.jmock.org/download.html\n\n```java\nassertThat(x, is(3));\nassertThat(x, is(not(4)));\nassertThat(responseString, either(containsString(\"color\")).or(containsString(\"colour\")));\nassertThat(myList, hasItem(\"3\"));\n```\n\nMore generally:\n\n```java\nassertThat([value], [matcher statement]);\n```\n\nAdvantages of this assertion syntax include:\n\n- More readable and typeable: this syntax allows you to think in terms of subject, verb, object\n  (assert \"x is 3\") rather than `assertEquals`, which uses verb, object, subject (assert \"equals 3 x\")\n\n- Combinations: any matcher statement `s` can be negated (`not(s)`), combined (`either(s).or(t)`),\n  mapped to a collection (`each(s)`), or used in custom combinations (`afterFiveSeconds(s)`)\n\n- Readable failure messages.  Compare\n\n```java\nassertTrue(responseString.contains(\"color\") || responseString.contains(\"colour\"));\n// ==> failure message: \n// java.lang.AssertionError:\n\nassertThat(responseString, anyOf(containsString(\"color\"), containsString(\"colour\")));\n// ==> failure message:\n// java.lang.AssertionError: \n// Expected: (a string containing \"color\" or a string containing \"colour\")\n//      got: \"Please choose a font\"\n```\n\n- Custom Matchers.  By implementing the `Matcher` interface yourself, you can get all of the\n  above benefits for your own custom assertions.\n\n- For a more thorough description of these points, see [Joe Walnes's\n  original post][walnes].\n\nWe have decided to include this API directly in JUnit.\nIt's an extensible and readable syntax, and it enables\nnew features, like [assumptions][] and [theories][].\n\n[assumptions]: #assumptions\n[theories]: #theories\n\nSome notes:\n\n- The old assert methods are never, ever, going away.  Developers may \n  continue using the old `assertEquals`, `assertTrue`, and so on.\n- The second parameter of an `assertThat` statement is a `Matcher`.\n  We include the Matchers we want as static imports, like this:\n\n```java\nimport static org.hamcrest.CoreMatchers.is;\n```\n\n  or:\n\n```java\nimport static org.hamcrest.CoreMatchers.*;\n```\n\n- Manually importing `Matcher` methods can be frustrating.  [Eclipse 3.3][] includes the ability to \n  define\n  \"Favorite\" classes to import static methods from, which makes it easier \n  (Search for \"Favorites\" in the Preferences dialog).\n  We expect that support for static imports will improve in all Java IDEs in the future.\n\n[Eclipse 3.3]: http://www.eclipse.org/downloads/\n\n- To allow compatibility with a wide variety of possible matchers, \n  we have decided to include the classes from hamcrest-core,\n  from the [Hamcrest][] project.  This is the first time that\n  third-party classes have been included in JUnit.  \n\n[Hamcrest]: http://code.google.com/p/hamcrest/\n\n- JUnit currently ships with a few matchers, defined in \n  `org.hamcrest.CoreMatchers` and `org.junit.matchers.JUnitMatchers`.  \n  To use many, many more, consider downloading the [full hamcrest package][].\n\n[full hamcrest package]: http://hamcrest.googlecode.com/files/hamcrest-all-1.1.jar\n\n- JUnit contains special support for comparing string and array\n  values, giving specific information on how they differ.  This is not\n  yet available using the `assertThat` syntax, but we hope to bring\n  the two assert methods into closer alignment in future releases.\n\n<a name=\"assumptions\" />\n### Assumptions ###\n\nIdeally, the developer writing a test has control of all of the forces that might cause a test to fail.\nIf this isn't immediately possible, making dependencies explicit can often improve a design.  \nFor example, if a test fails when run in a different locale than the developer intended,\nit can be fixed by explicitly passing a locale to the domain code.\n\nHowever, sometimes this is not desirable or possible.  \nIt's good to be able to run a test against the code as it is currently written, \nimplicit assumptions and all, or to write a test that exposes a known bug.\nFor these situations, JUnit now includes the ability to express \"assumptions\":\n\n```java\nimport static org.junit.Assume.*\n\n@Test public void filenameIncludesUsername() {\n    assumeThat(File.separatorChar, is('/'));\n    assertThat(new User(\"optimus\").configFileName(), is(\"configfiles/optimus.cfg\"));\n}\n\n@Test public void correctBehaviorWhenFilenameIsNull() {\n    assumeTrue(bugFixed(\"13356\"));  // bugFixed is not included in JUnit\n    assertThat(parse(null), is(new NullDocument()));\n}\n```\n\nWith this release, a failed assumption will lead to the test being marked as passing,\nregardless of what the code below the assumption may assert.\nIn the future, this may change, and a failed assumption may lead to the test being ignored:\nhowever, third-party runners do not currently allow this option.\n\nWe have included `assumeTrue` for convenience, but thanks to the\ninclusion of Hamcrest, we do not need to create `assumeEquals`,\n`assumeSame`, and other analogues to the `assert*` methods.  All of\nthose functionalities are subsumed in `assumeThat`, with the appropriate\nmatcher.\n\nA failing assumption in a `@Before` or `@BeforeClass` method will have the same effect\nas a failing assumption in each `@Test` method of the class.\n\n<a name=\"theories\" />\n### Theories ###\n\nMore flexible and expressive assertions, combined with the ability to\nstate assumptions clearly, lead to a new kind of statement of intent, \nwhich we call a \"Theory\".  A test captures the intended behavior in\none particular scenario.  A theory captures some aspect of the\nintended behavior in possibly\ninfinite numbers of potential scenarios.  For example:\n\n```java\n@RunWith(Theories.class)\npublic class UserTest {\n    @DataPoint public static String GOOD_USERNAME = \"optimus\";\n    @DataPoint public static String USERNAME_WITH_SLASH = \"optimus/prime\";\n\n    @Theory public void filenameIncludesUsername(String username) {\n        assumeThat(username, not(containsString(\"/\")));\n        assertThat(new User(username).configFileName(), containsString(username));\n    }\n}\n```\n\nThis makes it clear that the user's filename should be included in the\nconfig file name, only if it doesn't contain a slash.  Another test\nor theory might define what happens when a username does contain a slash.\n\n`UserTest` will attempt to run `filenameIncludesUsername` on \nevery compatible `DataPoint` defined in the class.  If any of the\nassumptions fail, the data point is silently ignored.  If all of the\nassumptions pass, but an assertion fails, the test fails.\n\nThe support for Theories has been absorbed from the [Popper][]\nproject, and [more complete documentation][popper-docs] can be found\nthere.\n\n[Popper]: http://popper.tigris.org\n[popper-docs]: http://popper.tigris.org/tutorial.html\n\nDefining general statements in this way can jog the developer's memory\nabout other potential data points and tests, also allows [automated\ntools][junit-factory] to [search][my-blog] for new, unexpected data\npoints that expose bugs.\n\n[junit-factory]: http://www.junitfactory.org\n[my-blog]: http://shareandenjoy.saff.net/2007/04/popper-and-junitfactory.html\n\n### Other changes ###\n\nThis release contains other bug fixes and new features.  Among them:\n\n- Annotated descriptions\n\n  Runner UIs, Filters, and Sorters operate on Descriptions of test\n  methods and test classes.  These Descriptions now include the\n  annotations on the original Java source element, allowing for richer\n  display of test results, and easier development of annotation-based\n  filters.\n\n- Bug fix (1715326): assertEquals now compares all Numbers using their\n  native implementation of `equals`.  This assertion, which passed in\n  4.3, will now fail:\n\n```java\nassertEquals(new Integer(1), new Long(1));\n```\n\n  Non-integer Numbers (Floats, Doubles, BigDecimals, etc),\n  which were compared incorrectly in 4.3, are now fixed.\n\n- `assertEquals(long, long)` and `assertEquals(double, double)` have\n  been re-introduced to the `Assert` class, to take advantage of\n  Java's native widening conversions.  Therefore, this still passes:\n\n```java\nassertEquals(1, 1L);\n```\n\n- The default runner for JUnit 4 test classes has been refactored.\n  The old version was named `TestClassRunner`, and the new is named\n  `JUnit4ClassRunner`.  Likewise, `OldTestClassRunner` is now\n  `JUnit3ClassRunner`.  The new design allows variations in running\n  individual test classes to be expressed with fewer custom classes.\n  For a good example, see the source to\n  `org.junit.experimental.theories.Theories`.\n\n- The rules for determining which runner is applied by default to a\n  test class have been simplified:\n\n  1. If the class has a `@RunWith` annotation, the annotated runner\n     class is used.\n\n  2. If the class can be run with the JUnit 3 test runner (it\n     subclasses `TestCase`, or contains a `public static Test suite()`\n     method), JUnit38ClassRunner is used.\n\n  3. Otherwise, JUnit4ClassRunner is used.\n\n  This default guess can always be overridden by an explicit\n  `@RunWith(JUnit4ClassRunner.class)` or\n  `@RunWith(JUnit38ClassRunner.class)` annotation.\n\n  The old class names `TestClassRunner` and `OldTestClassRunner`\n  remain as deprecated.\n\n- Bug fix (1739095): Filters and Sorters work correctly on test\n  classes that contain a `suite` method like:\n\n```java\npublic static junit.framework.Test suite() {\n    return new JUnit4TestAdapter(MyTest.class);\n}\n```\n\n- Bug fix (1745048): @After methods are now correctly called \n  after a test method times out.\n\n"
  },
  {
    "path": "doc/ReleaseNotes4.4.txt",
    "content": "Please see ReleaseNotes4.4.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.5.html",
    "content": "<h2>Summary of Changes in version 4.5</h2>\n\n<h3>Installation</h3>\n\n<ul>\n<li>We are releasing <code>junit-4.5.jar</code>, which contains all the classes\nnecessary to run JUnit, and <code>junit-dep-4.5.jar</code>, which leaves out\nhamcrest classes, for developers who already use hamcrest outside of\nJUnit.</li>\n</ul>\n\n<h3>Basic JUnit operation</h3>\n\n<ul>\n<li><p>JUnitCore now more often exits with the correct exit code (0 for\nsuccess, 1 for failure)</p></li>\n<li><p>Badly formed test classes (exceptions in constructors, classes\nwithout tests, multiple constructors, Suite without @SuiteClasses)\nproduce more helpful error messages</p></li>\n<li><p>Test classes whose only test methods are inherited from superclasses\nnow run.</p></li>\n<li><p>Optimization to annotation processing can cut JUnit overhead by more than half\non large test classes, especially when using Theories.  [Bug 1796847]</p></li>\n<li><p>A failing assumption in a constructor ignores the class</p></li>\n<li><p>Correct results when comparing the string \"null\" with potentially\nnull values.  [Bug 1857283]</p></li>\n<li><p>Annotating a class with <code>@RunWith(JUnit4.class)</code> will always invoke the\ndefault JUnit 4 runner in the current version of JUnit.  This default changed\nfrom <code>JUnit4ClassRunner</code> in 4.4 to <code>BlockJUnit4ClassRunner</code> in 4.5 (see below),\nand may change again.</p></li>\n</ul>\n\n<h3>Extension</h3>\n\n<ul>\n<li><p><code>BlockJUnit4Runner</code> is a new implementation of the standard JUnit 4\ntest class functionality.  In contrast to <code>JUnit4ClassRunner</code> (the old\nimplementation):</p>\n\n<ul>\n<li><p><code>BlockJUnit4Runner</code> has a much simpler implementation based on\nStatements, allowing new operations to be inserted into the\nappropriate point in the execution flow.</p></li>\n<li><p><code>BlockJUnit4Runner</code> is published, and extension and reuse are\nencouraged, whereas <code>JUnit4ClassRunner</code> was in an internal package,\nand is now deprecated.</p></li>\n</ul></li>\n<li><p><code>ParentRunner</code> is a base class for runners that iterate over\na list of \"children\", each an object representing a test or suite to run.\n<code>ParentRunner</code> provides filtering, sorting, <code>@BeforeClass</code>, <code>@AfterClass</code>,\nand method validation to subclasses.</p></li>\n<li><p><code>TestClass</code> wraps a class to be run, providing efficient, repeated access\nto all methods with a given annotation.</p></li>\n<li><p>The new <code>RunnerBuilder</code> API allows extending the behavior of\nSuite-like custom runners.</p></li>\n<li><p><code>AssumptionViolatedException.toString()</code> is more informative</p></li>\n</ul>\n\n<h3>Extra Runners</h3>\n\n<ul>\n<li><p><code>Parameterized.eachOne()</code> has been removed</p></li>\n<li><p>New runner <code>Enclosed</code> runs all static inner classes of an outer class.</p></li>\n</ul>\n\n<h3>Theories</h3>\n\n<ul>\n<li><p><code>@Before</code> and <code>@After</code> methods are run before and after each set of attempted parameters\non a Theory, and each set of parameters is run on a new instance of the test class.</p></li>\n<li><p>Exposed API's <code>ParameterSignature.getType()</code> and <code>ParameterSignature.getAnnotations()</code></p></li>\n<li><p>An array of data points can be introduced by a field or method\nmarked with the new annotation <code>@DataPoints</code></p></li>\n<li><p>The Theories custom runner has been refactored to make it faster and\neasier to extend</p></li>\n</ul>\n\n<h3>Development</h3>\n\n<ul>\n<li><p>Source has been split into directories <code>src/main/java</code> and\n<code>src/test/java</code>, making it easier to exclude tests from builds, and\nmaking JUnit more maven-friendly</p></li>\n<li><p>Test classes in <code>org.junit.tests</code> have been organized into\nsubpackages, hopefully making finding tests easier.</p></li>\n<li><p><code>ResultMatchers</code> has more informative descriptions.</p></li>\n<li><p><code>TestSystem</code> allows testing return codes and other system-level interactions.</p></li>\n</ul>\n\n<h2>Summary of Changes in version 4.4</h2>\n\n<p>JUnit is designed to efficiently capture developers' intentions about\ntheir code, and quickly check their code matches those intentions.\nOver the last year, we've been talking about what things developers\nwould like to say about their code that have been difficult in the\npast, and how we can make them easier.</p>\n\n<h3>assertThat</h3>\n\n<p>Two years ago, Joe Walnes built a <a href=\"http://joewalnes.com/2005/05/13/flexible-junit-assertions-with-assertthat/\">new assertion mechanism</a> on top of what was \nthen <a href=\"http://www.jmock.org/download.html\">JMock 1</a>.  The method name was <code>assertThat</code>, and the syntax looked like this:</p>\n\n<pre><code>assertThat(x, is(3));\nassertThat(x, is(not(4)));\nassertThat(responseString, either(containsString(\"color\")).or(containsString(\"colour\")));\nassertThat(myList, hasItem(\"3\"));\n</code></pre>\n\n<p>More generally:</p>\n\n<pre><code>assertThat([value], [matcher statement]);\n</code></pre>\n\n<p>Advantages of this assertion syntax include:</p>\n\n<ul>\n<li><p>More readable and typeable: this syntax allows you to think in terms of subject, verb, object\n(assert \"x is 3\") rathern than <code>assertEquals</code>, which uses verb, object, subject (assert \"equals 3 x\")</p></li>\n<li><p>Combinations: any matcher statement <code>s</code> can be negated (<code>not(s)</code>), combined (<code>either(s).or(t)</code>),\nmapped to a collection (<code>each(s)</code>), or used in custom combinations (<code>afterFiveSeconds(s)</code>)</p></li>\n<li><p>Readable failure messages.  Compare</p>\n\n<pre><code>assertTrue(responseString.contains(\"color\") || responseString.contains(\"colour\"));\n// ==&gt; failure message: \n// java.lang.AssertionError:\n\n\nassertThat(responseString, anyOf(containsString(\"color\"), containsString(\"colour\")));\n// ==&gt; failure message:\n// java.lang.AssertionError: \n// Expected: (a string containing \"color\" or a string containing \"colour\")\n//      got: \"Please choose a font\"\n</code></pre></li>\n<li><p>Custom Matchers.  By implementing the <code>Matcher</code> interface yourself, you can get all of the\nabove benefits for your own custom assertions.</p></li>\n<li><p>For a more thorough description of these points, see <a href=\"http://joewalnes.com/2005/05/13/flexible-junit-assertions-with-assertthat/\">Joe Walnes's\noriginal post</a>.:</p></li>\n</ul>\n\n<p>We have decided to include this API directly in JUnit.\nIt's an extensible and readable syntax, and because it enables\nnew features, like <a href=\"#assumptions\">assumptions</a> and <a href=\"#theories\">theories</a>.</p>\n\n<p>Some notes:</p>\n\n<ul>\n<li>The old assert methods are never, ever, going away. <br />\nDevelopers may continue using the old <code>assertEquals</code>, <code>assertTrue</code>, and\nso on.</li>\n<li><p>The second parameter of an <code>assertThat</code> statement is a <code>Matcher</code>.\nWe include the Matchers we want as static imports, like this:</p>\n\n<pre><code>import static org.hamcrest.CoreMatchers.is;\n</code></pre>\n\n<p>or:</p>\n\n<pre><code>import static org.hamcrest.CoreMatchers.*;\n</code></pre></li>\n<li><p>Manually importing <code>Matcher</code> methods can be frustrating.  [Eclipse\n3.3][] includes the ability to \ndefine\n\"Favorite\" classes to import static methods from, which makes it easier \n(Search for \"Favorites\" in the Preferences dialog).\nWe expect that support for static imports will improve in all Java IDEs in the future.</p></li>\n<li><p>To allow compatibility with a wide variety of possible matchers, \nwe have decided to include the classes from hamcrest-core,\nfrom the <a href=\"http://code.google.com/p/hamcrest/\">Hamcrest</a> project.  This is the first time that\nthird-party classes have been included in JUnit.  </p></li>\n<li><p>To allow developers to maintain full control of the classpath contents, the JUnit distribution also provides an unbundled junit-dep jar,\nie without hamcrest-core classes included.  This is intended for situations when using other libraries that also depend on hamcrest-core, to\navoid classloading conflicts or issues.  Developers using junit-dep should ensure a compatible version of hamcrest-core jar (ie 1.1+) is present in the classpath.</p></li>\n<li><p>JUnit currently ships with a few matchers, defined in \n<code>org.hamcrest.CoreMatchers</code> and <code>org.junit.matchers.JUnitMatchers</code>. <br />\nTo use many, many more, consider downloading the <a href=\"http://hamcrest.googlecode.com/files/hamcrest-all-1.1.jar\">full hamcrest package</a>.</p></li>\n<li><p>JUnit contains special support for comparing string and array\nvalues, giving specific information on how they differ.  This is not\nyet available using the <code>assertThat</code> syntax, but we hope to bring\nthe two assert methods into closer alignment in future releases.</p></li>\n</ul>\n\n<h3>assumeThat</h3>\n\n<p><a name=\"assumptions\" />\nIdeally, the developer writing a test has control of all of the forces that might cause a test to fail.\nIf this isn't immediately possible, making dependencies explicit can often improve a design. <br />\nFor example, if a test fails when run in a different locale than the developer intended,\nit can be fixed by explicitly passing a locale to the domain code.</p>\n\n<p>However, sometimes this is not desirable or possible. <br />\nIt's good to be able to run a test against the code as it is currently written, \nimplicit assumptions and all, or to write a test that exposes a known bug.\nFor these situations, JUnit now includes the ability to express \"assumptions\":</p>\n\n<pre><code>import static org.junit.Assume.*\n\n@Test public void filenameIncludesUsername() {\n   assumeThat(File.separatorChar, is('/'));\n   assertThat(new User(\"optimus\").configFileName(), is(\"configfiles/optimus.cfg\"));\n}\n\n@Test public void correctBehaviorWhenFilenameIsNull() {\n   assumeTrue(bugFixed(\"13356\"));  // bugFixed is not included in JUnit\n   assertThat(parse(null), is(new NullDocument()));\n}\n</code></pre>\n\n<p>With this beta release, a failed assumption will lead to the test being marked as passing,\nregardless of what the code below the assumption may assert.\nIn the future, this may change, and a failed assumption may lead to the test being ignored:\nhowever, third-party runners do not currently allow this option.</p>\n\n<p>We have included <code>assumeTrue</code> for convenience, but thanks to the\ninclusion of Hamcrest, we do not need to create <code>assumeEquals</code>,\n<code>assumeSame</code>, and other analogues to the <code>assert*</code> methods.  All of\nthose functionalities are subsumed in assumeThat, with the appropriate\nmatcher.</p>\n\n<p>A failing assumption in a <code>@Before</code> or <code>@BeforeClass</code> method will have the same effect\nas a failing assumption in each <code>@Test</code> method of the class.</p>\n\n<h3>Theories</h3>\n\n<p><a name=\"theories\" />\nMore flexible and expressive assertions, combined with the ability to\nstate assumptions clearly, lead to a new kind of statement of intent, \nwhich we call a \"Theory\".  A test captures the intended behavior in\none particular scenario.  A theory allows a developer to be\nas precise as desired about the behavior of the code in possibly\ninfinite numbers of possible scenarios.  For example:</p>\n\n<pre><code>@RunWith(Theories.class)\npublic class UserTest {\n  @DataPoint public static String GOOD_USERNAME = \"optimus\";\n  @DataPoint public static String USERNAME_WITH_SLASH = \"optimus/prime\";\n\n  @Theory public void filenameIncludesUsername(String username) {\n    assumeThat(username, not(containsString(\"/\")));\n    assertThat(new User(username).configFileName(), containsString(username));\n  }\n}\n</code></pre>\n\n<p>This makes it clear that the user's filename should be included in the\nconfig file name, only if it doesn't contain a slash.  Another test\nor theory might define what happens when a username does contain a slash.</p>\n\n<p><code>UserTest</code> will attempt to run <code>filenameIncludesUsername</code> on \nevery compatible <code>DataPoint</code> defined in the class.  If any of the\nassumptions fail, the data point is silently ignored.  If all of the\nassumptions pass, but an assertion fails, the test fails.</p>\n\n<p>The support for Theories has been absorbed from the <a href=\"http://popper.tigris.org\">Popper</a>\nproject, and <a href=\"http://popper.tigris.org/tutorial.html\">more complete documentation</a> can be found\nthere.</p>\n\n<p>Defining general statements in this way can jog the developer's memory\nabout other potential data points and tests, also allows <a href=\"http://www.junitfactory.org\">automated\ntools</a> to <a href=\"http://shareandenjoy.saff.net/2007/04/popper-and-junitfactory.html\">search</a> for new, unexpected data\npoints that expose bugs.</p>\n\n<h3>Other changes</h3>\n\n<p>This release contains other bug fixes and new features.  Among them:</p>\n\n<ul>\n<li><p>Annotated descriptions</p>\n\n<p>Runner UIs, Filters, and Sorters operate on Descriptions of test\nmethods and test classes.  These Descriptions now include the\nannotations on the original Java source element, allowing for richer\ndisplay of test results, and easier development of annotation-based\nfilters.</p></li>\n<li><p>Bug fix (1715326): assertEquals now compares all Numbers using their\nnative implementation of <code>equals</code>.  This assertion, which passed in\n4.3, will now fail:</p>\n\n<p>assertEquals(new Integer(1), new Long(1));</p>\n\n<p>Non-integer Numbers (Floats, Doubles, BigDecimals, etc),\nwhich were compared incorrectly in 4.3, are now fixed.</p></li>\n<li><p><code>assertEquals(long, long)</code> and <code>assertEquals(double, double)</code> have\nbeen re-introduced to the <code>Assert</code> class, to take advantage of\nJava's native widening conversions.  Therefore, this still passes:</p>\n\n<p>assertEquals(1, 1L);</p></li>\n<li><p>The default runner for JUnit 4 test classes has been refactored.\nThe old version was named <code>TestClassRunner</code>, and the new is named\n<code>JUnit4ClassRunner</code>.  Likewise, <code>OldTestClassRunner</code> is now\n<code>JUnit3ClassRunner</code>.  The new design allows variations in running\nindividual test classes to be expressed with fewer custom classes.\nFor a good example, see the source to\n<code>org.junit.experimental.theories.Theories</code>.</p></li>\n<li><p>The rules for determining which runner is applied by default to a\ntest class have been simplified:</p>\n\n<ol>\n<li><p>If the class has a <code>@RunWith</code> annotation, the annotated runner\nclass is used.</p></li>\n<li><p>If the class can be run with the JUnit 3 test runner (it\nsubclasses <code>TestCase</code>, or contains a <code>public static Test suite()</code>\nmethod), JUnit38ClassRunner is used.</p></li>\n<li><p>Otherwise, JUnit4ClassRunner is used.</p></li>\n</ol>\n\n<p>This default guess can always be overridden by an explicit\n<code>@RunWith(JUnit4ClassRunner.class)</code> or\n<code>@RunWith(JUnit38ClassRunner.class)</code> annotation.</p>\n\n<p>The old class names <code>TestClassRunner</code> and <code>OldTestClassRunner</code>\nremain as deprecated.</p></li>\n<li><p>Bug fix (1739095): Filters and Sorters work correctly on test\nclasses that contain a <code>suite</code> method like:</p>\n\n<p>public static junit.framework.Test suite() {\n  return new JUnit4TestAdapter(MyTest.class);\n}</p></li>\n<li><p>Bug fix (1745048): @After methods are now correctly called \nafter a test method times out.</p></li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.5.md",
    "content": "## Summary of Changes in version 4.5 ##\n\n### Installation ###\n\n- We are releasing `junit-4.5.jar`, which contains all the classes\n  necessary to run JUnit, and `junit-dep-4.5.jar`, which leaves out\n  hamcrest classes, for developers who already use hamcrest outside of\n  JUnit.\n\n### Basic JUnit operation ###\n\n- JUnitCore now more often exits with the correct exit code (0 for\n  success, 1 for failure)\n\n- Badly formed test classes (exceptions in constructors, classes\n  without tests, multiple constructors, Suite without @SuiteClasses)\n  produce more helpful error messages\n\n- Test classes whose only test methods are inherited from superclasses\n  now run.\n\n- Optimization to annotation processing can cut JUnit overhead by more than half\n  on large test classes, especially when using Theories.  [Bug 1796847]\n\n- A failing assumption in a constructor ignores the class\n\n- Correct results when comparing the string \"null\" with potentially\n  null values.  [Bug 1857283]\n\n- Annotating a class with `@RunWith(JUnit4.class)` will always invoke the\n  default JUnit 4 runner in the current version of JUnit.  This default changed\n  from `JUnit4ClassRunner` in 4.4 to `BlockJUnit4ClassRunner` in 4.5 (see below),\n  and may change again.\n\n### Extension ###\n\n- `BlockJUnit4Runner` is a new implementation of the standard JUnit 4\n  test class functionality.  In contrast to `JUnit4ClassRunner` (the old\n  implementation):\n\n  - `BlockJUnit4Runner` has a much simpler implementation based on\n    Statements, allowing new operations to be inserted into the\n    appropriate point in the execution flow.\n\n  - `BlockJUnit4Runner` is published, and extension and reuse are\n    encouraged, whereas `JUnit4ClassRunner` was in an internal package,\n    and is now deprecated.\n\n- `ParentRunner` is a base class for runners that iterate over\n  a list of \"children\", each an object representing a test or suite to run.\n  `ParentRunner` provides filtering, sorting, `@BeforeClass`, `@AfterClass`,\n  and method validation to subclasses.\n\n- `TestClass` wraps a class to be run, providing efficient, repeated access\n  to all methods with a given annotation.\n\n- The new `RunnerBuilder` API allows extending the behavior of\n  Suite-like custom runners.\n\n- `AssumptionViolatedException.toString()` is more informative\n\n### Extra Runners ###\n\n- `Parameterized.eachOne()` has been removed\n\n- New runner `Enclosed` runs all static inner classes of an outer class.\n\n### Theories ###\n\n- `@Before` and `@After` methods are run before and after each set of attempted parameters\n  on a Theory, and each set of parameters is run on a new instance of the test class.\n  \n- Exposed API's `ParameterSignature.getType()` and `ParameterSignature.getAnnotations()`\n\n- An array of data points can be introduced by a field or method\n  marked with the new annotation `@DataPoints`\n\n- The Theories custom runner has been refactored to make it faster and\n  easier to extend\n\n### Development ###\n\n- Source has been split into directories `src/main/java` and\n  `src/test/java`, making it easier to exclude tests from builds, and\n  making JUnit more maven-friendly\n\n- Test classes in `org.junit.tests` have been organized into\n  subpackages, hopefully making finding tests easier.\n\n- `ResultMatchers` has more informative descriptions.\n\n- `TestSystem` allows testing return codes and other system-level interactions.\n\n### Incompatible changes ###\n\n- Removed Request.classes(String, Class<?>...) factory method\n"
  },
  {
    "path": "doc/ReleaseNotes4.5.txt",
    "content": "Please see ReleaseNotes4.5.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.6.html",
    "content": "<h2>Summary of Changes in version 4.6</h2>\n\n<h3>Max</h3>\n\n<p>JUnit now includes a new experimental Core, <code>MaxCore</code>.  <code>MaxCore</code>\nremembers the results of previous test runs in order to run new\ntests out of order.  <code>MaxCore</code> prefers new tests to old tests, fast\ntests to slow tests, and recently failing tests to tests that last\nfailed long ago.  There's currently not a standard UI for running\n<code>MaxCore</code> included in JUnit, but there is a UI included in the JUnit\nMax Eclipse plug-in at:</p>\n\n<p>http://www.junitmax.com/junitmax/subscribe.html</p>\n\n<p>Example:</p>\n\n<pre><code>public static class TwoUnEqualTests {\n    @Test\n    public void slow() throws InterruptedException {\n        Thread.sleep(100);\n        fail();\n    }\n\n    @Test\n    public void fast() {\n        fail();\n    }\n}\n\n@Test\npublic void rememberOldRuns() {\n    File maxFile = new File(\"history.max\");\n    MaxCore firstMax = MaxCore.storedLocally(maxFile);\n    firstMax.run(TwoUnEqualTests.class);\n\n    MaxCore useHistory= MaxCore.storedLocally(maxFile);\n    List&lt;Failure&gt; failures= useHistory.run(TwoUnEqualTests.class)\n            .getFailures();\n    assertEquals(\"fast\", failures.get(0).getDescription().getMethodName());\n    assertEquals(\"slow\", failures.get(1).getDescription().getMethodName());\n}\n</code></pre>\n\n<h3>Test scheduling strategies</h3>\n\n<p><code>JUnitCore</code> now includes an experimental method that allows you to\nspecify a model of the <code>Computer</code> that runs your tests.  Currently,\nthe only built-in Computers are the default, serial runner, and two\nrunners provided in the <code>ParallelRunner</code> class:\n<code>ParallelRunner.classes()</code>, which runs classes in parallel, and\n<code>ParallelRunner.methods()</code>, which runs classes and methods in parallel.</p>\n\n<p>This feature is currently less stable than MaxCore, and may be\nmerged with MaxCore in some way in the future.</p>\n\n<p>Example:</p>\n\n<pre><code>public static class Example {\n    @Test public void one() throws InterruptedException {\n        Thread.sleep(1000);\n    }\n    @Test public void two() throws InterruptedException {\n        Thread.sleep(1000);\n    }\n}\n\n@Test public void testsRunInParallel() {\n    long start= System.currentTimeMillis();\n    Result result= JUnitCore.runClasses(ParallelComputer.methods(),\n            Example.class);\n    assertTrue(result.wasSuccessful());\n    long end= System.currentTimeMillis();\n    assertThat(end - start, betweenInclusive(1000, 1500));\n}\n</code></pre>\n\n<h3>Comparing double arrays</h3>\n\n<p>Arrays of doubles can be compared, using a delta allowance for equality:</p>\n\n<pre><code>@Test\npublic void doubleArraysAreEqual() {\n    assertArrayEquals(new double[] {1.0, 2.0}, new double[] {1.0, 2.0}, 0.01);\n}\n</code></pre>\n\n<h3><code>Filter.matchDescription</code> API</h3>\n\n<p>Since 4.0, it has been possible to run a single method using the <code>Request.method</code> \nAPI.  In 4.6, the filter that implements this is exposed as <code>Filter.matchDescription</code>.</p>\n\n<h3>Documentation</h3>\n\n<ul>\n<li><p>A couple classes and packages that once had empty javadoc have been\ndoc'ed.</p></li>\n<li><p>Added how to run JUnit from the command line to the cookbook.</p></li>\n<li><p>junit-4.x.zip now contains build.xml</p></li>\n</ul>\n\n<h3>Bug fixes</h3>\n\n<ul>\n<li>Fixed overly permissive @DataPoint processing (2191102)</li>\n<li>Fixed bug in test counting after an ignored method (2106324)</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.6.md",
    "content": "## Summary of Changes in version 4.6 ##\n\n### Max ###\n\nJUnit now includes a new experimental Core, `MaxCore`.  `MaxCore`\nremembers the results of previous test runs in order to run new\ntests out of order.  `MaxCore` prefers new tests to old tests, fast\ntests to slow tests, and recently failing tests to tests that last\nfailed long ago.  There's currently not a standard UI for running\n`MaxCore` included in JUnit, but there is a UI included in the JUnit\nMax Eclipse plug-in at:\n\n  http://www.junitmax.com/junitmax/subscribe.html\n\nExample:\n\n```java\npublic static class TwoUnEqualTests {\n\t@Test\n\tpublic void slow() throws InterruptedException {\n\t\tThread.sleep(100);\n\t\tfail();\n\t}\n\n\t@Test\n\tpublic void fast() {\n\t\tfail();\n\t}\n}\n\n@Test\npublic void rememberOldRuns() {\n\tFile maxFile = new File(\"history.max\");\n\tMaxCore firstMax = MaxCore.storedLocally(maxFile);\n\tfirstMax.run(TwoUnEqualTests.class);\n\n\tMaxCore useHistory= MaxCore.storedLocally(maxFile);\n\tList<Failure> failures= useHistory.run(TwoUnEqualTests.class)\n\t\t.getFailures();\n\tassertEquals(\"fast\", failures.get(0).getDescription().getMethodName());\n\tassertEquals(\"slow\", failures.get(1).getDescription().getMethodName());\n}\n```\n\n### Test scheduling strategies ###\n\n`JUnitCore` now includes an experimental method that allows you to\nspecify a model of the `Computer` that runs your tests.  Currently,\nthe only built-in Computers are the default, serial runner, and two\nrunners provided in the `ParallelRunner` class:\n`ParallelRunner.classes()`, which runs classes in parallel, and\n`ParallelRunner.methods()`, which runs classes and methods in parallel.\n\nThis feature is currently less stable than MaxCore, and may be\nmerged with MaxCore in some way in the future.\n\nExample:\n\n```java\npublic static class Example {\n\t@Test public void one() throws InterruptedException {\n\t\tThread.sleep(1000);\n\t}\n\t@Test public void two() throws InterruptedException {\n\t\tThread.sleep(1000);\n\t}\n}\n\t\n@Test public void testsRunInParallel() {\n\tlong start= System.currentTimeMillis();\n\tResult result= JUnitCore.runClasses(ParallelComputer.methods(),\n\t\t\tExample.class);\n\tassertTrue(result.wasSuccessful());\n\tlong end= System.currentTimeMillis();\n\tassertThat(end - start, betweenInclusive(1000, 1500));\n}\n```\n\n### Comparing double arrays ###\n\nArrays of doubles can be compared, using a delta allowance for equality:\n\n```java\n@Test\npublic void doubleArraysAreEqual() {\n\tassertArrayEquals(new double[] {1.0, 2.0}, new double[] {1.0, 2.0}, 0.01);\n}\n```\n\t\n### `Filter.matchDescription` API ###\n\nSince 4.0, it has been possible to run a single method using the `Request.method` \nAPI.  In 4.6, the filter that implements this is exposed as `Filter.matchDescription`.\n\n### Documentation ###\n\n- A couple classes and packages that once had empty javadoc have been\n  doc'ed.\n  \n- Added how to run JUnit from the command line to the cookbook.\n\n- junit-4.x.zip now contains build.xml\n\n### Bug fixes ###\n- Fixed overly permissive @DataPoint processing (2191102)\n- Fixed bug in test counting after an ignored method (2106324)\n"
  },
  {
    "path": "doc/ReleaseNotes4.6.txt",
    "content": "Please see ReleaseNotes4.6.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.7.html",
    "content": "<h2>Summary of Changes in version 4.7</h2>\n\n<h3>Rules</h3>\n\n<ul>\n<li><p>Rules allow very flexible addition or redefinition of the behavior\nof each test method in a test class.  Testers can reuse or extend one of the \nprovided Rules below, or write their own.</p>\n\n<p>For more on this feature, see http://www.threeriversinstitute.org/blog/?p=155</p></li>\n<li><p>The TemporaryFolder Rule allows creation of files and folders\nthat are guaranteed to be deleted when the test method finishes\n(whether it passes or fails):</p>\n\n<p>public static class HasTempFolder {\n    @Rule\n    public TemporaryFolder folder= new TemporaryFolder();</p>\n\n<pre><code>@Test\npublic void testUsingTempFolder() throws IOException {\n    File createdFile= folder.newFile(\"myfile.txt\");\n    File createdFolder= folder.newFolder(\"subfolder\");\n    // ...\n}\n</code></pre>\n\n<p>}</p></li>\n<li><p>ExternalResource is a base class for Rules (like TemporaryFolder)\nthat set up an external resource before a test (a file, socket, server,\ndatabase connection, etc.), and guarantee to tear it down afterward:</p>\n\n<p>public static class UsesExternalResource {\n    Server myServer = new Server();</p>\n\n<pre><code>@Rule public ExternalResource resource = new ExternalResource() {\n    @Override\n    protected void before() throws Throwable {\n        myServer.connect();\n    };\n\n\n<pre><code>@Override\nprotected void after() {\n    myServer.disconnect();\n};\n</code></pre>\n\n};\n\n\n@Test public void testFoo() {\n    new Client().run(myServer);\n}\n</code></pre>\n\n<p>}</p></li>\n<li><p>The ErrorCollector Rule allows execution of a test to continue\nafter the first problem is found (for example, to collect <em>all</em> the \nincorrect rows in a table, and report them all at once):</p>\n\n<p>public static class UsesErrorCollectorTwice {\n    @Rule\n    public ErrorCollector collector= new ErrorCollector();</p>\n\n<pre><code>@Test public void example() {\n    collector.addError(new Throwable(\"first thing went wrong\"));\n    collector.addError(new Throwable(\"second thing went wrong\"));\n}\n</code></pre>\n\n<p>}</p></li>\n<li><p>Verifier is a base class for Rules like ErrorCollector, which\ncan turn otherwise passing test methods into failing tests if a verification\ncheck is failed</p>\n\n<p>public static class ErrorLogVerifier() {\n   private ErrorLog errorLog = new ErrorLog();</p>\n\n<p>@Rule\n   public MethodRule verifier = new Verifier() {\n      @Override public void verify() {\n         assertTrue(errorLog.isEmpty());\n      }\n   }</p>\n\n<p>@Test public void testThatMightWriteErrorLog() {\n      // ...\n   }\n}</p></li>\n<li><p>TestWatchman is a base class for Rules that take note\nof the testing action, without modifying it.\nFor example, this class will keep a log of each passing and failing \ntest:</p>\n\n<p>public static class WatchmanTest {\n    private static String watchedLog;</p>\n\n<pre><code>@Rule\npublic MethodRule watchman= new TestWatchman() {\n    @Override\n    public void failed(Throwable e, FrameworkMethod method) {\n        watchedLog+= method.getName() + \" \"\n                + e.getClass().getSimpleName() + \"\\n\";\n    }\n\n\n<pre><code>@Override\npublic void succeeded(FrameworkMethod method) {\n    watchedLog+= method.getName() + \" \" + \"success!\\n\";\n}\n</code></pre>\n\n};\n\n\n@Test\npublic void fails() {\n    fail();\n}\n\n\n@Test\npublic void succeeds() {\n}\n</code></pre>\n\n<p>}</p></li>\n<li><p>The TestName Rule makes the current test name available inside test methods:</p>\n\n<p>public class NameRuleTest {\n    @Rule public TestName name = new TestName();</p>\n\n<pre><code>@Test public void testA() {\n    assertEquals(\"testA\", name.getMethodName());\n}\n\n\n@Test public void testB() {\n    assertEquals(\"testB\", name.getMethodName());\n}\n</code></pre>\n\n<p>}</p></li>\n<li><p>The Timeout Rule applies the same timeout to all test methods in a class:</p>\n\n<p>public static class HasGlobalTimeout {\n    public static String log;</p>\n\n<pre><code>@Rule public MethodRule globalTimeout = new Timeout(20);\n\n\n@Test public void testInfiniteLoop1() {\n    log+= \"ran1\";\n    for(;;) {}\n}\n\n\n@Test public void testInfiniteLoop2() {\n    log+= \"ran2\";\n    for(;;) {}\n}\n</code></pre>\n\n<p>}</p></li>\n<li><p>The ExpectedException Rule allows in-test specification\nof expected exception types and messages:</p>\n\n<p>public static class HasExpectedException {\n    @Rule\n    public ExpectedException thrown= ExpectedException.none();</p>\n\n<pre><code>@Test\npublic void throwsNothing() {\n\n\n}\n\n\n@Test\npublic void throwsNullPointerException() {\n    thrown.expect(NullPointerException.class);\n    throw new NullPointerException();\n}\n\n\n@Test\npublic void throwsNullPointerExceptionWithMessage() {\n    thrown.expect(NullPointerException.class);\n    thrown.expectMessage(\"happened?\");\n    thrown.expectMessage(startsWith(\"What\"));\n    throw new NullPointerException(\"What happened?\");\n}\n</code></pre>\n\n<p>}</p></li>\n</ul>\n\n<h3>Timeouts</h3>\n\n<ul>\n<li>Tests that time out now show the stack trace of the test thread.</li>\n</ul>\n\n<h3>Matchers</h3>\n\n<ul>\n<li>Due to typing incompatibilities, JUnit is still including the 1.1 release\nof hamcrest.  This is not a change from 4.6, but is a change from\npre-beta releases of 4.7.  Due to this incompatibility, tests using\nHamcrest 1.2 must still use the MatcherAssert.assertThat method from \nHamcrest, not Assert.assertThat from JUnit.</li>\n</ul>\n\n<h3>Docs</h3>\n\n<ul>\n<li>Javadocs now link to online JDK javadocs (bug 2090230)</li>\n<li>Parameterized runner javadocs improved (bug 2186792)</li>\n<li>Fixed Javadoc code sample for AfterClass (2126279)</li>\n<li>Fixed Javadoc for assertArraysEqual(float[], float[])</li>\n</ul>\n\n<h3>Bug fixes</h3>\n\n<ul>\n<li>Fixed: BaseTestRunner.getTest() requires class to extend TestCase (1812200)</li>\n<li>Fixed: Suite does not allow for inheritance in annotations (2783118)</li>\n<li>Fixed: ParallelComputer skipped tests that took longer than 2 seconds</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.7.md",
    "content": "## Summary of Changes in version 4.7 ##\n\n### Rules ###\n\n- Rules allow very flexible addition or redefinition of the behavior\n  of each test method in a test class.  Testers can reuse or extend one of the \n  provided Rules below, or write their own.\n \n  For more on this feature, see http://www.threeriversinstitute.org/blog/?p=155\n \n- The TemporaryFolder Rule allows creation of files and folders\n  that are guaranteed to be deleted when the test method finishes\n  (whether it passes or fails):\n  \n```java\npublic static class HasTempFolder {\n\t@Rule\n\tpublic TemporaryFolder folder= new TemporaryFolder();\n\n\t@Test\n\tpublic void testUsingTempFolder() throws IOException {\n\t\tFile createdFile= folder.newFile(\"myfile.txt\");\n\t\tFile createdFolder= folder.newFolder(\"subfolder\");\n\t\t// ...\n\t}\n}\n```\n\n- ExternalResource is a base class for Rules (like TemporaryFolder)\n  that set up an external resource before a test (a file, socket, server,\n  database connection, etc.), and guarantee to tear it down afterward:\n  \n```java\npublic static class UsesExternalResource {\n\tServer myServer = new Server();\n  \t\t\n\t@Rule public ExternalResource resource = new ExternalResource() {\n\t\t@Override\n\t\tprotected void before() throws Throwable {\n\t\t\tmyServer.connect();\n\t\t}\n\t\t\t\n\t\t@Override\n\t\tprotected void after() {\n\t\t\tmyServer.disconnect();\n\t\t}\n\t};\n\t\t\n\t@Test public void testFoo() {\n\t\tnew Client().run(myServer);\n\t}\n}\n```\n\n- The ErrorCollector Rule allows execution of a test to continue\n  after the first problem is found (for example, to collect _all_ the \n  incorrect rows in a table, and report them all at once):\n\n```java\npublic static class UsesErrorCollectorTwice {\n\t@Rule\n\tpublic ErrorCollector collector= new ErrorCollector();\n\t\t\n\t@Test public void example() {\n\t\tcollector.addError(new Throwable(\"first thing went wrong\"));\n\t\tcollector.addError(new Throwable(\"second thing went wrong\"));\n\t}\n}\n```\n\t\n- Verifier is a base class for Rules like ErrorCollector, which\n  can turn otherwise passing test methods into failing tests if a verification\n  check is failed\n  \n```java\npublic static class ErrorLogVerifier() {\n\tprivate ErrorLog errorLog = new ErrorLog();\n    \n\t@Rule\n\tpublic MethodRule verifier = new Verifier() {\n\t\t@Override public void verify() {\n\t\t\tassertTrue(errorLog.isEmpty());\n\t\t}\n\t}\n       \n\t@Test public void testThatMightWriteErrorLog() {\n\t\t// ...\n\t}\n}\n```\n\n- TestWatchman is a base class for Rules that take note\n  of the testing action, without modifying it.\n  For example, this class will keep a log of each passing and failing \n  test:\n  \n```java\npublic static class WatchmanTest {\n\tprivate static String watchedLog;\n\n\t@Rule\n\tpublic MethodRule watchman= new TestWatchman() {\n\t\t@Override\n\t\tpublic void failed(Throwable e, FrameworkMethod method) {\n\t\t\twatchedLog+= method.getName() + \" \"\n\t\t\t\t\t+ e.getClass().getSimpleName() + \"\\n\";\n\t\t}\n\n\t\t@Override\n\t\tpublic void succeeded(FrameworkMethod method) {\n\t\t\twatchedLog+= method.getName() + \" \" + \"success!\\n\";\n\t\t}\n\t};\n\n\t@Test\n\tpublic void fails() {\n\t\tfail();\n\t}\n\n\t@Test\n\tpublic void succeeds() {\n\t}\n}\n```\n\n- The TestName Rule makes the current test name available inside test methods:\n\n```java\npublic class NameRuleTest {\n\t@Rule public TestName name = new TestName();\n\t\t\n\t@Test public void testA() {\n\t\tassertEquals(\"testA\", name.getMethodName());\n\t}\n\t\t\n\t@Test public void testB() {\n\t\tassertEquals(\"testB\", name.getMethodName());\n\t}\n}\n```\n\n- The Timeout Rule applies the same timeout to all test methods in a class:\n\n```java\npublic static class HasGlobalTimeout {\n\tpublic static String log;\n\t\t\n\t@Rule public MethodRule globalTimeout = new Timeout(20);\n\t\t\n\t@Test public void testInfiniteLoop1() {\n\t\tlog+= \"ran1\";\n\t\tfor(;;) {}\n\t}\n\t\t\n\t@Test public void testInfiniteLoop2() {\n\t\tlog+= \"ran2\";\n\t\tfor(;;) {}\n\t}\n}\n```\n\n- The ExpectedException Rule allows in-test specification\n  of expected exception types and messages:\n   \n```java \npublic static class HasExpectedException {\n\t@Rule\n\tpublic ExpectedException thrown= ExpectedException.none();\n\n\t@Test\n\tpublic void throwsNothing() {\n\n\t}\n\n\t@Test\n\tpublic void throwsNullPointerException() {\n\t\tthrown.expect(NullPointerException.class);\n\t\tthrow new NullPointerException();\n\t}\n\n\t@Test\n\tpublic void throwsNullPointerExceptionWithMessage() {\n\t\tthrown.expect(NullPointerException.class);\n\t\tthrown.expectMessage(\"happened?\");\n\t\tthrown.expectMessage(startsWith(\"What\"));\n\t\tthrow new NullPointerException(\"What happened?\");\n\t}\n}\n```\n\n### Timeouts ###\n- Tests that time out now show the stack trace of the test thread.\n\n### Matchers ###\n- Due to typing incompatibilities, JUnit is still including the 1.1 release\n  of hamcrest.  This is not a change from 4.6, but is a change from\n  pre-beta releases of 4.7.  Due to this incompatibility, tests using\n  Hamcrest 1.2 must still use the MatcherAssert.assertThat method from \n  Hamcrest, not Assert.assertThat from JUnit.\n  \n### Docs ###\n- Javadocs now link to online JDK javadocs (bug 2090230)\n- Parameterized runner javadocs improved (bug 2186792)\n- Fixed Javadoc code sample for AfterClass (2126279)\n- Fixed Javadoc for assertArraysEqual(float[], float[])\n\n### Bug fixes ###\n- Fixed: BaseTestRunner.getTest() requires class to extend TestCase (1812200)\n- Fixed: Suite does not allow for inheritance in annotations (2783118)\n- Fixed: ParallelComputer skipped tests that took longer than 2 seconds\n"
  },
  {
    "path": "doc/ReleaseNotes4.7.txt",
    "content": "Please see ReleaseNotes4.7.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.1.html",
    "content": "<h2>Summary of Changes in version 4.8.1</h2>\n\n<p>This was a quick bugfix release for an important bug</p>\n\n<h3>Bug fixes</h3>\n\n<ul>\n<li>github#61: Category annotations on classes were not honored.</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.1.md",
    "content": "## Summary of Changes in version 4.8.1 ##\n\nThis was a quick bugfix release for an important bug\n\n### Bug fixes ###\n\n- github#61: Category annotations on classes were not honored."
  },
  {
    "path": "doc/ReleaseNotes4.8.1.txt",
    "content": "Please see ReleaseNotes4.8.1.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.2.html",
    "content": "<h2>Summary of Changes in version 4.8.2</h2>\n\n<p>This was a quick bugfix release</p>\n\n<h3>Bug fixes</h3>\n\n<ul>\n<li>github#96: TestSuite(MyTestCase.class) should dynamically detect if MyTestCase\nis a TestCase</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.2.md",
    "content": "## Summary of Changes in version 4.8.2 ##\n\nThis was a quick bugfix release\n\n### Bug fixes ###\n\n- github#96: TestSuite(MyTestCase.class) should dynamically detect if MyTestCase\n  is a TestCase\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.2.txt",
    "content": "Please see ReleaseNotes4.8.2.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.html",
    "content": "<h2>Summary of Changes in version 4.8</h2>\n\n<h3>Categories</h3>\n\n<p>From a given set of test classes, the <code>Categories</code> runner\nruns only the classes and methods\nthat are annotated with either the category given with the <code>@IncludeCategory</code>\nannotation, or a subtype of that category. Either classes or interfaces can be\nused as categories. Subtyping works, so if you say <code>@IncludeCategory(SuperClass.class)</code>,\na test marked <code>@Category({SubClass.class})</code> will be run.</p>\n\n<p>You can also exclude categories by using the <code>@ExcludeCategory</code> annotation</p>\n\n<p>Example:</p>\n\n<pre><code>public interface FastTests { /* category marker */ }\npublic interface SlowTests { /* category marker */ }\n\npublic class A {\n    @Test\n    public void a() {\n        fail();\n    }\n\n    @Category(SlowTests.class)\n    @Test\n    public void b() {\n    }\n}\n\n@Category({SlowTests.class, FastTests.class})\npublic class B {\n    @Test\n    public void c() {\n\n    }\n}\n\n@RunWith(Categories.class)\n@IncludeCategory(SlowTests.class)\n@SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite\npublic class SlowTestSuite {\n  // Will run A.b and B.c, but not A.a\n}\n\n@RunWith(Categories.class)\n@IncludeCategory(SlowTests.class)\n@ExcludeCategory(FastTests.class)\n@SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite\npublic class SlowTestSuite {\n  // Will run A.b, but not A.a or B.c\n}\n</code></pre>\n\n<h3>Bug fixes</h3>\n\n<ul>\n<li>github#16: thread safety of Result counting</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.md",
    "content": "## Summary of Changes in version 4.8 ##\n\n### Categories ###\n\nFrom a given set of test classes, the `Categories` runner\nruns only the classes and methods\nthat are annotated with either the category given with the `@IncludeCategory`\nannotation, or a subtype of that category. Either classes or interfaces can be\nused as categories. Subtyping works, so if you say `@IncludeCategory(SuperClass.class)`,\na test marked `@Category({SubClass.class})` will be run.\n\nYou can also exclude categories by using the `@ExcludeCategory` annotation\n \nExample:\n\n```java\npublic interface FastTests { /* category marker */ }\npublic interface SlowTests { /* category marker */ }\n\npublic class A {\n\t@Test\n\tpublic void a() {\n\t\tfail();\n\t}\n\n\t@Category(SlowTests.class)\n\t@Test\n\tpublic void b() {\n\t}\n}\n\n@Category({SlowTests.class, FastTests.class})\npublic class B {\n\t@Test\n\tpublic void c() {\n\t}\n}\n\n@RunWith(Categories.class)\n@IncludeCategory(SlowTests.class)\n@SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite\npublic class SlowTestSuite {\n\t// Will run A.b and B.c, but not A.a\n}\n\n@RunWith(Categories.class)\n@IncludeCategory(SlowTests.class)\n@ExcludeCategory(FastTests.class)\n@SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite\npublic class SlowTestSuite {\n\t// Will run A.b, but not A.a or B.c\n}\n```\n\n### Bug fixes ###\n\n- github#16: thread safety of Result counting\n"
  },
  {
    "path": "doc/ReleaseNotes4.8.txt",
    "content": "Please see ReleaseNotes4.8.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.9.1.md",
    "content": "## Summary of Changes in version 4.9.1 [unreleased!] ##\n\n### Theories ###\n\nThe `Theories` runner does not anticipate theory parameters that have generic\ntypes, as reported by github#64.  Fixing this won't happen until `Theories` is\nmoved to junit-contrib. In anticipation of this, 4.9.1 adds some of the\nnecessary machinery to the runner classes, and deprecates a method that only\nthe `Theories` runner uses, `FrameworkMethod`#producesType(). \nThe Common Public License that JUnit is released under is now included\nin the source repository.\n\nThanks to `@pholser` for identifying a potential resolution for github#64\nand initiating work on it.\n"
  },
  {
    "path": "doc/ReleaseNotes4.9.1.txt",
    "content": "Please see ReleaseNotes4.9.1.md\n"
  },
  {
    "path": "doc/ReleaseNotes4.9.html",
    "content": "<h2>Summary of Changes in version 4.9, final</h2>\n\n<p>Release theme: Test-class and suite level Rules.</p>\n\n<h3>ClassRule</h3>\n\n<p>The <code>ClassRule</code> annotation extends the idea of method-level Rules,\nadding static fields that can affect the operation of a whole class.  Any\nsubclass of <code>ParentRunner</code>, including the standard <code>BlockJUnit4ClassRunner</code> \nand <code>Suite</code> classes, will support <code>ClassRule</code>s.</p>\n\n<p>For example, here is a test suite that connects to a server once before\nall the test classes run, and disconnects after they are finished:</p>\n\n<pre><code>@RunWith(Suite.class)\n@SuiteClasses({A.class, B.class, C.class})\npublic class UsesExternalResource {\n    public static Server myServer= new Server();\n\n    @ClassRule\n    public static ExternalResource resource= new ExternalResource() {\n        @Override\n        protected void before() throws Throwable {\n            myServer.connect();\n        };\n\n        @Override\n        protected void after() {\n            myServer.disconnect();\n        };\n    };\n}\n</code></pre>\n\n<h3>TestRule</h3>\n\n<p>In JUnit 4.9, fields that can be annotated with either <code>@Rule</code> or <code>@ClassRule</code>\nshould be of type <code>TestRule</code>.  The old <code>MethodRule</code> type, which only made sense\nfor method-level rules, will still work, but is deprecated.</p>\n\n<p>Most built-in Rules have been moved to the new type already, in a way that\nshould be transparent to most users.  <code>TestWatchman</code> has been deprecated,\nand replaced by <code>TestWatcher</code>, which has the same functionality, but implements\nthe new type.</p>\n\n<h3>Maven support</h3>\n\n<p>Maven bundles have, in the past, been uploaded by kind volunteers.  Starting\nwith this release, the JUnit team is attempting to perform this task ourselves.</p>\n\n<h3>LICENSE checked in</h3>\n\n<p>The Common Public License that JUnit is released under is now included\nin the source repository.</p>\n\n<h3>Bug fixes</h3>\n\n<ul>\n<li>github#98: assumeTrue() does not work with expected exceptions</li>\n<li><p>github#74: Categories + Parameterized</p>\n\n<p>In JUnit 4.8.2, the Categories runner would fail to run correctly\nif any contained test class had a custom Runner with a structure\nsignificantly different from the built-in Runner.  With this fix,\nsuch classes can be assigned one or more categories at the class level,\nand will be run correctly.  Trying to assign categories to methods within\nsuch a class will flag an error.</p></li>\n<li><p>github#38: ParentRunner filters more than once</p>\n\n<p>Thanks to <code>@reinholdfuereder</code></p></li>\n<li><p>github#248: protected BlockJUnit4ClassRunner#rules method removed from 4.8.2</p></li>\n<li>github#187: Accidental dependency on Java 6</li>\n</ul>\n\n<p>Thanks to <code>@kcooney</code> for:</p>\n\n<ul>\n<li>github#163: Bad comparison failure message when using assertEquals(String, String)</li>\n<li>github#227: ParentRunner now assumes that getChildren() returns a modifiable list</li>\n</ul>\n\n<h3>Minor changes</h3>\n\n<ul>\n<li>Backed out unused folder \"experimental-use-of-antunit\", replaced by \nbash-based script at build_tests.sh</li>\n<li>Various Javadoc fixes</li>\n</ul>\n\n<p>Thanks to <code>@kcooney</code> for:</p>\n\n<ul>\n<li>Made MultipleFailureException public, to assist extension writers.</li>\n<li>github#240: Add \"test\" target to build.xml, for faster ant-driven testing.</li>\n<li>github#247: Give InitializationError a useful message</li>\n</ul>\n"
  },
  {
    "path": "doc/ReleaseNotes4.9.md",
    "content": "## Summary of Changes in version 4.9, final ##\n\nRelease theme: Test-class and suite level Rules.\n\n### ClassRule ###\n\nThe `ClassRule` annotation extends the idea of method-level Rules,\nadding static fields that can affect the operation of a whole class.  Any\nsubclass of `ParentRunner`, including the standard `BlockJUnit4ClassRunner` \nand `Suite` classes, will support `ClassRule`s.\n\nFor example, here is a test suite that connects to a server once before\nall the test classes run, and disconnects after they are finished:\n\n```java\n@RunWith(Suite.class)\n@SuiteClasses({A.class, B.class, C.class})\npublic class UsesExternalResource {\n\tpublic static Server myServer= new Server();\n\n\t@ClassRule\n\tpublic static ExternalResource resource= new ExternalResource() {\n\t\t@Override\n\t\tprotected void before() throws Throwable {\n\t\t\tmyServer.connect();\n\t\t}\n\t\n\t\t@Override\n\t\tprotected void after() {\n\t\t\tmyServer.disconnect();\n\t\t}\n\t};\n}\n```\n\n### TestRule ###\n\nIn JUnit 4.9, fields that can be annotated with either `@Rule` or `@ClassRule`\nshould be of type `TestRule`.  The old `MethodRule` type, which only made sense\nfor method-level rules, will still work, but is deprecated.\n\nMost built-in Rules have been moved to the new type already, in a way that\nshould be transparent to most users.  `TestWatchman` has been deprecated,\nand replaced by `TestWatcher`, which has the same functionality, but implements\nthe new type.\n\n### Maven support ###\n\nMaven bundles have, in the past, been uploaded by kind volunteers.  Starting\nwith this release, the JUnit team is attempting to perform this task ourselves.\n\n### LICENSE checked in ###\n\nThe Common Public License that JUnit is released under is now included\nin the source repository.\n\n### Bug fixes ###\n\n- github#98: assumeTrue() does not work with expected exceptions\n- github#74: Categories + Parameterized\n  \n  In JUnit 4.8.2, the Categories runner would fail to run correctly\n  if any contained test class had a custom Runner with a structure\n  significantly different from the built-in Runner.  With this fix,\n  such classes can be assigned one or more categories at the class level,\n  and will be run correctly.  Trying to assign categories to methods within\n  such a class will flag an error.\n\n- github#38: ParentRunner filters more than once\n\n  Thanks to `@reinholdfuereder`\n\n- github#248: protected BlockJUnit4ClassRunner#rules method removed from 4.8.2\n- github#187: Accidental dependency on Java 6\n\nThanks to `@kcooney` for:\n\n- github#163: Bad comparison failure message when using assertEquals(String, String)\n- github#227: ParentRunner now assumes that getChildren() returns a modifiable list\n\n### Minor changes ###\n\n- Backed out unused folder \"experimental-use-of-antunit\", replaced by \n  bash-based script at build_tests.sh\n- Various Javadoc fixes\n\nThanks to `@kcooney` for:\n\n- Made MultipleFailureException public, to assist extension writers.\n- github#240: Add \"test\" target to build.xml, for faster ant-driven testing.\n- github#247: Give InitializationError a useful message\n"
  },
  {
    "path": "doc/ReleaseNotes4.9.txt",
    "content": "Please see ReleaseNotes4.9.md\n"
  },
  {
    "path": "doc/building-junit.txt",
    "content": "Steps to build junit:\n\n- Must be manual\n  - Write release notes\n- Not too tedious:\n  - Push to github (junit-team)\n  - Run the ./mvnw clean install\n  - If not done, update $M2_HOME/settings.xml\n  - If not done, copy GnuPG keys in to ${gpg.homedir}. See settings.xml.\n  - Perform Maven deployment of a snapshot or release version in Jenkins\n    Remember that the version specified in the pom.xml indicates the version\n    to be deployed, with -SNAPSHOT indicating that this is an unofficial\n    pre-release version towards the goal of the version without the -SNAPSHOT\n\n    - (to deploy gpg signed snapshot version)\n\n      $ ./mvnw -Pjunit-release clean deploy\n\n    - (to cut a release of the current targetted version)\n\n      $ ./mvnw -B release:prepare release:perform\n\n      This will result in the current pom.xml version having -SNAPSHOT removed\n      and the release cut from that version. The version will then be incremented\n      and -SNAPSHOT added back in anticipation of the next release version.\n\n    - (to cut a release of while changing the version from the current target)\n\n      $ ./mvnw -B -DreleaseVersion=5.0 release:prepare release:perform\n\n      This will ignore the current version in the pom.xml, set it to 5.0 and\n      the release cut from that 5.0 version. Then 5.0 will be incremented (to 5.1)\n      and -SNAPSHOT added back in anticipation of the next release version.\n\n    - (to deploy specified release version and next target release in non-interactive mode -B)\n      An example with the next development version and deploying release version:\n\n      $ ./mvnw -B -DreleaseVersion=4.12 -DdevelopmentVersion=4.13-SNAPSHOT release:prepare release:perform\n\n  - If you are not an official release manager, and you want to cut a release of\n    JUnit for use within your organization, use the following command\n\n      $ ./mvnw -DpushChanges=false -DlocalCheckout '-Darguments=-Dgpg.skip=true -DaltDeploymentRepository=my-company-repo-id::default::my-company-repo-url' -B -DreleaseVersion=4.12-mycompany-1 release:prepare release:perform \n\n    where \n      - my-company-repo-id is the <id> of your company's <server> entry in your\n        settings.xml with the credentials to deploy to your company's Maven repository\n      - my-company-repo-url is the deployment URL of your company's Maven repository\n      - 4.12-mycompany-1 is the version you are deploying, be sure to namespace\n        the version so that you don't conflict with others, hence why the text \"mycompany\"\n        is included in the example version number.\n\n  - Promote the maven artifacts and close staging repository if released successfully\n- Tedious:\n  - Update SourceForge if major release\n  - Update javadocs on github site (and \"latest\" link)\n  - Update javadocs on junit.org\n  - Put release notes on github.\n  - Announce on blog, user list, dev list, announce list, junit.org, twitter \n- Profit!\n\n\n===================================================================================\n==        Internal template of Maven settings used by JUnit build machine.       ==\n==                                 settings.xml                                  ==\n===================================================================================\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"\n          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n          xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd\">\n    <servers>\n        <server>\n            <id>central-portal</id>\n            <username><!--a username registered with Sonatype for deployment--></username>\n            <password><!--corresponding password--></password>\n        </server>\n    </servers>\n    <profiles>\n        <profile>\n            <id>junit-release</id>\n            <properties>\n                <!-- NOTE: See keyname used by maven-gpg-plugin in pom.xml. -->\n                <gpg.passphrase>...</gpg.passphrase>\n                <gpg.defaultKeyring>false</gpg.defaultKeyring>\n                <gpg.useagent>true</gpg.useagent>\n                <gpg.homedir>/private/.../.gnupg</gpg.homedir>\n                <gpg.publicKeyring>/private/.../.gnupg/pubring.gpg</gpg.publicKeyring>\n                <gpg.secretKeyring>/private/.../.gnupg/secring.gpg</gpg.secretKeyring>\n            </properties>\n        </profile>\n    </profiles>\n</settings>\n===================================================================================\n"
  },
  {
    "path": "doc/cookstour/cookstour.htm",
    "content": "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n<html>\n<head>\n   <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n   <meta name=\"Generator\" content=\"Microsoft Word 97\">\n   <meta name=\"GENERATOR\" content=\"Mozilla/4.5 [en] (Win95; I) [Netscape]\">\n   <meta name=\"Author\" content=\"ERICH GAMMA\">\n   <title>JUnit: A Cooks Tour</title>\n</head>\n<body>\n\n<h1>\n<font color=\"#33FF33\">J</font><font color=\"#CC0000\">U</font>nit A Cook's\nTour</h1>\n<br>Note: this article is based on JUnit 3.8.x.\n<hr WIDTH=\"100%\">\n<p><b><font face=\"Arial\"><font size=+1>1. Introduction</font></font></b>\n<p><font size=-1>In an earlier article (see Test Infected: Programmers\nLove Writing Tests, Java Report, July 1998, Volume 3, Number 7), we described\nhow to use a simple framework to write repeatable tests. In this article,\nwe will take a peek under the covers and show you how the framework itself\nis constructed.</font>\n<p><font size=-1>We carefully studied the JUnit framework and reflected\non how we constructed it. We found lessons at many different levels. In\nthis article we will try communicate them all at once, a hopeless task,\nbut at least we will do it in the context of showing you the design and\nconstruction of a piece of software with proven value.</font>\n<p><font size=-1>We open with a discussion of the goals of the framework.\nThe goals will reappear in many small details during the presentation of\nthe framework itself. Following this, we present the design and implementation\nof the framework. The design will be described in terms of patterns (surprise,\nsurprise), the implementation as a literate program. We conclude with a\nfew choice thoughts about framework development.</font>\n<p><b><font face=\"Arial\"><font size=+1>2. Goals</font></font></b>\n<p><font size=-1>What are the goals of JUnit?</font>\n<p><font size=-1>First, we have to get back to the assumptions of development.\nIf a program feature lacks an automated test, we assume it doesnt work.\nThis seems much safer than the prevailing assumption, that if a developer\nassures us a program feature works, then it works now and forever.</font>\n<p><font size=-1>From this perspective, developers arent done when they\nwrite and debug the code, they must also write tests that demonstrate that\nthe program works. However, everybody is too busy, they have too much to\ndo, they dont have enough time, to screw around with testing. I have too\nmuch code to write already, how am I supposed write test code, too? Answer\nme that, Mr. Hard-case Project Manager.</font>\n<p><font size=-1>So, the number one goal is to write a framework within\nwhich we have some glimmer of hope that developers will actually write\ntests. The framework has to use familiar tools, so there is little new\nto learn. It has to require no more work than absolutely necessary to write\na new test. It has to eliminate duplicated effort.</font>\n<p><font size=-1>If this was all tests had to do, you would be done just\nby writing expressions in a debugger. However, this isnt sufficient for\ntesting. Telling me that your program works now doesnt help me, because\nit doesnt assure me that your program will work one minute from now after\nI integrate, and it doesnt assure me that your program will still work\nin five years, when you are long gone.</font>\n<p><font size=-1>So, the second goal of testing is creating tests that\nretain their value over time. Someone other than the original author has\nto be able to execute the tests and interpret the results. It should be\npossible to combine tests from various authors and run them together without\nfear of interference.</font>\n<p><font size=-1>Finally, it has to be possible to leverage existing tests\nto create new ones. Creating a setup or fixture is expensive and a framework\nhas to enable reusing fixtures to run different tests. Oh, is that all?</font>\n<p><b><font face=\"Arial\"><font size=+1>3. The Design of JUnit</font></font></b>\n<p><font size=-1>The design of JUnit will be presented in a style first\nused in (see \"Patterns Generate Architectures\", Kent Beck and Ralph Johnson,\nECOOP 94). The idea is to explain the design of a system by starting with\nnothing and applying patterns, one after another, until you have the architecture\nof the system. We will present the architectural problem to be solved,\nsummarize the pattern that solves it, and then show how the pattern was\napplied to JUnit.</font>\n<p><b><i><font face=\"Arial\">3.1 Getting started- TestCase</font></i></b>\n<p><font size=-1>First we have to make an object to represent our basic\nconcept, the TestCase. Developers often have tests cases in mind, but they\nrealize them in many different ways-</font>\n<ul>\n<li>\n<font size=-1>print statements,</font></li>\n\n<li>\n<font size=-1>debugger expressions,</font></li>\n\n<li>\n<font size=-1>test scripts.</font></li>\n</ul>\n<font size=-1>If we want to make manipulating tests easy, we have to make\nthem objects. This takes a test that was only implicit in the developers\nmind and makes it concrete, supporting our goal of creating tests that\nretain their value over time. At the same time, object developers are used\nto, well, developing with objects, so the decision to make tests into objects\nsupports our goal of making test writing more inviting (or at least less\nimposing).</font>\n<p><font size=-1>The Command pattern (see Gamma, E., et al. Design Patterns:\nElements of Reusable Object-Oriented Software, Addison-Wesley, Reading,\nMA, 1995) fits our needs quite nicely. Quoting from the intent, \"Encapsulate\na request as an object, thereby letting you queue or log requests\" Command\ntells us to create an object for an operation and give it a method \"execute\".\nHere is the code for the class definition of TestCase:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public abstract class <b>TestCase</b>\nimplements Test {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; </font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>Because we expect this class to be reused through inheritance,\nwe declare it \"public abstract\". For now, ignore the fact that it implements\nthe Test interface. For the purposes of our current design, you can think\nof TestCase as a lone class.</font>\n<p><font size=-1>Every TestCase is created with a name, so if a test fails,\nyou can identify which test failed.</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public abstract class <b>TestCase</b>\nimplements Test {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; private final String\nfName;</font></font>\n<p><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; public <b>TestCase</b>(String\nname) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nfName= name;</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<p><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; public abstract\nvoid <b>run</b>();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>To illustrate the evolution of JUnit, we use diagrams that\nshow snapshots of the architecture. The notation we use is simple. It annotates\nclasses with shaded boxes containing the associated pattern. When the role\nof the class in the pattern is obvious then only the pattern name is shown.\nIf the role isnt clear then the shaded box is augmented by the name of\nthe participant this class corresponds to. This notation minimizes the\nclutter in diagrams and was first shown in (see Gamma, E., Applying Design\nPatterns in Java, in Java Gems, SIGS Reference Library, 1997) Figure 1\nshows this notation applied to TestCase. Since we are dealing with a single\nclass and there can be no ambiguities just the pattern name is shown.</font>\n<center>\n<p><img SRC=\"Image1.gif\" height=92 width=238>\n<p><font size=-1><b>Figure 1</b> TestCase applies Command</font></center>\n\n<p><b><i><font face=\"Arial\">3.2 Blanks to fill in- run()</font></i></b>\n<p><font size=-1>The next problem to solve is giving the developer a convenient\n\"place\" to put their fixture code and their test code. The declaration\nof TestCase as abstract says that the developer is expected to reuse TestCase\nby subclassing. However, if all we could do was provide a superclass with\none variable and no behavior, we wouldnt be doing much to satisfy our\nfirst goal, making tests easier to write.</font>\n<p><font size=-1>Fortunately, there is a common structure to all tests-\nthey set up a test fixture, run some code against the fixture, check some\nresults, and then clean up the fixture. This means that each test will\nrun with a fresh fixture and the results of one test cant influence the\nresult of another. This supports the goal of maximizing the value of the\ntests.</font>\n<p><font size=-1>Template Method addresses our problem quite nicely. Quoting\nfrom the intent, \"Define the skeleton of an algorithm in an operation,\ndeferring some steps to subclasses. Template Method lets subclasses redefine\ncertain steps of an algorithm without changing the algorithms structure.\"\nThis is exactly right. We want the developer to be able to separately consider\nhow to write the fixture (set up and tear down) code and how to write the\ntesting code. The execution of this sequence, however, will remain the\nsame for all tests, no matter how the fixture code is written or how the\ntesting code is written.</font>\n<p><font size=-1>Here is the template method:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public void <b>run</b>() {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; setUp();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; runTest();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; tearDown();</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The default implementations of these methods do nothing:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>protected void <b>runTest</b>() {</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font>\n<p><font face=\"Arial\"><font size=-2>protected void <b>setUp</b>() {</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font>\n<p><font face=\"Arial\"><font size=-2>protected void <b>tearDown</b>() {</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>Since setUp and tearDown are intended to be overridden but\nwill be called by the framework we declare them as protected. The second\nsnapshot of our tour is depicted in Figure 2.</font>\n<center>\n<p><img SRC=\"Image2.gif\" height=142 width=270>\n<p><font size=-1><b>Figure 2</b> TestCase.run() applies Template Method</font></center>\n\n<p><b><i><font face=\"Arial\">3.3 Reporting results- TestResult</font></i></b>\n<p><font size=-1>If a TestCase runs in a forest, does anyone care about\nthe result? Sure- you run tests to make sure they run. After the test has\nrun, you want a record, a summary of what did and didnt work.</font>\n<p><font size=-1>If tests had equal chances of succeeding or failing, or\nif we only ever ran one test, we could just set a flag in the TestCase\nobject and go look at the flag when the test completed. However, tests\nare (intended to be) highly asymmetric- they usually work. Therefore, we\nonly want to record the failures and a highly condensed summary of the\nsuccesses.</font>\n<p><font size=-1>The Smalltalk Best Practice Patterns (see Beck, K. Smalltalk\nBest Practice Patterns, Prentice Hall, 1996) has a pattern that is applicable.\nIt is called <i>Collecting Parameter</i>. It suggests that when you need\nto collect results over several methods, you should add a parameter to\nthe method and pass an object that will collect the results for you. We\ncreate a new object, TestResult, to collect the results of running tests.</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public class <b>TestResult</b> extends\nObject {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; protected int fRunTests;</font></font>\n<p><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; public <b>TestResult</b>()\n{</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nfRunTests= 0;</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>This simple version of TestResult only counts the number\nof tests run. To use it, we have to add a parameter to the TestCase.run()\nmethod and notify the TestResult that the test is running:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public void <b>run</b>(TestResult\nresult) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; result.startTest(this);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; setUp();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; runTest();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; tearDown();</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>And the TestResult has to keep track of the number of tests\nrun:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public synchronized void <b>startTest</b>(Test\ntest) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; fRunTests++;</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>We declare the TestResult method startTest as synchronized\nso that a single TestResult can collect the results safely when the tests\nare run in different threads. Finally, we want to retain the simple external\ninterface of TestCase, so we create a no-parameter version of run() that\ncreates its own TestResult:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public TestResult <b>run</b>() {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; TestResult result=\ncreateResult();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; run(result);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; return result;</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font>\n<p><font face=\"Arial\"><font size=-2>protected TestResult <b>createResult</b>()\n{</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; return new TestResult();</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>Figure 3 shows our next design snapshot.</font>\n<center>\n<p><img SRC=\"Image3.gif\" height=149 width=325>\n<p><font size=-1>Figure 3: TestResult applies Collecting Parameter</font></center>\n\n<p><font size=-1>If tests always ran correctly, then we wouldnt have to\nwrite them. Tests are interesting when they fail, especially if we didnt\nexpect them to fail. Whats more, tests can fail in ways that we expect,\nfor example by computing an incorrect result, or they can fail in more\nspectacular ways, for example by writing outside the bounds of an array.\nNo matter how the test fails we want to execute the following tests.</font>\n<p><font size=-1>JUnit distinguishes between <i>failures</i> and <i>errors</i>.\nThe possibility of a failure is anticipated and checked for with assertions.\nErrors are unanticipated problems like an ArrayIndexOutOfBoundsException.\nFailures are signaled with an AssertionFailedError error. To distinguish\nan unanticipated error from a failure, failures are caught in an extra\ncatch clause (1). The second clause (2) catches all other exceptions and\nensures that our test run continues..</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public void <b>run</b>(TestResult\nresult) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; result.startTest(this);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; setUp();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; try {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nrunTest();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; catch (AssertionFailedError\ne) { //1</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nresult.addFailure(this, e);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<p><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; catch (Throwable\ne) { // 2</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nresult.addError(this, e);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; finally {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\ntearDown();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>An AssertionFailedError is triggered by the assert methods\nprovided by TestCase. JUnit provides a set of assert methods for different\npurposes. Here is the simplest one:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>protected void <b>assertTrue</b>(boolean\ncondition) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; if (!condition)</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nthrow new AssertionFailedError();</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The AssertionFailedError is not meant to be caught by the\nclient (a testing method inside a TestCase) but inside the Template Method\nTestCase.run(). We therefore derive AssertionFailedError from Error.</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public class <b>AssertionFailedError</b>\nextends Error {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; public AssertionFailedError\n() {}</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The methods to collect the errors in TestResult are shown\nbelow:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public synchronized void <b>addError</b>(Test\ntest, Throwable t) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; fErrors.addElement(new\nTestFailure(test, t));</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font>\n<p><font face=\"Arial\"><font size=-2>public synchronized void <b>addFailure</b>(Test\ntest, Throwable t) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; fFailures.addElement(new\nTestFailure(test, t));</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>TestFailure is a little framework internal helper class to\nbind together the failed test and the signaled exception for later reporting.</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public class <b>TestFailure</b> extends\nObject {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; protected Test\nfFailedTest;</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; protected Throwable\nfThrownException;</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The canonical form of collecting parameter requires us to\npass the collecting parameter to each method. If we followed this advice,\neach of the testing methods would require a parameter for the TestResult.\nThis results in a \"pollution\" of these method signatures. As a benevolent\nside effect of using exceptions to signal failures we can avoid this signature\npollution. A test case method, or a helper method called from it, can throw\nan exception without having to know about the TestResult. As a refresher\nhere is a sample test method from our MoneyTest suite. It illustrates how\na testing method doesnt have to know anything about a TestResult:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public void <b>testMoneyEquals</b>()\n{</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; assertTrue(!f12CHF.equals(null));</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; assertEquals(f12CHF,\nf12CHF);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; assertEquals(f12CHF,\nnew Money(12, \"CHF\"));</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; assertTrue(!f12CHF.equals(f14CHF));</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>JUnit comes with different implementations of TestResult.\nThe default implementation counts the number of failures and errors and\ncollects the results. TextTestResult collects the results and presents\nthem in a textual form. Finally, UITestResult is used by the graphical\nversion of the JUnit Test Runner to update the graphical test status.</font>\n<p><font size=-1>TestResult is an extension point of the framework. Clients\ncan define their own custom TestResult classes, for example, an HTMLTestResult\nreports the results as an HTML document.</font>\n<p><b><i><font face=\"Arial\">3.4 No stupid subclasses - TestCase again</font></i></b>\n<p><font size=-1>We have applied Command to represent a test. Command relies\non a single method like execute() (called run() in TestCase) to invoke\nit. This simple interface allows us to invoke different implementations\nof a command through the same interface.</font>\n<p><font size=-1>We need an interface to generically run our tests. However,\nall test cases are implemented as different methods in the same class.\nThis avoids the unnecessary proliferation of classes. A given test case\nclass may implement many different methods, each defining a single test\ncase. Each test case has a descriptive name like testMoneyEquals or testMoneyAdd.\nThe test cases dont conform to a simple command interface. Different instances\nof the same Command class need to be invoked with different methods. Therefore\nour next problem is make all the test cases look the same from the point\nof view of the invoker of the test.</font>\n<p><font size=-1>Reviewing the problems addressed by available design patterns,\nthe Adapter pattern springs to mind. Adapter has the following intent \"Convert\nthe interface of a class into another interface clients expect\". This sounds\nlike a good match. Adapter tells us different ways to do this. One of them\nis a class adapter, which uses subclassing to adapt the interface. For\nexample, to adapt testMoneyEquals to runTest we implement a subclass of\nMoneyTest and override runTest to invoke testMoneyEquals.</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public class <b>TestMoneyEquals</b>\nextends MoneyTest {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; public TestMoneyEquals()\n{ super(\"testMoneyEquals\"); }</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; protected void\nrunTest () { testMoneyEquals(); }</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The use of subclassing requires us to implement a subclass\nfor each test case. This puts an additional burden on the tester. This\nis against the JUnit goal that the framework should make it as simple as\npossible to add a test case. In addition, creating a subclass for each\ntesting method results in class bloat. Many classes with only a single\nmethod are not worth their costs and it will be difficult to come up with\nmeaningful names.</font>\n<p><font size=-1>Java provides anonymous inner classes which provide an\ninteresting Java-specific solution to the class naming problem. With anonymous\ninner classes we can create an Adapter without having to invent a class\nname:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>TestCase test= new MoneyTest(\"testMoneyEquals\n\") {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; protected void\nrunTest() { testMoneyEquals(); }</font></font>\n<br><font face=\"Arial\"><font size=-2>};</font></font></dir>\n</dir>\n<font size=-1>This is much more convenient than full subclassing. It preserves\ncompile-time type checking at the cost of some burden on the developer.\nSmalltalk Best Practice Patterns describes another solution for the problem\nof different instances behaving differently under the common heading of<i>\npluggable behavior</i>. The idea is to use a single class which can be\nparameterized to perform different logic without requiring subclassing.</font>\n<p><font size=-1>The simplest form of pluggable behavior is the <i>Pluggable\nSelector</i>. Pluggable Selector stores a Smalltalk method selector in\nan instance variable. This idea is not limited to Smalltalk. It is also\napplicable to Java. In Java there is no notion of a method selector. However,\nthe Java reflection API allows us to invoke a method from a string representing\nthe methods name. We can use this feature to implement a pluggable selector\nin Java. As an aside, we usually dont use reflection in ordinary application\ncode. In our case we are dealing with an infrastructure framework and it\nis therefore OK to wear the reflection hat.</font>\n<p><font size=-1>JUnit offers the client the choice of using pluggable\nselector or implementing an anonymous adapter class as shown above. To\ndo so, we provide the pluggable selector as the default implementation\nof the runTest method. In this case the name of the test case has to correspond\nto the name of a test method. We use reflection to invoke the method as\nshown below. First we look up the Method object. Once we have the method\nobject we can invoke it and pass its arguments. Since our test methods\ntake no arguments we can pass an empty argument array:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>protected void <b>runTest</b>() throws\nThrowable {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; Method runMethod=\nnull;</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; try {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nrunMethod= getClass().getMethod(fName, new Class[0]);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; } catch (NoSuchMethodException\ne) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nassertTrue(\"Method \\\"\"+fName+\"\\\" not found\", false);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; try {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nrunMethod.invoke(this, new Class[0]);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; // catch InvocationTargetException\nand IllegalAccessException</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The JDK 1.1 reflection API only allows us to find public\nmethods. For this reason you have to declare the test methods as public,\notherwise you will get a NoSuchMethodException.</font>\n<p><font size=-1>Here is the next design snapshot, with Adapter and Pluggable\nSelector added.</font>\n<center>\n<p><img SRC=\"Image4.gif\" height=271 width=278>\n<p><font size=-1>Figure 4: TestCase applies either Adapter with an anonymous\ninner class or Pluggable Selector</font></center>\n\n<p><b><i><font face=\"Arial\">3.5 Dont care about one or many - TestSuite</font></i></b>\n<p><font size=-1>To get confidence in the state of a system we need to\nrun many tests. Up to this point JUnit can run a single test case and report\nthe result in a TestResult. Our next challenge is to extend it so that\nit can run many different tests. This problem can be solved easily when\nthe invoker of the tests doesnt have to care about whether it runs one\nor many test cases. A popular pattern to pull out in such a situation is\nComposite. To quote its intent \"Compose objects into tree structures to\nrepresent part-whole hierarchies. Composite lets clients treat individual\nobjects and compositions of objects uniformly.\" The point about part-whole\nhierarchies is of interest here. We want to support suites of suites of\nsuites of tests.</font>\n<p><font size=-1>Composite introduces the following participants:</font>\n<ul>\n<li>\n<font size=-1>Component: declares the interface we want to use to interact\nwith our tests.</font></li>\n\n<li>\n<font size=-1>Composite: implements this interface and maintains a collection\nof tests.</font></li>\n\n<li>\n<font size=-1>Leaf: represents a test case in a composition that conforms\nto the Component interface.</font></li>\n</ul>\n<font size=-1>The pattern tells us to introduce an abstract class which\ndefines the common interface for single and composite objects. The primary\npurpose of the class is to define an interface. When applying Composite\nin Java we prefer to define an interface and not an abstract class. Using\nan interface avoids committing JUnit to a specific base class for tests.\nAll that is required is that the tests conform to this interface. We therefore\ntweak the pattern description and introduce a Test interface:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public interface <b>Test</b> {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; public abstract\nvoid run(TestResult result);</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>TestCase corresponds to a Leaf in Composite and implements\nthis interface as we have seen above.</font>\n<p><font size=-1>Next, we introduce the Composite participant. We name\nthe class TestSuite. A TestSuite keeps its child tests in a Vector:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public class <b>TestSuite</b> implements\n<b>Test</b>\n{</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; private Vector\nfTests= new Vector();</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The run() method delegates to its children:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public void <b>run</b>(TestResult\nresult) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; for (Enumeration\ne= fTests.elements(); e.hasMoreElements(); ) {</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nTest test= (Test)e.nextElement();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\ntest.run(result);</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; }</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n\n<center><img SRC=\"Image5.gif\" height=241 width=562>\n<p><font size=-1>Figure 5: TestSuite applies Composite</font></center>\n\n<p><font size=-1>Finally, clients have to be able to add tests to a suite,\nthey can do so with the method addTest:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public void <b>addTest</b>(Test test)\n{</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; fTests.addElement(test);</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>Notice how all of the above code only depends on the Test\ninterface. Since both TestCase and TestSuite conform to the Test interface\nwe can recursively compose suites of test suites. All developers can create\ntheir own TestSuites. We can run them all by creating a TestSuite composed\nof those suites.</font>\n<p><font size=-1>Here is an example of creating a TestSuite:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public static Test <b>suite</b>()\n{</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; TestSuite suite=\nnew TestSuite();</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; suite.addTest(new\nMoneyTest(\"testMoneyEquals\"));</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; suite.addTest(new\nMoneyTest(\"testSimpleAdd\"));</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>This works fine, but it requires us to add all the tests\nto a suite manually. Early adopters of JUnit told us this was stupid. Whenever\nyou write a new test case you have to remember to add it to a static suite()\nmethod, otherwise it will not be run. We added a convenience constructor\nto TestSuite which takes the test case class as an argument. Its purpose\nis to extract the test methods and create a suite containing them. The\ntest methods must follow the simple convention that they start with the\nprefix \"test\" and take no arguments. The convenience constructor uses this\nconvention, constructing the test objects by using reflection to find the\ntesting methods. Using this constructor the above code is simplified to:</font>\n<dir>\n<dir><font face=\"Arial\"><font size=-2>public static Test <b>suite</b>()\n{</font></font>\n<br><font face=\"Arial\"><font size=-2>&nbsp;&nbsp;&nbsp; return new TestSuite(MoneyTest.class);</font></font>\n<br><font face=\"Arial\"><font size=-2>}</font></font></dir>\n</dir>\n<font size=-1>The original way is still useful when you want to run a subset\nof the test cases only.</font>\n<p><b><i><font face=\"Arial\">3.6 Summary</font></i></b>\n<p><font size=-1>We are at the end of our cooks tour through JUnit. The\nfollowing figure shows the design of JUnit at a glance explained with patterns.</font>\n<center>\n<p><img SRC=\"Image6.gif\" height=394 width=605>\n<p><font size=-1>Figure 6: JUnit Patterns Summary</font></center>\n\n<p><font size=-1>Notice how TestCase, the central abstraction in the framework,\nis involved in four patterns. Pictures of mature object designs show this\nsame \"pattern density\". The star of the design has a rich set of relationships\nwith the supporting players.</font>\n<p><font size=-1>Here is another way of looking at all of the patterns\nin JUnit. In this storyboard you see an abstract representation of the\neffect of each of the patterns in turn. So, the Command pattern creates\nthe TestCase class, the Template Method pattern creates the run method,\nand so on. (The notation of the storyboard is the notation of figure 6\nwith all the text deleted).</font>\n<center>\n<p><img SRC=\"Image7.gif\" height=231 width=792>\n<p><font size=-1>Figure 7: JUnit Pattern Storyboard</font></center>\n\n<p><font size=-1>One point to notice about the storyboard is how the complexity\nof the picture jumps when we apply Composite. This is pictorial corroboration\nfor our intuition that Composite is a powerful pattern, but that it \"complicates\nthe picture.\" It should therefore be used with caution.</font>\n<p><b><font face=\"Arial\"><font size=+1>4. Conclusion</font></font></b>\n<p><font size=-1>To conclude, lets make some general observations:</font>\n<ul>\n<li>\n<i><font size=-1>Patterns</font></i></li>\n\n<br><font size=-1>We found discussing the design in terms of patterns to\nbe invaluable, both as we were developing the framework and as we try to\nexplain it to others. You are now in a perfect position to judge whether\ndescribing a framework with patterns is effective. If you liked the discussion\nabove, try the same style of presentation for your own system.</font>\n<li>\n<i><font size=-1>Pattern density</font></i></li>\n\n<br><font size=-1>There is a high pattern \"density\" around TestCase, which\nis the key abstraction of JUnit. Designs with high pattern density are\neasier to use but harder to change. We have found that such a high pattern\ndensity around key abstractions is common for mature frameworks. The opposite\nshould be true of immature frameworks - they should have low pattern density.\nOnce you discover what problem you are really solving, then you can begin\nto \"compress\" the solution, leading to a denser and denser field of patterns\nwhere they provide leverage.</font>\n<li>\n<i><font size=-1>Eat your own dog food</font></i></li>\n\n<br><font size=-1>As soon as we had the base unit testing functionality\nimplemented, we applied it ourselves. A TestTest verifies that the framework\nreports the correct results for errors, successes, and failures. We found\nthis invaluable as we continued to evolve the design of the framework.\nWe found that the most challenging application of JUnit was testing its\nown behavior.</font>\n<li>\n<i><font size=-1>Intersection, not union</font></i></li>\n\n<br><font size=-1>There is a temptation in framework development to include\nevery feature you can. After all, you want to make the framework as valuable\nas possible. However, there is a counteracting force- developers have to\ndecide to use your framework. The fewer features the framework has, the\neasier it is to learn, the more likely a developer will use it. JUnit is\nwritten in this style. It implements only those features absolutely essential\nto running tests- running suites of tests, isolating the execution of tests\nfrom each other, and running tests automatically. Sure, we couldnt resist\nadding some features but we were careful to put them into their own extensions\npackage (test.extensions). A notable member of this package is a TestDecorator\nallowing execution of additional code before and after a test.</font>\n<li>\n<i><font size=-1>Framework writers read their code</font></i></li>\n\n<br><font size=-1>We spent far more time reading the JUnit code than we\nspent writing it, and nearly as much time removing duplicate functionality\nas we spent adding new functionality. We experimented aggressively with\nthe design, adding new classes and moving responsibility around in as many\ndifferent ways as we could imagine. We were rewarded (and are still being\nrewarded) for our monomania by a continuous flow of insights into JUnit,\ntesting, object design, framework development, and opportunities for further\narticles.</font></ul>\n<font size=-1>The latest version of JUnit can be downloaded from http://www.junit.org.</font>\n<p><b><font face=\"Arial\"><font size=+1>5. Acknowledgements</font></font></b>\n<p><font size=-1>Thanks to John Vlissides, Ralph Johnson, and Nick Edgar\nfor careful reading and gentle correction.</font>\n</body>\n</html>\n"
  },
  {
    "path": "doc/markdown.sh",
    "content": "~/bin/Markdown.pl ReleaseNotes4.8.txt >ReleaseNotes4.8.html"
  },
  {
    "path": "doc/testinfected/testing.htm",
    "content": "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n<html>\n<head>\n   <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n   <meta name=\"GENERATOR\" content=\"Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]\">\n   <title>Test Infected: </title>\n</head>\n<body>\n\n<h1>\n<b><font color=\"#00CC00\">J</font><font color=\"#FF0000\">U</font><font color=\"#000000\">nit</font> <font size=+3>Test\nInfected: Programmers Love Writing Tests</font></b></h1>\n<br>Note: this article describes JUnit 3.8.x.\n\n<hr WIDTH=\"100%\">\n<p>Testing is not closely integrated with development. This prevents you\nfrom measuring the progress of development- you can't tell when something\nstarts working or when something stops working. Using <i>JUnit</i> you\ncan cheaply and incrementally build a test suite that will help you measure\nyour progress, spot unintended side effects, and focus your development\nefforts.\n<h1>\nContents</h1>\n\n<ul>\n<li>\n<a href=\"#TheProblem\">The Problem</a></li>\n\n<li>\n<a href=\"#Example\">Example</a></li>\n\n<li>\n<a href=\"#TestingPractices\">Testing Practices</a></li>\n\n<li>\n<a href=\"#Conclusion\">Conclusions</a></li>\n</ul>\n\n<h1>\n<a NAME=\"TheProblem\"></a>The Problem</h1>\nEvery programmer knows they should write tests for their code. Few do.\nThe universal response to \"Why not?\" is \"I'm in too much of a hurry.\" This\nquickly becomes a vicious cycle- the more pressure you feel, the fewer\ntests you write. The fewer tests you write, the less productive you are\nand the less stable your code becomes. The less productive and accurate\nyou are, the more pressure you feel.\n<p>Programmers burn out from just such cycles. Breaking out requires an\noutside influence. We found the outside influence we needed in a simple\ntesting framework that lets us do a little testing that makes a big difference.\n<p>The best way to convince you of the value of writing your own tests\nwould be to sit down with you and do a bit of development. Along the way,\nwe would encounter new bugs, catch them with tests, fix them, have them\ncome back, fix them again, and so on. You would see the value of the immediate\nfeedback you get from writing and saving and rerunning your own unit tests.\n<p>Unfortunately, this is an article, not an office overlooking charming\nold-town Z&uuml;rich, with the bustle of medieval commerce outside and\nthe thump of techno from the record store downstairs, so we'll have to\nsimulate the process of development. We'll write a simple program and its\ntests, and show you the results of running the tests. This way you can\nget a feel for the process we use and advocate without having to pay for\nour presence.\n<h1>\n<a NAME=\"Example\"></a>Example</h1>\nAs you read, pay attention to the interplay of the code and the tests.\nThe style here is to write a few lines of code, then a test that should\nrun, or even better, to write a test that won't run, then write the code\nthat will make it run.\n<p>The program we write will solve the problem of representing arithmetic\nwith multiple currencies. Arithmetic between single currencies is trivial,\nyou can just add the two amounts. Simple numbers suffice. You can ignore\nthe presence of currencies altogether.\n<p>Things get more interesting once multiple currencies are involved. You\ncannot just convert one currency into another for doing arithmetic since\nthere is no single conversion rate- you may need to compare the value of\na portfolio at yesterday's rate and today's rate.\n<p>Let's start simple and define a class <a href=\"#classMoney\">Money</a>\nto represent a value in a single currency. We represent the amount by a\nsimple int. To get full accuracy you would probably use double or java.math.BigDecimal\nto store arbitrary-precision signed decimal numbers. We represent a currency\nas a string holding the ISO three letter abbreviation (USD, CHF, etc.).\nIn more complex implementations, currency might deserve its own object.\n<pre><a NAME=\"classMoney\"></a><tt>class Money {\n&nbsp;&nbsp;&nbsp; private int fAmount;\n&nbsp;&nbsp;&nbsp; private String fCurrency;</tt></pre>\n\n<pre><tt>&nbsp;&nbsp;&nbsp; public Money(int amount, String currency) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fAmount= amount;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fCurrency= currency;\n&nbsp;&nbsp;&nbsp; }\n\n&nbsp;&nbsp;&nbsp; public int amount() {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return fAmount;\n&nbsp;&nbsp;&nbsp; }\n\n&nbsp;&nbsp;&nbsp; public String currency() {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return fCurrency;\n&nbsp;&nbsp;&nbsp; }\n}</tt></pre>\nWhen<font size=-1> </font>you add two Moneys of the same currency, the\nresulting Money has as its amount the sum of the other two amounts.\n<pre><a NAME=\"MoneyAdd\"></a><tt>public Money add(Money m) {\n&nbsp;&nbsp;&nbsp; return new Money(amount()+m.amount(), currency());\n}</tt></pre>\nNow, instead of just coding on, we want to get immediate feedback and practice\n\"code a little, test a little, code a little, test a little\". To implement\nour tests we use the JUnit framework. To write tests you need to get the\n<a href=\"http://sourceforge.net/projects/junit/\">latest\ncopy</a> JUnit (or write your own equivalent- it's not so much work).\n<p>JUnit defines how to structure your test cases and provides the tools\nto run them. You implement a test in a subclass of TestCase. To test our\nMoney implementation we therefore define <a href=\"#class MoneyTest\">MoneyTest</a>\nas a subclass of TestCase. In Java, classes are contained in packages and\nwe have to decide where to put MoneyTest. Our current practice is to put\nMoneyTest in the same package as the classes under test. In this way a\ntest case has access to the package private methods. We add a test method\ntestSimpleAdd, that will exercise the simple version of <a href=\"#MoneyAdd\">Money.add()</a>\nabove. A JUnit test method is an ordinary method without any parameters.\n<pre><a NAME=\"class MoneyTest\"></a><tt>public class MoneyTest extends TestCase {\n&nbsp;&nbsp;&nbsp; //\n&nbsp;&nbsp;&nbsp; public void testSimpleAdd() {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Money m12CHF= new Money(12, \"CHF\");&nbsp; //&nbsp;<a NAME=\"MoneyTest1\"></a>(1)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Money m14CHF= new Money(14, \"CHF\");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Money expected= new Money(26, \"CHF\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Money result= m12CHF.add(m14CHF);&nbsp;&nbsp;&nbsp; //&nbsp;<a NAME=\"MoneyTest2\"></a>(2)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.assertTrue(expected.equals(result));&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;<a NAME=\"MoneyTest3\"></a>(3)\n&nbsp;&nbsp;&nbsp; }\n}</tt></pre>\nThe testSimpleAdd() test case consists of:\n<ol>\n<li>\n<a href=\"#MoneyTest1\">Code</a> which creates the objects we will interact\nwith during the test. This testing context is commonly referred to as a\ntest's<i> fixture</i>. All we need for the testSimpleAdd test are some\nMoney objects.</li>\n\n<li>\n<a href=\"#MoneyTest2\">Code</a> which exercises the objects in the fixture.</li>\n\n<li>\n<a href=\"#MoneyTest3\">Code</a> which verifies the result.</li>\n</ol>\nBefore we can verify the result we have to digress a little since we need\na way to test that two Money objects are equal. The Java idiom to do so\nis to override the method <i>equals</i> defined in Object. Before we implement\nequals let's a write a test for equals in MoneyTest.\n<pre><tt>public void testEquals() {\n&nbsp;&nbsp;&nbsp; Money m12CHF= new Money(12, \"CHF\");\n&nbsp;&nbsp;&nbsp; Money m14CHF= new Money(14, \"CHF\");\n\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!m12CHF.equals(null));\n&nbsp;&nbsp;&nbsp; Assert.assertEquals(m12CHF, m12CHF);\n&nbsp;&nbsp;&nbsp; Assert.assertEquals(m12CHF, new Money(12, \"CHF\")); //&nbsp;<a NAME=\"TestEquals1\"></a>(1)\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!m12CHF.equals(m14CHF));\n}</tt></pre>\nThe equals method in Object returns true when both objects are the same.\nHowever, Money is a <i>value object</i>. Two Monies are considered equal\nif they have the same currency and value. To test this property we have\nadded a test <a href=\"#TestEquals1\">(1)</a> to verify that Monies are equal\nwhen they have the same value but are not the same object.\n<p>Next let's write the equals method in Money:\n<pre><tt>public boolean equals(Object anObject) {\n&nbsp;&nbsp;&nbsp; if (anObject instanceof Money) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Money aMoney= (Money)anObject;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return aMoney.currency().equals(currency())\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; amount() == aMoney.amount();\n&nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp;&nbsp; return false;\n}</tt></pre>\nSince equals can receive any kind of object as its argument we first have\nto check its type before we cast it as a Money. As an aside, it is a recommended\npractice to also override the method hashCode whenever you override method\nequals. However, we want to get back to our test case.\n<p>With an equals method in hand we can verify the outcome of testSimpleAdd.\nIn JUnit you do so by a calling\n<A HREF=\"../../javadoc/junit/framework/Assert.html#assertTrue(boolean)\">Assert.assertTrue</a>,\nwhich triggers a failure that is recorded by JUnit when the argument isn't\ntrue. Since assertions for equality are very common, there is also\nan Assert.assertEquals convenience method. In addition to testing for equality\nwith equals, it reports the printed value of the two objects in the case they\ndiffer. This lets us immediately see why a test failed in a JUnit test\nresult report. The value a string representation created by\nthe toString converter method.\nThere are <a href=\"../../javadoc/junit/framework/Assert.html\">\nother assertXXXX variants</a> not discussed here.\n<p>Now that we have implemented two test cases we notice some code duplication\nfor setting-up the tests. It would be nice to reuse some of this test set-up\ncode. In other words, we would like to have a common fixture for running\nthe tests. With JUnit you can do so by storing the fixture's objects in\ninstance variables of your\n<a href=\"../../javadoc/junit/framework/TestCase.html\">TestCase</a>\nsubclass and initialize them by overriding\nthe setUp method. The symmetric operation to setUp is tearDown which you\ncan override to clean up the test fixture at the end of a test. Each test\nruns in its own fixture and JUnit calls setUp and tearDown for each test\nso that there can be no side effects among test runs.\n<pre><tt>public class MoneyTest extends TestCase {\n&nbsp;&nbsp;&nbsp; private Money f12CHF;\n&nbsp;&nbsp;&nbsp; private Money f14CHF;&nbsp;&nbsp;&nbsp;\n\n&nbsp;&nbsp;&nbsp; protected void setUp() {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f12CHF= new Money(12, \"CHF\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f14CHF= new Money(14, \"CHF\");\n&nbsp;&nbsp;&nbsp; }\n}</tt></pre>\nWe can rewrite the two test case methods, removing the common setup code:\n<pre><tt>public void testEquals() {\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!f12CHF.equals(null));\n&nbsp;&nbsp;&nbsp; Assert.assertEquals(f12CHF, f12CHF);\n&nbsp;&nbsp;&nbsp; Assert.assertEquals(f12CHF, new Money(12, \"CHF\"));\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!f12CHF.equals(f14CHF));\n}\n\npublic void testSimpleAdd() {\n&nbsp;&nbsp;&nbsp; Money expected= new Money(26, \"CHF\");\n&nbsp;&nbsp;&nbsp; Money result= f12CHF.add(f14CHF);\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(expected.equals(result));\n}</tt></pre>\nTwo additional steps are needed to run the two test cases:\n<ol>\n<li>\ndefine how to run an individual test case,</li>\n\n<li>\ndefine how to run a <i>test suite</i>.</li>\n</ol>\nJUnit supports two ways of running single tests:\n<ul>\n<li>\nstatic</li>\n\n<li>\ndynamic</li>\n</ul>\nIn the static way you override the runTest method inherited from TestCase\nand call the desired test case. A convenient way to do this is with an\nanonymous inner class. Note that each test must be given a name, so you\ncan identify it if it fails.\n<pre><tt>TestCase test= new MoneyTest(\"simple add\") {\n&nbsp;&nbsp;&nbsp; public void runTest() {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; testSimpleAdd();\n&nbsp;&nbsp;&nbsp; }\n};</tt></pre>\nA template method<a href=\"#Gamma, E., et al. Design Patterns: Elements of\">[1]</a>\nin the superclass will make sure runTest is executed when the time comes.\n<p>The dynamic way to create a test case to be run uses reflection to implement\nrunTest. It assumes the name of the test is the name of the test case method\nto invoke. It dynamically finds and invokes the test method. To invoke\nthe testSimpleAdd test we therefore construct a MoneyTest as shown below:\n<pre><tt>TestCase test= new MoneyTest(\"testSimpleAdd\");</tt></pre>\nThe dynamic way is more compact to write but it is less static type safe.\nAn error in the name of the test case goes unnoticed until you run it and\nget a NoSuchMethodException. Since both approaches have advantages, we\ndecided to leave the choice of which to use up to you.\n<p>As the last step to getting both test cases to run together, we have\nto define a test suite. In JUnit this requires the definition of a static\nmethod called suite. The suite method is like a main method that is specialized\nto run tests. Inside suite you add the tests to be run to a\n<a href=\"../../javadoc/junit/framework/TestSuite.html\">TestSuite</a> object\nand return it. A TestSuite can run a collection of tests. TestSuite and\nTestCase both implement an interface called Test which defines the methods\nto run a test. This enables the creation of test suites by composing arbitrary\nTestCases and TestSuites. In short TestSuite is a Composite <a href=\"#Gamma, E., et al. Design Patterns: Elements of\">[1].</a>\nThe code below illustrates the creation of a test suite with the dynamic\nway to run a test.\n<pre><tt>public static Test suite() {\n&nbsp;&nbsp;&nbsp; TestSuite suite= new TestSuite();\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testEquals\"));\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testSimpleAdd\"));\n&nbsp;&nbsp;&nbsp; return suite;\n}</tt></pre>\nSince JUnit 2.0 there is an even simpler dynamic way. You only pass the\nclass with the tests to a TestSuite and it extracts the test methods automatically.\n<p><tt>public static Test suite() {<br>\n&nbsp;&nbsp;&nbsp; return new TestSuite(MoneyTest.class);<br>\n}</tt><tt></tt>\n<p>Here is the corresponding code using the static way.\n<pre><tt>public static Test suite() {\n&nbsp;&nbsp;&nbsp; TestSuite suite= new TestSuite();\n&nbsp;&nbsp;&nbsp; suite.addTest(\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new MoneyTest(\"money equals\") {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected void runTest() { testEquals(); }\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp;&nbsp; );\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp; suite.addTest(\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new MoneyTest(\"simple add\") {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected void runTest() { testSimpleAdd(); }\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp;&nbsp; );\n&nbsp;&nbsp;&nbsp; return suite;\n}</tt></pre>\nNow we are ready to run our tests. JUnit comes with a graphical&nbsp; interface\nto run tests. Type the name of your test class in the field at the top\nof the window. Press the Run button. While the test is run JUnit shows\nits progress with a progress bar below the input field. The bar is initially\ngreen but turns into red as soon as there is an unsuccessful test. Failed\ntests are shown in a list at the bottom. <a href=\"#Figure1\">Figure 1</a>\nshows the TestRunner window after we run our trivial test suite.\n<center><img SRC=\"IMG00001.GIF\" >\n<br><a NAME=\"Figure1\"></a><b>Figure 1</b>: A Successful Run</center>\n\n<p>After having verified that the simple currency case works we move on\nto multiple currencies. As mentioned above the problem of mixed currency\narithmetic is that there isn't a single exchange rate. To avoid this problem\nwe introduce a MoneyBag which defers exchange rate conversions. For example\nadding 12 Swiss Francs to 14 US Dollars is represented as a bag containing\nthe two Monies 12 CHF and 14 USD. Adding another 10 Swiss francs gives\na bag with 22 CHF and 14 USD. We can later evaluate a MoneyBag with different\nexchange rates.\n<p>A MoneyBag is represented as a list of Monies and provides different\nconstructors to create a MoneyBag. Note, that the constructors are package\nprivate since MoneyBags are created behind the scenes when doing currency\narithmetic.\n<pre><tt>class MoneyBag {\n&nbsp;&nbsp;&nbsp; private Vector fMonies= new Vector();\n\n&nbsp;&nbsp;&nbsp; MoneyBag(Money m1, Money m2) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appendMoney(m1);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appendMoney(m2);\n&nbsp;&nbsp;&nbsp; }\n\n&nbsp;&nbsp;&nbsp; MoneyBag(Money bag[]) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i= 0; i &lt; bag.length; i++)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appendMoney(bag[i]);\n&nbsp;&nbsp;&nbsp; }\n}</tt></pre>\nThe method appendMoney is an internal helper method that adds a Money to\nthe list of Moneys and takes care of consolidating Monies with the same\ncurrency. MoneyBag also needs an equals method together with a corresponding\ntest. We skip the implementation of equals and only show the testBagEquals\nmethod. In a first step we extend the fixture to include two MoneyBags.\n<pre><tt>protected void setUp() {\n&nbsp;&nbsp;&nbsp; f12CHF= new Money(12, \"CHF\");\n&nbsp;&nbsp;&nbsp; f14CHF= new Money(14, \"CHF\");\n&nbsp;&nbsp;&nbsp; f7USD=&nbsp; new Money( 7, \"USD\");\n&nbsp;&nbsp;&nbsp; f21USD= new Money(21, \"USD\");\n&nbsp;&nbsp;&nbsp; fMB1= new MoneyBag(f12CHF, f7USD);\n&nbsp;&nbsp;&nbsp; fMB2= new MoneyBag(f14CHF, f21USD);\n}</tt></pre>\nWith this fixture the testBagEquals test case becomes:\n<pre><tt>public void testBagEquals() {\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!fMB1.equals(null));\n&nbsp;&nbsp;&nbsp; Assert.assertEquals(fMB1, fMB1);\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!fMB1.equals(f12CHF));\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!f12CHF.equals(fMB1));\n&nbsp;&nbsp;&nbsp; Assert.assertTrue(!fMB1.equals(fMB2));\n}</tt></pre>\nFollowing \"code a little, test a little\" we run our extended test with\nJUnit and verify that we are still doing fine. With MoneyBag in hand, we\ncan now fix the add method in Money.\n<pre><tt>public Money add(Money m) {\n&nbsp;&nbsp;&nbsp; if (m.currency().equals(currency()) )\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new Money(amount()+m.amount(), currency());\n&nbsp;&nbsp;&nbsp; return new MoneyBag(this, m);\n}</tt></pre>\nAs defined above this method will not compile since it expects a Money\nand not a MoneyBag as its return value. With the introduction of MoneyBag\nthere are now two representations for Moneys which we would like to hide\nfrom the client code. To do so we introduce an interface IMoney that both\nrepresentations implement. Here is the IMoney interface:\n<pre><tt>interface IMoney {\n&nbsp;&nbsp;&nbsp; public abstract IMoney add(IMoney aMoney);\n&nbsp;&nbsp;&nbsp; //\n}</tt></pre>\nTo fully hide the different representations from the client we have to\nsupport arithmetic between all combinations of Moneys with MoneyBags. Before\nwe code on, we therefore define a couple more test cases. The expected\nMoneyBag results use the convenience constructor shown above, initializing\na MoneyBag from an array.\n<pre><tt>public void testMixedSimpleAdd() {&nbsp;\n&nbsp;&nbsp;&nbsp; // [12 CHF] + [7 USD] == {[12 CHF][7 USD]}&nbsp;\n&nbsp;&nbsp;&nbsp; Money bag[]= { f12CHF, f7USD };&nbsp;\n&nbsp;&nbsp;&nbsp; MoneyBag expected= new MoneyBag(bag);&nbsp;\n&nbsp;&nbsp;&nbsp; Assert.assertEquals(expected, f12CHF.add(f7USD));&nbsp;\n}</tt></pre>\nThe other tests follow the same pattern:\n<menu>\n<li>\ntestBagSimpleAdd - to add a MoneyBag to a simple Money</li>\n\n<li>\ntestSimpleBagAdd - to add a simple Money to a MoneyBag</li>\n\n<li>\ntestBagBagAdd - to add two MoneyBags</li>\n</menu>\nNext, we extend our test suite accordingly:\n<pre><tt>public static Test suite() {\n&nbsp;&nbsp;&nbsp; TestSuite suite= new TestSuite();\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testMoneyEquals\"));\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testBagEquals\"));\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testSimpleAdd\"));\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testMixedSimpleAdd\"));\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testBagSimpleAdd\"));\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testSimpleBagAdd\"));\n&nbsp;&nbsp;&nbsp; suite.addTest(new MoneyTest(\"testBagBagAdd\"));\n&nbsp;&nbsp;&nbsp; return suite;\n}</tt></pre>\nHaving defined the test cases we can start to implement them. The implementation\nchallenge here is dealing with all the different combinations of Money\nwith MoneyBag. Double dispatch <a href=\"#Beck, K. Smalltalk Best Practice Patterns,\">[2]</a>\nis an elegant way to solve this problem. The idea behind double dispatch\nis to use an additional call to discover the kind of argument we are dealing\nwith. We call a method on the argument with the name of the original method\nfollowed by the class name of the receiver. The add method in Money and\nMoneyBag becomes:\n<pre><tt>class Money implements IMoney {\n&nbsp;&nbsp;&nbsp; public IMoney add(IMoney m) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m.addMoney(this);\n&nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp;&nbsp; //\n}</tt></pre>\n\n<pre><tt>class MoneyBag implements IMoney {\n&nbsp;&nbsp;&nbsp; public IMoney add(IMoney m) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m.addMoneyBag(this);\n&nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp;&nbsp; //\n}</tt></pre>\nIn order to get this to compile we need to extend the interface of IMoney\nwith the two helper methods:\n<pre><tt>interface IMoney {\n//\n&nbsp;&nbsp;&nbsp; IMoney addMoney(Money aMoney);\n&nbsp;&nbsp;&nbsp; IMoney addMoneyBag(MoneyBag aMoneyBag);\n}</tt></pre>\nTo complete the implementation of double dispatch, we have to implement\nthese methods in Money and MoneyBag. This is the implementation in Money.\n<pre><tt>public IMoney addMoney(Money m) {\n&nbsp;&nbsp;&nbsp; if (m.currency().equals(currency()) )\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new Money(amount()+m.amount(), currency());\n&nbsp;&nbsp;&nbsp; return new MoneyBag(this, m);\n}\n\npublic IMoney addMoneyBag(MoneyBag s) {\n&nbsp;&nbsp;&nbsp; return s.addMoney(this);\n}</tt></pre>\nHere is the implementation in MoneyBag which assumes additional constructors\nto create a MoneyBag from a Money and a MoneyBag and from two MoneyBags.\n<pre><tt>public IMoney addMoney(Money m) {\n&nbsp;&nbsp;&nbsp; return new MoneyBag(m, this);\n}\n\npublic IMoney addMoneyBag(MoneyBag s) {\n&nbsp;&nbsp;&nbsp; return new MoneyBag(s, this);\n}</tt></pre>\nWe run the tests, and they pass. However, while reflecting on the implementation\nwe discover another interesting case. What happens when as the result of\nan addition a MoneyBag turns into a bag with only one Money? For example,\nadding -12 CHF to a Moneybag holding 7 USD and 12 CHF results in a bag\nwith just 7 USD. Obviously, such a bag should be equal with a single Money\nof 7 USD. To verify the problem let's implement a test case and run it.\n<pre><tt>public void testSimplify() {\n&nbsp;&nbsp;&nbsp; // {[12 CHF][7 USD]} + [-12 CHF] == [7 USD]\n&nbsp;&nbsp;&nbsp; Money expected= new Money(7, \"USD\");\n&nbsp;&nbsp;&nbsp; Assert.assertEquals(expected, fMB1.add(new Money(-12, \"CHF\")));\n}</tt></pre>\nWhen you are developing in this style you will often have a thought and\nturn immediately to writing a test, rather than going straight to the code.\n<p>It comes to no surprise that our test run ends with a red progress bar\nindicating the failure. So we fix the code in MoneyBag to get back to a\ngreen state.\n<pre><tt>public IMoney addMoney(Money m) {\n&nbsp;&nbsp;&nbsp; return (new MoneyBag(m, this)).simplify();\n}\n\npublic IMoney addMoneyBag(MoneyBag s) {\n&nbsp;&nbsp;&nbsp; return (new MoneyBag(s, this)).simplify();\n}\n\nprivate IMoney simplify() {\n&nbsp;&nbsp;&nbsp; if (fMonies.size() == 1)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (IMoney)fMonies.firstElement()\n&nbsp;&nbsp;&nbsp; return this;\n}</tt></pre>\nNow we run our tests again and voila we end up with green.\n<p>The code above solves only a small portion of the multi-currency arithmetic\nproblem. We have to represent different exchange rates, print formatting,\nand the other arithmetic operations, and do it all with reasonable speed.\nHowever, we hope you can see how you could develop the rest of the objects\none test at a time- a little test, a little code, a little test, a little\ncode.\n<p>In particular, review how in the development above:\n<ul>\n<li>\nWe wrote the first test, testSimpleAdd, immediately after we had written\nadd(). In general, your development will go much smoother if you write\ntests a little at a time as you develop. It is at the moment that you are\ncoding that you are imagining how that code will work. That's the perfect\ntime to capture your thoughts in a test.</li>\n\n<li>\nWe refactored the existing tests, testSimpleAdd and testEqual, as soon\nas we introduced the common setUp code. Test code is just like model code\nin working best if it is factored well. When you see you have the same\ntest code in two places, try to find a way to refactor it so it only appears\nonce.</li>\n\n<li>\nWe created a suite method, then extended it when we applied Double Dispatch.\nKeeping old tests running is just as important as making new ones run.\nThe ideal is to always run all of your tests. Sometimes that will be too\nslow to do 10 times an hour. Make sure you run all of your tests at least\ndaily.</li>\n\n<li>\nWe created a new test immediately when we thought of the requirement that\na one element MoneyBag should just return its element. It can be difficult\nto learn to switch gears like this, but we have found it valuable. When\nyou are struck by an idea of what your system should do, defer thinking\nabout the implementation. Instead, first write the test. Then run it (you\nnever know, it might already work). Then work on the implementation.</li>\n</ul>\n\n<h1>\n<a NAME=\"TestingPractices\"></a>Testing Practices</h1>\nMartin Fowler makes this easy for you. He says, \"Whenever you are tempted\nto type something into a print statement or a debugger expression, write\nit as a test instead.\" At first you will find that you have to create a\nnew fixtures all the time, and testing will seem to slow you down a little.\nSoon, however, you will begin reusing your library of fixtures and new\ntests will usually be as simple as adding a method to an existing TestCase\nsubclass.\n<p>You can always write more tests. However, you will quickly find that\nonly a fraction of the tests you can imagine are actually useful. What\nyou want is to write tests that fail even though you think they should\nwork, or tests that succeed even though you think they should fail. Another\nway to think of it is in cost/benefit terms. You want to write tests that\nwill pay you back with information.\n<p>Here are a couple of the times that you will receive a reasonable return\non your testing investment:\n<ul>\n<li>\nDuring Development- When you need to add new functionality to the system,\nwrite the tests first. Then, you will be done developing when the test\nruns.</li>\n\n<li>\nDuring Debugging- When someone discovers a defect in your code, first write\na test that will succeed if the code is working. Then debug until the test\nsucceeds.</li>\n</ul>\nOne word of caution about your tests. Once you get them running, make sure\nthey stay running. There is a huge difference between having your suite\nrunning and having it broken. Ideally, you would run every test in your\nsuite every time you change a method. Practically, your suite will soon\ngrow too large to run all the time. Try to optimize your setup code so\nyou can run all the tests. Or, at the very least, create special suites\nthat contain all the tests that might possibly be affected by your current\ndevelopment. Then, run the suite every time you compile. And make sure\nyou run every test at least once a day: overnight, during lunch, during\none of those long meetings.\n<h1>\n<a NAME=\"Conclusion\"></a>Conclusion</h1>\nThis article only scratches the surface of testing. However, it focuses\non a style of testing that with a remarkably small investment will make\nyou a faster, more productive, more predictable, and less stressed developer.\n<p>Once you've been test infected, your attitude toward development is\nlikely to change. Here are some of the changes we have noticed:\n<p>There is a huge difference between tests that are all running correctly\nand tests that aren't. Part of being test infected is not being able to\ngo home if your tests aren't 100%. If you run your suite ten or a hundred\ntimes an hour, though, you won't be able to create enough havoc to make\nyou late for supper.\n<p>Sometimes you just won't feel like writing tests, especially at first.\nDon't. However, pay attention to how much more trouble you get into, how\nmuch more time you spend debugging, and how much more stress you feel when\nyou don't have tests. We have been amazed at how much more fun programming\nis and how much more aggressive we are willing to be and how much less\nstress we feel when we are supported by tests. The difference is dramatic\nenough to keep us writing tests even when we don't feel like it.\n<p>You will be able to refactor much more aggressively once you have the\ntests. You won't understand at first just how much you can do, though.\nTry to catch yourself saying, \"Oh, I see, I should have designed this thus\nand so. I can't change it now. I don't want to break anything.\" When you\nsay this, save a copy of your current code and give yourself a couple of\nhours to clean up. (This part works best you can get a buddy to look over\nyour shoulder while you work.) Make your changes, all the while running\nyour tests. You will be surprised at how much ground you can cover in a\ncouple of hours if you aren't worrying every second about what you might\nbe breaking.\n<p>For example, we switched from the Vector-based implementation of MoneyBag\nto one based on HashTable. We were able to make the switch very quickly\nand confidently because we had so many tests to rely on. If the tests all\nworked, we were sure we hadn't changed the answers the system produced\nat all.\n<p>You will want to get the rest of your team writing tests. The best way\nwe have found to spread the test infection is through direct contact. The\nnext time someone asks you for help debugging, get them to talk about the\nproblem in terms of a fixture and expected results. Then say, \"I'd like\nto write down what you just told me in a form we can use.\" Have them watch\nwhile you write one little test. Run it. Fix it. Write another. Pretty\nsoon they will be writing their own.\n<p>So- give JUnit a try. If you make it better, please send us the changes\nso we can spread them around. Our next article will double click on the\nJUnit framework itself. We will show you how it is constructed, and talk\na little about our philosophy of framework development.\n<p>We would like to thank Martin Fowler, as good a programmer as any analyst\ncan ever hope to be, for his helpful comments in spite of being subjected\nto early versions of JUnit.\n<h1>\nReferences</h1>\n\n<ol>\n<li>\n<a NAME=\"Gamma, E., et al. Design Patterns: Elements of\"></a>Gamma, E.,\net al. Design Patterns: Elements of Reusable Object-Oriented Software,\nAddison-Wesley, Reading, MA, 1995</li>\n\n<li>\n<a NAME=\"Beck, K. Smalltalk Best Practice Patterns,\"></a>Beck, K. Smalltalk\nBest Practice Patterns, Prentice Hall, 1996</li>\n</ol>\n\n<hr SIZE=1 WIDTH=\"100%\">\n</body>\n</html>\n"
  },
  {
    "path": "epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<h2>Eclipse Public License - v 1.0</h2>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>"
  },
  {
    "path": "mvnw",
    "content": "#!/bin/sh\n# ----------------------------------------------------------------------------\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n# ----------------------------------------------------------------------------\n\n# ----------------------------------------------------------------------------\n# Apache Maven Wrapper startup batch script, version 3.3.1\n#\n# Optional ENV vars\n# -----------------\n#   JAVA_HOME - location of a JDK home dir, required when download maven via java source\n#   MVNW_REPOURL - repo url base for downloading maven distribution\n#   MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven\n#   MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output\n# ----------------------------------------------------------------------------\n\nset -euf\n[ \"${MVNW_VERBOSE-}\" != debug ] || set -x\n\n# OS specific support.\nnative_path() { printf %s\\\\n \"$1\"; }\ncase \"$(uname)\" in\nCYGWIN* | MINGW*)\n  [ -z \"${JAVA_HOME-}\" ] || JAVA_HOME=\"$(cygpath --unix \"$JAVA_HOME\")\"\n  native_path() { cygpath --path --windows \"$1\"; }\n  ;;\nesac\n\n# set JAVACMD and JAVACCMD\nset_java_home() {\n  # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched\n  if [ -n \"${JAVA_HOME-}\" ]; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ]; then\n      # IBM's JDK on AIX uses strange locations for the executables\n      JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n      JAVACCMD=\"$JAVA_HOME/jre/sh/javac\"\n    else\n      JAVACMD=\"$JAVA_HOME/bin/java\"\n      JAVACCMD=\"$JAVA_HOME/bin/javac\"\n\n      if [ ! -x \"$JAVACMD\" ] || [ ! -x \"$JAVACCMD\" ]; then\n        echo \"The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run.\" >&2\n        echo \"JAVA_HOME is set to \\\"$JAVA_HOME\\\", but \\\"\\$JAVA_HOME/bin/java\\\" or \\\"\\$JAVA_HOME/bin/javac\\\" does not exist.\" >&2\n        return 1\n      fi\n    fi\n  else\n    JAVACMD=\"$(\n      'set' +e\n      'unset' -f command 2>/dev/null\n      'command' -v java\n    )\" || :\n    JAVACCMD=\"$(\n      'set' +e\n      'unset' -f command 2>/dev/null\n      'command' -v javac\n    )\" || :\n\n    if [ ! -x \"${JAVACMD-}\" ] || [ ! -x \"${JAVACCMD-}\" ]; then\n      echo \"The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run.\" >&2\n      return 1\n    fi\n  fi\n}\n\n# hash string like Java String::hashCode\nhash_string() {\n  str=\"${1:-}\" h=0\n  while [ -n \"$str\" ]; do\n    char=\"${str%\"${str#?}\"}\"\n    h=$(((h * 31 + $(LC_CTYPE=C printf %d \"'$char\")) % 4294967296))\n    str=\"${str#?}\"\n  done\n  printf %x\\\\n $h\n}\n\nverbose() { :; }\n[ \"${MVNW_VERBOSE-}\" != true ] || verbose() { printf %s\\\\n \"${1-}\"; }\n\ndie() {\n  printf %s\\\\n \"$1\" >&2\n  exit 1\n}\n\n# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties\nwhile IFS=\"=\" read -r key value; do\n  case \"${key-}\" in\n  distributionUrl) distributionUrl=\"${value-}\" ;;\n  distributionSha256Sum) distributionSha256Sum=\"${value-}\" ;;\n  esac\ndone <\"${0%/*}/.mvn/wrapper/maven-wrapper.properties\"\n[ -n \"${distributionUrl-}\" ] || die \"cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties\"\n\ncase \"${distributionUrl##*/}\" in\nmaven-mvnd-*bin.*)\n  MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/\n  case \"${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)\" in\n  *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;\n  :Darwin*x86_64) distributionPlatform=darwin-amd64 ;;\n  :Darwin*arm64) distributionPlatform=darwin-aarch64 ;;\n  :Linux*x86_64*) distributionPlatform=linux-amd64 ;;\n  *)\n    echo \"Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version\" >&2\n    distributionPlatform=linux-amd64\n    ;;\n  esac\n  distributionUrl=\"${distributionUrl%-bin.*}-$distributionPlatform.zip\"\n  ;;\nmaven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;\n*) MVN_CMD=\"mvn${0##*/mvnw}\" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;\nesac\n\n# apply MVNW_REPOURL and calculate MAVEN_HOME\n# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>\n[ -z \"${MVNW_REPOURL-}\" ] || distributionUrl=\"$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*\"$_MVNW_REPO_PATTERN\"}\"\ndistributionUrlName=\"${distributionUrl##*/}\"\ndistributionUrlNameMain=\"${distributionUrlName%.*}\"\ndistributionUrlNameMain=\"${distributionUrlNameMain%-bin}\"\nMAVEN_HOME=\"$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string \"$distributionUrl\")\"\n\nexec_maven() {\n  unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :\n  exec \"$MAVEN_HOME/bin/$MVN_CMD\" \"$@\" || die \"cannot exec $MAVEN_HOME/bin/$MVN_CMD\"\n}\n\nif [ -d \"$MAVEN_HOME\" ]; then\n  verbose \"found existing MAVEN_HOME at $MAVEN_HOME\"\n  exec_maven \"$@\"\nfi\n\ncase \"${distributionUrl-}\" in\n*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;\n*) die \"distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'\" ;;\nesac\n\n# prepare tmp dir\nif TMP_DOWNLOAD_DIR=\"$(mktemp -d)\" && [ -d \"$TMP_DOWNLOAD_DIR\" ]; then\n  clean() { rm -rf -- \"$TMP_DOWNLOAD_DIR\"; }\n  trap clean HUP INT TERM EXIT\nelse\n  die \"cannot create temp dir\"\nfi\n\nmkdir -p -- \"${MAVEN_HOME%/*}\"\n\n# Download and Install Apache Maven\nverbose \"Couldn't find MAVEN_HOME, downloading and installing it ...\"\nverbose \"Downloading from: $distributionUrl\"\nverbose \"Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName\"\n\n# select .zip or .tar.gz\nif ! command -v unzip >/dev/null; then\n  distributionUrl=\"${distributionUrl%.zip}.tar.gz\"\n  distributionUrlName=\"${distributionUrl##*/}\"\nfi\n\n# verbose opt\n__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''\n[ \"${MVNW_VERBOSE-}\" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v\n\n# normalize http auth\ncase \"${MVNW_PASSWORD:+has-password}\" in\n'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;\nhas-password) [ -n \"${MVNW_USERNAME-}\" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;\nesac\n\nif [ -z \"${MVNW_USERNAME-}\" ] && command -v wget >/dev/null; then\n  verbose \"Found wget ... using wget\"\n  wget ${__MVNW_QUIET_WGET:+\"$__MVNW_QUIET_WGET\"} \"$distributionUrl\" -O \"$TMP_DOWNLOAD_DIR/$distributionUrlName\" || die \"wget: Failed to fetch $distributionUrl\"\nelif [ -z \"${MVNW_USERNAME-}\" ] && command -v curl >/dev/null; then\n  verbose \"Found curl ... using curl\"\n  curl ${__MVNW_QUIET_CURL:+\"$__MVNW_QUIET_CURL\"} -f -L -o \"$TMP_DOWNLOAD_DIR/$distributionUrlName\" \"$distributionUrl\" || die \"curl: Failed to fetch $distributionUrl\"\nelif set_java_home; then\n  verbose \"Falling back to use Java to download\"\n  javaSource=\"$TMP_DOWNLOAD_DIR/Downloader.java\"\n  targetZip=\"$TMP_DOWNLOAD_DIR/$distributionUrlName\"\n  cat >\"$javaSource\" <<-END\n\tpublic class Downloader extends java.net.Authenticator\n\t{\n\t  protected java.net.PasswordAuthentication getPasswordAuthentication()\n\t  {\n\t    return new java.net.PasswordAuthentication( System.getenv( \"MVNW_USERNAME\" ), System.getenv( \"MVNW_PASSWORD\" ).toCharArray() );\n\t  }\n\t  public static void main( String[] args ) throws Exception\n\t  {\n\t    setDefault( new Downloader() );\n\t    java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );\n\t  }\n\t}\n\tEND\n  # For Cygwin/MinGW, switch paths to Windows format before running javac and java\n  verbose \" - Compiling Downloader.java ...\"\n  \"$(native_path \"$JAVACCMD\")\" \"$(native_path \"$javaSource\")\" || die \"Failed to compile Downloader.java\"\n  verbose \" - Running Downloader.java ...\"\n  \"$(native_path \"$JAVACMD\")\" -cp \"$(native_path \"$TMP_DOWNLOAD_DIR\")\" Downloader \"$distributionUrl\" \"$(native_path \"$targetZip\")\"\nfi\n\n# If specified, validate the SHA-256 sum of the Maven distribution zip file\nif [ -n \"${distributionSha256Sum-}\" ]; then\n  distributionSha256Result=false\n  if [ \"$MVN_CMD\" = mvnd.sh ]; then\n    echo \"Checksum validation is not supported for maven-mvnd.\" >&2\n    echo \"Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties.\" >&2\n    exit 1\n  elif command -v sha256sum >/dev/null; then\n    if echo \"$distributionSha256Sum  $TMP_DOWNLOAD_DIR/$distributionUrlName\" | sha256sum -c >/dev/null 2>&1; then\n      distributionSha256Result=true\n    fi\n  elif command -v shasum >/dev/null; then\n    if echo \"$distributionSha256Sum  $TMP_DOWNLOAD_DIR/$distributionUrlName\" | shasum -a 256 -c >/dev/null 2>&1; then\n      distributionSha256Result=true\n    fi\n  else\n    echo \"Checksum validation was requested but neither 'sha256sum' or 'shasum' are available.\" >&2\n    echo \"Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties.\" >&2\n    exit 1\n  fi\n  if [ $distributionSha256Result = false ]; then\n    echo \"Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised.\" >&2\n    echo \"If you updated your Maven version, you need to update the specified distributionSha256Sum property.\" >&2\n    exit 1\n  fi\nfi\n\n# unzip and move\nif command -v unzip >/dev/null; then\n  unzip ${__MVNW_QUIET_UNZIP:+\"$__MVNW_QUIET_UNZIP\"} \"$TMP_DOWNLOAD_DIR/$distributionUrlName\" -d \"$TMP_DOWNLOAD_DIR\" || die \"failed to unzip\"\nelse\n  tar xzf${__MVNW_QUIET_TAR:+\"$__MVNW_QUIET_TAR\"} \"$TMP_DOWNLOAD_DIR/$distributionUrlName\" -C \"$TMP_DOWNLOAD_DIR\" || die \"failed to untar\"\nfi\nprintf %s\\\\n \"$distributionUrl\" >\"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url\"\nmv -- \"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain\" \"$MAVEN_HOME\" || [ -d \"$MAVEN_HOME\" ] || die \"fail to move MAVEN_HOME\"\n\nclean || :\nexec_maven \"$@\"\n"
  },
  {
    "path": "mvnw.cmd",
    "content": "<# : batch portion\n@REM ----------------------------------------------------------------------------\n@REM Licensed to the Apache Software Foundation (ASF) under one\n@REM or more contributor license agreements.  See the NOTICE file\n@REM distributed with this work for additional information\n@REM regarding copyright ownership.  The ASF licenses this file\n@REM to you under the Apache License, Version 2.0 (the\n@REM \"License\"); you may not use this file except in compliance\n@REM with the License.  You may obtain a copy of the License at\n@REM\n@REM    http://www.apache.org/licenses/LICENSE-2.0\n@REM\n@REM Unless required by applicable law or agreed to in writing,\n@REM software distributed under the License is distributed on an\n@REM \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n@REM KIND, either express or implied.  See the License for the\n@REM specific language governing permissions and limitations\n@REM under the License.\n@REM ----------------------------------------------------------------------------\n\n@REM ----------------------------------------------------------------------------\n@REM Apache Maven Wrapper startup batch script, version 3.3.1\n@REM\n@REM Optional ENV vars\n@REM   MVNW_REPOURL - repo url base for downloading maven distribution\n@REM   MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven\n@REM   MVNW_VERBOSE - true: enable verbose log; others: silence the output\n@REM ----------------------------------------------------------------------------\n\n@IF \"%__MVNW_ARG0_NAME__%\"==\"\" (SET __MVNW_ARG0_NAME__=%~nx0)\n@SET __MVNW_CMD__=\n@SET __MVNW_ERROR__=\n@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%\n@SET PSModulePath=\n@FOR /F \"usebackq tokens=1* delims==\" %%A IN (`powershell -noprofile \"& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}\"`) DO @(\n  IF \"%%A\"==\"MVN_CMD\" (set __MVNW_CMD__=%%B) ELSE IF \"%%B\"==\"\" (echo %%A) ELSE (echo %%A=%%B)\n)\n@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%\n@SET __MVNW_PSMODULEP_SAVE=\n@SET __MVNW_ARG0_NAME__=\n@SET MVNW_USERNAME=\n@SET MVNW_PASSWORD=\n@IF NOT \"%__MVNW_CMD__%\"==\"\" (%__MVNW_CMD__% %*)\n@echo Cannot start maven from wrapper >&2 && exit /b 1\n@GOTO :EOF\n: end batch / begin powershell #>\n\n$ErrorActionPreference = \"Stop\"\nif ($env:MVNW_VERBOSE -eq \"true\") {\n  $VerbosePreference = \"Continue\"\n}\n\n# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties\n$distributionUrl = (Get-Content -Raw \"$scriptDir/.mvn/wrapper/maven-wrapper.properties\" | ConvertFrom-StringData).distributionUrl\nif (!$distributionUrl) {\n  Write-Error \"cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties\"\n}\n\nswitch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {\n  \"maven-mvnd-*\" {\n    $USE_MVND = $true\n    $distributionUrl = $distributionUrl -replace '-bin\\.[^.]*$',\"-windows-amd64.zip\"\n    $MVN_CMD = \"mvnd.cmd\"\n    break\n  }\n  default {\n    $USE_MVND = $false\n    $MVN_CMD = $script -replace '^mvnw','mvn'\n    break\n  }\n}\n\n# apply MVNW_REPOURL and calculate MAVEN_HOME\n# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>\nif ($env:MVNW_REPOURL) {\n  $MVNW_REPO_PATTERN = if ($USE_MVND) { \"/org/apache/maven/\" } else { \"/maven/mvnd/\" }\n  $distributionUrl = \"$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')\"\n}\n$distributionUrlName = $distributionUrl -replace '^.*/',''\n$distributionUrlNameMain = $distributionUrlName -replace '\\.[^.]*$','' -replace '-bin$',''\n$MAVEN_HOME_PARENT = \"$HOME/.m2/wrapper/dists/$distributionUrlNameMain\"\n$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString(\"x2\")}) -join ''\n$MAVEN_HOME = \"$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME\"\n\nif (Test-Path -Path \"$MAVEN_HOME\" -PathType Container) {\n  Write-Verbose \"found existing MAVEN_HOME at $MAVEN_HOME\"\n  Write-Output \"MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD\"\n  exit $?\n}\n\nif (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {\n  Write-Error \"distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl\"\n}\n\n# prepare tmp dir\n$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile\n$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path \"$TMP_DOWNLOAD_DIR_HOLDER.dir\"\n$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null\ntrap {\n  if ($TMP_DOWNLOAD_DIR.Exists) {\n    try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }\n    catch { Write-Warning \"Cannot remove $TMP_DOWNLOAD_DIR\" }\n  }\n}\n\nNew-Item -Itemtype Directory -Path \"$MAVEN_HOME_PARENT\" -Force | Out-Null\n\n# Download and Install Apache Maven\nWrite-Verbose \"Couldn't find MAVEN_HOME, downloading and installing it ...\"\nWrite-Verbose \"Downloading from: $distributionUrl\"\nWrite-Verbose \"Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName\"\n\n$webclient = New-Object System.Net.WebClient\nif ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {\n  $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)\n}\n[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12\n$webclient.DownloadFile($distributionUrl, \"$TMP_DOWNLOAD_DIR/$distributionUrlName\") | Out-Null\n\n# If specified, validate the SHA-256 sum of the Maven distribution zip file\n$distributionSha256Sum = (Get-Content -Raw \"$scriptDir/.mvn/wrapper/maven-wrapper.properties\" | ConvertFrom-StringData).distributionSha256Sum\nif ($distributionSha256Sum) {\n  if ($USE_MVND) {\n    Write-Error \"Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties.\"\n  }\n  Import-Module $PSHOME\\Modules\\Microsoft.PowerShell.Utility -Function Get-FileHash\n  if ((Get-FileHash \"$TMP_DOWNLOAD_DIR/$distributionUrlName\" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {\n    Write-Error \"Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property.\"\n  }\n}\n\n# unzip and move\nExpand-Archive \"$TMP_DOWNLOAD_DIR/$distributionUrlName\" -DestinationPath \"$TMP_DOWNLOAD_DIR\" | Out-Null\nRename-Item -Path \"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain\" -NewName $MAVEN_HOME_NAME | Out-Null\ntry {\n  Move-Item -Path \"$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME\" -Destination $MAVEN_HOME_PARENT | Out-Null\n} catch {\n  if (! (Test-Path -Path \"$MAVEN_HOME\" -PathType Container)) {\n    Write-Error \"fail to move MAVEN_HOME\"\n  }\n} finally {\n  try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }\n  catch { Write-Warning \"Cannot remove $TMP_DOWNLOAD_DIR\" }\n}\n\nWrite-Output \"MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD\"\n"
  },
  {
    "path": "pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <groupId>junit</groupId>\n    <artifactId>junit</artifactId>\n    <version>4.13.3-SNAPSHOT</version>\n\n    <name>JUnit</name>\n    <description>JUnit is a unit testing framework for Java, created by Erich Gamma and Kent Beck.</description>\n    <url>http://junit.org</url>\n    <inceptionYear>2002</inceptionYear>\n    <organization>\n        <name>JUnit</name>\n        <url>http://www.junit.org</url>\n    </organization>\n    <licenses>\n        <license>\n            <name>Eclipse Public License 1.0</name>\n            <url>http://www.eclipse.org/legal/epl-v10.html</url>\n            <distribution>repo</distribution>\n        </license>\n    </licenses>\n\n    <developers>\n        <developer>\n            <id>dsaff</id>\n            <name>David Saff</name>\n            <email>david@saff.net</email>\n        </developer>\n        <developer>\n            <id>kcooney</id>\n            <name>Kevin Cooney</name>\n            <email>kcooney@gmail.com</email>\n        </developer>\n        <developer>\n            <id>stefanbirkner</id>\n            <name>Stefan Birkner</name>\n            <email>mail@stefan-birkner.de</email>\n        </developer>\n        <developer>\n            <id>marcphilipp</id>\n            <name>Marc Philipp</name>\n            <email>mail@marcphilipp.de</email>\n        </developer>\n    </developers>\n    <contributors>\n        <contributor>\n            <name>JUnit contributors</name>\n            <organization>JUnit</organization>\n            <email>team@junit.org</email>\n            <url>https://github.com/junit-team/junit4/graphs/contributors</url>\n            <roles>\n                <role>developers</role>\n            </roles>\n        </contributor>\n    </contributors>\n\n    <prerequisites>\n        <maven>3.0.4</maven>\n    </prerequisites>\n\n    <scm>\n        <connection>scm:git:git://github.com/junit-team/junit4.git</connection>\n        <developerConnection>scm:git:git@github.com:junit-team/junit4.git</developerConnection>\n        <url>https://github.com/junit-team/junit4</url>\n      <tag>HEAD</tag>\n  </scm>\n    <issueManagement>\n        <system>github</system>\n        <url>https://github.com/junit-team/junit4/issues</url>\n    </issueManagement>\n    <ciManagement>\n        <system>github</system>\n        <url>https://github.com/junit-team/junit4/actions</url>\n    </ciManagement>\n    <distributionManagement>\n        <downloadUrl>https://github.com/junit-team/junit4/wiki/Download-and-Install</downloadUrl>\n        <site>\n            <id>junit.github.io</id>\n            <url>gitsite:git@github.com/junit-team/junit4.git</url>\n        </site>\n    </distributionManagement>\n\n    <properties>\n        <jdkVersion>1.5</jdkVersion>\n        <surefireVersion>2.19.1</surefireVersion>\n        <hamcrestVersion>1.3</hamcrestVersion>\n        <enforcerPluginVersion>1.4</enforcerPluginVersion>\n        <jarPluginVersion>2.6</jarPluginVersion>\n        <javadocPluginVersion>2.10.3</javadocPluginVersion>\n        <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>\n        <arguments />\n        <gpg.keyname>FF6E2C001948C5F2F38B0CC385911F425EC61B51</gpg.keyname>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.hamcrest</groupId>\n            <artifactId>hamcrest-core</artifactId>\n            <version>${hamcrestVersion}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>org.hamcrest</groupId>\n            <artifactId>hamcrest-library</artifactId>\n            <version>${hamcrestVersion}</version>\n            <scope>test</scope>\n        </dependency>\n    </dependencies>\n\n    <build>\n        <resources>\n            <resource>\n                <directory>${project.basedir}/src/main/resources</directory>\n            </resource>\n            <resource>\n                <directory>${project.basedir}</directory>\n                <includes>\n                    <include>LICENSE-junit.txt</include>\n                </includes>\n            </resource>\n        </resources>\n        <plugins>\n            <!--\n            Both \"org.apache\" and \"org.codehaus\" are default providers of MOJO plugins\n            which are especially dedicated to Maven projects.\n            The MOJO stands for \"Maven plain Old Java Object\".\n            Each mojo is an executable goal in Maven, and a plugin is a distribution of\n            one or more related mojos.\n            For more information see http://maven.apache.org/plugin-developers/index.html\n\n            The following plugins are ordered according the Maven build lifecycle.\n            http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html\n            -->\n            <plugin>\n                <!--\n                Checks that the version of user's maven installation is 3.0.4,\n                the JDK is 1.5+, no non-standard repositories are specified in\n                the project, requires only release versions of dependencies of other artifacts.\n                -->\n                <artifactId>maven-enforcer-plugin</artifactId>\n                <version>${enforcerPluginVersion}</version>\n                <executions>\n                    <execution>\n                        <id>enforce-versions</id>\n                        <phase>initialize</phase>\n                        <goals>\n                            <goal>enforce</goal>\n                        </goals>\n                        <configuration>\n                            <fail>true</fail>\n                            <rules>\n                                <requireMavenVersion>\n                                    <!-- Some plugin features require a recent Maven runtime to work properly -->\n                                    <message>Current version of Maven ${maven.version} required to build the project\n                                        should be ${project.prerequisites.maven}, or higher!\n                                    </message>\n                                    <version>[${project.prerequisites.maven},)</version>\n                                </requireMavenVersion>\n                                <requireJavaVersion>\n                                    <message>Current JDK version ${java.version} should be ${jdkVersion}, or higher!\n                                    </message>\n                                    <version>${jdkVersion}</version>\n                                </requireJavaVersion>\n                                <requireNoRepositories>\n                                    <message>Best Practice is to never define repositories in pom.xml (use a repository\n                                        manager instead).\n                                    </message>\n                                </requireNoRepositories>\n                                <requireReleaseDeps>\n                                    <message>No Snapshots Dependencies Allowed!</message>\n                                </requireReleaseDeps>\n                            </rules>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <!--\n                Updates Version#id().\n                -->\n                <groupId>com.google.code.maven-replacer-plugin</groupId>\n                <artifactId>replacer</artifactId>\n                <version>1.5.3</version>\n                <executions>\n                    <execution>\n                        <phase>process-sources</phase>\n                        <goals>\n                            <goal>replace</goal>\n                        </goals>\n                    </execution>\n                </executions>\n                <configuration>\n                    <ignoreMissingFile>false</ignoreMissingFile>\n                    <file>${project.build.sourceDirectory}/junit/runner/Version.java.template</file>\n                    <outputFile>${project.build.sourceDirectory}/junit/runner/Version.java</outputFile>\n                    <regex>false</regex>\n                    <token>@version@</token>\n                    <value>${project.version}</value>\n                </configuration>\n            </plugin>\n            <plugin><!-- Using jdk 1.5.0_22, package-info.java files are compiled correctly. -->\n                <!--\n                java compiler plugin forked in extra process\n                -->\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.3</version>\n                <configuration>\n                    <encoding>${project.build.sourceEncoding}</encoding>\n                    <source>${jdkVersion}</source>\n                    <target>${jdkVersion}</target>\n                    <testSource>${jdkVersion}</testSource>\n                    <testTarget>${jdkVersion}</testTarget>\n                    <compilerVersion>1.5</compilerVersion>\n                    <showDeprecation>true</showDeprecation>\n                    <showWarnings>true</showWarnings>\n                    <debug>true</debug>\n                    <fork>true</fork>\n                    <compilerArgs>\n                        <arg>-Xlint:unchecked</arg>\n                    </compilerArgs>\n                    <maxmem>128m</maxmem>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.codehaus.mojo</groupId>\n                <artifactId>animal-sniffer-maven-plugin</artifactId>\n                <version>1.14</version>\n                <executions>\n                    <execution>\n                        <id>signature-check</id>\n                        <phase>test</phase>\n                        <goals>\n                            <goal>check</goal>\n                        </goals>\n                        <configuration>\n                            <signature>\n                                <groupId>org.codehaus.mojo.signature</groupId>\n                                <artifactId>java15</artifactId>\n                                <version>1.0</version>\n                            </signature>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <!--\n                A plugin which uses the JUnit framework in order to start\n                our junit suite \"AllTests\" after the sources are compiled.\n                -->\n                <artifactId>maven-surefire-plugin</artifactId>\n                <version>${surefireVersion}</version>\n                <configuration>\n                    <includes>\n                        <include>org/junit/tests/AllTests.java</include>\n                    </includes>\n                    <useSystemClassLoader>true</useSystemClassLoader>\n                    <enableAssertions>false</enableAssertions>\n                </configuration>\n                <dependencies>\n                    <dependency>\n                        <groupId>org.apache.maven.surefire</groupId>\n                        <artifactId>surefire-junit47</artifactId>\n                        <version>${surefireVersion}</version>\n                    </dependency>\n                </dependencies>\n            </plugin>\n            <plugin>\n                <!--\n                This plugin can package the main artifact's sources (src/main/java)\n                in to jar archive. See target/junit-*-sources.jar.\n                -->\n                <artifactId>maven-source-plugin</artifactId>\n                <version>2.4</version>\n            </plugin>\n            <plugin>\n                <!--\n                This plugin can generate Javadoc by a forked\n                process and then package the Javadoc\n                in jar archive target/junit-*-javadoc.jar.\n                -->\n                <artifactId>maven-javadoc-plugin</artifactId>\n                <version>${javadocPluginVersion}</version>\n                <configuration>\n                    <stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>\n                    <show>protected</show>\n                    <author>false</author>\n                    <version>false</version>\n                    <detectLinks>false</detectLinks>\n                    <linksource>true</linksource>\n                    <keywords>true</keywords>\n                    <use>true</use>\n                    <windowtitle>JUnit API</windowtitle>\n                    <encoding>UTF-8</encoding>\n                    <locale>en</locale>\n                    <javadocVersion>${jdkVersion}</javadocVersion>\n                    <javaApiLinks>\n                        <property>\n                            <name>api_${jdkVersion}</name>\n                            <value>http://docs.oracle.com/javase/${jdkVersion}.0/docs/api/</value>\n                        </property>\n                    </javaApiLinks>\n                    <excludePackageNames>*.internal.*</excludePackageNames>\n                    <verbose>true</verbose>\n                    <minmemory>32m</minmemory>\n                    <maxmemory>128m</maxmemory>\n                    <failOnError>true</failOnError>\n                    <includeDependencySources>true</includeDependencySources>\n                    <dependencySourceIncludes>\n                        <dependencySourceInclude>org.hamcrest:hamcrest-core:*</dependencySourceInclude>\n                    </dependencySourceIncludes>\n                </configuration>\n            </plugin>\n            <plugin>\n                <artifactId>maven-release-plugin</artifactId>\n                <version>2.5.2</version>\n                <configuration>\n                    <mavenExecutorId>forked-path</mavenExecutorId>\n                    <useReleaseProfile>false</useReleaseProfile>\n                    <arguments>-Pgenerate-docs,junit-release ${arguments}</arguments>\n                    <tagNameFormat>r@{project.version}</tagNameFormat>\n                </configuration>\n            </plugin>\n            <plugin>\n                <artifactId>maven-site-plugin</artifactId>\n                <version>3.4</version>\n                <dependencies>\n                    <dependency>\n                        <groupId>com.github.stephenc.wagon</groupId>\n                        <artifactId>wagon-gitsite</artifactId>\n                        <version>0.4.1</version>\n                    </dependency>\n                    <dependency>\n                        <groupId>org.apache.maven.doxia</groupId>\n                        <artifactId>doxia-module-markdown</artifactId>\n                        <version>1.5</version>\n                    </dependency>\n                </dependencies>\n            </plugin>\n            <plugin>\n                <artifactId>maven-jar-plugin</artifactId>\n                <version>${jarPluginVersion}</version>\n                <configuration>\n                    <archive>\n                        <addMavenDescriptor>false</addMavenDescriptor>\n                        <manifest>\n                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>\n                        </manifest>\n                        <manifestEntries>\n                            <Automatic-Module-Name>junit</Automatic-Module-Name>\n                        </manifestEntries>                        \n                    </archive>\n                </configuration>\n            </plugin>\n            <plugin>\n                <artifactId>maven-clean-plugin</artifactId>\n                <version>2.6.1</version>\n            </plugin>\n            <plugin>\n                <artifactId>maven-deploy-plugin</artifactId>\n                <version>2.8.2</version>\n            </plugin>\n            <plugin>\n                <artifactId>maven-install-plugin</artifactId>\n                <version>2.5.2</version>\n            </plugin>\n            <plugin>\n                <artifactId>maven-resources-plugin</artifactId>\n                <version>2.7</version>\n            </plugin>\n            <plugin>\n                <groupId>org.sonatype.central</groupId>\n                <artifactId>central-publishing-maven-plugin</artifactId>\n                <version>0.7.0</version>\n                <extensions>true</extensions>\n                <configuration>\n                    <publishingServerId>central-portal</publishingServerId>\n                    <waitUntil>validated</waitUntil>\n                    <deploymentName>junit-${project.version}</deploymentName>\n                </configuration>\n            </plugin>\n        </plugins>\n    </build>\n\n    <reporting>\n        <plugins>\n            <plugin>\n                <artifactId>maven-project-info-reports-plugin</artifactId>\n                <version>2.8</version>\n                <configuration>\n                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>\n                    <!-- waiting for MPIR-267 -->\n                </configuration>\n                <reportSets>\n                    <reportSet>\n                        <reports>\n                            <report>index</report>\n                            <report>dependency-info</report>\n                            <report>modules</report>\n                            <report>license</report>\n                            <report>project-team</report>\n                            <report>scm</report>\n                            <report>issue-tracking</report>\n                            <report>mailing-list</report>\n                            <report>dependency-management</report>\n                            <report>dependencies</report>\n                            <report>dependency-convergence</report>\n                            <report>cim</report>\n                            <report>distribution-management</report>\n                        </reports>\n                    </reportSet>\n                </reportSets>\n            </plugin>\n            <plugin>\n                <artifactId>maven-javadoc-plugin</artifactId>\n                <version>${javadocPluginVersion}</version>\n                <configuration>\n                    <destDir>javadoc/latest</destDir>\n                    <stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>\n                    <show>protected</show>\n                    <author>false</author>\n                    <version>false</version>\n                    <detectLinks>false</detectLinks>\n                    <linksource>true</linksource>\n                    <keywords>true</keywords>\n                    <use>true</use>\n                    <windowtitle>JUnit API</windowtitle>\n                    <encoding>UTF-8</encoding>\n                    <locale>en</locale>\n                    <javadocVersion>${jdkVersion}</javadocVersion>\n                    <javaApiLinks>\n                        <property>\n                            <name>api_${jdkVersion}</name>\n                            <value>http://docs.oracle.com/javase/${jdkVersion}.0/docs/api/</value>\n                        </property>\n                    </javaApiLinks>\n                    <excludePackageNames>junit.*,*.internal.*</excludePackageNames>\n                    <verbose>true</verbose>\n                    <minmemory>32m</minmemory>\n                    <maxmemory>128m</maxmemory>\n                    <failOnError>true</failOnError>\n                    <includeDependencySources>true</includeDependencySources>\n                    <dependencySourceIncludes>\n                        <dependencySourceInclude>org.hamcrest:hamcrest-core:*</dependencySourceInclude>\n                    </dependencySourceIncludes>\n                </configuration>\n                <reportSets>\n                    <reportSet>\n                        <reports>\n                            <report>javadoc</report>\n                        </reports>\n                    </reportSet>\n                </reportSets>\n            </plugin>\n        </plugins>\n    </reporting>\n\n    <profiles>\n        <profile>\n            <id>junit-release</id>\n            <!--\n            Signs all artifacts before deploying to Maven Central.\n            -->\n            <build>\n                <plugins>\n                    <plugin>\n                        <!--\n                        The goal is to sign all artifacts so that the user may verify them before downloading.\n                        The automatic build system may reuire your key ID, and passphrase specified using system properties:\n                        -Dgpg.passphrase=\"<passphrase>\" -Dgpg.keyname=\"<your key ID>\"\n                        In order to create the key pair, use the command \"gpg &ndash;&ndash;gen-key\".\n                        (&ndash;&ndash; stands for double dash)\n                        -->\n                        <artifactId>maven-gpg-plugin</artifactId>\n                        <version>1.6</version>\n                        <executions>\n                            <execution>\n                                <id>gpg-sign</id>\n                                <phase>verify</phase>\n                                <goals>\n                                    <goal>sign</goal>\n                                </goals>\n                            </execution>\n                        </executions>\n                    </plugin>\n                </plugins>\n            </build>\n        </profile>\n        <profile>\n            <id>generate-docs</id>\n            <!--\n            Generate the documentation artifacts. \n            Note: this profile is also required to be active for release\n            builds due to the packaging requirements of the Central repo\n            -->\n            <build>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-source-plugin</artifactId>\n                        <executions>\n                            <execution>\n                                <id>attach-sources</id>\n                                <phase>prepare-package</phase>\n                                <goals>\n                                    <goal>jar-no-fork</goal>\n                                </goals>\n                            </execution>\n                        </executions>\n                    </plugin>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <executions>\n                            <execution>\n                                <id>attach-javadoc</id>\n                                <phase>package</phase>\n                                <goals>\n                                    <goal>jar</goal>\n                                </goals>\n                            </execution>\n                        </executions>\n                    </plugin>\n                </plugins>\n            </build>\n        </profile>\n        <profile>\n            <id>restrict-doclint</id>\n            <!-- doclint is only supported by JDK 8 -->\n            <activation>\n                <jdk>[1.8,)</jdk>\n            </activation>\n            <build>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-compiler-plugin</artifactId>\n                        <configuration>\n                            <compilerArgs>\n                                <arg>-Xlint:unchecked</arg>\n                                <arg>-Xdoclint:accessibility,reference,syntax</arg>\n                            </compilerArgs>\n                        </configuration>\n                    </plugin>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <additionalparam>-Xdoclint:accessibility -Xdoclint:reference</additionalparam>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </build>\n            <reporting>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <additionalparam>-Xdoclint:accessibility -Xdoclint:reference</additionalparam>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </reporting>\n        </profile>\n        <profile>\n            <id>java9</id>\n            <activation>\n                <jdk>[1.9,12)</jdk>\n            </activation>\n            <properties>\n                <!-- JDK 9 minimal source and target versions are 1.6 -->\n                <jdkVersion>1.6</jdkVersion>\n            </properties>\n            <build>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <source>1.6</source>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </build>\n            <reporting>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <source>1.6</source>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </reporting>\n        </profile>\n        <profile>\n            <id>java12</id>\n            <activation>\n                <jdk>[12,20)</jdk>\n            </activation>\n            <properties>\n                <!-- JDK 12 minimal source and target versions are 1.7 -->\n                <jdkVersion>1.7</jdkVersion>\n                <enforcerPluginVersion>3.0.0-M3</enforcerPluginVersion>\n                <jarPluginVersion>3.2.0</jarPluginVersion>\n                <javadocPluginVersion>3.2.0</javadocPluginVersion>\n            </properties>\n            <build>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <source>1.7</source>\n                            <failOnError>false</failOnError>\n                        </configuration>\n                    </plugin>\n                    <plugin>\n                        <artifactId>maven-compiler-plugin</artifactId>\n                        <configuration>\n                            <compilerArgs>\n                                <arg>-Xdoclint:none</arg>\n                            </compilerArgs>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </build>\n            <reporting>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <source>1.7</source>\n                            <failOnError>false</failOnError>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </reporting>\n        </profile>\n        <profile>\n            <id>java20</id>\n            <activation>\n                <jdk>[20,)</jdk>\n            </activation>\n            <properties>\n                <!-- JDK 20 minimal source and target versions are 1.8 -->\n                <jdkVersion>1.8</jdkVersion>\n            </properties>\n            <build>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <source>1.8</source>\n                            <failOnError>false</failOnError>\n                        </configuration>\n                    </plugin>\n                    <plugin>\n                        <artifactId>maven-compiler-plugin</artifactId>\n                        <configuration>\n                            <compilerArgs>\n                                <arg>-Xdoclint:none</arg>\n                            </compilerArgs>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </build>\n            <reporting>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-javadoc-plugin</artifactId>\n                        <configuration>\n                            <source>1.8</source>\n                            <failOnError>false</failOnError>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </reporting>\n        </profile>\n    </profiles>\n</project>\n"
  },
  {
    "path": "src/main/java/junit/extensions/ActiveTestSuite.java",
    "content": "package junit.extensions;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\n\n/**\n * A TestSuite for active Tests. It runs each\n * test in a separate thread and waits until all\n * threads have terminated.\n * -- Aarhus Radisson Scandinavian Center 11th floor\n */\npublic class ActiveTestSuite extends TestSuite {\n    private volatile int fActiveTestDeathCount;\n\n    public ActiveTestSuite() {\n    }\n\n    public ActiveTestSuite(Class<? extends TestCase> theClass) {\n        super(theClass);\n    }\n\n    public ActiveTestSuite(String name) {\n        super(name);\n    }\n\n    public ActiveTestSuite(Class<? extends TestCase> theClass, String name) {\n        super(theClass, name);\n    }\n\n    @Override\n    public void run(TestResult result) {\n        fActiveTestDeathCount = 0;\n        super.run(result);\n        waitUntilFinished();\n    }\n\n    @Override\n    public void runTest(final Test test, final TestResult result) {\n        Thread t = new Thread() {\n            @Override\n            public void run() {\n                try {\n                    // inlined due to limitation in VA/Java\n                    //ActiveTestSuite.super.runTest(test, result);\n                    test.run(result);\n                } finally {\n                    ActiveTestSuite.this.runFinished();\n                }\n            }\n        };\n        t.start();\n    }\n\n    synchronized void waitUntilFinished() {\n        while (fActiveTestDeathCount < testCount()) {\n            try {\n                wait();\n            } catch (InterruptedException e) {\n                return; // ignore\n            }\n        }\n    }\n\n    public synchronized void runFinished() {\n        fActiveTestDeathCount++;\n        notifyAll();\n    }\n}"
  },
  {
    "path": "src/main/java/junit/extensions/RepeatedTest.java",
    "content": "package junit.extensions;\n\nimport junit.framework.Test;\nimport junit.framework.TestResult;\n\n/**\n * A Decorator that runs a test repeatedly.\n */\npublic class RepeatedTest extends TestDecorator {\n    private int fTimesRepeat;\n\n    public RepeatedTest(Test test, int repeat) {\n        super(test);\n        if (repeat < 0) {\n            throw new IllegalArgumentException(\"Repetition count must be >= 0\");\n        }\n        fTimesRepeat = repeat;\n    }\n\n    @Override\n    public int countTestCases() {\n        return super.countTestCases() * fTimesRepeat;\n    }\n\n    @Override\n    public void run(TestResult result) {\n        for (int i = 0; i < fTimesRepeat; i++) {\n            if (result.shouldStop()) {\n                break;\n            }\n            super.run(result);\n        }\n    }\n\n    @Override\n    public String toString() {\n        return super.toString() + \"(repeated)\";\n    }\n}"
  },
  {
    "path": "src/main/java/junit/extensions/TestDecorator.java",
    "content": "package junit.extensions;\n\nimport junit.framework.Assert;\nimport junit.framework.Test;\nimport junit.framework.TestResult;\n\n/**\n * A Decorator for Tests. Use TestDecorator as the base class for defining new\n * test decorators. Test decorator subclasses can be introduced to add behaviour\n * before or after a test is run.\n */\n@SuppressWarnings(\"deprecation\")\npublic class TestDecorator extends Assert implements Test {\n    protected Test fTest;\n\n    public TestDecorator(Test test) {\n        fTest = test;\n    }\n\n    /**\n     * The basic run behaviour.\n     */\n    public void basicRun(TestResult result) {\n        fTest.run(result);\n    }\n\n    public int countTestCases() {\n        return fTest.countTestCases();\n    }\n\n    public void run(TestResult result) {\n        basicRun(result);\n    }\n\n    @Override\n    public String toString() {\n        return fTest.toString();\n    }\n\n    public Test getTest() {\n        return fTest;\n    }\n}"
  },
  {
    "path": "src/main/java/junit/extensions/TestSetup.java",
    "content": "package junit.extensions;\n\nimport junit.framework.Protectable;\nimport junit.framework.Test;\nimport junit.framework.TestResult;\n\n/**\n * A Decorator to set up and tear down additional fixture state. Subclass\n * TestSetup and insert it into your tests when you want to set up additional\n * state once before the tests are run.\n */\npublic class TestSetup extends TestDecorator {\n\n    public TestSetup(Test test) {\n        super(test);\n    }\n\n    @Override\n    public void run(final TestResult result) {\n        Protectable p = new Protectable() {\n            public void protect() throws Exception {\n                setUp();\n                basicRun(result);\n                tearDown();\n            }\n        };\n        result.runProtected(this, p);\n    }\n\n    /**\n     * Sets up the fixture. Override to set up additional fixture state.\n     */\n    protected void setUp() throws Exception {\n    }\n\n    /**\n     * Tears down the fixture. Override to tear down the additional fixture\n     * state.\n     */\n    protected void tearDown() throws Exception {\n    }\n}"
  },
  {
    "path": "src/main/java/junit/extensions/package-info.java",
    "content": "/**\n * Provides extended functionality for JUnit v3.x.\n */\npackage junit.extensions;"
  },
  {
    "path": "src/main/java/junit/framework/Assert.java",
    "content": "package junit.framework;\n\n/**\n * A set of assert methods.  Messages are only displayed when an assert fails.\n *\n * @deprecated Please use {@link org.junit.Assert} instead.\n */\n@Deprecated\npublic class Assert {\n    /**\n     * Protect constructor since it is a static only class\n     */\n    protected Assert() {\n    }\n\n    /**\n     * Asserts that a condition is true. If it isn't it throws\n     * an AssertionFailedError with the given message.\n     */\n    public static void assertTrue(String message, boolean condition) {\n        if (!condition) {\n            fail(message);\n        }\n    }\n\n    /**\n     * Asserts that a condition is true. If it isn't it throws\n     * an AssertionFailedError.\n     */\n    public static void assertTrue(boolean condition) {\n        assertTrue(null, condition);\n    }\n\n    /**\n     * Asserts that a condition is false. If it isn't it throws\n     * an AssertionFailedError with the given message.\n     */\n    public static void assertFalse(String message, boolean condition) {\n        assertTrue(message, !condition);\n    }\n\n    /**\n     * Asserts that a condition is false. If it isn't it throws\n     * an AssertionFailedError.\n     */\n    public static void assertFalse(boolean condition) {\n        assertFalse(null, condition);\n    }\n\n    /**\n     * Fails a test with the given message.\n     */\n    public static void fail(String message) {\n        if (message == null) {\n            throw new AssertionFailedError();\n        }\n        throw new AssertionFailedError(message);\n    }\n\n    /**\n     * Fails a test with no message.\n     */\n    public static void fail() {\n        fail(null);\n    }\n\n    /**\n     * Asserts that two objects are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, Object expected, Object actual) {\n        if (expected == null && actual == null) {\n            return;\n        }\n        if (expected != null && expected.equals(actual)) {\n            return;\n        }\n        failNotEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects are equal. If they are not\n     * an AssertionFailedError is thrown.\n     */\n    public static void assertEquals(Object expected, Object actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two Strings are equal.\n     */\n    public static void assertEquals(String message, String expected, String actual) {\n        if (expected == null && actual == null) {\n            return;\n        }\n        if (expected != null && expected.equals(actual)) {\n            return;\n        }\n        String cleanMessage = message == null ? \"\" : message;\n        throw new ComparisonFailure(cleanMessage, expected, actual);\n    }\n\n    /**\n     * Asserts that two Strings are equal.\n     */\n    public static void assertEquals(String expected, String actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two doubles are equal concerning a delta.  If they are not\n     * an AssertionFailedError is thrown with the given message.  If the expected\n     * value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(String message, double expected, double actual, double delta) {\n        if (Double.compare(expected, actual) == 0) {\n            return;\n        }\n        if (!(Math.abs(expected - actual) <= delta)) {\n            failNotEquals(message, Double.valueOf(expected), Double.valueOf(actual));\n        }\n    }\n\n    /**\n     * Asserts that two doubles are equal concerning a delta. If the expected\n     * value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(double expected, double actual, double delta) {\n        assertEquals(null, expected, actual, delta);\n    }\n\n    /**\n     * Asserts that two floats are equal concerning a positive delta. If they\n     * are not an AssertionFailedError is thrown with the given message. If the\n     * expected value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(String message, float expected, float actual, float delta) {\n        if (Float.compare(expected, actual) == 0) {\n            return;\n        }\n        if (!(Math.abs(expected - actual) <= delta)) {\n            failNotEquals(message, Float.valueOf(expected), Float.valueOf(actual));\n        }\n    }\n\n    /**\n     * Asserts that two floats are equal concerning a delta. If the expected\n     * value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(float expected, float actual, float delta) {\n        assertEquals(null, expected, actual, delta);\n    }\n\n    /**\n     * Asserts that two longs are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, long expected, long actual) {\n        assertEquals(message, Long.valueOf(expected), Long.valueOf(actual));\n    }\n\n    /**\n     * Asserts that two longs are equal.\n     */\n    public static void assertEquals(long expected, long actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two booleans are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, boolean expected, boolean actual) {\n        assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual));\n    }\n\n    /**\n     * Asserts that two booleans are equal.\n     */\n    public static void assertEquals(boolean expected, boolean actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two bytes are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, byte expected, byte actual) {\n        assertEquals(message, Byte.valueOf(expected), Byte.valueOf(actual));\n    }\n\n    /**\n     * Asserts that two bytes are equal.\n     */\n    public static void assertEquals(byte expected, byte actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two chars are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, char expected, char actual) {\n        assertEquals(message, Character.valueOf(expected), Character.valueOf(actual));\n    }\n\n    /**\n     * Asserts that two chars are equal.\n     */\n    public static void assertEquals(char expected, char actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two shorts are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, short expected, short actual) {\n        assertEquals(message, Short.valueOf(expected), Short.valueOf(actual));\n    }\n\n    /**\n     * Asserts that two shorts are equal.\n     */\n    public static void assertEquals(short expected, short actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two ints are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, int expected, int actual) {\n        assertEquals(message, Integer.valueOf(expected), Integer.valueOf(actual));\n    }\n\n    /**\n     * Asserts that two ints are equal.\n     */\n    public static void assertEquals(int expected, int actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that an object isn't null.\n     */\n    public static void assertNotNull(Object object) {\n        assertNotNull(null, object);\n    }\n\n    /**\n     * Asserts that an object isn't null. If it is\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertNotNull(String message, Object object) {\n        assertTrue(message, object != null);\n    }\n\n    /**\n     * Asserts that an object is null. If it isn't an {@link AssertionError} is\n     * thrown.\n     * Message contains: Expected: <null> but was: object\n     *\n     * @param object Object to check or <code>null</code>\n     */\n    public static void assertNull(Object object) {\n        if (object != null) {\n            assertNull(\"Expected: <null> but was: \" + object.toString(), object);\n        }\n    }\n\n    /**\n     * Asserts that an object is null.  If it is not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertNull(String message, Object object) {\n        assertTrue(message, object == null);\n    }\n\n    /**\n     * Asserts that two objects refer to the same object. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertSame(String message, Object expected, Object actual) {\n        if (expected == actual) {\n            return;\n        }\n        failNotSame(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects refer to the same object. If they are not\n     * the same an AssertionFailedError is thrown.\n     */\n    public static void assertSame(Object expected, Object actual) {\n        assertSame(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects do not refer to the same object. If they do\n     * refer to the same object an AssertionFailedError is thrown with the\n     * given message.\n     */\n    public static void assertNotSame(String message, Object expected, Object actual) {\n        if (expected == actual) {\n            failSame(message);\n        }\n    }\n\n    /**\n     * Asserts that two objects do not refer to the same object. If they do\n     * refer to the same object an AssertionFailedError is thrown.\n     */\n    public static void assertNotSame(Object expected, Object actual) {\n        assertNotSame(null, expected, actual);\n    }\n\n    public static void failSame(String message) {\n        String formatted = (message != null) ? message + \" \" : \"\";\n        fail(formatted + \"expected not same\");\n    }\n\n    public static void failNotSame(String message, Object expected, Object actual) {\n        String formatted = (message != null) ? message + \" \" : \"\";\n        fail(formatted + \"expected same:<\" + expected + \"> was not:<\" + actual + \">\");\n    }\n\n    public static void failNotEquals(String message, Object expected, Object actual) {\n        fail(format(message, expected, actual));\n    }\n\n    public static String format(String message, Object expected, Object actual) {\n        String formatted = \"\";\n        if (message != null && message.length() > 0) {\n            formatted = message + \" \";\n        }\n        return formatted + \"expected:<\" + expected + \"> but was:<\" + actual + \">\";\n    }\n}\n"
  },
  {
    "path": "src/main/java/junit/framework/AssertionFailedError.java",
    "content": "package junit.framework;\n\n/**\n * Thrown when an assertion failed.\n */\npublic class AssertionFailedError extends AssertionError {\n\n    private static final long serialVersionUID = 1L;\n    \n    /**\n     * Constructs a new AssertionFailedError without a detail message.\n     */\n    public AssertionFailedError() {\n    }\n\n    /**\n     * Constructs a new AssertionFailedError with the specified detail message.\n     * A null message is replaced by an empty String.\n     * @param message the detail message. The detail message is saved for later \n     * retrieval by the {@code Throwable.getMessage()} method.\n     */\n    public AssertionFailedError(String message) {\n        super(defaultString(message));\n    }\n\n    private static String defaultString(String message) {\n        return message == null ? \"\" : message;\n    }\n}"
  },
  {
    "path": "src/main/java/junit/framework/ComparisonCompactor.java",
    "content": "package junit.framework;\n\npublic class ComparisonCompactor {\n\n    private static final String ELLIPSIS = \"...\";\n    private static final String DELTA_END = \"]\";\n    private static final String DELTA_START = \"[\";\n\n    private int fContextLength;\n    private String fExpected;\n    private String fActual;\n    private int fPrefix;\n    private int fSuffix;\n\n    public ComparisonCompactor(int contextLength, String expected, String actual) {\n        fContextLength = contextLength;\n        fExpected = expected;\n        fActual = actual;\n    }\n\n    @SuppressWarnings(\"deprecation\")\n    public String compact(String message) {\n        if (fExpected == null || fActual == null || areStringsEqual()) {\n            return Assert.format(message, fExpected, fActual);\n        }\n\n        findCommonPrefix();\n        findCommonSuffix();\n        String expected = compactString(fExpected);\n        String actual = compactString(fActual);\n        return Assert.format(message, expected, actual);\n    }\n\n    private String compactString(String source) {\n        String result = DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END;\n        if (fPrefix > 0) {\n            result = computeCommonPrefix() + result;\n        }\n        if (fSuffix > 0) {\n            result = result + computeCommonSuffix();\n        }\n        return result;\n    }\n\n    private void findCommonPrefix() {\n        fPrefix = 0;\n        int end = Math.min(fExpected.length(), fActual.length());\n        for (; fPrefix < end; fPrefix++) {\n            if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix)) {\n                break;\n            }\n        }\n    }\n\n    private void findCommonSuffix() {\n        int expectedSuffix = fExpected.length() - 1;\n        int actualSuffix = fActual.length() - 1;\n        for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) {\n            if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix)) {\n                break;\n            }\n        }\n        fSuffix = fExpected.length() - expectedSuffix;\n    }\n\n    private String computeCommonPrefix() {\n        return (fPrefix > fContextLength ? ELLIPSIS : \"\") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix);\n    }\n\n    private String computeCommonSuffix() {\n        int end = Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length());\n        return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : \"\");\n    }\n\n    private boolean areStringsEqual() {\n        return fExpected.equals(fActual);\n    }\n}\n"
  },
  {
    "path": "src/main/java/junit/framework/ComparisonFailure.java",
    "content": "package junit.framework;\n\n/**\n * Thrown when an assert equals for Strings failed.\n *\n * Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com\n */\npublic class ComparisonFailure extends AssertionFailedError {\n    private static final int MAX_CONTEXT_LENGTH = 20;\n    private static final long serialVersionUID = 1L;\n\n    private String fExpected;\n    private String fActual;\n\n    /**\n     * Constructs a comparison failure.\n     *\n     * @param message the identifying message or null\n     * @param expected the expected string value\n     * @param actual the actual string value\n     */\n    public ComparisonFailure(String message, String expected, String actual) {\n        super(message);\n        fExpected = expected;\n        fActual = actual;\n    }\n\n    /**\n     * Returns \"...\" in place of common prefix and \"...\" in\n     * place of common suffix between expected and actual.\n     *\n     * @see Throwable#getMessage()\n     */\n    @Override\n    public String getMessage() {\n        return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());\n    }\n\n    /**\n     * Gets the actual string value\n     *\n     * @return the actual string value\n     */\n    public String getActual() {\n        return fActual;\n    }\n\n    /**\n     * Gets the expected string value\n     *\n     * @return the expected string value\n     */\n    public String getExpected() {\n        return fExpected;\n    }\n}"
  },
  {
    "path": "src/main/java/junit/framework/JUnit4TestAdapter.java",
    "content": "package junit.framework;\n\nimport java.util.List;\n\nimport org.junit.Ignore;\nimport org.junit.runner.Describable;\nimport org.junit.runner.Description;\nimport org.junit.runner.Request;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.Filterable;\nimport org.junit.runner.manipulation.Orderer;\nimport org.junit.runner.manipulation.InvalidOrderingException;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runner.manipulation.Orderable;\nimport org.junit.runner.manipulation.Sorter;\n\n/**\n * The JUnit4TestAdapter enables running JUnit-4-style tests using a JUnit-3-style test runner.\n *\n * <p> To use it, add the following to a test class:\n * <pre>\n      public static Test suite() {\n        return new JUnit4TestAdapter(<em>YourJUnit4TestClass</em>.class);\n      }\n</pre>\n */\npublic class JUnit4TestAdapter implements Test, Filterable, Orderable, Describable {\n    private final Class<?> fNewTestClass;\n\n    private final Runner fRunner;\n\n    private final JUnit4TestAdapterCache fCache;\n\n    public JUnit4TestAdapter(Class<?> newTestClass) {\n        this(newTestClass, JUnit4TestAdapterCache.getDefault());\n    }\n\n    public JUnit4TestAdapter(final Class<?> newTestClass, JUnit4TestAdapterCache cache) {\n        fCache = cache;\n        fNewTestClass = newTestClass;\n        fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner();\n    }\n\n    public int countTestCases() {\n        return fRunner.testCount();\n    }\n\n    public void run(TestResult result) {\n        fRunner.run(fCache.getNotifier(result, this));\n    }\n\n    // reflective interface for Eclipse\n    public List<Test> getTests() {\n        return fCache.asTestList(getDescription());\n    }\n\n    // reflective interface for Eclipse\n    public Class<?> getTestClass() {\n        return fNewTestClass;\n    }\n\n    public Description getDescription() {\n        Description description = fRunner.getDescription();\n        return removeIgnored(description);\n    }\n\n    private Description removeIgnored(Description description) {\n        if (isIgnored(description)) {\n            return Description.EMPTY;\n        }\n        Description result = description.childlessCopy();\n        for (Description each : description.getChildren()) {\n            Description child = removeIgnored(each);\n            if (!child.isEmpty()) {\n                result.addChild(child);\n            }\n        }\n        return result;\n    }\n\n    private boolean isIgnored(Description description) {\n        return description.getAnnotation(Ignore.class) != null;\n    }\n\n    @Override\n    public String toString() {\n        return fNewTestClass.getName();\n    }\n\n    public void filter(Filter filter) throws NoTestsRemainException {\n        filter.apply(fRunner);\n    }\n\n    public void sort(Sorter sorter) {\n        sorter.apply(fRunner);\n    }\n\n    /**\n     * {@inheritDoc}\n     *\n     * @since 4.13\n     */\n    public void order(Orderer orderer) throws InvalidOrderingException {\n        orderer.apply(fRunner);\n    }\n}"
  },
  {
    "path": "src/main/java/junit/framework/JUnit4TestAdapterCache.java",
    "content": "package junit.framework;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.List;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runner.notification.RunNotifier;\n\npublic class JUnit4TestAdapterCache extends HashMap<Description, Test> {\n    private static final long serialVersionUID = 1L;\n    private static final JUnit4TestAdapterCache fInstance = new JUnit4TestAdapterCache();\n\n    public static JUnit4TestAdapterCache getDefault() {\n        return fInstance;\n    }\n\n    public Test asTest(Description description) {\n        if (description.isSuite()) {\n            return createTest(description);\n        } else {\n            if (!containsKey(description)) {\n                put(description, createTest(description));\n            }\n            return get(description);\n        }\n    }\n\n    Test createTest(Description description) {\n        if (description.isTest()) {\n            return new JUnit4TestCaseFacade(description);\n        } else {\n            TestSuite suite = new TestSuite(description.getDisplayName());\n            for (Description child : description.getChildren()) {\n                suite.addTest(asTest(child));\n            }\n            return suite;\n        }\n    }\n\n    public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) {\n        RunNotifier notifier = new RunNotifier();\n        notifier.addListener(new RunListener() {\n            @Override\n            public void testFailure(Failure failure) throws Exception {\n                result.addError(asTest(failure.getDescription()), failure.getException());\n            }\n\n            @Override\n            public void testFinished(Description description) throws Exception {\n                result.endTest(asTest(description));\n            }\n\n            @Override\n            public void testStarted(Description description) throws Exception {\n                result.startTest(asTest(description));\n            }\n        });\n        return notifier;\n    }\n\n    public List<Test> asTestList(Description description) {\n        if (description.isTest()) {\n            return Arrays.asList(asTest(description));\n        } else {\n            List<Test> returnThis = new ArrayList<Test>();\n            for (Description child : description.getChildren()) {\n                returnThis.add(asTest(child));\n            }\n            return returnThis;\n        }\n    }\n\n}"
  },
  {
    "path": "src/main/java/junit/framework/JUnit4TestCaseFacade.java",
    "content": "package junit.framework;\n\nimport org.junit.runner.Describable;\nimport org.junit.runner.Description;\n\npublic class JUnit4TestCaseFacade implements Test, Describable {\n    private final Description fDescription;\n\n    JUnit4TestCaseFacade(Description description) {\n        fDescription = description;\n    }\n\n    @Override\n    public String toString() {\n        return getDescription().toString();\n    }\n\n    public int countTestCases() {\n        return 1;\n    }\n\n    public void run(TestResult result) {\n        throw new RuntimeException(\n                \"This test stub created only for informational purposes.\");\n    }\n\n    public Description getDescription() {\n        return fDescription;\n    }\n}"
  },
  {
    "path": "src/main/java/junit/framework/Protectable.java",
    "content": "package junit.framework;\n\n/**\n * A <em>Protectable</em> can be run and can throw a Throwable.\n *\n * @see TestResult\n */\npublic interface Protectable {\n\n    /**\n     * Run the following method protected.\n     */\n    public abstract void protect() throws Throwable;\n}\n"
  },
  {
    "path": "src/main/java/junit/framework/Test.java",
    "content": "package junit.framework;\n\n/**\n * A <em>Test</em> can be run and collect its results.\n *\n * @see TestResult\n */\npublic interface Test {\n    /**\n     * Counts the number of test cases that will be run by this test.\n     */\n    public abstract int countTestCases();\n\n    /**\n     * Runs a test and collects its result in a TestResult instance.\n     */\n    public abstract void run(TestResult result);\n}"
  },
  {
    "path": "src/main/java/junit/framework/TestCase.java",
    "content": "package junit.framework;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\n\n/**\n * A test case defines the fixture to run multiple tests. To define a test case<br/>\n * <ol>\n *   <li>implement a subclass of <code>TestCase</code></li>\n *   <li>define instance variables that store the state of the fixture</li>\n *   <li>initialize the fixture state by overriding {@link #setUp()}</li>\n *   <li>clean-up after a test by overriding {@link #tearDown()}.</li>\n * </ol>\n * Each test runs in its own fixture so there\n * can be no side effects among test runs.\n * Here is an example:\n * <pre>\n * public class MathTest extends TestCase {\n *    protected double fValue1;\n *    protected double fValue2;\n *\n *    protected void setUp() {\n *       fValue1= 2.0;\n *       fValue2= 3.0;\n *    }\n * }\n * </pre>\n *\n * For each test implement a method which interacts\n * with the fixture. Verify the expected results with assertions specified\n * by calling {@link junit.framework.Assert#assertTrue(String, boolean)} with a boolean.\n * <pre>\n *    public void testAdd() {\n *       double result= fValue1 + fValue2;\n *       assertTrue(result == 5.0);\n *    }\n * </pre>\n *\n * Once the methods are defined you can run them. The framework supports\n * both a static type safe and more dynamic way to run a test.\n * In the static way you override the runTest method and define the method to\n * be invoked. A convenient way to do so is with an anonymous inner class.\n * <pre>\n * TestCase test= new MathTest(\"add\") {\n *    public void runTest() {\n *       testAdd();\n *    }\n * };\n * test.run();\n * </pre>\n * The dynamic way uses reflection to implement {@link #runTest()}. It dynamically finds\n * and invokes a method.\n * In this case the name of the test case has to correspond to the test method\n * to be run.\n * <pre>\n * TestCase test= new MathTest(\"testAdd\");\n * test.run();\n * </pre>\n *\n * The tests to be run can be collected into a TestSuite. JUnit provides\n * different <i>test runners</i> which can run a test suite and collect the results.\n * A test runner either expects a static method <code>suite</code> as the entry\n * point to get a test to run or it will extract the suite automatically.\n * <pre>\n * public static Test suite() {\n *    suite.addTest(new MathTest(\"testAdd\"));\n *    suite.addTest(new MathTest(\"testDivideByZero\"));\n *    return suite;\n * }\n * </pre>\n *\n * @see TestResult\n * @see TestSuite\n */\n@SuppressWarnings(\"deprecation\")\npublic abstract class TestCase extends Assert implements Test {\n    /**\n     * the name of the test case\n     */\n    private String fName;\n\n    /**\n     * No-arg constructor to enable serialization. This method\n     * is not intended to be used by mere mortals without calling setName().\n     */\n    public TestCase() {\n        fName = null;\n    }\n\n    /**\n     * Constructs a test case with the given name.\n     */\n    public TestCase(String name) {\n        fName = name;\n    }\n\n    /**\n     * Counts the number of test cases executed by run(TestResult result).\n     */\n    public int countTestCases() {\n        return 1;\n    }\n\n    /**\n     * Creates a default TestResult object.\n     *\n     * @see TestResult\n     */\n    protected TestResult createResult() {\n        return new TestResult();\n    }\n\n    /**\n     * A convenience method to run this test, collecting the results with a\n     * default TestResult object.\n     *\n     * @see TestResult\n     */\n    public TestResult run() {\n        TestResult result = createResult();\n        run(result);\n        return result;\n    }\n\n    /**\n     * Runs the test case and collects the results in TestResult.\n     */\n    public void run(TestResult result) {\n        result.run(this);\n    }\n\n    /**\n     * Runs the bare test sequence.\n     *\n     * @throws Throwable if any exception is thrown\n     */\n    public void runBare() throws Throwable {\n        Throwable exception = null;\n        setUp();\n        try {\n            runTest();\n        } catch (Throwable running) {\n            exception = running;\n        } finally {\n            try {\n                tearDown();\n            } catch (Throwable tearingDown) {\n                if (exception == null) exception = tearingDown;\n            }\n        }\n        if (exception != null) throw exception;\n    }\n\n    /**\n     * Override to run the test and assert its state.\n     *\n     * @throws Throwable if any exception is thrown\n     */\n    protected void runTest() throws Throwable {\n        assertNotNull(\"TestCase.fName cannot be null\", fName); // Some VMs crash when calling getMethod(null,null);\n        Method runMethod = null;\n        try {\n            // use getMethod to get all public inherited\n            // methods. getDeclaredMethods returns all\n            // methods of this class but excludes the\n            // inherited ones.\n            runMethod = getClass().getMethod(fName, (Class[]) null);\n        } catch (NoSuchMethodException e) {\n            fail(\"Method \\\"\" + fName + \"\\\" not found\");\n        }\n        if (!Modifier.isPublic(runMethod.getModifiers())) {\n            fail(\"Method \\\"\" + fName + \"\\\" should be public\");\n        }\n\n        try {\n            runMethod.invoke(this);\n        } catch (InvocationTargetException e) {\n            e.fillInStackTrace();\n            throw e.getTargetException();\n        } catch (IllegalAccessException e) {\n            e.fillInStackTrace();\n            throw e;\n        }\n    }\n\n    /**\n     * Asserts that a condition is true. If it isn't it throws\n     * an AssertionFailedError with the given message.\n     */\n    public static void assertTrue(String message, boolean condition) {\n        Assert.assertTrue(message, condition);\n    }\n\n    /**\n     * Asserts that a condition is true. If it isn't it throws\n     * an AssertionFailedError.\n     */\n    public static void assertTrue(boolean condition) {\n        Assert.assertTrue(condition);\n    }\n\n    /**\n     * Asserts that a condition is false. If it isn't it throws\n     * an AssertionFailedError with the given message.\n     */\n    public static void assertFalse(String message, boolean condition) {\n        Assert.assertFalse(message, condition);\n    }\n\n    /**\n     * Asserts that a condition is false. If it isn't it throws\n     * an AssertionFailedError.\n     */\n    public static void assertFalse(boolean condition) {\n        Assert.assertFalse(condition);\n    }\n\n    /**\n     * Fails a test with the given message.\n     */\n    public static void fail(String message) {\n        Assert.fail(message);\n    }\n\n    /**\n     * Fails a test with no message.\n     */\n    public static void fail() {\n        Assert.fail();\n    }\n\n    /**\n     * Asserts that two objects are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, Object expected, Object actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects are equal. If they are not\n     * an AssertionFailedError is thrown.\n     */\n    public static void assertEquals(Object expected, Object actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that two Strings are equal.\n     */\n    public static void assertEquals(String message, String expected, String actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two Strings are equal.\n     */\n    public static void assertEquals(String expected, String actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that two doubles are equal concerning a delta.  If they are not\n     * an AssertionFailedError is thrown with the given message.  If the expected\n     * value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(String message, double expected, double actual, double delta) {\n        Assert.assertEquals(message, expected, actual, delta);\n    }\n\n    /**\n     * Asserts that two doubles are equal concerning a delta. If the expected\n     * value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(double expected, double actual, double delta) {\n        Assert.assertEquals(expected, actual, delta);\n    }\n\n    /**\n     * Asserts that two floats are equal concerning a positive delta. If they\n     * are not an AssertionFailedError is thrown with the given message. If the\n     * expected value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(String message, float expected, float actual, float delta) {\n        Assert.assertEquals(message, expected, actual, delta);\n    }\n\n    /**\n     * Asserts that two floats are equal concerning a delta. If the expected\n     * value is infinity then the delta value is ignored.\n     */\n    public static void assertEquals(float expected, float actual, float delta) {\n        Assert.assertEquals(expected, actual, delta);\n    }\n\n    /**\n     * Asserts that two longs are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, long expected, long actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two longs are equal.\n     */\n    public static void assertEquals(long expected, long actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that two booleans are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, boolean expected, boolean actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two booleans are equal.\n     */\n    public static void assertEquals(boolean expected, boolean actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that two bytes are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, byte expected, byte actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two bytes are equal.\n     */\n    public static void assertEquals(byte expected, byte actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that two chars are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, char expected, char actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two chars are equal.\n     */\n    public static void assertEquals(char expected, char actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that two shorts are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, short expected, short actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two shorts are equal.\n     */\n    public static void assertEquals(short expected, short actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that two ints are equal. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertEquals(String message, int expected, int actual) {\n        Assert.assertEquals(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two ints are equal.\n     */\n    public static void assertEquals(int expected, int actual) {\n        Assert.assertEquals(expected, actual);\n    }\n\n    /**\n     * Asserts that an object isn't null.\n     */\n    public static void assertNotNull(Object object) {\n        Assert.assertNotNull(object);\n    }\n\n    /**\n     * Asserts that an object isn't null. If it is\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertNotNull(String message, Object object) {\n        Assert.assertNotNull(message, object);\n    }\n\n    /**\n     * Asserts that an object is null. If it isn't an {@link AssertionError} is\n     * thrown.\n     * Message contains: Expected: <null> but was: object\n     *\n     * @param object Object to check or <code>null</code>\n     */\n    public static void assertNull(Object object) {\n        Assert.assertNull(object);\n    }\n\n    /**\n     * Asserts that an object is null.  If it is not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertNull(String message, Object object) {\n        Assert.assertNull(message, object);\n    }\n\n    /**\n     * Asserts that two objects refer to the same object. If they are not\n     * an AssertionFailedError is thrown with the given message.\n     */\n    public static void assertSame(String message, Object expected, Object actual) {\n        Assert.assertSame(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects refer to the same object. If they are not\n     * the same an AssertionFailedError is thrown.\n     */\n    public static void assertSame(Object expected, Object actual) {\n        Assert.assertSame(expected, actual);\n    }\n\n    /**\n     * Asserts that two objects do not refer to the same object. If they do\n     * refer to the same object an AssertionFailedError is thrown with the\n     * given message.\n     */\n    public static void assertNotSame(String message, Object expected, Object actual) {\n        Assert.assertNotSame(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects do not refer to the same object. If they do\n     * refer to the same object an AssertionFailedError is thrown.\n     */\n    public static void assertNotSame(Object expected, Object actual) {\n        Assert.assertNotSame(expected, actual);\n    }\n\n    public static void failSame(String message) {\n        Assert.failSame(message);\n    }\n\n    public static void failNotSame(String message, Object expected, Object actual) {\n        Assert.failNotSame(message, expected, actual);\n    }\n\n    public static void failNotEquals(String message, Object expected, Object actual) {\n        Assert.failNotEquals(message, expected, actual);\n    }\n\n    public static String format(String message, Object expected, Object actual) {\n        return Assert.format(message, expected, actual);\n    }\n\n    /**\n     * Sets up the fixture, for example, open a network connection.\n     * This method is called before a test is executed.\n     */\n    protected void setUp() throws Exception {\n    }\n\n    /**\n     * Tears down the fixture, for example, close a network connection.\n     * This method is called after a test is executed.\n     */\n    protected void tearDown() throws Exception {\n    }\n\n    /**\n     * Returns a string representation of the test case.\n     */\n    @Override\n    public String toString() {\n        return getName() + \"(\" + getClass().getName() + \")\";\n    }\n\n    /**\n     * Gets the name of a TestCase.\n     *\n     * @return the name of the TestCase\n     */\n    public String getName() {\n        return fName;\n    }\n\n    /**\n     * Sets the name of a TestCase.\n     *\n     * @param name the name to set\n     */\n    public void setName(String name) {\n        fName = name;\n    }\n}\n"
  },
  {
    "path": "src/main/java/junit/framework/TestFailure.java",
    "content": "package junit.framework;\n\nimport org.junit.internal.Throwables;\n\n\n/**\n * A {@code TestFailure} collects a failed test together with\n * the caught exception.\n *\n * @see TestResult\n */\npublic class TestFailure {\n    protected Test fFailedTest;\n    protected Throwable fThrownException;\n\n    /**\n     * Constructs a TestFailure with the given test and exception.\n     */\n    public TestFailure(Test failedTest, Throwable thrownException) {\n        fFailedTest = failedTest;\n        fThrownException = thrownException;\n    }\n\n    /**\n     * Gets the failed test.\n     */\n    public Test failedTest() {\n        return fFailedTest;\n    }\n\n    /**\n     * Gets the thrown exception.\n     */\n    public Throwable thrownException() {\n        return fThrownException;\n    }\n\n    /**\n     * Returns a short description of the failure.\n     */\n    @Override\n    public String toString() {\n        return fFailedTest + \": \" + fThrownException.getMessage();\n    }\n    \n    /**\n     * Returns a String containing the stack trace of the error\n     * thrown by TestFailure.\n     */\n    public String trace() {\n        return Throwables.getStacktrace(thrownException());\n    }\n\n    /**\n     * Returns a String containing the message from the thrown exception.\n     */\n    public String exceptionMessage() {\n        return thrownException().getMessage();\n    }\n\n    /**\n     * Returns {@code true} if the error is considered a failure\n     * (i.e. if it is an instance of {@code AssertionFailedError}),\n     * {@code false} otherwise.\n     */\n    public boolean isFailure() {\n        return thrownException() instanceof AssertionFailedError;\n    }\n}"
  },
  {
    "path": "src/main/java/junit/framework/TestListener.java",
    "content": "package junit.framework;\n\n/**\n * A Listener for test progress\n */\npublic interface TestListener {\n    /**\n     * An error occurred.\n     */\n    public void addError(Test test, Throwable e);\n\n    /**\n     * A failure occurred.\n     */\n    public void addFailure(Test test, AssertionFailedError e);\n\n    /**\n     * A test ended.\n     */\n    public void endTest(Test test);\n\n    /**\n     * A test started.\n     */\n    public void startTest(Test test);\n}"
  },
  {
    "path": "src/main/java/junit/framework/TestResult.java",
    "content": "package junit.framework;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Enumeration;\nimport java.util.List;\n\n/**\n * A <code>TestResult</code> collects the results of executing\n * a test case. It is an instance of the Collecting Parameter pattern.\n * The test framework distinguishes between <i>failures</i> and <i>errors</i>.\n * A failure is anticipated and checked for with assertions. Errors are\n * unanticipated problems like an {@link ArrayIndexOutOfBoundsException}.\n *\n * @see Test\n */\npublic class TestResult {\n    protected List<TestFailure> fFailures;\n    protected List<TestFailure> fErrors;\n    protected List<TestListener> fListeners;\n    protected int fRunTests;\n    private boolean fStop;\n\n    public TestResult() {\n        fFailures = new ArrayList<TestFailure>();\n        fErrors = new ArrayList<TestFailure>();\n        fListeners = new ArrayList<TestListener>();\n        fRunTests = 0;\n        fStop = false;\n    }\n\n    /**\n     * Adds an error to the list of errors. The passed in exception\n     * caused the error.\n     */\n    public synchronized void addError(Test test, Throwable e) {\n        fErrors.add(new TestFailure(test, e));\n        for (TestListener each : cloneListeners()) {\n            each.addError(test, e);\n        }\n    }\n\n    /**\n     * Adds a failure to the list of failures. The passed in exception\n     * caused the failure.\n     */\n    public synchronized void addFailure(Test test, AssertionFailedError e) {\n        fFailures.add(new TestFailure(test, e));\n        for (TestListener each : cloneListeners()) {\n            each.addFailure(test, e);\n        }\n    }\n\n    /**\n     * Registers a TestListener.\n     */\n    public synchronized void addListener(TestListener listener) {\n        fListeners.add(listener);\n    }\n\n    /**\n     * Unregisters a TestListener.\n     */\n    public synchronized void removeListener(TestListener listener) {\n        fListeners.remove(listener);\n    }\n\n    /**\n     * Returns a copy of the listeners.\n     */\n    private synchronized List<TestListener> cloneListeners() {\n        List<TestListener> result = new ArrayList<TestListener>();\n        result.addAll(fListeners);\n        return result;\n    }\n\n    /**\n     * Informs the result that a test was completed.\n     */\n    public void endTest(Test test) {\n        for (TestListener each : cloneListeners()) {\n            each.endTest(test);\n        }\n    }\n\n    /**\n     * Gets the number of detected errors.\n     */\n    public synchronized int errorCount() {\n        return fErrors.size();\n    }\n\n    /**\n     * Returns an Enumeration for the errors.\n     */\n    public synchronized Enumeration<TestFailure> errors() {\n        return Collections.enumeration(fErrors);\n    }\n\n\n    /**\n     * Gets the number of detected failures.\n     */\n    public synchronized int failureCount() {\n        return fFailures.size();\n    }\n\n    /**\n     * Returns an Enumeration for the failures.\n     */\n    public synchronized Enumeration<TestFailure> failures() {\n        return Collections.enumeration(fFailures);\n    }\n\n    /**\n     * Runs a TestCase.\n     */\n    protected void run(final TestCase test) {\n        startTest(test);\n        Protectable p = new Protectable() {\n            public void protect() throws Throwable {\n                test.runBare();\n            }\n        };\n        runProtected(test, p);\n\n        endTest(test);\n    }\n\n    /**\n     * Gets the number of run tests.\n     */\n    public synchronized int runCount() {\n        return fRunTests;\n    }\n\n    /**\n     * Runs a TestCase.\n     */\n    public void runProtected(final Test test, Protectable p) {\n        try {\n            p.protect();\n        } catch (AssertionFailedError e) {\n            addFailure(test, e);\n        } catch (ThreadDeath e) { // don't catch ThreadDeath by accident\n            throw e;\n        } catch (Throwable e) {\n            addError(test, e);\n        }\n    }\n\n    /**\n     * Checks whether the test run should stop.\n     */\n    public synchronized boolean shouldStop() {\n        return fStop;\n    }\n\n    /**\n     * Informs the result that a test will be started.\n     */\n    public void startTest(Test test) {\n        final int count = test.countTestCases();\n        synchronized (this) {\n            fRunTests += count;\n        }\n        for (TestListener each : cloneListeners()) {\n            each.startTest(test);\n        }\n    }\n\n    /**\n     * Marks that the test run should stop.\n     */\n    public synchronized void stop() {\n        fStop = true;\n    }\n\n    /**\n     * Returns whether the entire test was successful or not.\n     */\n    public synchronized boolean wasSuccessful() {\n        return failureCount() == 0 && errorCount() == 0;\n    }\n}\n"
  },
  {
    "path": "src/main/java/junit/framework/TestSuite.java",
    "content": "package junit.framework;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.Enumeration;\nimport java.util.List;\nimport java.util.Vector;\n\nimport org.junit.internal.MethodSorter;\nimport org.junit.internal.Throwables;\n\n/**\n * A <code>TestSuite</code> is a <code>Composite</code> of Tests.\n * It runs a collection of test cases. Here is an example using\n * the dynamic test definition.\n * <pre>\n * TestSuite suite= new TestSuite();\n * suite.addTest(new MathTest(\"testAdd\"));\n * suite.addTest(new MathTest(\"testDivideByZero\"));\n * </pre>\n * <p>\n * Alternatively, a TestSuite can extract the tests to be run automatically.\n * To do so you pass the class of your TestCase class to the\n * TestSuite constructor.\n * <pre>\n * TestSuite suite= new TestSuite(MathTest.class);\n * </pre>\n * <p>\n * This constructor creates a suite with all the methods\n * starting with \"test\" that take no arguments.\n * <p>\n * A final option is to do the same for a large array of test classes.\n * <pre>\n * Class[] testClasses = { MathTest.class, AnotherTest.class };\n * TestSuite suite= new TestSuite(testClasses);\n * </pre>\n *\n * @see Test\n */\npublic class TestSuite implements Test {\n\n    /**\n     * ...as the moon sets over the early morning Merlin, Oregon\n     * mountains, our intrepid adventurers type...\n     */\n    static public Test createTest(Class<?> theClass, String name) {\n        Constructor<?> constructor;\n        try {\n            constructor = getTestConstructor(theClass);\n        } catch (NoSuchMethodException e) {\n            return warning(\"Class \" + theClass.getName() + \" has no public constructor TestCase(String name) or TestCase()\");\n        }\n        Object test;\n        try {\n            if (constructor.getParameterTypes().length == 0) {\n                test = constructor.newInstance(new Object[0]);\n                if (test instanceof TestCase) {\n                    ((TestCase) test).setName(name);\n                }\n            } else {\n                test = constructor.newInstance(new Object[]{name});\n            }\n        } catch (InstantiationException e) {\n            return (warning(\"Cannot instantiate test case: \" + name + \" (\" + Throwables.getStacktrace(e) + \")\"));\n        } catch (InvocationTargetException e) {\n            return (warning(\"Exception in constructor: \" + name + \" (\" + Throwables.getStacktrace(e.getTargetException()) + \")\"));\n        } catch (IllegalAccessException e) {\n            return (warning(\"Cannot access test case: \" + name + \" (\" + Throwables.getStacktrace(e) + \")\"));\n        }\n        return (Test) test;\n    }\n\n    /**\n     * Gets a constructor which takes a single String as\n     * its argument or a no arg constructor.\n     */\n    public static Constructor<?> getTestConstructor(Class<?> theClass) throws NoSuchMethodException {\n        try {\n            return theClass.getConstructor(String.class);\n        } catch (NoSuchMethodException e) {\n            // fall through\n        }\n        return theClass.getConstructor();\n    }\n\n    /**\n     * Returns a test which will fail and log a warning message.\n     */\n    public static Test warning(final String message) {\n        return new TestCase(\"warning\") {\n            @Override\n            protected void runTest() {\n                fail(message);\n            }\n        };\n    }\n\n    private String fName;\n\n    private Vector<Test> fTests = new Vector<Test>(10); // Cannot convert this to List because it is used directly by some test runners\n\n    /**\n     * Constructs an empty TestSuite.\n     */\n    public TestSuite() {\n    }\n\n    /**\n     * Constructs a TestSuite from the given class. Adds all the methods\n     * starting with \"test\" as test cases to the suite.\n     * Parts of this method were written at 2337 meters in the Hueffihuette,\n     * Kanton Uri\n     */\n    public TestSuite(final Class<?> theClass) {\n        addTestsFromTestCase(theClass);\n    }\n\n    private void addTestsFromTestCase(final Class<?> theClass) {\n        fName = theClass.getName();\n        try {\n            getTestConstructor(theClass); // Avoid generating multiple error messages\n        } catch (NoSuchMethodException e) {\n            addTest(warning(\"Class \" + theClass.getName() + \" has no public constructor TestCase(String name) or TestCase()\"));\n            return;\n        }\n\n        if (!Modifier.isPublic(theClass.getModifiers())) {\n            addTest(warning(\"Class \" + theClass.getName() + \" is not public\"));\n            return;\n        }\n\n        Class<?> superClass = theClass;\n        List<String> names = new ArrayList<String>();\n        while (Test.class.isAssignableFrom(superClass)) {\n            for (Method each : MethodSorter.getDeclaredMethods(superClass)) {\n                addTestMethod(each, names, theClass);\n            }\n            superClass = superClass.getSuperclass();\n        }\n        if (fTests.size() == 0) {\n            addTest(warning(\"No tests found in \" + theClass.getName()));\n        }\n    }\n\n    /**\n     * Constructs a TestSuite from the given class with the given name.\n     *\n     * @see TestSuite#TestSuite(Class)\n     */\n    public TestSuite(Class<? extends TestCase> theClass, String name) {\n        this(theClass);\n        setName(name);\n    }\n\n    /**\n     * Constructs an empty TestSuite.\n     */\n    public TestSuite(String name) {\n        setName(name);\n    }\n\n    /**\n     * Constructs a TestSuite from the given array of classes.\n     *\n     * @param classes {@link TestCase}s\n     */\n    public TestSuite(Class<?>... classes) {\n        for (Class<?> each : classes) {\n            addTest(testCaseForClass(each));\n        }\n    }\n\n    private Test testCaseForClass(Class<?> each) {\n        if (TestCase.class.isAssignableFrom(each)) {\n            return new TestSuite(each.asSubclass(TestCase.class));\n        } else {\n            return warning(each.getCanonicalName() + \" does not extend TestCase\");\n        }\n    }\n\n    /**\n     * Constructs a TestSuite from the given array of classes with the given name.\n     *\n     * @see TestSuite#TestSuite(Class[])\n     */\n    public TestSuite(Class<? extends TestCase>[] classes, String name) {\n        this(classes);\n        setName(name);\n    }\n\n    /**\n     * Adds a test to the suite.\n     */\n    public void addTest(Test test) {\n        fTests.add(test);\n    }\n\n    /**\n     * Adds the tests from the given class to the suite.\n     */\n    public void addTestSuite(Class<? extends TestCase> testClass) {\n        addTest(new TestSuite(testClass));\n    }\n\n    /**\n     * Counts the number of test cases that will be run by this test.\n     */\n    public int countTestCases() {\n        int count = 0;\n        for (Test each : fTests) {\n            count += each.countTestCases();\n        }\n        return count;\n    }\n\n    /**\n     * Returns the name of the suite. Not all\n     * test suites have a name and this method\n     * can return null.\n     */\n    public String getName() {\n        return fName;\n    }\n\n    /**\n     * Runs the tests and collects their result in a TestResult.\n     */\n    public void run(TestResult result) {\n        for (Test each : fTests) {\n            if (result.shouldStop()) {\n                break;\n            }\n            runTest(each, result);\n        }\n    }\n\n    public void runTest(Test test, TestResult result) {\n        test.run(result);\n    }\n\n    /**\n     * Sets the name of the suite.\n     *\n     * @param name the name to set\n     */\n    public void setName(String name) {\n        fName = name;\n    }\n\n    /**\n     * Returns the test at the given index.\n     */\n    public Test testAt(int index) {\n        return fTests.get(index);\n    }\n\n    /**\n     * Returns the number of tests in this suite.\n     */\n    public int testCount() {\n        return fTests.size();\n    }\n\n    /**\n     * Returns the tests as an enumeration.\n     */\n    public Enumeration<Test> tests() {\n        return fTests.elements();\n    }\n\n    /**\n     */\n    @Override\n    public String toString() {\n        if (getName() != null) {\n            return getName();\n        }\n        return super.toString();\n    }\n\n    private void addTestMethod(Method m, List<String> names, Class<?> theClass) {\n        String name = m.getName();\n        if (names.contains(name)) {\n            return;\n        }\n        if (!isPublicTestMethod(m)) {\n            if (isTestMethod(m)) {\n                addTest(warning(\"Test method isn't public: \" + m.getName() + \"(\" + theClass.getCanonicalName() + \")\"));\n            }\n            return;\n        }\n        names.add(name);\n        addTest(createTest(theClass, name));\n    }\n\n    private boolean isPublicTestMethod(Method m) {\n        return isTestMethod(m) && Modifier.isPublic(m.getModifiers());\n    }\n\n    private boolean isTestMethod(Method m) {\n        return m.getParameterTypes().length == 0 &&\n                m.getName().startsWith(\"test\") &&\n                m.getReturnType().equals(Void.TYPE);\n    }\n}\n"
  },
  {
    "path": "src/main/java/junit/framework/package-info.java",
    "content": "/**\n * Provides JUnit v3.x core classes.\n */\npackage junit.framework;"
  },
  {
    "path": "src/main/java/junit/runner/BaseTestRunner.java",
    "content": "package junit.runner;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.io.StringReader;\nimport java.io.StringWriter;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.text.NumberFormat;\nimport java.util.Properties;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.Test;\nimport junit.framework.TestListener;\nimport junit.framework.TestSuite;\n\nimport org.junit.internal.Throwables;\n\n/**\n * Base class for all test runners.\n * This class was born live on stage in Sardinia during XP2000.\n */\npublic abstract class BaseTestRunner implements TestListener {\n    public static final String SUITE_METHODNAME = \"suite\";\n\n    private static Properties fPreferences;\n    static int fgMaxMessageLength = 500;\n    static boolean fgFilterStack = true;\n    boolean fLoading = true;\n\n    /*\n    * Implementation of TestListener\n    */\n    public synchronized void startTest(Test test) {\n        testStarted(test.toString());\n    }\n\n    protected static void setPreferences(Properties preferences) {\n        fPreferences = preferences;\n    }\n\n    protected static Properties getPreferences() {\n        if (fPreferences == null) {\n            fPreferences = new Properties();\n            fPreferences.put(\"loading\", \"true\");\n            fPreferences.put(\"filterstack\", \"true\");\n            readPreferences();\n        }\n        return fPreferences;\n    }\n\n    public static void savePreferences() throws IOException {\n        FileOutputStream fos = new FileOutputStream(getPreferencesFile());\n        try {\n            getPreferences().store(fos, \"\");\n        } finally {\n            fos.close();\n        }\n    }\n\n    public static void setPreference(String key, String value) {\n        getPreferences().put(key, value);\n    }\n\n    public synchronized void endTest(Test test) {\n        testEnded(test.toString());\n    }\n\n    public synchronized void addError(final Test test, final Throwable e) {\n        testFailed(TestRunListener.STATUS_ERROR, test, e);\n    }\n\n    public synchronized void addFailure(final Test test, final AssertionFailedError e) {\n        testFailed(TestRunListener.STATUS_FAILURE, test, e);\n    }\n\n    // TestRunListener implementation\n\n    public abstract void testStarted(String testName);\n\n    public abstract void testEnded(String testName);\n\n    public abstract void testFailed(int status, Test test, Throwable e);\n\n    /**\n     * Returns the Test corresponding to the given suite. This is\n     * a template method, subclasses override runFailed(), clearStatus().\n     */\n    public Test getTest(String suiteClassName) {\n        if (suiteClassName.length() <= 0) {\n            clearStatus();\n            return null;\n        }\n        Class<?> testClass = null;\n        try {\n            testClass = loadSuiteClass(suiteClassName);\n        } catch (ClassNotFoundException e) {\n            String clazz = e.getMessage();\n            if (clazz == null) {\n                clazz = suiteClassName;\n            }\n            runFailed(\"Class not found \\\"\" + clazz + \"\\\"\");\n            return null;\n        } catch (Exception e) {\n            runFailed(\"Error: \" + e.toString());\n            return null;\n        }\n        Method suiteMethod = null;\n        try {\n            suiteMethod = testClass.getMethod(SUITE_METHODNAME);\n        } catch (Exception e) {\n            // try to extract a test suite automatically\n            clearStatus();\n            return new TestSuite(testClass);\n        }\n        if (!Modifier.isStatic(suiteMethod.getModifiers())) {\n            runFailed(\"Suite() method must be static\");\n            return null;\n        }\n        Test test = null;\n        try {\n            test = (Test) suiteMethod.invoke(null); // static method\n            if (test == null) {\n                return test;\n            }\n        } catch (InvocationTargetException e) {\n            runFailed(\"Failed to invoke suite():\" + e.getTargetException().toString());\n            return null;\n        } catch (IllegalAccessException e) {\n            runFailed(\"Failed to invoke suite():\" + e.toString());\n            return null;\n        }\n\n        clearStatus();\n        return test;\n    }\n\n    /**\n     * Returns the formatted string of the elapsed time.\n     */\n    public String elapsedTimeAsString(long runTime) {\n        return NumberFormat.getInstance().format((double) runTime / 1000);\n    }\n\n    /**\n     * Processes the command line arguments and\n     * returns the name of the suite class to run or null\n     */\n    protected String processArguments(String[] args) {\n        String suiteName = null;\n        for (int i = 0; i < args.length; i++) {\n            if (args[i].equals(\"-noloading\")) {\n                setLoading(false);\n            } else if (args[i].equals(\"-nofilterstack\")) {\n                fgFilterStack = false;\n            } else if (args[i].equals(\"-c\")) {\n                if (args.length > i + 1) {\n                    suiteName = extractClassName(args[i + 1]);\n                } else {\n                    System.out.println(\"Missing Test class name\");\n                }\n                i++;\n            } else {\n                suiteName = args[i];\n            }\n        }\n        return suiteName;\n    }\n\n    /**\n     * Sets the loading behaviour of the test runner\n     */\n    public void setLoading(boolean enable) {\n        fLoading = enable;\n    }\n\n    /**\n     * Extract the class name from a String in VA/Java style\n     */\n    public String extractClassName(String className) {\n        if (className.startsWith(\"Default package for\")) {\n            return className.substring(className.lastIndexOf(\".\") + 1);\n        }\n        return className;\n    }\n\n    /**\n     * Truncates a String to the maximum length.\n     */\n    public static String truncate(String s) {\n        if (fgMaxMessageLength != -1 && s.length() > fgMaxMessageLength) {\n            s = s.substring(0, fgMaxMessageLength) + \"...\";\n        }\n        return s;\n    }\n\n    /**\n     * Override to define how to handle a failed loading of\n     * a test suite.\n     */\n    protected abstract void runFailed(String message);\n\n    /**\n     * Returns the loaded Class for a suite name.\n     */\n    protected Class<?> loadSuiteClass(String suiteClassName) throws ClassNotFoundException {\n        return Class.forName(suiteClassName);\n    }\n\n    /**\n     * Clears the status message.\n     */\n    protected void clearStatus() { // Belongs in the GUI TestRunner class\n    }\n\n    protected boolean useReloadingTestSuiteLoader() {\n        return getPreference(\"loading\").equals(\"true\") && fLoading;\n    }\n\n    private static File getPreferencesFile() {\n        String home = System.getProperty(\"user.home\");\n        return new File(home, \"junit.properties\");\n    }\n\n    private static void readPreferences() {\n        InputStream is = null;\n        try {\n            is = new FileInputStream(getPreferencesFile());\n            setPreferences(new Properties(getPreferences()));\n            getPreferences().load(is);\n        } catch (IOException ignored) {\n        } catch (SecurityException ignored) {\n        } finally {\n            try {\n                if (is != null) {\n                    is.close();\n                }\n            } catch (IOException e1) {\n            }\n        }\n    }\n\n    public static String getPreference(String key) {\n        return getPreferences().getProperty(key);\n    }\n\n    public static int getPreference(String key, int dflt) {\n        String value = getPreference(key);\n        int intValue = dflt;\n        if (value == null) {\n            return intValue;\n        }\n        try {\n            intValue = Integer.parseInt(value);\n        } catch (NumberFormatException ne) {\n        }\n        return intValue;\n    }\n\n    /**\n     * Returns a filtered stack trace\n     */\n    public static String getFilteredTrace(Throwable e) {\n        return BaseTestRunner.getFilteredTrace(Throwables.getStacktrace(e));\n    }\n\n    /**\n     * Filters stack frames from internal JUnit classes\n     */\n    public static String getFilteredTrace(String stack) {\n        if (showStackRaw()) {\n            return stack;\n        }\n\n        StringWriter sw = new StringWriter();\n        PrintWriter pw = new PrintWriter(sw);\n        StringReader sr = new StringReader(stack);\n        BufferedReader br = new BufferedReader(sr);\n\n        String line;\n        try {\n            while ((line = br.readLine()) != null) {\n                if (!filterLine(line)) {\n                    pw.println(line);\n                }\n            }\n        } catch (Exception IOException) {\n            return stack; // return the stack unfiltered\n        }\n        return sw.toString();\n    }\n\n    protected static boolean showStackRaw() {\n        return !getPreference(\"filterstack\").equals(\"true\") || fgFilterStack == false;\n    }\n\n    static boolean filterLine(String line) {\n        String[] patterns = new String[]{\n                \"junit.framework.TestCase\",\n                \"junit.framework.TestResult\",\n                \"junit.framework.TestSuite\",\n                \"junit.framework.Assert.\", // don't filter AssertionFailure\n                \"junit.swingui.TestRunner\",\n                \"junit.awtui.TestRunner\",\n                \"junit.textui.TestRunner\",\n                \"java.lang.reflect.Method.invoke(\"\n        };\n        for (int i = 0; i < patterns.length; i++) {\n            if (line.indexOf(patterns[i]) > 0) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    static {\n        fgMaxMessageLength = getPreference(\"maxmessage\", fgMaxMessageLength);\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/junit/runner/TestRunListener.java",
    "content": "package junit.runner;\n\n/**\n * A listener interface for observing the\n * execution of a test run. Unlike TestListener,\n * this interface using only primitive objects,\n * making it suitable for remote test execution.\n */\npublic interface TestRunListener {\n    /* test status constants*/\n    int STATUS_ERROR = 1;\n    int STATUS_FAILURE = 2;\n\n    void testRunStarted(String testSuiteName, int testCount);\n\n    void testRunEnded(long elapsedTime);\n\n    void testRunStopped(long elapsedTime);\n\n    void testStarted(String testName);\n\n    void testEnded(String testName);\n\n    void testFailed(int status, String testName, String trace);\n}\n"
  },
  {
    "path": "src/main/java/junit/runner/Version.java",
    "content": "package junit.runner;\n\n/**\n * This class defines the current version of JUnit\n */\npublic class Version {\n\tprivate Version() {\n\t\t// don't instantiate\n\t}\n\n\tpublic static String id() {\n\t\treturn \"4.13.3-SNAPSHOT\";\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tSystem.out.println(id());\n\t}\n}\n"
  },
  {
    "path": "src/main/java/junit/runner/Version.java.template",
    "content": "package junit.runner;\n\n/**\n * This class defines the current version of JUnit\n */\npublic class Version {\n\tprivate Version() {\n\t\t// don't instantiate\n\t}\n\n\tpublic static String id() {\n\t\treturn \"@version@\";\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tSystem.out.println(id());\n\t}\n}\n"
  },
  {
    "path": "src/main/java/junit/runner/package-info.java",
    "content": "/**\n * Provides JUnit v3.x test runners.\n */\npackage junit.runner;"
  },
  {
    "path": "src/main/java/junit/textui/ResultPrinter.java",
    "content": "package junit.textui;\n\nimport java.io.PrintStream;\nimport java.text.NumberFormat;\nimport java.util.Enumeration;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.Test;\nimport junit.framework.TestFailure;\nimport junit.framework.TestListener;\nimport junit.framework.TestResult;\nimport junit.runner.BaseTestRunner;\n\npublic class ResultPrinter implements TestListener {\n    PrintStream fWriter;\n    int fColumn = 0;\n\n    public ResultPrinter(PrintStream writer) {\n        fWriter = writer;\n    }\n\n    /* API for use by textui.TestRunner */\n\n    synchronized void print(TestResult result, long runTime) {\n        printHeader(runTime);\n        printErrors(result);\n        printFailures(result);\n        printFooter(result);\n    }\n\n    void printWaitPrompt() {\n        getWriter().println();\n        getWriter().println(\"<RETURN> to continue\");\n    }\n\n    /* Internal methods */\n\n    protected void printHeader(long runTime) {\n        getWriter().println();\n        getWriter().println(\"Time: \" + elapsedTimeAsString(runTime));\n    }\n\n    protected void printErrors(TestResult result) {\n        printDefects(result.errors(), result.errorCount(), \"error\");\n    }\n\n    protected void printFailures(TestResult result) {\n        printDefects(result.failures(), result.failureCount(), \"failure\");\n    }\n\n    protected void printDefects(Enumeration<TestFailure> booBoos, int count, String type) {\n        if (count == 0) return;\n        if (count == 1) {\n            getWriter().println(\"There was \" + count + \" \" + type + \":\");\n        } else {\n            getWriter().println(\"There were \" + count + \" \" + type + \"s:\");\n        }\n        for (int i = 1; booBoos.hasMoreElements(); i++) {\n            printDefect(booBoos.nextElement(), i);\n        }\n    }\n\n    public void printDefect(TestFailure booBoo, int count) { // only public for testing purposes\n        printDefectHeader(booBoo, count);\n        printDefectTrace(booBoo);\n    }\n\n    protected void printDefectHeader(TestFailure booBoo, int count) {\n        // I feel like making this a println, then adding a line giving the throwable a chance to print something\n        // before we get to the stack trace.\n        getWriter().print(count + \") \" + booBoo.failedTest());\n    }\n\n    protected void printDefectTrace(TestFailure booBoo) {\n        getWriter().print(BaseTestRunner.getFilteredTrace(booBoo.trace()));\n    }\n\n    protected void printFooter(TestResult result) {\n        if (result.wasSuccessful()) {\n            getWriter().println();\n            getWriter().print(\"OK\");\n            getWriter().println(\" (\" + result.runCount() + \" test\" + (result.runCount() == 1 ? \"\" : \"s\") + \")\");\n\n        } else {\n            getWriter().println();\n            getWriter().println(\"FAILURES!!!\");\n            getWriter().println(\"Tests run: \" + result.runCount() +\n                    \",  Failures: \" + result.failureCount() +\n                    \",  Errors: \" + result.errorCount());\n        }\n        getWriter().println();\n    }\n\n    /**\n     * Returns the formatted string of the elapsed time.\n     * Duplicated from BaseTestRunner. Fix it.\n     */\n    protected String elapsedTimeAsString(long runTime) {\n        return NumberFormat.getInstance().format((double) runTime / 1000);\n    }\n\n    public PrintStream getWriter() {\n        return fWriter;\n    }\n\n    /**\n     * @see junit.framework.TestListener#addError(Test, Throwable)\n     */\n    public void addError(Test test, Throwable e) {\n        getWriter().print(\"E\");\n    }\n\n    /**\n     * @see junit.framework.TestListener#addFailure(Test, AssertionFailedError)\n     */\n    public void addFailure(Test test, AssertionFailedError t) {\n        getWriter().print(\"F\");\n    }\n\n    /**\n     * @see junit.framework.TestListener#endTest(Test)\n     */\n    public void endTest(Test test) {\n    }\n\n    /**\n     * @see junit.framework.TestListener#startTest(Test)\n     */\n    public void startTest(Test test) {\n        getWriter().print(\".\");\n        if (fColumn++ >= 40) {\n            getWriter().println();\n            fColumn = 0;\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/junit/textui/TestRunner.java",
    "content": "package junit.textui;\n\n\nimport java.io.PrintStream;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\nimport junit.runner.BaseTestRunner;\nimport junit.runner.Version;\n\n/**\n * A command line based tool to run tests.\n * <pre>\n * java junit.textui.TestRunner [-wait] TestCaseClass\n * </pre>\n * <p>\n * TestRunner expects the name of a TestCase class as argument.\n * If this class defines a static <code>suite</code> method it\n * will be invoked and the returned test is run. Otherwise all\n * the methods starting with \"test\" having no arguments are run.\n * <p>\n * When the wait command line argument is given TestRunner\n * waits until the users types RETURN.\n * <p>\n * TestRunner prints a trace as the tests are executed followed by a\n * summary at the end.\n */\npublic class TestRunner extends BaseTestRunner {\n    private ResultPrinter fPrinter;\n\n    public static final int SUCCESS_EXIT = 0;\n    public static final int FAILURE_EXIT = 1;\n    public static final int EXCEPTION_EXIT = 2;\n\n    /**\n     * Constructs a TestRunner.\n     */\n    public TestRunner() {\n        this(System.out);\n    }\n\n    /**\n     * Constructs a TestRunner using the given stream for all the output\n     */\n    public TestRunner(PrintStream writer) {\n        this(new ResultPrinter(writer));\n    }\n\n    /**\n     * Constructs a TestRunner using the given ResultPrinter all the output\n     */\n    public TestRunner(ResultPrinter printer) {\n        fPrinter = printer;\n    }\n\n    /**\n     * Runs a suite extracted from a TestCase subclass.\n     */\n    static public void run(Class<? extends TestCase> testClass) {\n        run(new TestSuite(testClass));\n    }\n\n    /**\n     * Runs a single test and collects its results.\n     * This method can be used to start a test run\n     * from your program.\n     * <pre>\n     * public static void main (String[] args) {\n     *    test.textui.TestRunner.run(suite());\n     * }\n     * </pre>\n     */\n    static public TestResult run(Test test) {\n        TestRunner runner = new TestRunner();\n        return runner.doRun(test);\n    }\n\n    /**\n     * Runs a single test and waits until the user\n     * types RETURN.\n     */\n    static public void runAndWait(Test suite) {\n        TestRunner aTestRunner = new TestRunner();\n        aTestRunner.doRun(suite, true);\n    }\n\n    @Override\n    public void testFailed(int status, Test test, Throwable e) {\n    }\n\n    @Override\n    public void testStarted(String testName) {\n    }\n\n    @Override\n    public void testEnded(String testName) {\n    }\n\n    /**\n     * Creates the TestResult to be used for the test run.\n     */\n    protected TestResult createTestResult() {\n        return new TestResult();\n    }\n\n    public TestResult doRun(Test test) {\n        return doRun(test, false);\n    }\n\n    public TestResult doRun(Test suite, boolean wait) {\n        TestResult result = createTestResult();\n        result.addListener(fPrinter);\n        long startTime = System.currentTimeMillis();\n        suite.run(result);\n        long endTime = System.currentTimeMillis();\n        long runTime = endTime - startTime;\n        fPrinter.print(result, runTime);\n\n        pause(wait);\n        return result;\n    }\n\n    protected void pause(boolean wait) {\n        if (!wait) return;\n        fPrinter.printWaitPrompt();\n        try {\n            System.in.read();\n        } catch (Exception e) {\n        }\n    }\n\n    public static void main(String[] args) {\n        TestRunner aTestRunner = new TestRunner();\n        try {\n            TestResult r = aTestRunner.start(args);\n            if (!r.wasSuccessful()) {\n                System.exit(FAILURE_EXIT);\n            }\n            System.exit(SUCCESS_EXIT);\n        } catch (Exception e) {\n            System.err.println(e.getMessage());\n            System.exit(EXCEPTION_EXIT);\n        }\n    }\n\n    /**\n     * Starts a test run. Analyzes the command line arguments and runs the given\n     * test suite.\n     */\n    public TestResult start(String[] args) throws Exception {\n        String testCase = \"\";\n        String method = \"\";\n        boolean wait = false;\n\n        for (int i = 0; i < args.length; i++) {\n            if (args[i].equals(\"-wait\")) {\n                wait = true;\n            } else if (args[i].equals(\"-c\")) {\n                testCase = extractClassName(args[++i]);\n            } else if (args[i].equals(\"-m\")) {\n                String arg = args[++i];\n                int lastIndex = arg.lastIndexOf('.');\n                testCase = arg.substring(0, lastIndex);\n                method = arg.substring(lastIndex + 1);\n            } else if (args[i].equals(\"-v\")) {\n                System.err.println(\"JUnit \" + Version.id() + \" by Kent Beck and Erich Gamma\");\n            } else {\n                testCase = args[i];\n            }\n        }\n\n        if (testCase.equals(\"\")) {\n            throw new Exception(\"Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class\");\n        }\n\n        try {\n            if (!method.equals(\"\")) {\n                return runSingleMethod(testCase, method, wait);\n            }\n            Test suite = getTest(testCase);\n            return doRun(suite, wait);\n        } catch (Exception e) {\n            throw new Exception(\"Could not create and run test suite: \" + e);\n        }\n    }\n\n    protected TestResult runSingleMethod(String testCase, String method, boolean wait) throws Exception {\n        Class<? extends TestCase> testClass = loadSuiteClass(testCase).asSubclass(TestCase.class);\n        Test test = TestSuite.createTest(testClass, method);\n        return doRun(test, wait);\n    }\n\n    @Override\n    protected void runFailed(String message) {\n        System.err.println(message);\n        System.exit(FAILURE_EXIT);\n    }\n\n    public void setPrinter(ResultPrinter printer) {\n        fPrinter = printer;\n    }\n\n\n}"
  },
  {
    "path": "src/main/java/junit/textui/package-info.java",
    "content": "/**\n * Provides JUnit v3.x command line based tool to run tests.\n */\npackage junit.textui;"
  },
  {
    "path": "src/main/java/org/junit/After.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * If you allocate external resources in a {@link org.junit.Before} method you need to release them\n * after the test runs. Annotating a <code>public void</code> method\n * with <code>&#064;After</code> causes that method to be run after the {@link org.junit.Test} method. All <code>&#064;After</code>\n * methods are guaranteed to run even if a {@link org.junit.Before} or {@link org.junit.Test} method throws an\n * exception. The <code>&#064;After</code> methods declared in superclasses will be run after those of the current\n * class, unless they are overridden in the current class.\n * <p>\n * Here is a simple example:\n * <pre>\n * public class Example {\n *    File output;\n *    &#064;Before public void createOutputFile() {\n *          output= new File(...);\n *    }\n *    &#064;Test public void something() {\n *          ...\n *    }\n *    &#064;After public void deleteOutputFile() {\n *          output.delete();\n *    }\n * }\n * </pre>\n *\n * @see org.junit.Before\n * @see org.junit.Test\n * @since 4.0\n */\n\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.METHOD)\npublic @interface After {\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/AfterClass.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * If you allocate expensive external resources in a {@link org.junit.BeforeClass} method you need to release them\n * after all the tests in the class have run. Annotating a <code>public static void</code> method\n * with <code>&#064;AfterClass</code> causes that method to be run after all the tests in the class have been run. All <code>&#064;AfterClass</code>\n * methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an\n * exception. The <code>&#064;AfterClass</code> methods declared in superclasses will be run after those of the current\n * class, unless they are shadowed in the current class.\n * <p>\n * Here is a simple example:\n * <pre>\n * public class Example {\n *    private static DatabaseConnection database;\n *    &#064;BeforeClass public static void login() {\n *          database= ...;\n *    }\n *    &#064;Test public void something() {\n *          ...\n *    }\n *    &#064;Test public void somethingElse() {\n *          ...\n *    }\n *    &#064;AfterClass public static void logout() {\n *          database.logout();\n *    }\n * }\n * </pre>\n *\n * @see org.junit.BeforeClass\n * @see org.junit.Test\n * @since 4.0\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.METHOD)\npublic @interface AfterClass {\n}\n"
  },
  {
    "path": "src/main/java/org/junit/Assert.java",
    "content": "package org.junit;\n\nimport org.hamcrest.Matcher;\nimport org.hamcrest.MatcherAssert;\nimport org.junit.function.ThrowingRunnable;\nimport org.junit.internal.ArrayComparisonFailure;\nimport org.junit.internal.ExactComparisonCriteria;\nimport org.junit.internal.InexactComparisonCriteria;\n\n/**\n * A set of assertion methods useful for writing tests. Only failed assertions\n * are recorded. These methods can be used directly:\n * <code>Assert.assertEquals(...)</code>, however, they read better if they\n * are referenced through static import:\n *\n * <pre>\n * import static org.junit.Assert.*;\n *    ...\n *    assertEquals(...);\n * </pre>\n *\n * @see AssertionError\n * @since 4.0\n */\npublic class Assert {\n    /**\n     * Protect constructor since it is a static only class\n     */\n    protected Assert() {\n    }\n\n    /**\n     * Asserts that a condition is true. If it isn't it throws an\n     * {@link AssertionError} with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param condition condition to be checked\n     */\n    public static void assertTrue(String message, boolean condition) {\n        if (!condition) {\n            fail(message);\n        }\n    }\n\n    /**\n     * Asserts that a condition is true. If it isn't it throws an\n     * {@link AssertionError} without a message.\n     *\n     * @param condition condition to be checked\n     */\n    public static void assertTrue(boolean condition) {\n        assertTrue(null, condition);\n    }\n\n    /**\n     * Asserts that a condition is false. If it isn't it throws an\n     * {@link AssertionError} with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param condition condition to be checked\n     */\n    public static void assertFalse(String message, boolean condition) {\n        assertTrue(message, !condition);\n    }\n\n    /**\n     * Asserts that a condition is false. If it isn't it throws an\n     * {@link AssertionError} without a message.\n     *\n     * @param condition condition to be checked\n     */\n    public static void assertFalse(boolean condition) {\n        assertFalse(null, condition);\n    }\n\n    /**\n     * Fails a test with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @see AssertionError\n     */\n    public static void fail(String message) {\n        if (message == null) {\n            throw new AssertionError();\n        }\n        throw new AssertionError(message);\n    }\n\n    /**\n     * Fails a test with no message.\n     */\n    public static void fail() {\n        fail(null);\n    }\n\n    /**\n     * Asserts that two objects are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message. If\n     * <code>expected</code> and <code>actual</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expected expected value\n     * @param actual actual value\n     */\n    public static void assertEquals(String message, Object expected,\n            Object actual) {\n        if (equalsRegardingNull(expected, actual)) {\n            return;\n        }\n        if (expected instanceof String && actual instanceof String) {\n            String cleanMessage = message == null ? \"\" : message;\n            throw new ComparisonFailure(cleanMessage, (String) expected,\n                    (String) actual);\n        } else {\n            failNotEquals(message, expected, actual);\n        }\n    }\n\n    private static boolean equalsRegardingNull(Object expected, Object actual) {\n        if (expected == null) {\n            return actual == null;\n        }\n\n        return isEquals(expected, actual);\n    }\n\n    private static boolean isEquals(Object expected, Object actual) {\n        return expected.equals(actual);\n    }\n\n    /**\n     * Asserts that two objects are equal. If they are not, an\n     * {@link AssertionError} without a message is thrown. If\n     * <code>expected</code> and <code>actual</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param expected expected value\n     * @param actual the value to check against <code>expected</code>\n     */\n    public static void assertEquals(Object expected, Object actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects are <b>not</b> equals. If they are, an\n     * {@link AssertionError} is thrown with the given message. If\n     * <code>unexpected</code> and <code>actual</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param unexpected unexpected value to check\n     * @param actual the value to check against <code>unexpected</code>\n     */\n    public static void assertNotEquals(String message, Object unexpected,\n            Object actual) {\n        if (equalsRegardingNull(unexpected, actual)) {\n            failEquals(message, actual);\n        }\n    }\n\n    /**\n     * Asserts that two objects are <b>not</b> equals. If they are, an\n     * {@link AssertionError} without a message is thrown. If\n     * <code>unexpected</code> and <code>actual</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param unexpected unexpected value to check\n     * @param actual the value to check against <code>unexpected</code>\n     */\n    public static void assertNotEquals(Object unexpected, Object actual) {\n        assertNotEquals(null, unexpected, actual);\n    }\n\n    private static void failEquals(String message, Object actual) {\n        String formatted = \"Values should be different. \";\n        if (message != null) {\n            formatted = message + \". \";\n        }\n\n        formatted += \"Actual: \" + actual;\n        fail(formatted);\n    }\n\n    /**\n     * Asserts that two longs are <b>not</b> equals. If they are, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param unexpected unexpected value to check\n     * @param actual the value to check against <code>unexpected</code>\n     */\n    public static void assertNotEquals(String message, long unexpected, long actual) {\n        if (unexpected == actual) {\n            failEquals(message, Long.valueOf(actual));\n        }\n    }\n\n    /**\n     * Asserts that two longs are <b>not</b> equals. If they are, an\n     * {@link AssertionError} without a message is thrown.\n     *\n     * @param unexpected unexpected value to check\n     * @param actual the value to check against <code>unexpected</code>\n     */\n    public static void assertNotEquals(long unexpected, long actual) {\n        assertNotEquals(null, unexpected, actual);\n    }\n\n    /**\n     * Asserts that two doubles are <b>not</b> equal to within a positive delta.\n     * If they are, an {@link AssertionError} is thrown with the given\n     * message. If the unexpected value is infinity then the delta value is\n     * ignored. NaNs are considered equal:\n     * <code>assertNotEquals(Double.NaN, Double.NaN, *)</code> fails\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param unexpected unexpected value\n     * @param actual the value to check against <code>unexpected</code>\n     * @param delta the maximum delta between <code>unexpected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertNotEquals(String message, double unexpected,\n            double actual, double delta) {\n        if (!doubleIsDifferent(unexpected, actual, delta)) {\n            failEquals(message, Double.valueOf(actual));\n        }\n    }\n\n    /**\n     * Asserts that two doubles are <b>not</b> equal to within a positive delta.\n     * If they are, an {@link AssertionError} is thrown. If the unexpected\n     * value is infinity then the delta value is ignored.NaNs are considered\n     * equal: <code>assertNotEquals(Double.NaN, Double.NaN, *)</code> fails\n     *\n     * @param unexpected unexpected value\n     * @param actual the value to check against <code>unexpected</code>\n     * @param delta the maximum delta between <code>unexpected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertNotEquals(double unexpected, double actual, double delta) {\n        assertNotEquals(null, unexpected, actual, delta);\n    }\n\n    /**\n     * Asserts that two floats are <b>not</b> equal to within a positive delta.\n     * If they are, an {@link AssertionError} is thrown. If the unexpected\n     * value is infinity then the delta value is ignored.NaNs are considered\n     * equal: <code>assertNotEquals(Float.NaN, Float.NaN, *)</code> fails\n     *\n     * @param unexpected unexpected value\n     * @param actual the value to check against <code>unexpected</code>\n     * @param delta the maximum delta between <code>unexpected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertNotEquals(float unexpected, float actual, float delta) {\n        assertNotEquals(null, unexpected, actual, delta);\n    }\n\n    /**\n     * Asserts that two object arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message. If\n     * <code>expecteds</code> and <code>actuals</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds Object array or array of arrays (multi-dimensional array) with\n     * expected values.\n     * @param actuals Object array or array of arrays (multi-dimensional array) with\n     * actual values\n     */\n    public static void assertArrayEquals(String message, Object[] expecteds,\n            Object[] actuals) throws ArrayComparisonFailure {\n        internalArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two object arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown. If <code>expected</code> and\n     * <code>actual</code> are <code>null</code>, they are considered\n     * equal.\n     *\n     * @param expecteds Object array or array of arrays (multi-dimensional array) with\n     * expected values\n     * @param actuals Object array or array of arrays (multi-dimensional array) with\n     * actual values\n     */\n    public static void assertArrayEquals(Object[] expecteds, Object[] actuals) {\n        assertArrayEquals(null, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two boolean arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message. If\n     * <code>expecteds</code> and <code>actuals</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds boolean array with expected values.\n     * @param actuals boolean array with expected values.\n     */\n    public static void assertArrayEquals(String message, boolean[] expecteds,\n            boolean[] actuals) throws ArrayComparisonFailure {\n        internalArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two boolean arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown. If <code>expected</code> and\n     * <code>actual</code> are <code>null</code>, they are considered\n     * equal.\n     *\n     * @param expecteds boolean array with expected values.\n     * @param actuals boolean array with expected values.\n     */\n    public static void assertArrayEquals(boolean[] expecteds, boolean[] actuals) {\n        assertArrayEquals(null, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two byte arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds byte array with expected values.\n     * @param actuals byte array with actual values\n     */\n    public static void assertArrayEquals(String message, byte[] expecteds,\n            byte[] actuals) throws ArrayComparisonFailure {\n        internalArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two byte arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expecteds byte array with expected values.\n     * @param actuals byte array with actual values\n     */\n    public static void assertArrayEquals(byte[] expecteds, byte[] actuals) {\n        assertArrayEquals(null, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two char arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds char array with expected values.\n     * @param actuals char array with actual values\n     */\n    public static void assertArrayEquals(String message, char[] expecteds,\n            char[] actuals) throws ArrayComparisonFailure {\n        internalArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two char arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expecteds char array with expected values.\n     * @param actuals char array with actual values\n     */\n    public static void assertArrayEquals(char[] expecteds, char[] actuals) {\n        assertArrayEquals(null, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two short arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds short array with expected values.\n     * @param actuals short array with actual values\n     */\n    public static void assertArrayEquals(String message, short[] expecteds,\n            short[] actuals) throws ArrayComparisonFailure {\n        internalArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two short arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expecteds short array with expected values.\n     * @param actuals short array with actual values\n     */\n    public static void assertArrayEquals(short[] expecteds, short[] actuals) {\n        assertArrayEquals(null, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two int arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds int array with expected values.\n     * @param actuals int array with actual values\n     */\n    public static void assertArrayEquals(String message, int[] expecteds,\n            int[] actuals) throws ArrayComparisonFailure {\n        internalArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two int arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expecteds int array with expected values.\n     * @param actuals int array with actual values\n     */\n    public static void assertArrayEquals(int[] expecteds, int[] actuals) {\n        assertArrayEquals(null, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two long arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds long array with expected values.\n     * @param actuals long array with actual values\n     */\n    public static void assertArrayEquals(String message, long[] expecteds,\n            long[] actuals) throws ArrayComparisonFailure {\n        internalArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two long arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expecteds long array with expected values.\n     * @param actuals long array with actual values\n     */\n    public static void assertArrayEquals(long[] expecteds, long[] actuals) {\n        assertArrayEquals(null, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two double arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds double array with expected values.\n     * @param actuals double array with actual values\n     * @param delta the maximum delta between <code>expecteds[i]</code> and\n     * <code>actuals[i]</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertArrayEquals(String message, double[] expecteds,\n            double[] actuals, double delta) throws ArrayComparisonFailure {\n        new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two double arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expecteds double array with expected values.\n     * @param actuals double array with actual values\n     * @param delta the maximum delta between <code>expecteds[i]</code> and\n     * <code>actuals[i]</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertArrayEquals(double[] expecteds, double[] actuals, double delta) {\n        assertArrayEquals(null, expecteds, actuals, delta);\n    }\n\n    /**\n     * Asserts that two float arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds float array with expected values.\n     * @param actuals float array with actual values\n     * @param delta the maximum delta between <code>expecteds[i]</code> and\n     * <code>actuals[i]</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertArrayEquals(String message, float[] expecteds,\n            float[] actuals, float delta) throws ArrayComparisonFailure {\n        new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two float arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expecteds float array with expected values.\n     * @param actuals float array with actual values\n     * @param delta the maximum delta between <code>expecteds[i]</code> and\n     * <code>actuals[i]</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertArrayEquals(float[] expecteds, float[] actuals, float delta) {\n        assertArrayEquals(null, expecteds, actuals, delta);\n    }\n\n    /**\n     * Asserts that two object arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message. If\n     * <code>expecteds</code> and <code>actuals</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds Object array or array of arrays (multi-dimensional array) with\n     * expected values.\n     * @param actuals Object array or array of arrays (multi-dimensional array) with\n     * actual values\n     */\n    private static void internalArrayEquals(String message, Object expecteds,\n            Object actuals) throws ArrayComparisonFailure {\n        new ExactComparisonCriteria().arrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two doubles are equal to within a positive delta.\n     * If they are not, an {@link AssertionError} is thrown with the given\n     * message. If the expected value is infinity then the delta value is\n     * ignored. NaNs are considered equal:\n     * <code>assertEquals(Double.NaN, Double.NaN, *)</code> passes\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expected expected value\n     * @param actual the value to check against <code>expected</code>\n     * @param delta the maximum delta between <code>expected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertEquals(String message, double expected,\n            double actual, double delta) {\n        if (doubleIsDifferent(expected, actual, delta)) {\n            failNotEquals(message, Double.valueOf(expected), Double.valueOf(actual));\n        }\n    }\n\n    /**\n     * Asserts that two floats are equal to within a positive delta.\n     * If they are not, an {@link AssertionError} is thrown with the given\n     * message. If the expected value is infinity then the delta value is\n     * ignored. NaNs are considered equal:\n     * <code>assertEquals(Float.NaN, Float.NaN, *)</code> passes\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expected expected value\n     * @param actual the value to check against <code>expected</code>\n     * @param delta the maximum delta between <code>expected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertEquals(String message, float expected,\n            float actual, float delta) {\n        if (floatIsDifferent(expected, actual, delta)) {\n            failNotEquals(message, Float.valueOf(expected), Float.valueOf(actual));\n        }\n    }\n\n    /**\n     * Asserts that two floats are <b>not</b> equal to within a positive delta.\n     * If they are, an {@link AssertionError} is thrown with the given\n     * message. If the unexpected value is infinity then the delta value is\n     * ignored. NaNs are considered equal:\n     * <code>assertNotEquals(Float.NaN, Float.NaN, *)</code> fails\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param unexpected unexpected value\n     * @param actual the value to check against <code>unexpected</code>\n     * @param delta the maximum delta between <code>unexpected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertNotEquals(String message, float unexpected,\n            float actual, float delta) {\n        if (!floatIsDifferent(unexpected, actual, delta)) {\n            failEquals(message, Float.valueOf(actual));\n        }\n    }\n\n    private static boolean doubleIsDifferent(double d1, double d2, double delta) {\n        if (Double.compare(d1, d2) == 0) {\n            return false;\n        }\n        if ((Math.abs(d1 - d2) <= delta)) {\n            return false;\n        }\n\n        return true;\n    }\n\n    private static boolean floatIsDifferent(float f1, float f2, float delta) {\n        if (Float.compare(f1, f2) == 0) {\n            return false;\n        }\n        if ((Math.abs(f1 - f2) <= delta)) {\n            return false;\n        }\n\n        return true;\n    }\n\n    /**\n     * Asserts that two longs are equal. If they are not, an\n     * {@link AssertionError} is thrown.\n     *\n     * @param expected expected long value.\n     * @param actual actual long value\n     */\n    public static void assertEquals(long expected, long actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two longs are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expected long expected value.\n     * @param actual long actual value\n     */\n    public static void assertEquals(String message, long expected, long actual) {\n        if (expected != actual) {\n            failNotEquals(message, Long.valueOf(expected), Long.valueOf(actual));\n        }\n    }\n\n    /**\n     * @deprecated Use\n     *             <code>assertEquals(double expected, double actual, double delta)</code>\n     *             instead\n     */\n    @Deprecated\n    public static void assertEquals(double expected, double actual) {\n        assertEquals(null, expected, actual);\n    }\n\n    /**\n     * @deprecated Use\n     *             <code>assertEquals(String message, double expected, double actual, double delta)</code>\n     *             instead\n     */\n    @Deprecated\n    public static void assertEquals(String message, double expected,\n            double actual) {\n        fail(\"Use assertEquals(expected, actual, delta) to compare floating-point numbers\");\n    }\n\n    /**\n     * Asserts that two doubles are equal to within a positive delta.\n     * If they are not, an {@link AssertionError} is thrown. If the expected\n     * value is infinity then the delta value is ignored.NaNs are considered\n     * equal: <code>assertEquals(Double.NaN, Double.NaN, *)</code> passes\n     *\n     * @param expected expected value\n     * @param actual the value to check against <code>expected</code>\n     * @param delta the maximum delta between <code>expected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertEquals(double expected, double actual, double delta) {\n        assertEquals(null, expected, actual, delta);\n    }\n\n    /**\n     * Asserts that two floats are equal to within a positive delta.\n     * If they are not, an {@link AssertionError} is thrown. If the expected\n     * value is infinity then the delta value is ignored. NaNs are considered\n     * equal: <code>assertEquals(Float.NaN, Float.NaN, *)</code> passes\n     *\n     * @param expected expected value\n     * @param actual the value to check against <code>expected</code>\n     * @param delta the maximum delta between <code>expected</code> and\n     * <code>actual</code> for which both numbers are still\n     * considered equal.\n     */\n    public static void assertEquals(float expected, float actual, float delta) {\n        assertEquals(null, expected, actual, delta);\n    }\n\n    /**\n     * Asserts that an object isn't null. If it is an {@link AssertionError} is\n     * thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param object Object to check or <code>null</code>\n     */\n    public static void assertNotNull(String message, Object object) {\n        assertTrue(message, object != null);\n    }\n\n    /**\n     * Asserts that an object isn't null. If it is an {@link AssertionError} is\n     * thrown.\n     *\n     * @param object Object to check or <code>null</code>\n     */\n    public static void assertNotNull(Object object) {\n        assertNotNull(null, object);\n    }\n\n    /**\n     * Asserts that an object is null. If it is not, an {@link AssertionError}\n     * is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param object Object to check or <code>null</code>\n     */\n    public static void assertNull(String message, Object object) {\n        if (object == null) {\n            return;\n        }\n        failNotNull(message, object);\n    }\n\n    /**\n     * Asserts that an object is null. If it isn't an {@link AssertionError} is\n     * thrown.\n     *\n     * @param object Object to check or <code>null</code>\n     */\n    public static void assertNull(Object object) {\n        assertNull(null, object);\n    }\n\n    private static void failNotNull(String message, Object actual) {\n        String formatted = \"\";\n        if (message != null) {\n            formatted = message + \" \";\n        }\n        fail(formatted + \"expected null, but was:<\" + actual + \">\");\n    }\n\n    /**\n     * Asserts that two objects refer to the same object. If they are not, an\n     * {@link AssertionError} is thrown with the given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expected the expected object\n     * @param actual the object to compare to <code>expected</code>\n     */\n    public static void assertSame(String message, Object expected, Object actual) {\n        if (expected == actual) {\n            return;\n        }\n        failNotSame(message, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects refer to the same object. If they are not the\n     * same, an {@link AssertionError} without a message is thrown.\n     *\n     * @param expected the expected object\n     * @param actual the object to compare to <code>expected</code>\n     */\n    public static void assertSame(Object expected, Object actual) {\n        assertSame(null, expected, actual);\n    }\n\n    /**\n     * Asserts that two objects do not refer to the same object. If they do\n     * refer to the same object, an {@link AssertionError} is thrown with the\n     * given message.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param unexpected the object you don't expect\n     * @param actual the object to compare to <code>unexpected</code>\n     */\n    public static void assertNotSame(String message, Object unexpected,\n            Object actual) {\n        if (unexpected == actual) {\n            failSame(message);\n        }\n    }\n\n    /**\n     * Asserts that two objects do not refer to the same object. If they do\n     * refer to the same object, an {@link AssertionError} without a message is\n     * thrown.\n     *\n     * @param unexpected the object you don't expect\n     * @param actual the object to compare to <code>unexpected</code>\n     */\n    public static void assertNotSame(Object unexpected, Object actual) {\n        assertNotSame(null, unexpected, actual);\n    }\n\n    private static void failSame(String message) {\n        String formatted = \"\";\n        if (message != null) {\n            formatted = message + \" \";\n        }\n        fail(formatted + \"expected not same\");\n    }\n\n    private static void failNotSame(String message, Object expected,\n            Object actual) {\n        String formatted = \"\";\n        if (message != null) {\n            formatted = message + \" \";\n        }\n        fail(formatted + \"expected same:<\" + expected + \"> was not:<\" + actual\n                + \">\");\n    }\n\n    private static void failNotEquals(String message, Object expected,\n            Object actual) {\n        fail(format(message, expected, actual));\n    }\n\n    static String format(String message, Object expected, Object actual) {\n        String formatted = \"\";\n        if (message != null && !\"\".equals(message)) {\n            formatted = message + \" \";\n        }\n        String expectedString = String.valueOf(expected);\n        String actualString = String.valueOf(actual);\n        if (equalsRegardingNull(expectedString, actualString)) {\n            return formatted + \"expected: \"\n                    + formatClassAndValue(expected, expectedString)\n                    + \" but was: \" + formatClassAndValue(actual, actualString);\n        } else {\n            return formatted + \"expected:<\" + expectedString + \"> but was:<\"\n                    + actualString + \">\";\n        }\n    }\n\n    private static String formatClass(Class<?> value) {\n        String className = value.getCanonicalName();\n        return className == null ? value.getName() : className;\n    }\n\n    private static String formatClassAndValue(Object value, String valueString) {\n        String className = value == null ? \"null\" : value.getClass().getName();\n        return className + \"<\" + valueString + \">\";\n    }\n\n    /**\n     * Asserts that two object arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown with the given message. If\n     * <code>expecteds</code> and <code>actuals</code> are <code>null</code>,\n     * they are considered equal.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expecteds Object array or array of arrays (multi-dimensional array) with\n     * expected values.\n     * @param actuals Object array or array of arrays (multi-dimensional array) with\n     * actual values\n     * @deprecated use assertArrayEquals\n     */\n    @Deprecated\n    public static void assertEquals(String message, Object[] expecteds,\n            Object[] actuals) {\n        assertArrayEquals(message, expecteds, actuals);\n    }\n\n    /**\n     * Asserts that two object arrays are equal. If they are not, an\n     * {@link AssertionError} is thrown. If <code>expected</code> and\n     * <code>actual</code> are <code>null</code>, they are considered\n     * equal.\n     *\n     * @param expecteds Object array or array of arrays (multi-dimensional array) with\n     * expected values\n     * @param actuals Object array or array of arrays (multi-dimensional array) with\n     * actual values\n     * @deprecated use assertArrayEquals\n     */\n    @Deprecated\n    public static void assertEquals(Object[] expecteds, Object[] actuals) {\n        assertArrayEquals(expecteds, actuals);\n    }\n\n    /**\n     * Asserts that <code>actual</code> satisfies the condition specified by\n     * <code>matcher</code>. If not, an {@link AssertionError} is thrown with\n     * information about the matcher and failing value. Example:\n     *\n     * <pre>\n     *   assertThat(0, is(1)); // fails:\n     *     // failure message:\n     *     // expected: is &lt;1&gt;\n     *     // got value: &lt;0&gt;\n     *   assertThat(0, is(not(1))) // passes\n     * </pre>\n     *\n     * <code>org.hamcrest.Matcher</code> does not currently document the meaning\n     * of its type parameter <code>T</code>.  This method assumes that a matcher\n     * typed as <code>Matcher&lt;T&gt;</code> can be meaningfully applied only\n     * to values that could be assigned to a variable of type <code>T</code>.\n     *\n     * @param <T> the static type accepted by the matcher (this can flag obvious\n     * compile-time problems such as {@code assertThat(1, is(\"a\"))}\n     * @param actual the computed value being compared\n     * @param matcher an expression, built of {@link Matcher}s, specifying allowed\n     * values\n     * @see org.hamcrest.CoreMatchers\n     * @deprecated use {@code org.hamcrest.MatcherAssert.assertThat()}\n     */\n    @Deprecated\n    public static <T> void assertThat(T actual, Matcher<? super T> matcher) {\n        assertThat(\"\", actual, matcher);\n    }\n\n    /**\n     * Asserts that <code>actual</code> satisfies the condition specified by\n     * <code>matcher</code>. If not, an {@link AssertionError} is thrown with\n     * the reason and information about the matcher and failing value. Example:\n     *\n     * <pre>\n     *   assertThat(&quot;Help! Integers don't work&quot;, 0, is(1)); // fails:\n     *     // failure message:\n     *     // Help! Integers don't work\n     *     // expected: is &lt;1&gt;\n     *     // got value: &lt;0&gt;\n     *   assertThat(&quot;Zero is one&quot;, 0, is(not(1))) // passes\n     * </pre>\n     *\n     * <code>org.hamcrest.Matcher</code> does not currently document the meaning\n     * of its type parameter <code>T</code>.  This method assumes that a matcher\n     * typed as <code>Matcher&lt;T&gt;</code> can be meaningfully applied only\n     * to values that could be assigned to a variable of type <code>T</code>.\n     *\n     * @param reason additional information about the error\n     * @param <T> the static type accepted by the matcher (this can flag obvious\n     * compile-time problems such as {@code assertThat(1, is(\"a\"))}\n     * @param actual the computed value being compared\n     * @param matcher an expression, built of {@link Matcher}s, specifying allowed\n     * values\n     * @see org.hamcrest.CoreMatchers\n     * @deprecated use {@code org.hamcrest.MatcherAssert.assertThat()}\n     */\n    @Deprecated\n    public static <T> void assertThat(String reason, T actual,\n            Matcher<? super T> matcher) {\n        MatcherAssert.assertThat(reason, actual, matcher);\n    }\n\n    /**\n     * Asserts that {@code runnable} throws an exception of type {@code expectedThrowable} when\n     * executed. If it does, the exception object is returned. If it does not throw an exception, an\n     * {@link AssertionError} is thrown. If it throws the wrong type of exception, an {@code\n     * AssertionError} is thrown describing the mismatch; the exception that was actually thrown can\n     * be obtained by calling {@link AssertionError#getCause}.\n     *\n     * @param expectedThrowable the expected type of the exception\n     * @param runnable       a function that is expected to throw an exception when executed\n     * @return the exception thrown by {@code runnable}\n     * @since 4.13\n     */\n    public static <T extends Throwable> T assertThrows(Class<T> expectedThrowable,\n            ThrowingRunnable runnable) {\n        return assertThrows(null, expectedThrowable, runnable);\n    }\n\n    /**\n     * Asserts that {@code runnable} throws an exception of type {@code expectedThrowable} when\n     * executed. If it does, the exception object is returned. If it does not throw an exception, an\n     * {@link AssertionError} is thrown. If it throws the wrong type of exception, an {@code\n     * AssertionError} is thrown describing the mismatch; the exception that was actually thrown can\n     * be obtained by calling {@link AssertionError#getCause}.\n     *\n     * @param message the identifying message for the {@link AssertionError} (<code>null</code>\n     * okay)\n     * @param expectedThrowable the expected type of the exception\n     * @param runnable a function that is expected to throw an exception when executed\n     * @return the exception thrown by {@code runnable}\n     * @since 4.13\n     */\n    public static <T extends Throwable> T assertThrows(String message, Class<T> expectedThrowable,\n            ThrowingRunnable runnable) {\n        try {\n            runnable.run();\n        } catch (Throwable actualThrown) {\n            if (expectedThrowable.isInstance(actualThrown)) {\n                @SuppressWarnings(\"unchecked\") T retVal = (T) actualThrown;\n                return retVal;\n            } else {\n                String expected = formatClass(expectedThrowable);\n                Class<? extends Throwable> actualThrowable = actualThrown.getClass();\n                String actual = formatClass(actualThrowable);\n                if (expected.equals(actual)) {\n                    // There must be multiple class loaders. Add the identity hash code so the message\n                    // doesn't say \"expected: java.lang.String<my.package.MyException> ...\"\n                    expected += \"@\" + Integer.toHexString(System.identityHashCode(expectedThrowable));\n                    actual += \"@\" + Integer.toHexString(System.identityHashCode(actualThrowable));\n                }\n                String mismatchMessage = buildPrefix(message)\n                        + format(\"unexpected exception type thrown;\", expected, actual);\n\n                // The AssertionError(String, Throwable) ctor is only available on JDK7.\n                AssertionError assertionError = new AssertionError(mismatchMessage);\n                assertionError.initCause(actualThrown);\n                throw assertionError;\n            }\n        }\n        String notThrownMessage = buildPrefix(message) + String\n                .format(\"expected %s to be thrown, but nothing was thrown\",\n                        formatClass(expectedThrowable));\n        throw new AssertionError(notThrownMessage);\n    }\n\n    private static String buildPrefix(String message) {\n        return message != null && message.length() != 0 ? message + \": \" : \"\";\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/Assume.java",
    "content": "package org.junit;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.CoreMatchers.everyItem;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.notNullValue;\nimport static org.hamcrest.CoreMatchers.nullValue;\n\nimport org.hamcrest.Matcher;\n\n/**\n * A set of methods useful for stating assumptions about the conditions in which a test is meaningful.\n * A failed assumption does not mean the code is broken, but that the test provides no useful information. Assume\n * basically means \"don't run this test if these conditions don't apply\". The default JUnit runner skips tests with\n * failing assumptions. Custom runners may behave differently.\n * <p>\n *     A good example of using assumptions is in <a href=\"https://github.com/junit-team/junit4/wiki/Theories\">Theories</a> where they are needed to exclude certain datapoints that aren't suitable or allowed for a certain test case.\n * </p>\n * Failed assumptions are usually not logged, because there may be many tests that don't apply to certain\n * configurations.\n *\n * <p>\n * These methods can be used directly: <code>Assume.assumeTrue(...)</code>, however, they\n * read better if they are referenced through static import:<br/>\n * <pre>\n * import static org.junit.Assume.*;\n *    ...\n *    assumeTrue(...);\n * </pre>\n * </p>\n *\n * @see <a href=\"https://github.com/junit-team/junit4/wiki/Theories\">Theories</a>\n *\n * @since 4.4\n */\npublic class Assume {\n\n    /**\n     * Do not instantiate.\n     * @deprecated since 4.13.\n     */\n    @Deprecated\n    public Assume() {\n    }\n\n    /**\n     * If called with an expression evaluating to {@code false}, the test will halt and be ignored.\n     */\n    public static void assumeTrue(boolean b) {\n        assumeThat(b, is(true));\n    }\n\n    /**\n     * The inverse of {@link #assumeTrue(boolean)}.\n     */\n    public static void assumeFalse(boolean b) {\n        assumeThat(b, is(false));\n    }\n\n    /**\n     * If called with an expression evaluating to {@code false}, the test will halt and be ignored.\n     *\n     * @param b If <code>false</code>, the method will attempt to stop the test and ignore it by\n     * throwing {@link AssumptionViolatedException}.\n     * @param message A message to pass to {@link AssumptionViolatedException}.\n     */\n    public static void assumeTrue(String message, boolean b) {\n        if (!b) throw new AssumptionViolatedException(message);\n    }\n\n    /**\n     * The inverse of {@link #assumeTrue(String, boolean)}.\n     */\n    public static void assumeFalse(String message, boolean b) {\n        assumeTrue(message, !b);\n    }\n\n    /**\n     * If called with a {@code null} array or one or more {@code null} elements in {@code objects},\n     * the test will halt and be ignored.\n     */\n    public static void assumeNotNull(Object... objects) {\n        assumeThat(objects, notNullValue());\n        assumeThat(asList(objects), everyItem(notNullValue()));\n    }\n\n    /**\n     * Call to assume that <code>actual</code> satisfies the condition specified by <code>matcher</code>.\n     * If not, the test halts and is ignored.\n     * Example:\n     * <pre>:\n     *   assumeThat(1, is(1)); // passes\n     *   foo(); // will execute\n     *   assumeThat(0, is(1)); // assumption failure! test halts\n     *   int x = 1 / 0; // will never execute\n     * </pre>\n     *\n     * @param <T> the static type accepted by the matcher (this can flag obvious compile-time problems such as {@code assumeThat(1, is(\"a\"))}\n     * @param actual the computed value being compared\n     * @param matcher an expression, built of {@link Matcher}s, specifying allowed values\n     * @see org.hamcrest.CoreMatchers\n     * @see org.junit.matchers.JUnitMatchers\n     */\n    public static <T> void assumeThat(T actual, Matcher<T> matcher) {\n        if (!matcher.matches(actual)) {\n            throw new AssumptionViolatedException(actual, matcher);\n        }\n    }\n\n    /**\n     * Call to assume that <code>actual</code> satisfies the condition specified by <code>matcher</code>.\n     * If not, the test halts and is ignored.\n     * Example:\n     * <pre>:\n     *   assumeThat(\"alwaysPasses\", 1, is(1)); // passes\n     *   foo(); // will execute\n     *   assumeThat(\"alwaysFails\", 0, is(1)); // assumption failure! test halts\n     *   int x = 1 / 0; // will never execute\n     * </pre>\n     *\n     * @param <T> the static type accepted by the matcher (this can flag obvious compile-time problems such as {@code assumeThat(1, is(\"a\"))}\n     * @param actual the computed value being compared\n     * @param matcher an expression, built of {@link Matcher}s, specifying allowed values\n     * @see org.hamcrest.CoreMatchers\n     * @see org.junit.matchers.JUnitMatchers\n     */\n    public static <T> void assumeThat(String message, T actual, Matcher<T> matcher) {\n        if (!matcher.matches(actual)) {\n            throw new AssumptionViolatedException(message, actual, matcher);\n        }\n    }\n\n    /**\n     * Use to assume that an operation completes normally.  If {@code e} is non-null, the test will halt and be ignored.\n     *\n     * For example:\n     * <pre>\n     * \\@Test public void parseDataFile() {\n     *   DataFile file;\n     *   try {\n     *     file = DataFile.open(\"sampledata.txt\");\n     *   } catch (IOException e) {\n     *     // stop test and ignore if data can't be opened\n     *     assumeNoException(e);\n     *   }\n     *   // ...\n     * }\n     * </pre>\n     *\n     * @param e if non-null, the offending exception\n     */\n    public static void assumeNoException(Throwable e) {\n        assumeThat(e, nullValue());\n    }\n\n    /**\n     * Attempts to halt the test and ignore it if Throwable <code>e</code> is\n     * not <code>null</code>. Similar to {@link #assumeNoException(Throwable)},\n     * but provides an additional message that can explain the details\n     * concerning the assumption.\n     *\n     * @param e if non-null, the offending exception\n     * @param message Additional message to pass to {@link AssumptionViolatedException}.\n     * @see #assumeNoException(Throwable)\n     */\n    public static void assumeNoException(String message, Throwable e) {\n        assumeThat(message, e, nullValue());\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/AssumptionViolatedException.java",
    "content": "package org.junit;\n\nimport org.hamcrest.Matcher;\n\n/**\n * An exception class used to implement <i>assumptions</i> (state in which a given test\n * is meaningful and should or should not be executed). A test for which an assumption\n * fails should not generate a test case failure.\n *\n * @see org.junit.Assume\n * @since 4.12\n */\n@SuppressWarnings(\"deprecation\")\npublic class AssumptionViolatedException extends org.junit.internal.AssumptionViolatedException {\n    private static final long serialVersionUID = 1L;\n\n    /**\n     * An assumption exception with the given <i>actual</i> value and a <i>matcher</i> describing \n     * the expectation that failed.\n     */\n    public <T> AssumptionViolatedException(T actual, Matcher<T> matcher) {\n        super(actual, matcher);\n    }\n\n    /**\n     * An assumption exception with a message with the given <i>actual</i> value and a\n     * <i>matcher</i> describing the expectation that failed.\n     */\n    public <T> AssumptionViolatedException(String message, T expected, Matcher<T> matcher) {\n        super(message, expected, matcher);\n    }\n\n    /**\n     * An assumption exception with the given message only.\n     */\n    public AssumptionViolatedException(String message) {\n        super(message);\n    }\n\n    /**\n     * An assumption exception with the given message and a cause.\n     */\n    public AssumptionViolatedException(String message, Throwable t) {\n        super(message, t);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/Before.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * When writing tests, it is common to find that several tests need similar\n * objects created before they can run. Annotating a <code>public void</code> method\n * with <code>&#064;Before</code> causes that method to be run before the {@link org.junit.Test} method.\n * The <code>&#064;Before</code> methods of superclasses will be run before those of the current class,\n * unless they are overridden in the current class. No other ordering is defined.\n * <p>\n * Here is a simple example:\n * <pre>\n * public class Example {\n *    List empty;\n *    &#064;Before public void initialize() {\n *       empty= new ArrayList();\n *    }\n *    &#064;Test public void size() {\n *       ...\n *    }\n *    &#064;Test public void remove() {\n *       ...\n *    }\n * }\n * </pre>\n *\n * @see org.junit.BeforeClass\n * @see org.junit.After\n * @since 4.0\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.METHOD)\npublic @interface Before {\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/BeforeClass.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Sometimes several tests need to share computationally expensive setup\n * (like logging into a database). While this can compromise the independence of\n * tests, sometimes it is a necessary optimization. Annotating a <code>public static void</code> no-arg method\n * with <code>@BeforeClass</code> causes it to be run once before any of\n * the test methods in the class. The <code>@BeforeClass</code> methods of superclasses\n * will be run before those of the current class, unless they are shadowed in the current class.\n * <p>\n * For example:\n * <pre>\n * public class Example {\n *    &#064;BeforeClass public static void onlyOnce() {\n *       ...\n *    }\n *    &#064;Test public void one() {\n *       ...\n *    }\n *    &#064;Test public void two() {\n *       ...\n *    }\n * }\n * </pre>\n *\n * @see org.junit.AfterClass\n * @since 4.0\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.METHOD)\npublic @interface BeforeClass {\n}\n"
  },
  {
    "path": "src/main/java/org/junit/ClassRule.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Annotates static fields that reference rules or methods that return them. A field must be public,\n * static, and a subtype of {@link org.junit.rules.TestRule}.  A method must be public static, and return\n * a subtype of {@link org.junit.rules.TestRule}.\n * <p>\n * The {@link org.junit.runners.model.Statement} passed\n * to the {@link org.junit.rules.TestRule} will run any {@link BeforeClass} methods,\n * then the entire body of the test class (all contained methods, if it is\n * a standard JUnit test class, or all contained classes, if it is a\n * {@link org.junit.runners.Suite}), and finally any {@link AfterClass} methods.\n * <p>\n * The statement passed to the {@link org.junit.rules.TestRule} will never throw an exception,\n * and throwing an exception from the {@link org.junit.rules.TestRule} will result in undefined\n * behavior.  This means that some {@link org.junit.rules.TestRule}s, such as\n * {@link org.junit.rules.ErrorCollector},\n * {@link org.junit.rules.ExpectedException},\n * and {@link org.junit.rules.Timeout},\n * have undefined behavior when used as {@link ClassRule}s.\n * <p>\n * If there are multiple\n * annotated {@link ClassRule}s on a class, they will be applied in an order\n * that depends on your JVM's implementation of the reflection API, which is\n * undefined, in general. However, Rules defined by fields will always be applied\n * after Rules defined by methods, i.e. the Statements returned by the former will\n * be executed around those returned by the latter.\n *\n * <h3>Usage</h3>\n * <p>\n * For example, here is a test suite that connects to a server once before\n * all the test classes run, and disconnects after they are finished:\n * <pre>\n * &#064;RunWith(Suite.class)\n * &#064;SuiteClasses({A.class, B.class, C.class})\n * public class UsesExternalResource {\n *     public static Server myServer= new Server();\n *\n *     &#064;ClassRule\n *     public static ExternalResource resource= new ExternalResource() {\n *       &#064;Override\n *       protected void before() throws Throwable {\n *          myServer.connect();\n *      }\n *\n *      &#064;Override\n *      protected void after() {\n * \t        myServer.disconnect();\n *      }\n *   };\n * }\n * </pre>\n * <p>\n * and the same using a method\n * <pre>\n * &#064;RunWith(Suite.class)\n * &#064;SuiteClasses({A.class, B.class, C.class})\n * public class UsesExternalResource {\n *     public static Server myServer= new Server();\n *\n *     &#064;ClassRule\n *     public static ExternalResource getResource() {\n *         return new ExternalResource() {\n *             &#064;Override\n *             protected void before() throws Throwable {\n *                 myServer.connect();\n *             }\n *\n *             &#064;Override\n *             protected void after() {\n *                 myServer.disconnect();\n *             }\n *         };\n *     }\n * }\n * </pre>\n * <p>\n * For more information and more examples, see {@link org.junit.rules.TestRule}.\n *\n * <h3>Ordering</h3>\n * <p>\n * You can use {@link #order()} if you want to have control over the order in\n * which the Rules are applied.\n *\n * <pre>\n * public class ThreeClassRules {\n *     &#064;ClassRule(order = 0)\n *     public static LoggingRule outer = new LoggingRule(\"outer rule\");\n *\n *     &#064;ClassRule(order = 1)\n *     public static LoggingRule middle = new LoggingRule(\"middle rule\");\n *\n *     &#064;ClassRule(order = 2)\n *     public static LoggingRule inner = new LoggingRule(\"inner rule\");\n *\n *     // ...\n * }\n * </pre>\n *\n * @since 4.9\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({ElementType.FIELD, ElementType.METHOD})\npublic @interface ClassRule {\n\n    /**\n     * Specifies the order in which rules are applied. The rules with a higher value are inner.\n     *\n     * @since 4.13\n     */\n    int order() default Rule.DEFAULT_ORDER;\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/ComparisonFailure.java",
    "content": "package org.junit;\n\n/**\n * Thrown when an {@link org.junit.Assert#assertEquals(Object, Object) assertEquals(String, String)} fails.\n * Create and throw a <code>ComparisonFailure</code> manually if you want to show users the\n * difference between two complex strings.\n * <p/>\n * Inspired by a patch from Alex Chaffee (alex@purpletech.com)\n *\n * @since 4.0\n */\npublic class ComparisonFailure extends AssertionError {\n    /**\n     * The maximum length for expected and actual strings. If it is exceeded, the strings should be shortened.\n     *\n     * @see ComparisonCompactor\n     */\n    private static final int MAX_CONTEXT_LENGTH = 20;\n    private static final long serialVersionUID = 1L;\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private String fExpected;\n    private String fActual;\n\n    /**\n     * Constructs a comparison failure.\n     *\n     * @param message the identifying message or null\n     * @param expected the expected string value\n     * @param actual the actual string value\n     */\n    public ComparisonFailure(String message, String expected, String actual) {\n        super(message);\n        this.fExpected = expected;\n        this.fActual = actual;\n    }\n\n    /**\n     * Returns \"...\" in place of common prefix and \"...\" in place of common suffix between expected and actual.\n     *\n     * @see Throwable#getMessage()\n     */\n    @Override\n    public String getMessage() {\n        return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());\n    }\n\n    /**\n     * Returns the actual string value\n     *\n     * @return the actual string value\n     */\n    public String getActual() {\n        return fActual;\n    }\n\n    /**\n     * Returns the expected string value\n     *\n     * @return the expected string value\n     */\n    public String getExpected() {\n        return fExpected;\n    }\n\n    private static class ComparisonCompactor {\n        private static final String ELLIPSIS = \"...\";\n        private static final String DIFF_END = \"]\";\n        private static final String DIFF_START = \"[\";\n\n        /**\n         * The maximum length for <code>expected</code> and <code>actual</code> strings to show. When\n         * <code>contextLength</code> is exceeded, the Strings are shortened.\n         */\n        private final int contextLength;\n        private final String expected;\n        private final String actual;\n\n        /**\n         * @param contextLength the maximum length of context surrounding the difference between the compared strings.\n         * When context length is exceeded, the prefixes and suffixes are compacted.\n         * @param expected the expected string value\n         * @param actual the actual string value\n         */\n        public ComparisonCompactor(int contextLength, String expected, String actual) {\n            this.contextLength = contextLength;\n            this.expected = expected;\n            this.actual = actual;\n        }\n\n        public String compact(String message) {\n            if (expected == null || actual == null || expected.equals(actual)) {\n                return Assert.format(message, expected, actual);\n            } else {\n                DiffExtractor extractor = new DiffExtractor();\n                String compactedPrefix = extractor.compactPrefix();\n                String compactedSuffix = extractor.compactSuffix();\n                return Assert.format(message,\n                        compactedPrefix + extractor.expectedDiff() + compactedSuffix,\n                        compactedPrefix + extractor.actualDiff() + compactedSuffix);\n            }\n        }\n\n        private String sharedPrefix() {\n            int end = Math.min(expected.length(), actual.length());\n            for (int i = 0; i < end; i++) {\n                if (expected.charAt(i) != actual.charAt(i)) {\n                    return expected.substring(0, i);\n                }\n            }\n            return expected.substring(0, end);\n        }\n\n        private String sharedSuffix(String prefix) {\n            int suffixLength = 0;\n            int maxSuffixLength = Math.min(expected.length() - prefix.length(),\n                    actual.length() - prefix.length()) - 1;\n            for (; suffixLength <= maxSuffixLength; suffixLength++) {\n                if (expected.charAt(expected.length() - 1 - suffixLength)\n                        != actual.charAt(actual.length() - 1 - suffixLength)) {\n                    break;\n                }\n            }\n            return expected.substring(expected.length() - suffixLength);\n        }\n\n        private class DiffExtractor {\n            private final String sharedPrefix;\n            private final String sharedSuffix;\n\n            /**\n             * Can not be instantiated outside {@link org.junit.ComparisonFailure.ComparisonCompactor}.\n             */\n            private DiffExtractor() {\n                sharedPrefix = sharedPrefix();\n                sharedSuffix = sharedSuffix(sharedPrefix);\n            }\n\n            public String expectedDiff() {\n                return extractDiff(expected);\n            }\n\n            public String actualDiff() {\n                return extractDiff(actual);\n            }\n\n            public String compactPrefix() {\n                if (sharedPrefix.length() <= contextLength) {\n                    return sharedPrefix;\n                }\n                return ELLIPSIS + sharedPrefix.substring(sharedPrefix.length() - contextLength);\n            }\n\n            public String compactSuffix() {\n                if (sharedSuffix.length() <= contextLength) {\n                    return sharedSuffix;\n                }\n                return sharedSuffix.substring(0, contextLength) + ELLIPSIS;\n            }\n\n            private String extractDiff(String source) {\n                return DIFF_START + source.substring(sharedPrefix.length(), source.length() - sharedSuffix.length())\n                        + DIFF_END;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/FixMethodOrder.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\nimport org.junit.runners.MethodSorters;\n\n/**\n * This class allows the user to choose the order of execution of the methods within a test class.\n *\n * <p>The default order of execution of JUnit tests within a class is deterministic but not predictable.\n * The order of execution is not guaranteed for Java 7 (and some previous versions), and can even change\n * from run to run, so the order of execution was changed to be deterministic (in JUnit 4.11)\n *\n * <p>It is recommended that test methods be written so that they are independent of the order that they are executed.\n * However, there may be a number of dependent tests either through error or by design.\n * This class allows the user to specify the order of execution of test methods.\n *\n * <p>For possibilities, see {@link MethodSorters}\n *\n * Here is an example:\n *\n * <pre>\n * &#064;FixMethodOrder(MethodSorters.NAME_ASCENDING)\n * public class MyTest {\n * }\n * </pre>\n *\n * @see org.junit.runners.MethodSorters\n * @since 4.11\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({ElementType.TYPE})\npublic @interface FixMethodOrder {\n    /**\n     * Optionally specify <code>value</code> to have the methods executed in a particular order\n     */\n    MethodSorters value() default MethodSorters.DEFAULT;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/Ignore.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Sometimes you want to temporarily disable a test or a group of tests. Methods annotated with\n * {@link org.junit.Test} that are also annotated with <code>&#064;Ignore</code> will not be executed as tests.\n * Also, you can annotate a class containing test methods with <code>&#064;Ignore</code> and none of the containing\n * tests will be executed. Native JUnit 4 test runners should report the number of ignored tests along with the\n * number of tests that ran and the number of tests that failed.\n *\n * <p>For example:\n * <pre>\n *    &#064;Ignore &#064;Test public void something() { ...\n * </pre>\n * &#064;Ignore takes an optional default parameter if you want to record why a test is being ignored:\n * <pre>\n *    &#064;Ignore(\"not ready yet\") &#064;Test public void something() { ...\n * </pre>\n * &#064;Ignore can also be applied to the test class:\n * <pre>\n *      &#064;Ignore public class IgnoreMe {\n *          &#064;Test public void test1() { ... }\n *          &#064;Test public void test2() { ... }\n *         }\n * </pre>\n *\n * @since 4.0\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({ElementType.METHOD, ElementType.TYPE})\npublic @interface Ignore {\n    /**\n     * The optional reason why the test is ignored.\n     */\n    String value() default \"\";\n}\n"
  },
  {
    "path": "src/main/java/org/junit/Rule.java",
    "content": "package org.junit;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Annotates fields that reference rules or methods that return a rule. A field must be public, not\n * static, and a subtype of {@link org.junit.rules.TestRule} (preferred) or\n * {@link org.junit.rules.MethodRule}. A method must be public, not static,\n * and must return a subtype of {@link org.junit.rules.TestRule} (preferred) or\n * {@link org.junit.rules.MethodRule}.\n * <p>\n * The {@link org.junit.runners.model.Statement} passed\n * to the {@link org.junit.rules.TestRule} will run any {@link Before} methods,\n * then the {@link Test} method, and finally any {@link After} methods,\n * throwing an exception if any of these fail.  If there are multiple\n * annotated {@link Rule}s on a class, they will be applied in order of methods first, then fields.\n * However, if there are multiple fields (or methods) they will be applied in an order\n * that depends on your JVM's implementation of the reflection API, which is\n * undefined, in general. Rules defined by fields will always be applied\n * after Rules defined by methods, i.e. the Statements returned by the former will\n * be executed around those returned by the latter.\n *\n * <h3>Usage</h3>\n * <p>\n * For example, here is a test class that creates a temporary folder before\n * each test method, and deletes it after each:\n * <pre>\n * public static class HasTempFolder {\n *     &#064;Rule\n *     public TemporaryFolder folder= new TemporaryFolder();\n *\n *     &#064;Test\n *     public void testUsingTempFolder() throws IOException {\n *         File createdFile= folder.newFile(&quot;myfile.txt&quot;);\n *         File createdFolder= folder.newFolder(&quot;subfolder&quot;);\n *         // ...\n *     }\n * }\n * </pre>\n * <p>\n * And the same using a method.\n * <pre>\n * public static class HasTempFolder {\n *     private TemporaryFolder folder= new TemporaryFolder();\n *\n *     &#064;Rule\n *     public TemporaryFolder getFolder() {\n *         return folder;\n *     }\n *\n *     &#064;Test\n *     public void testUsingTempFolder() throws IOException {\n *         File createdFile= folder.newFile(&quot;myfile.txt&quot;);\n *         File createdFolder= folder.newFolder(&quot;subfolder&quot;);\n *         // ...\n *     }\n * }\n * </pre>\n * <p>\n * For more information and more examples, see\n * {@link org.junit.rules.TestRule}.\n *\n * <h3>Ordering</h3>\n * <p>\n * You can use {@link #order()} if you want to have control over the order in\n * which the Rules are applied.\n *\n * <pre>\n * public class ThreeRules {\n *     &#064;Rule(order = 0)\n *     public LoggingRule outer = new LoggingRule(\"outer rule\");\n *\n *     &#064;Rule(order = 1)\n *     public LoggingRule middle = new LoggingRule(\"middle rule\");\n *\n *     &#064;Rule(order = 2)\n *     public LoggingRule inner = new LoggingRule(\"inner rule\");\n *\n *     // ...\n * }\n * </pre>\n *\n * @since 4.7\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({ElementType.FIELD, ElementType.METHOD})\npublic @interface Rule {\n\n    int DEFAULT_ORDER = -1;\n\n    /**\n     * Specifies the order in which rules are applied. The rules with a higher value are inner.\n     *\n     * @since 4.13\n     */\n    int order() default DEFAULT_ORDER;\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/Test.java",
    "content": "package org.junit;\n\nimport org.junit.function.ThrowingRunnable;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * The <code>Test</code> annotation tells JUnit that the <code>public void</code> method\n * to which it is attached can be run as a test case. To run the method,\n * JUnit first constructs a fresh instance of the class then invokes the\n * annotated method. Any exceptions thrown by the test will be reported\n * by JUnit as a failure. If no exceptions are thrown, the test is assumed\n * to have succeeded.\n * <p>\n * A simple test looks like this:\n * <pre>\n * public class Example {\n *    <b>&#064;Test</b>\n *    public void method() {\n *       org.junit.Assert.assertTrue( new ArrayList().isEmpty() );\n *    }\n * }\n * </pre>\n * <p>\n * The <code>Test</code> annotation supports two optional parameters for\n * exception testing and for limiting test execution time.\n *\n * <h3>Exception Testing</h3>\n * <p>\n * The parameter <code>expected</code> declares that a test method should throw\n * an exception. If it doesn't throw an exception or if it throws a different exception\n * than the one declared, the test fails. For example, the following test succeeds:\n * <pre>\n *    &#064;Test(<b>expected=IndexOutOfBoundsException.class</b>)\n *    public void outOfBounds() {\n *       new ArrayList&lt;Object&gt;().get(1);\n *    }\n * </pre>\n *\n * Using the parameter <code>expected</code> for exception testing comes with\n * some limitations: only the exception's type can be checked and it is not\n * possible to precisely specify the code that throws the exception. Therefore\n * JUnit 4 has improved its support for exception testing with\n * {@link Assert#assertThrows(Class, ThrowingRunnable)} and the\n * {@link org.junit.rules.ExpectedException ExpectedException} rule.\n * With <code>assertThrows</code> the code that throws the exception can be\n * precisely specified. If the exception's message or one of its properties\n * should be verified, the <code>ExpectedException</code> rule can be used. Further\n * information about exception testing can be found at the\n * <a href=\"https://github.com/junit-team/junit4/wiki/Exception-testing\">JUnit Wiki</a>.\n *\n * <h3>Timeout</h3>\n * <p>\n * The parameter <code>timeout</code> causes a test to fail if it takes\n * longer than a specified amount of clock time (measured in milliseconds). The following test fails:\n * <pre>\n *    &#064;Test(<b>timeout=100</b>)\n *    public void infinity() {\n *       while(true);\n *    }\n * </pre>\n * <b>Warning</b>: while <code>timeout</code> is useful to catch and terminate\n * infinite loops, it should <em>not</em> be considered deterministic. The\n * following test may or may not fail depending on how the operating system\n * schedules threads:\n * <pre>\n *    &#064;Test(<b>timeout=100</b>)\n *    public void sleep100() {\n *       Thread.sleep(100);\n *    }\n * </pre>\n * <b>THREAD SAFETY WARNING:</b> Test methods with a timeout parameter are run in a thread other than the\n * thread which runs the fixture's @Before and @After methods. This may yield different behavior for\n * code that is not thread safe when compared to the same test method without a timeout parameter.\n * <b>Consider using the {@link org.junit.rules.Timeout} rule instead</b>, which ensures a test method is run on the\n * same thread as the fixture's @Before and @After methods.\n *\n * @since 4.0\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({ElementType.METHOD})\npublic @interface Test {\n\n    /**\n     * Default empty exception.\n     */\n    static class None extends Throwable {\n        private static final long serialVersionUID = 1L;\n\n        private None() {\n        }\n    }\n\n    /**\n     * Optionally specify <code>expected</code>, a Throwable, to cause a test method to succeed if\n     * and only if an exception of the specified class is thrown by the method. If the Throwable's\n     * message or one of its properties should be verified, the\n     * {@link org.junit.rules.ExpectedException ExpectedException} rule can be used instead.\n     */\n    Class<? extends Throwable> expected() default None.class;\n\n    /**\n     * Optionally specify <code>timeout</code> in milliseconds to cause a test method to fail if it\n     * takes longer than that number of milliseconds.\n     * <p>\n     * <b>THREAD SAFETY WARNING:</b> Test methods with a timeout parameter are run in a thread other than the\n     * thread which runs the fixture's @Before and @After methods. This may yield different behavior for\n     * code that is not thread safe when compared to the same test method without a timeout parameter.\n     * <b>Consider using the {@link org.junit.rules.Timeout} rule instead</b>, which ensures a test method is run on the\n     * same thread as the fixture's @Before and @After methods.\n     * </p>\n     */\n    long timeout() default 0L;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/TestCouldNotBeSkippedException.java",
    "content": "package org.junit;\n\n/**\n * Indicates that a test that indicated that it should be skipped could not be skipped.\n * This can be thrown if a test uses the methods in {@link Assume} to indicate that\n * it should be skipped, but before processing of the test was completed, other failures\n * occured.\n *\n * @see org.junit.Assume\n * @since 4.13\n */\npublic class TestCouldNotBeSkippedException extends RuntimeException {\n    private static final long serialVersionUID = 1L;\n\n    /** Creates an instance using the given assumption failure. */\n    public TestCouldNotBeSkippedException(org.junit.internal.AssumptionViolatedException cause) {\n        super(\"Test could not be skipped due to other failures\", cause);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/ParallelComputer.java",
    "content": "package org.junit.experimental;\n\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.TimeUnit;\n\nimport org.junit.runner.Computer;\nimport org.junit.runner.Runner;\nimport org.junit.runners.ParentRunner;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerBuilder;\nimport org.junit.runners.model.RunnerScheduler;\n\npublic class ParallelComputer extends Computer {\n    private final boolean classes;\n\n    private final boolean methods;\n\n    public ParallelComputer(boolean classes, boolean methods) {\n        this.classes = classes;\n        this.methods = methods;\n    }\n\n    public static Computer classes() {\n        return new ParallelComputer(true, false);\n    }\n\n    public static Computer methods() {\n        return new ParallelComputer(false, true);\n    }\n\n    private static Runner parallelize(Runner runner) {\n        if (runner instanceof ParentRunner) {\n            ((ParentRunner<?>) runner).setScheduler(new RunnerScheduler() {\n                private final ExecutorService fService = Executors.newCachedThreadPool();\n\n                public void schedule(Runnable childStatement) {\n                    fService.submit(childStatement);\n                }\n\n                public void finished() {\n                    try {\n                        fService.shutdown();\n                        fService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);\n                    } catch (InterruptedException e) {\n                        e.printStackTrace(System.err);\n                    }\n                }\n            });\n        }\n        return runner;\n    }\n\n    @Override\n    public Runner getSuite(RunnerBuilder builder, java.lang.Class<?>[] classes)\n            throws InitializationError {\n        Runner suite = super.getSuite(builder, classes);\n        return this.classes ? parallelize(suite) : suite;\n    }\n\n    @Override\n    protected Runner getRunner(RunnerBuilder builder, Class<?> testClass)\n            throws Throwable {\n        Runner runner = super.getRunner(builder, testClass);\n        return methods ? parallelize(runner) : runner;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/categories/Categories.java",
    "content": "package org.junit.experimental.categories;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.LinkedHashSet;\nimport java.util.Set;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runners.Suite;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerBuilder;\n\n/**\n * From a given set of test classes, runs only the classes and methods that are\n * annotated with either the category given with the @IncludeCategory\n * annotation, or a subtype of that category.\n * <p>\n * Note that, for now, annotating suites with {@code @Category} has no effect.\n * Categories must be annotated on the direct method or class.\n * <p>\n * Example:\n * <pre>\n * public interface FastTests {\n * }\n *\n * public interface SlowTests {\n * }\n *\n * public interface SmokeTests\n * }\n *\n * public static class A {\n *     &#064;Test\n *     public void a() {\n *         fail();\n *     }\n *\n *     &#064;Category(SlowTests.class)\n *     &#064;Test\n *     public void b() {\n *     }\n *\n *     &#064;Category({FastTests.class, SmokeTests.class})\n *     &#064;Test\n *     public void c() {\n *     }\n * }\n *\n * &#064;Category({SlowTests.class, FastTests.class})\n * public static class B {\n *     &#064;Test\n *     public void d() {\n *     }\n * }\n *\n * &#064;RunWith(Categories.class)\n * &#064;IncludeCategory(SlowTests.class)\n * &#064;SuiteClasses({A.class, B.class})\n * // Note that Categories is a kind of Suite\n * public static class SlowTestSuite {\n *     // Will run A.b and B.d, but not A.a and A.c\n * }\n * </pre>\n * <p>\n * Example to run multiple categories:\n * <pre>\n * &#064;RunWith(Categories.class)\n * &#064;IncludeCategory({FastTests.class, SmokeTests.class})\n * &#064;SuiteClasses({A.class, B.class})\n * public static class FastOrSmokeTestSuite {\n *     // Will run A.c and B.d, but not A.b because it is not any of FastTests or SmokeTests\n * }\n * </pre>\n *\n * @version 4.12\n * @see <a href=\"https://github.com/junit-team/junit4/wiki/Categories\">Categories at JUnit wiki</a>\n */\npublic class Categories extends Suite {\n\n    @Retention(RetentionPolicy.RUNTIME)\n    public @interface IncludeCategory {\n        /**\n         * Determines the tests to run that are annotated with categories specified in\n         * the value of this annotation or their subtypes unless excluded with {@link ExcludeCategory}.\n         */\n        Class<?>[] value() default {};\n\n        /**\n         * If <tt>true</tt>, runs tests annotated with <em>any</em> of the categories in\n         * {@link IncludeCategory#value()}. Otherwise, runs tests only if annotated with <em>all</em> of the categories.\n         */\n        boolean matchAny() default true;\n    }\n\n    @Retention(RetentionPolicy.RUNTIME)\n    public @interface ExcludeCategory {\n        /**\n         * Determines the tests which do not run if they are annotated with categories specified in the\n         * value of this annotation or their subtypes regardless of being included in {@link IncludeCategory#value()}.\n         */\n        Class<?>[] value() default {};\n\n        /**\n         * If <tt>true</tt>, the tests annotated with <em>any</em> of the categories in {@link ExcludeCategory#value()}\n         * do not run. Otherwise, the tests do not run if and only if annotated with <em>all</em> categories.\n         */\n        boolean matchAny() default true;\n    }\n\n    public static class CategoryFilter extends Filter {\n        private final Set<Class<?>> included;\n        private final Set<Class<?>> excluded;\n        private final boolean includedAny;\n        private final boolean excludedAny;\n\n        public static CategoryFilter include(boolean matchAny, Class<?>... categories) {\n            return new CategoryFilter(matchAny, categories, true, null);\n        }\n\n        public static CategoryFilter include(Class<?> category) {\n            return include(true, category);\n        }\n\n        public static CategoryFilter include(Class<?>... categories) {\n            return include(true, categories);\n        }\n\n        public static CategoryFilter exclude(boolean matchAny, Class<?>... categories) {\n            return new CategoryFilter(true, null, matchAny, categories);\n        }\n\n        public static CategoryFilter exclude(Class<?> category) {\n            return exclude(true, category);\n        }\n\n        public static CategoryFilter exclude(Class<?>... categories) {\n            return exclude(true, categories);\n        }\n\n        public static CategoryFilter categoryFilter(boolean matchAnyInclusions, Set<Class<?>> inclusions,\n                                                    boolean matchAnyExclusions, Set<Class<?>> exclusions) {\n            return new CategoryFilter(matchAnyInclusions, inclusions, matchAnyExclusions, exclusions);\n        }\n\n        @Deprecated\n        public CategoryFilter(Class<?> includedCategory, Class<?> excludedCategory) {\n            includedAny = true;\n            excludedAny = true;\n            included = nullableClassToSet(includedCategory);\n            excluded = nullableClassToSet(excludedCategory);\n        }\n\n        protected CategoryFilter(boolean matchAnyIncludes, Set<Class<?>> includes,\n                                 boolean matchAnyExcludes, Set<Class<?>> excludes) {\n            includedAny = matchAnyIncludes;\n            excludedAny = matchAnyExcludes;\n            included = copyAndRefine(includes);\n            excluded = copyAndRefine(excludes);\n        }\n\n        private CategoryFilter(boolean matchAnyIncludes, Class<?>[] inclusions,\n                               boolean matchAnyExcludes, Class<?>[] exclusions) {\n            includedAny = matchAnyIncludes; \n            excludedAny = matchAnyExcludes;\n            included = createSet(inclusions);\n            excluded = createSet(exclusions);\n        }\n\n        /**\n         * @see #toString()\n         */\n        @Override\n        public String describe() {\n            return toString();\n        }\n\n        /**\n         * Returns string in the form <tt>&quot;[included categories] - [excluded categories]&quot;</tt>, where both\n         * sets have comma separated names of categories.\n         *\n         * @return string representation for the relative complement of excluded categories set\n         * in the set of included categories. Examples:\n         * <ul>\n         *  <li> <tt>&quot;categories [all]&quot;</tt> for all included categories and no excluded ones;\n         *  <li> <tt>&quot;categories [all] - [A, B]&quot;</tt> for all included categories and given excluded ones;\n         *  <li> <tt>&quot;categories [A, B] - [C, D]&quot;</tt> for given included categories and given excluded ones.\n         * </ul>\n         * @see Class#toString() name of category\n         */\n        @Override public String toString() {\n            StringBuilder description= new StringBuilder(\"categories \")\n                .append(included.isEmpty() ? \"[all]\" : included);\n            if (!excluded.isEmpty()) {\n                description.append(\" - \").append(excluded);\n            }\n            return description.toString();\n        }\n\n        @Override\n        public boolean shouldRun(Description description) {\n            if (hasCorrectCategoryAnnotation(description)) {\n                return true;\n            }\n\n            for (Description each : description.getChildren()) {\n                if (shouldRun(each)) {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n\n        private boolean hasCorrectCategoryAnnotation(Description description) {\n            final Set<Class<?>> childCategories= categories(description);\n\n            // If a child has no categories, immediately return.\n            if (childCategories.isEmpty()) {\n                return included.isEmpty();\n            }\n\n            if (!excluded.isEmpty()) {\n                if (excludedAny) {\n                    if (matchesAnyParentCategories(childCategories, excluded)) {\n                        return false;\n                    }\n                } else {\n                    if (matchesAllParentCategories(childCategories, excluded)) {\n                        return false;\n                    }\n                }\n            }\n\n            if (included.isEmpty()) {\n                // Couldn't be excluded, and with no suite's included categories treated as should run.\n                return true;\n            } else {\n                if (includedAny) {\n                    return matchesAnyParentCategories(childCategories, included);\n                } else {\n                    return matchesAllParentCategories(childCategories, included);\n                }\n            }\n        }\n\n        /**\n         * @return <tt>true</tt> if at least one (any) parent category match a child, otherwise <tt>false</tt>.\n         * If empty <tt>parentCategories</tt>, returns <tt>false</tt>.\n         */\n        private boolean matchesAnyParentCategories(Set<Class<?>> childCategories, Set<Class<?>> parentCategories) {\n            for (Class<?> parentCategory : parentCategories) {\n                if (hasAssignableTo(childCategories, parentCategory)) {\n                    return true;\n                }\n            }\n            return false;\n        }\n\n        /**\n         * @return <tt>false</tt> if at least one parent category does not match children, otherwise <tt>true</tt>.\n         * If empty <tt>parentCategories</tt>, returns <tt>true</tt>.\n         */\n        private boolean matchesAllParentCategories(Set<Class<?>> childCategories, Set<Class<?>> parentCategories) {\n            for (Class<?> parentCategory : parentCategories) {\n                if (!hasAssignableTo(childCategories, parentCategory)) {\n                    return false;\n                }\n            }\n            return true;\n        }\n\n        private static Set<Class<?>> categories(Description description) {\n            Set<Class<?>> categories= new HashSet<Class<?>>();\n            Collections.addAll(categories, directCategories(description));\n            Collections.addAll(categories, directCategories(parentDescription(description)));\n            return categories;\n        }\n\n        private static Description parentDescription(Description description) {\n            Class<?> testClass= description.getTestClass();\n            return testClass == null ? null : Description.createSuiteDescription(testClass);\n        }\n\n        private static Class<?>[] directCategories(Description description) {\n            if (description == null) {\n                return new Class<?>[0];\n            }\n\n            Category annotation= description.getAnnotation(Category.class);\n            return annotation == null ? new Class<?>[0] : annotation.value();\n        }\n\n        private static Set<Class<?>> copyAndRefine(Set<Class<?>> classes) {\n            Set<Class<?>> c= new LinkedHashSet<Class<?>>();\n            if (classes != null) {\n                c.addAll(classes);\n            }\n            c.remove(null);\n            return c;\n        }\n    }\n\n    public Categories(Class<?> klass, RunnerBuilder builder) throws InitializationError {\n        super(klass, builder);\n        try {\n            Set<Class<?>> included= getIncludedCategory(klass);\n            Set<Class<?>> excluded= getExcludedCategory(klass);\n            boolean isAnyIncluded= isAnyIncluded(klass);\n            boolean isAnyExcluded= isAnyExcluded(klass);\n\n            filter(CategoryFilter.categoryFilter(isAnyIncluded, included, isAnyExcluded, excluded));\n        } catch (NoTestsRemainException e) {\n            throw new InitializationError(e);\n        }\n    }\n\n    private static Set<Class<?>> getIncludedCategory(Class<?> klass) {\n        IncludeCategory annotation= klass.getAnnotation(IncludeCategory.class);\n        return createSet(annotation == null ? null : annotation.value());\n    }\n\n    private static boolean isAnyIncluded(Class<?> klass) {\n        IncludeCategory annotation= klass.getAnnotation(IncludeCategory.class);\n        return annotation == null || annotation.matchAny();\n    }\n\n    private static Set<Class<?>> getExcludedCategory(Class<?> klass) {\n        ExcludeCategory annotation= klass.getAnnotation(ExcludeCategory.class);\n        return createSet(annotation == null ? null : annotation.value());\n    }\n\n    private static boolean isAnyExcluded(Class<?> klass) {\n        ExcludeCategory annotation= klass.getAnnotation(ExcludeCategory.class);\n        return annotation == null || annotation.matchAny();\n    }\n\n    private static boolean hasAssignableTo(Set<Class<?>> assigns, Class<?> to) {\n        for (final Class<?> from : assigns) {\n            if (to.isAssignableFrom(from)) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    private static Set<Class<?>> createSet(Class<?>[] classes) {\n        // Not throwing a NPE if t is null is a bad idea, but it's the behavior from JUnit 4.12\n        // for include(boolean, Class<?>...) and exclude(boolean, Class<?>...)\n        if (classes == null || classes.length == 0) {\n            return Collections.emptySet();\n        }\n        for (Class<?> category : classes) {\n            if (category == null) {\n                throw new NullPointerException(\"has null category\");\n            }\n        }\n\n        return classes.length == 1\n            ? Collections.<Class<?>>singleton(classes[0])\n            : new LinkedHashSet<Class<?>>(Arrays.asList(classes));\n    }\n\n    private static Set<Class<?>> nullableClassToSet(Class<?> nullableClass) {\n        // Not throwing a NPE if t is null is a bad idea, but it's the behavior from JUnit 4.11\n        // for CategoryFilter(Class<?> includedCategory, Class<?> excludedCategory)\n        return nullableClass == null\n                ? Collections.<Class<?>>emptySet()\n                : Collections.<Class<?>>singleton(nullableClass);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/categories/Category.java",
    "content": "package org.junit.experimental.categories;\n\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\n\nimport org.junit.validator.ValidateWith;\n\n/**\n * Marks a test class or test method as belonging to one or more categories of tests.\n * The value is an array of arbitrary classes.\n *\n * This annotation is only interpreted by the Categories runner (at present).\n *\n * For example:\n * <pre>\n * public interface FastTests {}\n * public interface SlowTests {}\n *\n * public static class A {\n * &#064;Test\n * public void a() {\n * fail();\n * }\n *\n * &#064;Category(SlowTests.class)\n * &#064;Test\n * public void b() {\n * }\n * }\n *\n * &#064;Category({SlowTests.class, FastTests.class})\n * public static class B {\n * &#064;Test\n * public void c() {\n *\n * }\n * }\n * </pre>\n *\n * For more usage, see code example on {@link Categories}.\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Inherited\n@ValidateWith(CategoryValidator.class)\npublic @interface Category {\n    Class<?>[] value();\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/categories/CategoryFilterFactory.java",
    "content": "package org.junit.experimental.categories;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport org.junit.internal.Classes;\r\nimport org.junit.runner.FilterFactory;\r\nimport org.junit.runner.FilterFactoryParams;\r\nimport org.junit.runner.manipulation.Filter;\r\n\r\n/**\r\n * Implementation of FilterFactory for Category filtering.\r\n */\r\nabstract class CategoryFilterFactory implements FilterFactory {\r\n    /**\r\n     * Creates a {@link org.junit.experimental.categories.Categories.CategoryFilter} given a\r\n     * {@link FilterFactoryParams} argument.\r\n     *\r\n     * @param params Parameters needed to create the {@link Filter}\r\n     */\r\n    public Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException {\r\n        try {\r\n            return createFilter(parseCategories(params.getArgs()));\r\n        } catch (ClassNotFoundException e) {\r\n            throw new FilterNotCreatedException(e);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Creates a {@link org.junit.experimental.categories.Categories.CategoryFilter} given an array of classes.\r\n     *\r\n     * @param categories Category classes.\r\n     */\r\n    protected abstract Filter createFilter(List<Class<?>> categories);\r\n\r\n    private List<Class<?>> parseCategories(String categories) throws ClassNotFoundException {\r\n        List<Class<?>> categoryClasses = new ArrayList<Class<?>>();\r\n\r\n        for (String category : categories.split(\",\")) {\r\n            /*\r\n             * Load the category class using the context class loader.\r\n             * If there is no context class loader, use the class loader for this class.\r\n             */\r\n            Class<?> categoryClass = Classes.getClass(category, getClass());\r\n\r\n            categoryClasses.add(categoryClass);\r\n        }\r\n\r\n        return categoryClasses;\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/categories/CategoryValidator.java",
    "content": "package org.junit.experimental.categories;\n\nimport static java.util.Arrays.asList;\nimport static java.util.Collections.unmodifiableList;\nimport static java.util.Collections.unmodifiableSet;\n\nimport java.lang.annotation.Annotation;\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.validator.AnnotationValidator;\n\n/**\n * Validates that there are no errors in the use of the {@code Category}\n * annotation. If there is, a {@code Throwable} object will be added to the list\n * of errors.\n *\n * @since 4.12\n */\npublic final class CategoryValidator extends AnnotationValidator {\n\n    @SuppressWarnings(\"unchecked\")\n    private static final Set<Class<? extends Annotation>> INCOMPATIBLE_ANNOTATIONS = unmodifiableSet(new HashSet<Class<? extends Annotation>>(\n            asList(BeforeClass.class, AfterClass.class, Before.class, After.class)));\n\n    /**\n     * Adds to {@code errors} a throwable for each problem detected. Looks for\n     * {@code BeforeClass}, {@code AfterClass}, {@code Before} and {@code After}\n     * annotations.\n     *\n     * @param method the method that is being validated\n     * @return A list of exceptions detected\n     *\n     * @since 4.12\n     */\n    @Override\n    public List<Exception> validateAnnotatedMethod(FrameworkMethod method) {\n        List<Exception> errors = new ArrayList<Exception>();\n        Annotation[] annotations = method.getAnnotations();\n        for (Annotation annotation : annotations) {\n            for (Class<?> clazz : INCOMPATIBLE_ANNOTATIONS) {\n                if (annotation.annotationType().isAssignableFrom(clazz)) {\n                    addErrorMessage(errors, clazz);\n                }\n            }\n        }\n        return unmodifiableList(errors);\n    }\n\n    private void addErrorMessage(List<Exception> errors, Class<?> clazz) {\n        String message = String.format(\"@%s can not be combined with @Category\",\n                clazz.getSimpleName());\n        errors.add(new Exception(message));\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/categories/ExcludeCategories.java",
    "content": "package org.junit.experimental.categories;\r\n\r\nimport java.util.HashSet;\r\nimport java.util.List;\r\nimport java.util.Set;\r\n\r\nimport org.junit.experimental.categories.Categories.CategoryFilter;\r\nimport org.junit.runner.manipulation.Filter;\r\n\r\n/**\r\n * {@link org.junit.runner.FilterFactory} to exclude categories.\r\n *\r\n * The {@link Filter} that is created will filter out tests that are categorized with any of the\r\n * given categories.\r\n *\r\n * Usage from command line:\r\n * <code>\r\n *     --filter=org.junit.experimental.categories.ExcludeCategories=pkg.of.Cat1,pkg.of.Cat2\r\n * </code>\r\n *\r\n * Usage from API:\r\n * <code>\r\n *     new ExcludeCategories().createFilter(Cat1.class, Cat2.class);\r\n * </code>\r\n */\r\npublic final class ExcludeCategories extends CategoryFilterFactory {\r\n    /**\r\n     * Creates a {@link Filter} which is only passed by tests that are\r\n     * not categorized with any of the specified categories.\r\n     *\r\n     * @param categories Category classes.\r\n     */\r\n    @Override\r\n    protected Filter createFilter(List<Class<?>> categories) {\r\n        return new ExcludesAny(categories);\r\n    }\r\n\r\n    private static class ExcludesAny extends CategoryFilter {\r\n        public ExcludesAny(List<Class<?>> categories) {\r\n            this(new HashSet<Class<?>>(categories));\r\n        }\r\n\r\n        public ExcludesAny(Set<Class<?>> categories) {\r\n            super(true, null, true, categories);\r\n        }\r\n\r\n        @Override\r\n        public String describe() {\r\n            return \"excludes \" + super.describe();\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/categories/IncludeCategories.java",
    "content": "package org.junit.experimental.categories;\r\n\r\nimport java.util.HashSet;\r\nimport java.util.List;\r\nimport java.util.Set;\r\n\r\nimport org.junit.experimental.categories.Categories.CategoryFilter;\r\nimport org.junit.runner.manipulation.Filter;\r\n\r\n/**\r\n * {@link org.junit.runner.FilterFactory} to include categories.\r\n *\r\n * The {@link Filter} that is created will filter out tests that are categorized with any of the\r\n * given categories.\r\n *\r\n * Usage from command line:\r\n * <code>\r\n *     --filter=org.junit.experimental.categories.IncludeCategories=pkg.of.Cat1,pkg.of.Cat2\r\n * </code>\r\n *\r\n * Usage from API:\r\n * <code>\r\n *     new IncludeCategories().createFilter(Cat1.class, Cat2.class);\r\n * </code>\r\n */\r\npublic final class IncludeCategories extends CategoryFilterFactory {\r\n    /**\r\n     * Creates a {@link Filter} which is only passed by tests that are\r\n     * categorized with any of the specified categories.\r\n     *\r\n     * @param categories Category classes.\r\n     */\r\n    @Override\r\n    protected Filter createFilter(List<Class<?>> categories) {\r\n        return new IncludesAny(categories);\r\n    }\r\n\r\n    private static class IncludesAny extends CategoryFilter {\r\n        public IncludesAny(List<Class<?>> categories) {\r\n            this(new HashSet<Class<?>>(categories));\r\n        }\r\n\r\n        public IncludesAny(Set<Class<?>> categories) {\r\n            super(true, categories, true, null);\r\n        }\r\n\r\n        @Override\r\n        public String describe() {\r\n            return \"includes \" + super.describe();\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/max/CouldNotReadCoreException.java",
    "content": "package org.junit.experimental.max;\n\n/**\n * Thrown when Max cannot read the MaxCore serialization\n */\npublic class CouldNotReadCoreException extends Exception {\n    private static final long serialVersionUID = 1L;\n\n    /**\n     * Constructs\n     */\n    public CouldNotReadCoreException(Throwable e) {\n        super(e);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/max/MaxCore.java",
    "content": "package org.junit.experimental.max;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport junit.framework.TestSuite;\nimport org.junit.internal.requests.SortingRequest;\nimport org.junit.internal.runners.ErrorReportingRunner;\nimport org.junit.internal.runners.JUnit38ClassRunner;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.Runner;\nimport org.junit.runners.Suite;\nimport org.junit.runners.model.InitializationError;\n\n/**\n * A replacement for JUnitCore, which keeps track of runtime and failure history, and reorders tests\n * to maximize the chances that a failing test occurs early in the test run.\n *\n * The rules for sorting are:\n * <ol>\n * <li> Never-run tests first, in arbitrary order\n * <li> Group remaining tests by the date at which they most recently failed.\n * <li> Sort groups such that the most recent failure date is first, and never-failing tests are at the end.\n * <li> Within a group, run the fastest tests first.\n * </ol>\n */\npublic class MaxCore {\n    private static final String MALFORMED_JUNIT_3_TEST_CLASS_PREFIX = \"malformed JUnit 3 test class: \";\n\n    /**\n     * Create a new MaxCore from a serialized file stored at storedResults\n     *\n     * @deprecated use storedLocally()\n     */\n    @Deprecated\n    public static MaxCore forFolder(String folderName) {\n        return storedLocally(new File(folderName));\n    }\n\n    /**\n     * Create a new MaxCore from a serialized file stored at storedResults\n     */\n    public static MaxCore storedLocally(File storedResults) {\n        return new MaxCore(storedResults);\n    }\n\n    private final MaxHistory history;\n\n    private MaxCore(File storedResults) {\n        history = MaxHistory.forFolder(storedResults);\n    }\n\n    /**\n     * Run all the tests in <code>class</code>.\n     *\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public Result run(Class<?> testClass) {\n        return run(Request.aClass(testClass));\n    }\n\n    /**\n     * Run all the tests contained in <code>request</code>.\n     *\n     * @param request the request describing tests\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public Result run(Request request) {\n        return run(request, new JUnitCore());\n    }\n\n    /**\n     * Run all the tests contained in <code>request</code>.\n     *\n     * This variant should be used if {@code core} has attached listeners that this\n     * run should notify.\n     *\n     * @param request the request describing tests\n     * @param core a JUnitCore to delegate to.\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public Result run(Request request, JUnitCore core) {\n        core.addListener(history.listener());\n        return core.run(sortRequest(request).getRunner());\n    }\n\n    /**\n     * @return a new Request, which contains all of the same tests, but in a new order.\n     */\n    public Request sortRequest(Request request) {\n        if (request instanceof SortingRequest) {\n            // We'll pay big karma points for this\n            return request;\n        }\n        List<Description> leaves = findLeaves(request);\n        Collections.sort(leaves, history.testComparator());\n        return constructLeafRequest(leaves);\n    }\n\n    private Request constructLeafRequest(List<Description> leaves) {\n        final List<Runner> runners = new ArrayList<Runner>();\n        for (Description each : leaves) {\n            runners.add(buildRunner(each));\n        }\n        return new Request() {\n            @Override\n            public Runner getRunner() {\n                try {\n                    return new Suite((Class<?>) null, runners) {\n                    };\n                } catch (InitializationError e) {\n                    return new ErrorReportingRunner(null, e);\n                }\n            }\n        };\n    }\n\n    private Runner buildRunner(Description each) {\n        if (each.toString().equals(\"TestSuite with 0 tests\")) {\n            return Suite.emptySuite();\n        }\n        if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {\n            // This is cheating, because it runs the whole class\n            // to get the warning for this method, but we can't do better,\n            // because JUnit 3.8's\n            // thrown away which method the warning is for.\n            return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));\n        }\n        Class<?> type = each.getTestClass();\n        if (type == null) {\n            throw new RuntimeException(\"Can't build a runner from description [\" + each + \"]\");\n        }\n        String methodName = each.getMethodName();\n        if (methodName == null) {\n            return Request.aClass(type).getRunner();\n        }\n        return Request.method(type, methodName).getRunner();\n    }\n\n    private Class<?> getMalformedTestClass(Description each) {\n        try {\n            return Class.forName(each.toString().replace(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX, \"\"));\n        } catch (ClassNotFoundException e) {\n            return null;\n        }\n    }\n\n    /**\n     * @param request a request to run\n     * @return a list of method-level tests to run, sorted in the order\n     *         specified in the class comment.\n     */\n    public List<Description> sortedLeavesForTest(Request request) {\n        return findLeaves(sortRequest(request));\n    }\n\n    private List<Description> findLeaves(Request request) {\n        List<Description> results = new ArrayList<Description>();\n        findLeaves(null, request.getRunner().getDescription(), results);\n        return results;\n    }\n\n    private void findLeaves(Description parent, Description description, List<Description> results) {\n        if (description.getChildren().isEmpty()) {\n            if (description.toString().equals(\"warning(junit.framework.TestSuite$1)\")) {\n                results.add(Description.createSuiteDescription(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX + parent));\n            } else {\n                results.add(description);\n            }\n        } else {\n            for (Description each : description.getChildren()) {\n                findLeaves(description, each, results);\n            }\n        }\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/max/MaxHistory.java",
    "content": "package org.junit.experimental.max;\n\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\nimport java.io.Serializable;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\n\n/**\n * Stores a subset of the history of each test:\n * <ul>\n * <li>Last failure timestamp\n * <li>Duration of last execution\n * </ul>\n */\npublic class MaxHistory implements Serializable {\n    private static final long serialVersionUID = 1L;\n\n    /**\n     * Loads a {@link MaxHistory} from {@code file}, or generates a new one that\n     * will be saved to {@code file}.\n     */\n    public static MaxHistory forFolder(File file) {\n        if (file.exists()) {\n            try {\n                return readHistory(file);\n            } catch (CouldNotReadCoreException e) {\n                e.printStackTrace();\n                file.delete();\n            }\n        }\n        return new MaxHistory(file);\n    }\n\n    private static MaxHistory readHistory(File storedResults)\n            throws CouldNotReadCoreException {\n        try {\n            FileInputStream file = new FileInputStream(storedResults);\n            try {\n                ObjectInputStream stream = new ObjectInputStream(file);\n                try {\n                    return (MaxHistory) stream.readObject();\n                } finally {\n                    stream.close();\n                }\n            } finally {\n                file.close();\n            }\n        } catch (Exception e) {\n            throw new CouldNotReadCoreException(e);\n        }\n    }\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final Map<String, Long> fDurations = new HashMap<String, Long>();\n    private final Map<String, Long> fFailureTimestamps = new HashMap<String, Long>();\n    private final File fHistoryStore;\n\n    private MaxHistory(File storedResults) {\n        fHistoryStore = storedResults;\n    }\n\n    private void save() throws IOException {\n        ObjectOutputStream stream = null;\n        try {\n            stream = new ObjectOutputStream(new FileOutputStream(fHistoryStore));\n            stream.writeObject(this);\n        } finally {\n            if (stream != null) {\n                stream.close();\n            }\n        }\n    }\n\n    Long getFailureTimestamp(Description key) {\n        return fFailureTimestamps.get(key.toString());\n    }\n\n    void putTestFailureTimestamp(Description key, long end) {\n        fFailureTimestamps.put(key.toString(), end);\n    }\n\n    boolean isNewTest(Description key) {\n        return !fDurations.containsKey(key.toString());\n    }\n\n    Long getTestDuration(Description key) {\n        return fDurations.get(key.toString());\n    }\n\n    void putTestDuration(Description description, long duration) {\n        fDurations.put(description.toString(), duration);\n    }\n\n    private final class RememberingListener extends RunListener {\n        private long overallStart = System.currentTimeMillis();\n\n        private Map<Description, Long> starts = new HashMap<Description, Long>();\n\n        @Override\n        public void testStarted(Description description) throws Exception {\n            starts.put(description, System.nanoTime()); // Get most accurate\n            // possible time\n        }\n\n        @Override\n        public void testFinished(Description description) throws Exception {\n            long end = System.nanoTime();\n            long start = starts.get(description);\n            putTestDuration(description, end - start);\n        }\n\n        @Override\n        public void testFailure(Failure failure) throws Exception {\n            putTestFailureTimestamp(failure.getDescription(), overallStart);\n        }\n\n        @Override\n        public void testRunFinished(Result result) throws Exception {\n            save();\n        }\n    }\n\n    private class TestComparator implements Comparator<Description> {\n        public int compare(Description o1, Description o2) {\n            // Always prefer new tests\n            if (isNewTest(o1)) {\n                return -1;\n            }\n            if (isNewTest(o2)) {\n                return 1;\n            }\n            // Then most recently failed first\n            int result = getFailure(o2).compareTo(getFailure(o1));\n            return result != 0 ? result\n                    // Then shorter tests first\n                    : getTestDuration(o1).compareTo(getTestDuration(o2));\n        }\n\n        private Long getFailure(Description key) {\n            Long result = getFailureTimestamp(key);\n            if (result == null) {\n                return 0L; // 0 = \"never failed (that I know about)\"\n            }\n            return result;\n        }\n    }\n\n    /**\n     * @return a listener that will update this history based on the test\n     *         results reported.\n     */\n    public RunListener listener() {\n        return new RememberingListener();\n    }\n\n    /**\n     * @return a comparator that ranks tests based on the JUnit Max sorting\n     *         rules, as described in the {@link MaxCore} class comment.\n     */\n    public Comparator<Description> testComparator() {\n        return new TestComparator();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/results/FailureList.java",
    "content": "package org.junit.experimental.results;\n\nimport java.util.List;\n\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\n\nclass FailureList {\n    private final List<Failure> failures;\n\n    public FailureList(List<Failure> failures) {\n        this.failures = failures;\n    }\n\n    public Result result() {\n        Result result = new Result();\n        RunListener listener = result.createListener();\n        for (Failure failure : failures) {\n            try {\n                listener.testFailure(failure);\n            } catch (Exception e) {\n                throw new RuntimeException(\"I can't believe this happened\");\n            }\n        }\n        return result;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/results/PrintableResult.java",
    "content": "package org.junit.experimental.results;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.PrintStream;\nimport java.util.List;\n\nimport org.junit.internal.TextListener;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\n\n/**\n * A test result that prints nicely in error messages.\n * This is only intended to be used in JUnit self-tests.\n * For example:\n *\n * <pre>\n *    assertThat(testResult(HasExpectedException.class), isSuccessful());\n * </pre>\n */\npublic class PrintableResult {\n    private Result result;\n\n    /**\n     * The result of running JUnit on {@code type}\n     */\n    public static PrintableResult testResult(Class<?> type) {\n        return testResult(Request.aClass(type));\n    }\n\n    /**\n     * The result of running JUnit on Request {@code request}\n     */\n    public static PrintableResult testResult(Request request) {\n        return new PrintableResult(new JUnitCore().run(request));\n    }\n\n    /**\n     * A result that includes the given {@code failures}\n     */\n    public PrintableResult(List<Failure> failures) {\n        this(new FailureList(failures).result());\n    }\n\n    private PrintableResult(Result result) {\n        this.result = result;\n    }\n\n    /**\n     * Returns the number of failures in this result.\n     */\n    public int failureCount() {\n        return result.getFailures().size();\n    }\n\n    /**\n     * Returns the failures in this result.\n     *\n     * @since 4.13\n     */\n    public List<Failure> failures() {\n        return result.getFailures();\n    }\n\n    @Override\n    public String toString() {\n        ByteArrayOutputStream stream = new ByteArrayOutputStream();\n        new TextListener(new PrintStream(stream)).testRunFinished(result);\n        return stream.toString();\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/results/ResultMatchers.java",
    "content": "package org.junit.experimental.results;\n\nimport org.hamcrest.BaseMatcher;\nimport org.hamcrest.Description;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.TypeSafeMatcher;\n\n/**\n * Matchers on a PrintableResult, to enable JUnit self-tests.\n * For example:\n *\n * <pre>\n * assertThat(testResult(HasExpectedException.class), isSuccessful());\n * </pre>\n */\npublic class ResultMatchers {\n\n    /**\n     * Do not instantiate.\n     * @deprecated will be private soon.\n     */\n    @Deprecated\n    public ResultMatchers() {\n    }\n\n    /**\n     * Matches if the tests are all successful\n     */\n    public static Matcher<PrintableResult> isSuccessful() {\n        return failureCountIs(0);\n    }\n\n    /**\n     * Matches if there are {@code count} failures\n     */\n    public static Matcher<PrintableResult> failureCountIs(final int count) {\n        return new TypeSafeMatcher<PrintableResult>() {\n            public void describeTo(Description description) {\n                description.appendText(\"has \" + count + \" failures\");\n            }\n\n            @Override\n            public boolean matchesSafely(PrintableResult item) {\n                return item.failureCount() == count;\n            }\n        };\n    }\n\n    /**\n     * Matches if the result has exactly one failure, and it contains {@code string}\n     */\n    public static Matcher<Object> hasSingleFailureContaining(final String string) {\n        return new BaseMatcher<Object>() {\n            public boolean matches(Object item) {\n                return item.toString().contains(string) && failureCountIs(1).matches(item);\n            }\n\n            public void describeTo(Description description) {\n                description.appendText(\"has single failure containing \" + string);\n            }\n        };\n    }\n\n    /**\n     * Matches if the result has exactly one failure matching the given matcher.\n     *\n     * @since 4.13\n     */\n    public static Matcher<PrintableResult> hasSingleFailureMatching(final Matcher<Throwable> matcher) {\n        return new TypeSafeMatcher<PrintableResult>() {\n            @Override\n            public boolean matchesSafely(PrintableResult item) {\n                return item.failureCount() == 1 && matcher.matches(item.failures().get(0).getException());\n            }\n\n            public void describeTo(Description description) {\n                description.appendText(\"has failure with exception matching \");\n                matcher.describeTo(description);\n            }\n        };\n    }\n\n    /**\n     * Matches if the result has one or more failures, and at least one of them\n     * contains {@code string}\n     */\n    public static Matcher<PrintableResult> hasFailureContaining(final String string) {\n        return new TypeSafeMatcher<PrintableResult>() {\n            @Override\n            public boolean matchesSafely(PrintableResult item) {\n                return item.failureCount() > 0 && item.toString().contains(string);\n            }\n\n            public void describeTo(Description description) {\n                description.appendText(\"has failure containing \" + string);\n            }\n        };\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/runners/Enclosed.java",
    "content": "package org.junit.experimental.runners;\n\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.runners.Suite;\nimport org.junit.runners.model.RunnerBuilder;\n\n/**\n * If you put tests in inner classes, Ant, for example, won't find them. By running the outer class\n * with Enclosed, the tests in the inner classes will be run. You might put tests in inner classes\n * to group them for convenience or to share constants. Abstract inner classes are ignored.\n * <p>\n * So, for example:\n * <pre>\n * &#064;RunWith(Enclosed.class)\n * public class ListTests {\n *     ...useful shared stuff...\n *     public static class OneKindOfListTest {...}\n *     public static class AnotherKind {...}\n *     abstract public static class Ignored {...}\n * }\n * </pre>\n */\npublic class Enclosed extends Suite {\n    /**\n     * Only called reflectively. Do not use programmatically.\n     */\n    public Enclosed(Class<?> klass, RunnerBuilder builder) throws Throwable {\n        super(builder, klass, filterAbstractClasses(klass.getClasses()));\n    }\n    \n    private static Class<?>[] filterAbstractClasses(final Class<?>[] classes) {     \n        final List<Class<?>> filteredList= new ArrayList<Class<?>>(classes.length);\n\n        for (final Class<?> clazz : classes) {\n            if (!Modifier.isAbstract(clazz.getModifiers())) {\n                filteredList.add(clazz);\n            }\n        }\n        \n        return filteredList.toArray(new Class<?>[filteredList.size()]);\n    }   \n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/DataPoint.java",
    "content": "package org.junit.experimental.theories;\n\nimport static java.lang.annotation.ElementType.FIELD;\nimport static java.lang.annotation.ElementType.METHOD;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Annotating an field or method with &#064;DataPoint will cause the field value\n * or the value returned by the method to be used as a potential parameter for\n * theories in that class, when run with the\n * {@link org.junit.experimental.theories.Theories Theories} runner.\n * <p>\n * A DataPoint is only considered as a potential value for parameters for\n * which its type is assignable. When multiple {@code DataPoint}s exist \n * with overlapping types more control can be obtained by naming each DataPoint \n * using the value of this annotation, e.g. with\n * <code>&#064;DataPoint({\"dataset1\", \"dataset2\"})</code>, and then specifying\n * which named set to consider as potential values for each parameter using the\n * {@link org.junit.experimental.theories.FromDataPoints &#064;FromDataPoints}\n * annotation.\n * <p>\n * Parameters with no specified source (i.e. without &#064;FromDataPoints or\n * other {@link org.junit.experimental.theories.ParametersSuppliedBy\n * &#064;ParameterSuppliedBy} annotations) will use all {@code DataPoint}s that are\n * assignable to the parameter type as potential values, including named sets of\n * {@code DataPoint}s.\n * \n * <pre>\n * &#064;DataPoint\n * public static String dataPoint = \"value\";\n * \n * &#064;DataPoint(\"generated\")\n * public static String generatedDataPoint() {\n *     return \"generated value\";\n * }\n * \n * &#064;Theory\n * public void theoryMethod(String param) {\n *     ...\n * }\n * </pre>\n * \n * @see org.junit.experimental.theories.Theories\n * @see org.junit.experimental.theories.Theory\n * @see org.junit.experimental.theories.DataPoint\n * @see org.junit.experimental.theories.FromDataPoints\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({FIELD, METHOD})\npublic @interface DataPoint {\n    String[] value() default {};\n    Class<? extends Throwable>[] ignoredExceptions() default {};\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/DataPoints.java",
    "content": "package org.junit.experimental.theories;\n\nimport static java.lang.annotation.ElementType.FIELD;\nimport static java.lang.annotation.ElementType.METHOD;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Annotating an array or iterable-typed field or method with &#064;DataPoints\n * will cause the values in the array or iterable given to be used as potential\n * parameters for theories in that class when run with the\n * {@link org.junit.experimental.theories.Theories Theories} runner.\n * <p>\n * DataPoints will only be considered as potential values for parameters for\n * which their types are assignable. When multiple sets of DataPoints exist with\n * overlapping types more control can be obtained by naming the DataPoints using\n * the value of this annotation, e.g. with\n * <code>&#064;DataPoints({\"dataset1\", \"dataset2\"})</code>, and then specifying\n * which named set to consider as potential values for each parameter using the\n * {@link org.junit.experimental.theories.FromDataPoints &#064;FromDataPoints}\n * annotation.\n * <p>\n * Parameters with no specified source (i.e. without &#064;FromDataPoints or\n * other {@link org.junit.experimental.theories.ParametersSuppliedBy\n * &#064;ParameterSuppliedBy} annotations) will use all DataPoints that are\n * assignable to the parameter type as potential values, including named sets of\n * DataPoints.\n * <p>\n * DataPoints methods whose array types aren't assignable from the target\n * parameter type (and so can't possibly return relevant values) will not be\n * called when generating values for that parameter. Iterable-typed datapoints\n * methods must always be called though, as this information is not available\n * here after generic type erasure, so expensive methods returning iterable\n * datapoints are a bad idea.\n * \n * <pre>\n * &#064;DataPoints\n * public static String[] dataPoints = new String[] { ... };\n * \n * &#064;DataPoints\n * public static String[] generatedDataPoints() {\n *     return new String[] { ... };\n * }\n * \n * &#064;Theory\n * public void theoryMethod(String param) {\n *     ...\n * }\n * </pre>\n * \n * @see org.junit.experimental.theories.Theories\n * @see org.junit.experimental.theories.Theory\n * @see org.junit.experimental.theories.DataPoint\n * @see org.junit.experimental.theories.FromDataPoints\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({ FIELD, METHOD })\npublic @interface DataPoints {\n    String[] value() default {};\n\n    Class<? extends Throwable>[] ignoredExceptions() default {};\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/FromDataPoints.java",
    "content": "package org.junit.experimental.theories;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\nimport org.junit.experimental.theories.internal.SpecificDataPointsSupplier;\n\n/**\n * Annotating a parameter of a {@link org.junit.experimental.theories.Theory\n * &#064;Theory} method with <code>&#064;FromDataPoints</code> will limit the\n * datapoints considered as potential values for that parameter to just the\n * {@link org.junit.experimental.theories.DataPoints DataPoints} with the given\n * name. DataPoint names can be given as the value parameter of the\n * &#064;DataPoints annotation.\n * <p>\n * DataPoints without names will not be considered as values for any parameters\n * annotated with &#064;FromDataPoints.\n * <pre>\n * &#064;DataPoints\n * public static String[] unnamed = new String[] { ... };\n * \n * &#064;DataPoints(\"regexes\")\n * public static String[] regexStrings = new String[] { ... };\n * \n * &#064;DataPoints({\"forMatching\", \"alphanumeric\"})\n * public static String[] testStrings = new String[] { ... }; \n * \n * &#064;Theory\n * public void stringTheory(String param) {\n *     // This will be called with every value in 'regexStrings',\n *     // 'testStrings' and 'unnamed'.\n * }\n * \n * &#064;Theory\n * public void regexTheory(&#064;FromDataPoints(\"regexes\") String regex,\n *                         &#064;FromDataPoints(\"forMatching\") String value) {\n *     // This will be called with only the values in 'regexStrings' as \n *     // regex, only the values in 'testStrings' as value, and none \n *     // of the values in 'unnamed'.\n * }\n * </pre>\n * \n * @see org.junit.experimental.theories.Theory\n * @see org.junit.experimental.theories.DataPoint\n * @see org.junit.experimental.theories.DataPoints\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.PARAMETER)\n@ParametersSuppliedBy(SpecificDataPointsSupplier.class)\npublic @interface FromDataPoints {\n    String value();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/ParameterSignature.java",
    "content": "package org.junit.experimental.theories;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\npublic class ParameterSignature {\n    \n    private static final Map<Class<?>, Class<?>> CONVERTABLE_TYPES_MAP = buildConvertableTypesMap();\n    \n    private static Map<Class<?>, Class<?>> buildConvertableTypesMap() {\n        Map<Class<?>, Class<?>> map = new HashMap<Class<?>, Class<?>>();\n\n        putSymmetrically(map, boolean.class, Boolean.class);\n        putSymmetrically(map, byte.class, Byte.class);\n        putSymmetrically(map, short.class, Short.class);\n        putSymmetrically(map, char.class, Character.class);\n        putSymmetrically(map, int.class, Integer.class);\n        putSymmetrically(map, long.class, Long.class);\n        putSymmetrically(map, float.class, Float.class);\n        putSymmetrically(map, double.class, Double.class);\n\n        return Collections.unmodifiableMap(map);\n    }\n    \n    private static <T> void putSymmetrically(Map<T, T> map, T a, T b) {\n        map.put(a, b);\n        map.put(b, a);\n    }\n    \n    public static ArrayList<ParameterSignature> signatures(Method method) {\n        return signatures(method.getParameterTypes(), method\n                .getParameterAnnotations());\n    }\n\n    public static List<ParameterSignature> signatures(Constructor<?> constructor) {\n        return signatures(constructor.getParameterTypes(), constructor\n                .getParameterAnnotations());\n    }\n\n    private static ArrayList<ParameterSignature> signatures(\n            Class<?>[] parameterTypes, Annotation[][] parameterAnnotations) {\n        ArrayList<ParameterSignature> sigs = new ArrayList<ParameterSignature>();\n        for (int i = 0; i < parameterTypes.length; i++) {\n            sigs.add(new ParameterSignature(parameterTypes[i],\n                    parameterAnnotations[i]));\n        }\n        return sigs;\n    }\n\n    private final Class<?> type;\n\n    private final Annotation[] annotations;\n\n    private ParameterSignature(Class<?> type, Annotation[] annotations) {\n        this.type = type;\n        this.annotations = annotations;\n    }\n\n    public boolean canAcceptValue(Object candidate) {\n        return (candidate == null) ? !type.isPrimitive() : canAcceptType(candidate.getClass());\n    }\n\n    public boolean canAcceptType(Class<?> candidate) {\n        return type.isAssignableFrom(candidate) ||\n                isAssignableViaTypeConversion(type, candidate);\n    }\n    \n    public boolean canPotentiallyAcceptType(Class<?> candidate) {\n        return candidate.isAssignableFrom(type) ||\n                isAssignableViaTypeConversion(candidate, type) ||\n                canAcceptType(candidate);\n    }\n\n    private boolean isAssignableViaTypeConversion(Class<?> targetType, Class<?> candidate) {\n        if (CONVERTABLE_TYPES_MAP.containsKey(candidate)) {\n            Class<?> wrapperClass = CONVERTABLE_TYPES_MAP.get(candidate);\n            return targetType.isAssignableFrom(wrapperClass);\n        } else {\n            return false;\n        }\n    }\n\n    public Class<?> getType() {\n        return type;\n    }\n\n    public List<Annotation> getAnnotations() {\n        return Arrays.asList(annotations);\n    }\n\n    public boolean hasAnnotation(Class<? extends Annotation> type) {\n        return getAnnotation(type) != null;\n    }\n\n    public <T extends Annotation> T findDeepAnnotation(Class<T> annotationType) {\n        Annotation[] annotations2 = annotations;\n        return findDeepAnnotation(annotations2, annotationType, 3);\n    }\n\n    private <T extends Annotation> T findDeepAnnotation(\n            Annotation[] annotations, Class<T> annotationType, int depth) {\n        if (depth == 0) {\n            return null;\n        }\n        for (Annotation each : annotations) {\n            if (annotationType.isInstance(each)) {\n                return annotationType.cast(each);\n            }\n            Annotation candidate = findDeepAnnotation(each.annotationType()\n                    .getAnnotations(), annotationType, depth - 1);\n            if (candidate != null) {\n                return annotationType.cast(candidate);\n            }\n        }\n\n        return null;\n    }\n\n    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {\n        for (Annotation each : getAnnotations()) {\n            if (annotationType.isInstance(each)) {\n                return annotationType.cast(each);\n            }\n        }\n        return null;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/ParameterSupplier.java",
    "content": "package org.junit.experimental.theories;\n\nimport java.util.List;\n\n/**\n * Abstract parent class for suppliers of input data points for theories. Extend this class to customize how {@link\n * org.junit.experimental.theories.Theories Theories} runner\n * finds accepted data points. Then use your class together with <b>&#064;ParametersSuppliedBy</b> on input\n * parameters for theories.\n *\n * <p>\n * For example, here is a supplier for values between two integers, and an annotation that references it:\n *\n * <pre>\n *     &#064;Retention(RetentionPolicy.RUNTIME)\n *     <b>&#064;ParametersSuppliedBy</b>(BetweenSupplier.class)\n *     public @interface Between {\n *         int first();\n *\n *         int last();\n *     }\n *\n *     public static class BetweenSupplier extends <b>ParameterSupplier</b> {\n *         &#064;Override\n *         public List&lt;<b>PotentialAssignment</b>&gt; getValueSources(<b>ParameterSignature</b> sig) {\n *             List&lt;<b>PotentialAssignment</b>&gt; list = new ArrayList&lt;PotentialAssignment&gt;();\n *             Between annotation = (Between) sig.getSupplierAnnotation();\n *\n *             for (int i = annotation.first(); i &lt;= annotation.last(); i++)\n *                 list.add(<b>PotentialAssignment</b>.forValue(\"ints\", i));\n *             return list;\n *         }\n *     }\n * </pre>\n * </p>\n *\n * @see org.junit.experimental.theories.ParametersSuppliedBy\n * @see org.junit.experimental.theories.Theories\n * @see org.junit.experimental.theories.FromDataPoints\n */\npublic abstract class ParameterSupplier {\n    public abstract List<PotentialAssignment> getValueSources(ParameterSignature sig) throws Throwable;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java",
    "content": "package org.junit.experimental.theories;\n\nimport static java.lang.annotation.ElementType.ANNOTATION_TYPE;\nimport static java.lang.annotation.ElementType.PARAMETER;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Annotating a {@link org.junit.experimental.theories.Theory Theory} method\n * parameter with &#064;ParametersSuppliedBy causes it to be supplied with\n * values from the named\n * {@link org.junit.experimental.theories.ParameterSupplier ParameterSupplier}\n * when run as a theory by the {@link org.junit.experimental.theories.Theories\n * Theories} runner.\n * \n * In addition, annotations themselves can be annotated with\n * &#064;ParametersSuppliedBy, and then used similarly. ParameterSuppliedBy\n * annotations on parameters are detected by searching up this hierarchy such\n * that these act as syntactic sugar, making:\n * \n * <pre>\n * &#064;ParametersSuppliedBy(Supplier.class)\n * public &#064;interface SpecialParameter { }\n * \n * &#064;Theory\n * public void theoryMethod(&#064;SpecialParameter String param) {\n *   ...\n * }\n * </pre>\n * \n * equivalent to:\n * \n * <pre>\n * &#064;Theory\n * public void theoryMethod(&#064;ParametersSuppliedBy(Supplier.class) String param) {\n *   ...\n * }\n * </pre>\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target({ ANNOTATION_TYPE, PARAMETER })\npublic @interface ParametersSuppliedBy {\n\n    Class<? extends ParameterSupplier> value();\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/PotentialAssignment.java",
    "content": "package org.junit.experimental.theories;\n\nimport static java.lang.String.format;\n\npublic abstract class PotentialAssignment {\n    public static class CouldNotGenerateValueException extends Exception {\n        private static final long serialVersionUID = 1L;\n        \n        public CouldNotGenerateValueException() {\n        }\n        \n        public CouldNotGenerateValueException(Throwable e) {\n            super(e);\n        }\n    }\n\n    public static PotentialAssignment forValue(final String name, final Object value) {\n        return new PotentialAssignment() {\n            @Override\n            public Object getValue() {\n                return value;\n            }\n\n            @Override\n            public String toString() {\n                return format(\"[%s]\", value);\n            }\n\n            @Override\n            public String getDescription() {\n                String valueString;\n\n                if (value == null) {\n                    valueString = \"null\";\n                } else {\n                    try {\n                        valueString = format(\"\\\"%s\\\"\", value);\n                    } catch (Throwable e) {\n                        valueString = format(\"[toString() threw %s: %s]\", \n                                             e.getClass().getSimpleName(), e.getMessage());\n                    }\n                }\n\n                return format(\"%s <from %s>\", valueString, name);\n            }\n        };\n    }\n\n    public abstract Object getValue() throws CouldNotGenerateValueException;\n\n    public abstract String getDescription() throws CouldNotGenerateValueException;\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/Theories.java",
    "content": "package org.junit.experimental.theories;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.Assert;\nimport org.junit.Assume;\nimport org.junit.experimental.theories.internal.Assignments;\nimport org.junit.experimental.theories.internal.ParameterizedAssertionError;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.Statement;\nimport org.junit.runners.model.TestClass;\n\n/**\n * The Theories runner allows to test a certain functionality against a subset of an infinite set of data points.\n * <p>\n * A Theory is a piece of functionality (a method) that is executed against several data inputs called data points.\n * To make a test method a theory you mark it with <b>&#064;Theory</b>. To create a data point you create a public\n * field in your test class and mark it with <b>&#064;DataPoint</b>. The Theories runner then executes your test\n * method as many times as the number of data points declared, providing a different data point as\n * the input argument on each invocation.\n * </p>\n * <p>\n * A Theory differs from standard test method in that it captures some aspect of the intended behavior in possibly\n * infinite numbers of scenarios which corresponds to the number of data points declared. Using assumptions and\n * assertions properly together with covering multiple scenarios with different data points can make your tests more\n * flexible and bring them closer to scientific theories (hence the name).\n * </p>\n * <p>\n * For example:\n * <pre>\n *\n * &#064;RunWith(<b>Theories.class</b>)\n * public class UserTest {\n *      <b>&#064;DataPoint</b>\n *      public static String GOOD_USERNAME = \"optimus\";\n *      <b>&#064;DataPoint</b>\n *      public static String USERNAME_WITH_SLASH = \"optimus/prime\";\n *\n *      <b>&#064;Theory</b>\n *      public void filenameIncludesUsername(String username) {\n *          assumeThat(username, not(containsString(\"/\")));\n *          assertThat(new User(username).configFileName(), containsString(username));\n *      }\n * }\n * </pre>\n * This makes it clear that the username should be included in the config file name,\n * only if it doesn't contain a slash. Another test or theory might define what happens when a username does contain\n * a slash. <code>UserTest</code> will attempt to run <code>filenameIncludesUsername</code> on every compatible data\n * point defined in the class. If any of the assumptions fail, the data point is silently ignored. If all of the\n * assumptions pass, but an assertion fails, the test fails. If no parameters can be found that satisfy all assumptions, the test fails.\n * <p>\n * Defining general statements as theories allows data point reuse across a bunch of functionality tests and also\n * allows automated tools to search for new, unexpected data points that expose bugs.\n * </p>\n * <p>\n * The support for Theories has been absorbed from the Popper project, and more complete documentation can be found\n * from that projects archived documentation.\n * </p>\n *\n * @see <a href=\"http://web.archive.org/web/20071012143326/popper.tigris.org/tutorial.html\">Archived Popper project documentation</a>\n * @see <a href=\"http://web.archive.org/web/20110608210825/http://shareandenjoy.saff.net/tdd-specifications.pdf\">Paper on Theories</a>\n */\npublic class Theories extends BlockJUnit4ClassRunner {\n    public Theories(Class<?> klass) throws InitializationError {\n        super(klass);\n    }\n\n    /** @since 4.13 */\n    protected Theories(TestClass testClass) throws InitializationError {\n        super(testClass);\n    }\n\n    @Override\n    protected void collectInitializationErrors(List<Throwable> errors) {\n        super.collectInitializationErrors(errors);\n        validateDataPointFields(errors);\n        validateDataPointMethods(errors);\n    }\n\n    private void validateDataPointFields(List<Throwable> errors) {\n        Field[] fields = getTestClass().getJavaClass().getDeclaredFields();\n\n        for (Field field : fields) {\n            if (field.getAnnotation(DataPoint.class) == null && field.getAnnotation(DataPoints.class) == null) {\n                continue;\n            }\n            if (!Modifier.isStatic(field.getModifiers())) {\n                errors.add(new Error(\"DataPoint field \" + field.getName() + \" must be static\"));\n            }\n            if (!Modifier.isPublic(field.getModifiers())) {\n                errors.add(new Error(\"DataPoint field \" + field.getName() + \" must be public\"));\n            }\n        }\n    }\n\n    private void validateDataPointMethods(List<Throwable> errors) {\n        Method[] methods = getTestClass().getJavaClass().getDeclaredMethods();\n        \n        for (Method method : methods) {\n            if (method.getAnnotation(DataPoint.class) == null && method.getAnnotation(DataPoints.class) == null) {\n                continue;\n            }\n            if (!Modifier.isStatic(method.getModifiers())) {\n                errors.add(new Error(\"DataPoint method \" + method.getName() + \" must be static\"));\n            }\n            if (!Modifier.isPublic(method.getModifiers())) {\n                errors.add(new Error(\"DataPoint method \" + method.getName() + \" must be public\"));\n            }\n        }\n    }\n\n    @Override\n    protected void validateConstructor(List<Throwable> errors) {\n        validateOnlyOneConstructor(errors);\n    }\n\n    @Override\n    protected void validateTestMethods(List<Throwable> errors) {\n        for (FrameworkMethod each : computeTestMethods()) {\n            if (each.getAnnotation(Theory.class) != null) {\n                each.validatePublicVoid(false, errors);\n                each.validateNoTypeParametersOnArgs(errors);\n            } else {\n                each.validatePublicVoidNoArg(false, errors);\n            }\n            \n            for (ParameterSignature signature : ParameterSignature.signatures(each.getMethod())) {\n                ParametersSuppliedBy annotation = signature.findDeepAnnotation(ParametersSuppliedBy.class);\n                if (annotation != null) {\n                    validateParameterSupplier(annotation.value(), errors);\n                }\n            }\n        }\n    }\n\n    private void validateParameterSupplier(Class<? extends ParameterSupplier> supplierClass, List<Throwable> errors) {\n        Constructor<?>[] constructors = supplierClass.getConstructors();\n        \n        if (constructors.length != 1) {\n            errors.add(new Error(\"ParameterSupplier \" + supplierClass.getName() + \n                                 \" must have only one constructor (either empty or taking only a TestClass)\"));\n        } else {\n            Class<?>[] paramTypes = constructors[0].getParameterTypes();\n            if (!(paramTypes.length == 0) && !paramTypes[0].equals(TestClass.class)) {\n                errors.add(new Error(\"ParameterSupplier \" + supplierClass.getName() + \n                                     \" constructor must take either nothing or a single TestClass instance\"));\n            }\n        }\n    }\n\n    @Override\n    protected List<FrameworkMethod> computeTestMethods() {\n        List<FrameworkMethod> testMethods = new ArrayList<FrameworkMethod>(super.computeTestMethods());\n        List<FrameworkMethod> theoryMethods = getTestClass().getAnnotatedMethods(Theory.class);\n        testMethods.removeAll(theoryMethods);\n        testMethods.addAll(theoryMethods);\n        return testMethods;\n    }\n\n    @Override\n    public Statement methodBlock(final FrameworkMethod method) {\n        return new TheoryAnchor(method, getTestClass());\n    }\n\n    public static class TheoryAnchor extends Statement {\n        private int successes = 0;\n\n        private final FrameworkMethod testMethod;\n        private final TestClass testClass;\n\n        private List<AssumptionViolatedException> fInvalidParameters = new ArrayList<AssumptionViolatedException>();\n\n        public TheoryAnchor(FrameworkMethod testMethod, TestClass testClass) {\n            this.testMethod = testMethod;\n            this.testClass = testClass;\n        }\n\n        private TestClass getTestClass() {\n            return testClass;\n        }\n\n        @Override\n        public void evaluate() throws Throwable {\n            runWithAssignment(Assignments.allUnassigned(\n                    testMethod.getMethod(), getTestClass()));\n            \n            //if this test method is not annotated with Theory, then no successes is a valid case\n            boolean hasTheoryAnnotation = testMethod.getAnnotation(Theory.class) != null;\n            if (successes == 0 && hasTheoryAnnotation) {\n                Assert\n                        .fail(\"Never found parameters that satisfied method assumptions.  Violated assumptions: \"\n                                + fInvalidParameters);\n            }\n        }\n\n        protected void runWithAssignment(Assignments parameterAssignment)\n                throws Throwable {\n            if (!parameterAssignment.isComplete()) {\n                runWithIncompleteAssignment(parameterAssignment);\n            } else {\n                runWithCompleteAssignment(parameterAssignment);\n            }\n        }\n\n        protected void runWithIncompleteAssignment(Assignments incomplete)\n                throws Throwable {\n            for (PotentialAssignment source : incomplete\n                    .potentialsForNextUnassigned()) {\n                runWithAssignment(incomplete.assignNext(source));\n            }\n        }\n\n        protected void runWithCompleteAssignment(final Assignments complete)\n                throws Throwable {\n            new BlockJUnit4ClassRunner(getTestClass()) {\n                @Override\n                protected void collectInitializationErrors(\n                        List<Throwable> errors) {\n                    // do nothing\n                }\n\n                @Override\n                public Statement methodBlock(FrameworkMethod method) {\n                    final Statement statement = super.methodBlock(method);\n                    return new Statement() {\n                        @Override\n                        public void evaluate() throws Throwable {\n                            try {\n                                statement.evaluate();\n                                handleDataPointSuccess();\n                            } catch (AssumptionViolatedException e) {\n                                handleAssumptionViolation(e);\n                            } catch (Throwable e) {\n                                reportParameterizedError(e, complete\n                                        .getArgumentStrings(nullsOk()));\n                            }\n                        }\n\n                    };\n                }\n\n                @Override\n                protected Statement methodInvoker(FrameworkMethod method, Object test) {\n                    return methodCompletesWithParameters(method, complete, test);\n                }\n\n                @Override\n                public Object createTest() throws Exception {\n                    Object[] params = complete.getConstructorArguments();\n                    \n                    if (!nullsOk()) {\n                        Assume.assumeNotNull(params);\n                    }\n                    \n                    return getTestClass().getOnlyConstructor().newInstance(params);\n                }\n            }.methodBlock(testMethod).evaluate();\n        }\n\n        private Statement methodCompletesWithParameters(\n                final FrameworkMethod method, final Assignments complete, final Object freshInstance) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    final Object[] values = complete.getMethodArguments();\n                    \n                    if (!nullsOk()) {\n                        Assume.assumeNotNull(values);\n                    }\n                    \n                    method.invokeExplosively(freshInstance, values);\n                }\n            };\n        }\n\n        protected void handleAssumptionViolation(AssumptionViolatedException e) {\n            fInvalidParameters.add(e);\n        }\n\n        protected void reportParameterizedError(Throwable e, Object... params)\n                throws Throwable {\n            if (params.length == 0) {\n                throw e;\n            }\n            throw new ParameterizedAssertionError(e, testMethod.getName(),\n                    params);\n        }\n\n        private boolean nullsOk() {\n            Theory annotation = testMethod.getMethod().getAnnotation(\n                    Theory.class);\n            if (annotation == null) {\n                return false;\n            }\n            return annotation.nullsAccepted();\n        }\n\n        protected void handleDataPointSuccess() {\n            successes++;\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/Theory.java",
    "content": "package org.junit.experimental.theories;\n\nimport static java.lang.annotation.ElementType.METHOD;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Marks test methods that should be read as theories by the {@link org.junit.experimental.theories.Theories Theories} runner.\n *\n * @see org.junit.experimental.theories.Theories\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(METHOD)\npublic @interface Theory {\n    boolean nullsAccepted() default true;\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java",
    "content": "package org.junit.experimental.theories.internal;\n\nimport java.lang.reflect.Array;\nimport java.lang.reflect.Field;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.junit.Assume;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.ParameterSupplier;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.runners.model.FrameworkField;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.TestClass;\n\n/**\n * Supplies Theory parameters based on all public members of the target class.\n */\npublic class AllMembersSupplier extends ParameterSupplier {\n    static class MethodParameterValue extends PotentialAssignment {\n        private final FrameworkMethod method;\n\n        private MethodParameterValue(FrameworkMethod dataPointMethod) {\n            method = dataPointMethod;\n        }\n\n        @Override\n        public Object getValue() throws CouldNotGenerateValueException {\n            try {\n                return method.invokeExplosively(null);\n            } catch (IllegalArgumentException e) {\n                throw new RuntimeException(\n                        \"unexpected: argument length is checked\");\n            } catch (IllegalAccessException e) {\n                throw new RuntimeException(\n                        \"unexpected: getMethods returned an inaccessible method\");\n            } catch (Throwable throwable) {\n                DataPoint annotation = method.getAnnotation(DataPoint.class);\n                Assume.assumeTrue(annotation == null || !isAssignableToAnyOf(annotation.ignoredExceptions(), throwable));\n                \n                throw new CouldNotGenerateValueException(throwable);\n            }\n        }\n\n        @Override\n        public String getDescription() throws CouldNotGenerateValueException {\n            return method.getName();\n        }\n    }\n    \n    private final TestClass clazz;\n\n    /**\n     * Constructs a new supplier for {@code type}\n     */\n    public AllMembersSupplier(TestClass type) {\n        clazz = type;\n    }\n\n    @Override\n    public List<PotentialAssignment> getValueSources(ParameterSignature sig) throws Throwable {\n        List<PotentialAssignment> list = new ArrayList<PotentialAssignment>();\n\n        addSinglePointFields(sig, list);\n        addMultiPointFields(sig, list);\n        addSinglePointMethods(sig, list);\n        addMultiPointMethods(sig, list);\n\n        return list;\n    }\n\n    private void addMultiPointMethods(ParameterSignature sig, List<PotentialAssignment> list) throws Throwable {\n        for (FrameworkMethod dataPointsMethod : getDataPointsMethods(sig)) {\n            Class<?> returnType = dataPointsMethod.getReturnType();\n            \n            if ((returnType.isArray() && sig.canPotentiallyAcceptType(returnType.getComponentType())) ||\n                    Iterable.class.isAssignableFrom(returnType)) {\n                try {\n                    addDataPointsValues(returnType, sig, dataPointsMethod.getName(), list, \n                            dataPointsMethod.invokeExplosively(null));\n                } catch (Throwable throwable) {\n                    DataPoints annotation = dataPointsMethod.getAnnotation(DataPoints.class);\n                    if (annotation != null && isAssignableToAnyOf(annotation.ignoredExceptions(), throwable)) {\n                        return;\n                    } else {\n                        throw throwable;\n                    }\n                }\n            }\n        }\n    }\n\n    private void addSinglePointMethods(ParameterSignature sig, List<PotentialAssignment> list) {\n        for (FrameworkMethod dataPointMethod : getSingleDataPointMethods(sig)) {\n            if (sig.canAcceptType(dataPointMethod.getType())) {\n                list.add(new MethodParameterValue(dataPointMethod));\n            }\n        }\n    }\n    \n    private void addMultiPointFields(ParameterSignature sig, List<PotentialAssignment> list) {\n        for (final Field field : getDataPointsFields(sig)) {\n            Class<?> type = field.getType();\n            addDataPointsValues(type, sig, field.getName(), list, getStaticFieldValue(field));\n        }\n    }\n\n    private void addSinglePointFields(ParameterSignature sig, List<PotentialAssignment> list) {\n        for (final Field field : getSingleDataPointFields(sig)) {\n            Object value = getStaticFieldValue(field);\n            \n            if (sig.canAcceptValue(value)) {\n                list.add(PotentialAssignment.forValue(field.getName(), value));\n            }\n        }\n    }\n    \n    private void addDataPointsValues(Class<?> type, ParameterSignature sig, String name, \n            List<PotentialAssignment> list, Object value) {\n        if (type.isArray()) {\n            addArrayValues(sig, name, list, value);\n        }\n        else if (Iterable.class.isAssignableFrom(type)) {\n            addIterableValues(sig, name, list, (Iterable<?>) value);\n        }\n    }\n\n    private void addArrayValues(ParameterSignature sig, String name, List<PotentialAssignment> list, Object array) {\n        for (int i = 0; i < Array.getLength(array); i++) {\n            Object value = Array.get(array, i);\n            if (sig.canAcceptValue(value)) {\n                list.add(PotentialAssignment.forValue(name + \"[\" + i + \"]\", value));\n            }\n        }\n    }\n    \n    private void addIterableValues(ParameterSignature sig, String name, List<PotentialAssignment> list, Iterable<?> iterable) {\n        Iterator<?> iterator = iterable.iterator();\n        int i = 0;\n        while (iterator.hasNext()) {\n            Object value = iterator.next();\n            if (sig.canAcceptValue(value)) {\n                list.add(PotentialAssignment.forValue(name + \"[\" + i + \"]\", value));\n            }\n            i += 1;\n        }\n    }\n\n    private Object getStaticFieldValue(final Field field) {\n        try {\n            return field.get(null);\n        } catch (IllegalArgumentException e) {\n            throw new RuntimeException(\n                    \"unexpected: field from getClass doesn't exist on object\");\n        } catch (IllegalAccessException e) {\n            throw new RuntimeException(\n                    \"unexpected: getFields returned an inaccessible field\");\n        }\n    }\n    \n    private static boolean isAssignableToAnyOf(Class<?>[] typeArray, Object target) {\n        for (Class<?> type : typeArray) {\n            if (type.isAssignableFrom(target.getClass())) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) {\n        return clazz.getAnnotatedMethods(DataPoints.class);\n    }\n    \n    protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) {\n        List<FrameworkField> fields = clazz.getAnnotatedFields(DataPoint.class);\n        Collection<Field> validFields = new ArrayList<Field>();\n\n        for (FrameworkField frameworkField : fields) {\n            validFields.add(frameworkField.getField());\n        }\n\n        return validFields;\n    }\n    \n    protected Collection<Field> getDataPointsFields(ParameterSignature sig) {\n        List<FrameworkField> fields = clazz.getAnnotatedFields(DataPoints.class);\n        Collection<Field> validFields = new ArrayList<Field>();\n\n        for (FrameworkField frameworkField : fields) {\n            validFields.add(frameworkField.getField());\n        }\n\n        return validFields;\n    }\n    \n    protected Collection<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) {\n        return clazz.getAnnotatedMethods(DataPoint.class);\n    }\n\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/internal/Assignments.java",
    "content": "package org.junit.experimental.theories.internal;\n\nimport static java.util.Collections.emptyList;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.ParameterSupplier;\nimport org.junit.experimental.theories.ParametersSuppliedBy;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.PotentialAssignment.CouldNotGenerateValueException;\nimport org.junit.runners.model.TestClass;\n\n/**\n * A potentially incomplete list of value assignments for a method's formal\n * parameters\n */\npublic class Assignments {\n    private final List<PotentialAssignment> assigned;\n\n    private final List<ParameterSignature> unassigned;\n\n    private final TestClass clazz;\n\n    private Assignments(List<PotentialAssignment> assigned,\n            List<ParameterSignature> unassigned, TestClass clazz) {\n        this.unassigned = unassigned;\n        this.assigned = assigned;\n        this.clazz = clazz;\n    }\n\n    /**\n     * Returns a new assignment list for {@code testMethod}, with no params\n     * assigned.\n     */\n    public static Assignments allUnassigned(Method testMethod,\n            TestClass testClass) {\n        List<ParameterSignature> signatures;\n        signatures = ParameterSignature.signatures(testClass\n                .getOnlyConstructor());\n        signatures.addAll(ParameterSignature.signatures(testMethod));\n        return new Assignments(new ArrayList<PotentialAssignment>(),\n                signatures, testClass);\n    }\n\n    public boolean isComplete() {\n        return unassigned.isEmpty();\n    }\n\n    public ParameterSignature nextUnassigned() {\n        return unassigned.get(0);\n    }\n\n    public Assignments assignNext(PotentialAssignment source) {\n        List<PotentialAssignment> potentialAssignments = new ArrayList<PotentialAssignment>(assigned);\n        potentialAssignments.add(source);\n\n        return new Assignments(potentialAssignments, unassigned.subList(1,\n                unassigned.size()), clazz);\n    }\n\n    public Object[] getActualValues(int start, int stop) \n            throws CouldNotGenerateValueException {\n        Object[] values = new Object[stop - start];\n        for (int i = start; i < stop; i++) {\n            values[i - start] = assigned.get(i).getValue();\n        }\n        return values;\n    }\n\n    public List<PotentialAssignment> potentialsForNextUnassigned()\n            throws Throwable {\n        ParameterSignature unassigned = nextUnassigned();\n        List<PotentialAssignment> assignments = getSupplier(unassigned).getValueSources(unassigned);\n        \n        if (assignments.isEmpty()) {\n            assignments = generateAssignmentsFromTypeAlone(unassigned);\n        }\n        \n        return assignments;\n    }\n\n    private List<PotentialAssignment> generateAssignmentsFromTypeAlone(ParameterSignature unassigned) {\n        Class<?> paramType = unassigned.getType();\n        \n        if (paramType.isEnum()) {\n            return new EnumSupplier(paramType).getValueSources(unassigned);  \n        } else if (paramType.equals(Boolean.class) || paramType.equals(boolean.class)) {\n            return new BooleanSupplier().getValueSources(unassigned);\n        } else {\n            return emptyList();\n        }\n    }\n\n    private ParameterSupplier getSupplier(ParameterSignature unassigned)\n            throws Exception {\n        ParametersSuppliedBy annotation = unassigned\n                .findDeepAnnotation(ParametersSuppliedBy.class);\n        \n        if (annotation != null) {\n            return buildParameterSupplierFromClass(annotation.value());\n        } else {\n            return new AllMembersSupplier(clazz);\n        }\n    }\n\n    private ParameterSupplier buildParameterSupplierFromClass(\n            Class<? extends ParameterSupplier> cls) throws Exception {\n        Constructor<?>[] supplierConstructors = cls.getConstructors();\n\n        for (Constructor<?> constructor : supplierConstructors) {\n            Class<?>[] parameterTypes = constructor.getParameterTypes();\n            if (parameterTypes.length == 1\n                    && parameterTypes[0].equals(TestClass.class)) {\n                return (ParameterSupplier) constructor.newInstance(clazz);\n            }\n        }\n\n        return cls.newInstance();\n    }\n\n    public Object[] getConstructorArguments()\n            throws CouldNotGenerateValueException {\n        return getActualValues(0, getConstructorParameterCount());\n    }\n\n    public Object[] getMethodArguments() throws CouldNotGenerateValueException {\n        return getActualValues(getConstructorParameterCount(), assigned.size());\n    }\n\n    public Object[] getAllArguments() throws CouldNotGenerateValueException {\n        return getActualValues(0, assigned.size());\n    }\n\n    private int getConstructorParameterCount() {\n        List<ParameterSignature> signatures = ParameterSignature\n                .signatures(clazz.getOnlyConstructor());\n        int constructorParameterCount = signatures.size();\n        return constructorParameterCount;\n    }\n\n    public Object[] getArgumentStrings(boolean nullsOk)\n            throws CouldNotGenerateValueException {\n        Object[] values = new Object[assigned.size()];\n        for (int i = 0; i < values.length; i++) {\n            values[i] = assigned.get(i).getDescription();\n        }\n        return values;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/internal/BooleanSupplier.java",
    "content": "package org.junit.experimental.theories.internal;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.ParameterSupplier;\nimport org.junit.experimental.theories.PotentialAssignment;\n\npublic class BooleanSupplier extends ParameterSupplier {\n\n    @Override\n    public List<PotentialAssignment> getValueSources(ParameterSignature sig) {\n        return Arrays.asList(PotentialAssignment.forValue(\"true\", true),\n                             PotentialAssignment.forValue(\"false\", false));\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/internal/EnumSupplier.java",
    "content": "package org.junit.experimental.theories.internal;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.ParameterSupplier;\nimport org.junit.experimental.theories.PotentialAssignment;\n\npublic class EnumSupplier extends ParameterSupplier {\n\n    private Class<?> enumType;\n\n    public EnumSupplier(Class<?> enumType) {\n        this.enumType = enumType;\n    }\n\n    @Override\n    public List<PotentialAssignment> getValueSources(ParameterSignature sig) {\n        Object[] enumValues = enumType.getEnumConstants();\n        \n        List<PotentialAssignment> assignments = new ArrayList<PotentialAssignment>();\n        for (Object value : enumValues) {\n            assignments.add(PotentialAssignment.forValue(value.toString(), value));\n        }\n        \n        return assignments;\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/internal/ParameterizedAssertionError.java",
    "content": "package org.junit.experimental.theories.internal;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Iterator;\n\npublic class ParameterizedAssertionError extends AssertionError {\n    private static final long serialVersionUID = 1L;\n\n    public ParameterizedAssertionError(Throwable targetException,\n            String methodName, Object... params) {\n        super(String.format(\"%s(%s)\", methodName, join(\", \", params)));\n        this.initCause(targetException);\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        return obj instanceof ParameterizedAssertionError && toString().equals(obj.toString());\n    }\n\n    @Override\n    public int hashCode() {\n        return toString().hashCode();\n    }\n\n    public static String join(String delimiter, Object... params) {\n        return join(delimiter, Arrays.asList(params));\n    }\n\n    public static String join(String delimiter, Collection<Object> values) {\n        StringBuilder sb = new StringBuilder();\n        Iterator<Object> iter = values.iterator();\n        while (iter.hasNext()) {\n            Object next = iter.next();\n            sb.append(stringValueOf(next));\n            if (iter.hasNext()) {\n                sb.append(delimiter);\n            }\n        }\n        return sb.toString();\n    }\n\n    private static String stringValueOf(Object next) {\n        try {\n            return String.valueOf(next);\n        } catch (Throwable e) {\n            return \"[toString failed]\";\n        }\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/internal/SpecificDataPointsSupplier.java",
    "content": "package org.junit.experimental.theories.internal;\n\nimport java.lang.reflect.Field;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.FromDataPoints;\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.TestClass;\n\npublic class SpecificDataPointsSupplier extends AllMembersSupplier {\n\n    public SpecificDataPointsSupplier(TestClass testClass) {\n        super(testClass);\n    }\n    \n    @Override\n    protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) {\n        Collection<Field> fields = super.getSingleDataPointFields(sig);        \n        String requestedName = sig.getAnnotation(FromDataPoints.class).value();\n\n        List<Field> fieldsWithMatchingNames = new ArrayList<Field>();\n        \n        for (Field field : fields) {\n            String[] fieldNames = field.getAnnotation(DataPoint.class).value();\n            if (Arrays.asList(fieldNames).contains(requestedName)) {\n                fieldsWithMatchingNames.add(field);\n            }\n        }\n        \n        return fieldsWithMatchingNames;\n    }\n    \n    @Override\n    protected Collection<Field> getDataPointsFields(ParameterSignature sig) {\n        Collection<Field> fields = super.getDataPointsFields(sig);        \n        String requestedName = sig.getAnnotation(FromDataPoints.class).value();\n        \n        List<Field> fieldsWithMatchingNames = new ArrayList<Field>();\n        \n        for (Field field : fields) {\n            String[] fieldNames = field.getAnnotation(DataPoints.class).value();\n            if (Arrays.asList(fieldNames).contains(requestedName)) {\n                fieldsWithMatchingNames.add(field);\n            }\n        }\n        \n        return fieldsWithMatchingNames;\n    }\n    \n    @Override\n    protected Collection<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) {\n        Collection<FrameworkMethod> methods = super.getSingleDataPointMethods(sig);\n        String requestedName = sig.getAnnotation(FromDataPoints.class).value();\n        \n        List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();\n        \n        for (FrameworkMethod method : methods) {\n            String[] methodNames = method.getAnnotation(DataPoint.class).value();\n            if (Arrays.asList(methodNames).contains(requestedName)) {\n                methodsWithMatchingNames.add(method);\n            }\n        }\n        \n        return methodsWithMatchingNames;\n    }\n    \n    @Override\n    protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) {\n        Collection<FrameworkMethod> methods = super.getDataPointsMethods(sig);\n        String requestedName = sig.getAnnotation(FromDataPoints.class).value();\n        \n        List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();\n        \n        for (FrameworkMethod method : methods) {\n            String[] methodNames = method.getAnnotation(DataPoints.class).value();\n            if (Arrays.asList(methodNames).contains(requestedName)) {\n                methodsWithMatchingNames.add(method);\n            }\n        }\n        \n        return methodsWithMatchingNames;\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/suppliers/TestedOn.java",
    "content": "package org.junit.experimental.theories.suppliers;\n\nimport static java.lang.annotation.ElementType.PARAMETER;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\nimport org.junit.experimental.theories.ParametersSuppliedBy;\n\n/**\n * Annotating a {@link org.junit.experimental.theories.Theory Theory} method int\n * parameter with &#064;TestedOn causes it to be supplied with values from the\n * ints array given when run as a theory by the\n * {@link org.junit.experimental.theories.Theories Theories} runner. For\n * example, the below method would be called three times by the Theories runner,\n * once with each of the int parameters specified.\n * \n * <pre>\n * &#064;Theory\n * public void shouldPassForSomeInts(&#064;TestedOn(ints={1, 2, 3}) int param) {\n *     ...\n * }\n * </pre>\n */\n@ParametersSuppliedBy(TestedOnSupplier.class)\n@Retention(RetentionPolicy.RUNTIME)\n@Target(PARAMETER)\npublic @interface TestedOn {\n    int[] ints();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/experimental/theories/suppliers/TestedOnSupplier.java",
    "content": "package org.junit.experimental.theories.suppliers;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.ParameterSupplier;\nimport org.junit.experimental.theories.PotentialAssignment;\n\n/**\n * @see org.junit.experimental.theories.suppliers.TestedOn\n * @see org.junit.experimental.theories.ParameterSupplier\n */\npublic class TestedOnSupplier extends ParameterSupplier {\n    @Override\n    public List<PotentialAssignment> getValueSources(ParameterSignature sig) {\n        List<PotentialAssignment> list = new ArrayList<PotentialAssignment>();\n        TestedOn testedOn = sig.getAnnotation(TestedOn.class);\n        int[] ints = testedOn.ints();\n        for (final int i : ints) {\n            list.add(PotentialAssignment.forValue(\"ints\", i));\n        }\n        return list;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/function/ThrowingRunnable.java",
    "content": "package org.junit.function;\n\n/**\n * This interface facilitates the use of\n * {@link org.junit.Assert#assertThrows(Class, ThrowingRunnable)} from Java 8. It allows method\n * references to void methods (that declare checked exceptions) to be passed directly into\n * {@code assertThrows}\n * without wrapping. It is not meant to be implemented directly.\n *\n * @since 4.13\n */\npublic interface ThrowingRunnable {\n    void run() throws Throwable;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/ArrayComparisonFailure.java",
    "content": "package org.junit.internal;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.Assert;\n\n/**\n * Thrown when two array elements differ\n *\n * @see Assert#assertArrayEquals(String, Object[], Object[])\n */\npublic class ArrayComparisonFailure extends AssertionError {\n\n    private static final long serialVersionUID = 1L;\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility.\n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final List<Integer> fIndices = new ArrayList<Integer>();\n    private final String fMessage;\n    private final AssertionError fCause;\n\n    /**\n     * Construct a new <code>ArrayComparisonFailure</code> with an error text and the array's\n     * dimension that was not equal\n     *\n     * @param cause the exception that caused the array's content to fail the assertion test\n     * @param index the array position of the objects that are not equal.\n     * @see Assert#assertArrayEquals(String, Object[], Object[])\n     */\n    public ArrayComparisonFailure(String message, AssertionError cause, int index) {\n        this.fMessage = message;\n        this.fCause = cause;\n        initCause(fCause);\n        addDimension(index);\n    }\n\n    public void addDimension(int index) {\n        fIndices.add(0, index);\n    }\n\n    @Override\n    public synchronized Throwable getCause() {\n        return super.getCause() == null ? fCause : super.getCause();\n    }\n\n    @Override\n    public String getMessage() {\n        StringBuilder sb = new StringBuilder();\n        if (fMessage != null) {\n            sb.append(fMessage);\n        }\n        sb.append(\"arrays first differed at element \");\n        for (int each : fIndices) {\n            sb.append(\"[\");\n            sb.append(each);\n            sb.append(\"]\");\n        }\n        sb.append(\"; \");\n        sb.append(getCause().getMessage());\n        return sb.toString();\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    @Override\n    public String toString() {\n        return getMessage();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/AssumptionViolatedException.java",
    "content": "package org.junit.internal;\n\nimport java.io.IOException;\nimport java.io.ObjectOutputStream;\n\nimport org.hamcrest.Description;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.SelfDescribing;\nimport org.hamcrest.StringDescription;\n\n/**\n * An exception class used to implement <i>assumptions</i> (state in which a given test\n * is meaningful and should or should not be executed). A test for which an assumption\n * fails should not generate a test case failure.\n *\n * @see org.junit.Assume\n */\npublic class AssumptionViolatedException extends RuntimeException implements SelfDescribing {\n    private static final long serialVersionUID = 2L;\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final String fAssumption;\n    private final boolean fValueMatcher;\n    private final Object fValue;\n    private final Matcher<?> fMatcher;\n\n    /**\n     * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead.\n     */\n    @Deprecated\n    public AssumptionViolatedException(String assumption, boolean hasValue, Object value, Matcher<?> matcher) {\n        this.fAssumption = assumption;\n        this.fValue = value;\n        this.fMatcher = matcher;\n        this.fValueMatcher = hasValue;\n\n        if (value instanceof Throwable) {\n          initCause((Throwable) value);\n        }\n    }\n\n    /**\n     * An assumption exception with the given <i>value</i> (String or\n     * Throwable) and an additional failing {@link Matcher}.\n     *\n     * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead.\n     */\n    @Deprecated\n    public AssumptionViolatedException(Object value, Matcher<?> matcher) {\n        this(null, true, value, matcher);\n    }\n\n    /**\n     * An assumption exception with the given <i>value</i> (String or\n     * Throwable) and an additional failing {@link Matcher}.\n     *\n     * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead.\n     */\n    @Deprecated\n    public AssumptionViolatedException(String assumption, Object value, Matcher<?> matcher) {\n        this(assumption, true, value, matcher);\n    }\n\n    /**\n     * An assumption exception with the given message only.\n     *\n     * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead.\n     */\n    @Deprecated\n    public AssumptionViolatedException(String assumption) {\n        this(assumption, false, null, null);\n    }\n\n    /**\n     * An assumption exception with the given message and a cause.\n     *\n     * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead.\n     */\n    @Deprecated\n    public AssumptionViolatedException(String assumption, Throwable e) {\n        this(assumption, false, null, null);\n        initCause(e);\n    }\n\n    @Override\n    public String getMessage() {\n        return StringDescription.asString(this);\n    }\n\n    public void describeTo(Description description) {\n        if (fAssumption != null) {\n            description.appendText(fAssumption);\n        }\n\n        if (fValueMatcher) {\n            // a value was passed in when this instance was constructed; print it\n            if (fAssumption != null) {\n                description.appendText(\": \");\n            }\n\n            description.appendText(\"got: \");\n            description.appendValue(fValue);\n\n            if (fMatcher != null) {\n                description.appendText(\", expected: \");\n                description.appendDescriptionOf(fMatcher);\n            }\n        }\n    }\n\n    /**\n     * Override default Java object serialization to correctly deal with potentially unserializable matchers or values.\n     * By not implementing readObject, we assure ourselves of backwards compatibility and compatibility with the\n     * standard way of Java serialization.\n     *\n     * @param objectOutputStream The outputStream to write our representation to\n     * @throws IOException When serialization fails\n     */\n    private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {\n        ObjectOutputStream.PutField putField = objectOutputStream.putFields();\n        putField.put(\"fAssumption\", fAssumption);\n        putField.put(\"fValueMatcher\", fValueMatcher);\n\n        // We have to wrap the matcher into a serializable form.\n        putField.put(\"fMatcher\", SerializableMatcherDescription.asSerializableMatcher(fMatcher));\n\n        // We have to wrap the value inside a non-String class (instead of serializing the String value directly) as\n        // A Description will handle a String and non-String object differently (1st is surrounded by '\"' while the\n        // latter will be surrounded by '<' '>'. Wrapping it makes sure that the description of a serialized and\n        // non-serialized instance produce the exact same description\n        putField.put(\"fValue\", SerializableValueDescription.asSerializableValue(fValue));\n\n        objectOutputStream.writeFields();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/Checks.java",
    "content": "package org.junit.internal;\n\n/** @since 4.13 */\npublic final class Checks {\n\n    private Checks() {}\n\n    /**\n     * Checks that the given value is not {@code null}.\n     *\n     * @param value object reference to check\n     * @return the passed-in value, if not {@code null}\n     * @throws NullPointerException if {@code value} is {@code null}\n     */\n    public static <T> T notNull(T value) {\n        if (value == null) {\n            throw new NullPointerException();\n        }\n        return value;\n    }\n\n    /**\n     * Checks that the given value is not {@code null}, using the given message\n     * as the exception message if an exception is thrown.\n     *\n     * @param value object reference to check\n     * @param message message to use if {@code value} is {@code null}\n     * @return the passed-in value, if not {@code null}\n     * @throws NullPointerException if {@code value} is {@code null}\n     */\n    public static <T> T notNull(T value, String message) {\n        if (value == null) {\n            throw new NullPointerException(message);\n        }\n        return value;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/Classes.java",
    "content": "package org.junit.internal;\r\n\r\nimport static java.lang.Thread.currentThread;\r\n\r\n/**\r\n * Miscellaneous functions dealing with classes.\r\n */\r\npublic class Classes {\r\n\r\n    /**\r\n     * Do not instantiate.\r\n     * @deprecated will be private soon.\r\n     */\r\n    @Deprecated\r\n    public Classes() {\r\n    }\r\n\r\n    /**\r\n     * Returns Class.forName for {@code className} using the current thread's class loader.\r\n     * If the current thread does not have a class loader, falls back to the class loader for\r\n     * {@link Classes}.\r\n     *\r\n     * @param className Name of the class.\r\n     */\r\n    public static Class<?> getClass(String className) throws ClassNotFoundException {\r\n        return getClass(className, Classes.class);\r\n    }\r\n\r\n    /**\r\n     * Returns Class.forName for {@code className} using the current thread's class loader.\r\n     * If the current thread does not have a class loader, falls back to the class loader for the\r\n     * passed-in class.\r\n     *\r\n     * @param className Name of the class.\r\n     * @param callingClass Class that is requesting a the class\r\n     * @since 4.13\r\n     */\r\n    public static Class<?> getClass(String className, Class<?> callingClass) throws ClassNotFoundException {\r\n        ClassLoader classLoader = currentThread().getContextClassLoader();\r\n        return Class.forName(className, true, classLoader == null ? callingClass.getClassLoader() : classLoader);\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/internal/ComparisonCriteria.java",
    "content": "package org.junit.internal;\n\nimport java.lang.reflect.Array;\nimport java.util.Arrays;\n\nimport org.junit.Assert;\n\n/**\n * Defines criteria for finding two items \"equal enough\". Concrete subclasses\n * may demand exact equality, or, for example, equality within a given delta.\n */\npublic abstract class ComparisonCriteria {\n    /**\n     * Asserts that two arrays are equal, according to the criteria defined by\n     * the concrete subclass. If they are not, an {@link AssertionError} is\n     * thrown with the given message. If <code>expecteds</code> and\n     * <code>actuals</code> are <code>null</code>, they are considered equal.\n     *\n     * @param message the identifying message for the {@link AssertionError} (\n     * <code>null</code> okay)\n     * @param expecteds Object array or array of arrays (multi-dimensional array) with\n     * expected values.\n     * @param actuals Object array or array of arrays (multi-dimensional array) with\n     * actual values\n     */\n    public void arrayEquals(String message, Object expecteds, Object actuals)\n            throws ArrayComparisonFailure {\n        arrayEquals(message, expecteds, actuals, true);\n    }\n\n    private void arrayEquals(String message, Object expecteds, Object actuals, boolean outer)\n            throws ArrayComparisonFailure {\n        if (expecteds == actuals\n            || Arrays.deepEquals(new Object[] {expecteds}, new Object[] {actuals})) {\n            // The reflection-based loop below is potentially very slow, especially for primitive\n            // arrays. The deepEquals check allows us to circumvent it in the usual case where\n            // the arrays are exactly equal.\n            return;\n        }\n        String header = message == null ? \"\" : message + \": \";\n\n        // Only include the user-provided message in the outer exception.\n        String exceptionMessage = outer ? header : \"\";\n\n        if (expecteds == null) {\n            Assert.fail(exceptionMessage + \"expected array was null\");\n        }\n        if (actuals == null) {\n            Assert.fail(exceptionMessage + \"actual array was null\");\n        }\n\n        int actualsLength = Array.getLength(actuals);\n        int expectedsLength = Array.getLength(expecteds);\n        if (actualsLength != expectedsLength) {\n            header += \"array lengths differed, expected.length=\"\n                    + expectedsLength + \" actual.length=\" + actualsLength + \"; \";\n        }\n        int prefixLength = Math.min(actualsLength, expectedsLength);\n\n        for (int i = 0; i < prefixLength; i++) {\n            Object expected = Array.get(expecteds, i);\n            Object actual = Array.get(actuals, i);\n\n            if (isArray(expected) && isArray(actual)) {\n                try {\n                    arrayEquals(message, expected, actual, false);\n                } catch (ArrayComparisonFailure e) {\n                    e.addDimension(i);\n                    throw e;\n                } catch (AssertionError e) {\n                    // Array lengths differed.\n                    throw new ArrayComparisonFailure(header, e, i);\n                }\n            } else {\n                try {\n                    assertElementsEqual(expected, actual);\n                } catch (AssertionError e) {\n                    throw new ArrayComparisonFailure(header, e, i);\n                }\n            }\n        }\n\n        if (actualsLength != expectedsLength) {\n            Object expected = getToStringableArrayElement(expecteds, expectedsLength, prefixLength);\n            Object actual = getToStringableArrayElement(actuals, actualsLength, prefixLength);\n            try {\n                Assert.assertEquals(expected, actual);\n            } catch (AssertionError e) {\n                throw new ArrayComparisonFailure(header, e, prefixLength);\n            }\n        }\n    }\n\n    private static final Object END_OF_ARRAY_SENTINEL = objectWithToString(\"end of array\");\n\n    private Object getToStringableArrayElement(Object array, int length, int index) {\n        if (index < length) {\n            Object element = Array.get(array, index);\n            if (isArray(element)) {\n                return objectWithToString(componentTypeName(element.getClass()) + \"[\" + Array.getLength(element) + \"]\");\n            } else {\n                return element;\n            }\n        } else {\n            return END_OF_ARRAY_SENTINEL;\n        }\n    }\n\n    private static Object objectWithToString(final String string) {\n        return new Object() {\n            @Override\n            public String toString() {\n                return string;\n            }\n        };\n    }\n\n    private String componentTypeName(Class<?> arrayClass) {\n        Class<?> componentType = arrayClass.getComponentType();\n        if (componentType.isArray()) {\n            return componentTypeName(componentType) + \"[]\";\n        } else {\n            return componentType.getName();\n        }\n    }\n\n    private boolean isArray(Object expected) {\n        return expected != null && expected.getClass().isArray();\n    }\n\n    protected abstract void assertElementsEqual(Object expected, Object actual);\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/ExactComparisonCriteria.java",
    "content": "package org.junit.internal;\n\nimport org.junit.Assert;\n\npublic class ExactComparisonCriteria extends ComparisonCriteria {\n    @Override\n    protected void assertElementsEqual(Object expected, Object actual) {\n        Assert.assertEquals(expected, actual);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/InexactComparisonCriteria.java",
    "content": "package org.junit.internal;\n\nimport org.junit.Assert;\n\npublic class InexactComparisonCriteria extends ComparisonCriteria {\n    public Object fDelta;\n\n    public InexactComparisonCriteria(double delta) {\n        fDelta = delta;\n    }\n\n    public InexactComparisonCriteria(float delta) {\n        fDelta = delta;\n    }\n\n    @Override\n    protected void assertElementsEqual(Object expected, Object actual) {\n        if (expected instanceof Double) {\n            Assert.assertEquals((Double) expected, (Double) actual, (Double) fDelta);\n        } else {\n            Assert.assertEquals((Float) expected, (Float) actual, (Float) fDelta);\n        }\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/JUnitSystem.java",
    "content": "package org.junit.internal;\n\nimport java.io.PrintStream;\n\npublic interface JUnitSystem {\n\n    /**\n     * Will be removed in the next major release\n     */\n    @Deprecated\n    void exit(int code);\n\n    PrintStream out();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/MethodSorter.java",
    "content": "package org.junit.internal;\n\nimport java.lang.reflect.Method;\nimport java.util.Arrays;\nimport java.util.Comparator;\n\nimport org.junit.FixMethodOrder;\n\npublic class MethodSorter {\n    /**\n     * DEFAULT sort order\n     */\n    public static final Comparator<Method> DEFAULT = new Comparator<Method>() {\n        public int compare(Method m1, Method m2) {\n            int i1 = m1.getName().hashCode();\n            int i2 = m2.getName().hashCode();\n            if (i1 != i2) {\n                return i1 < i2 ? -1 : 1;\n            }\n            return NAME_ASCENDING.compare(m1, m2);\n        }\n    };\n\n    /**\n     * Method name ascending lexicographic sort order, with {@link Method#toString()} as a tiebreaker\n     */\n    public static final Comparator<Method> NAME_ASCENDING = new Comparator<Method>() {\n        public int compare(Method m1, Method m2) {\n            final int comparison = m1.getName().compareTo(m2.getName());\n            if (comparison != 0) {\n                return comparison;\n            }\n            return m1.toString().compareTo(m2.toString());\n        }\n    };\n\n    /**\n     * Gets declared methods of a class in a predictable order, unless @FixMethodOrder(MethodSorters.JVM) is specified.\n     *\n     * Using the JVM order is unwise since the Java platform does not\n     * specify any particular order, and in fact JDK 7 returns a more or less\n     * random order; well-written test code would not assume any order, but some\n     * does, and a predictable failure is better than a random failure on\n     * certain platforms. By default, uses an unspecified but deterministic order.\n     *\n     * @param clazz a class\n     * @return same as {@link Class#getDeclaredMethods} but sorted\n     * @see <a href=\"http://bugs.sun.com/view_bug.do?bug_id=7023180\">JDK\n     *      (non-)bug #7023180</a>\n     */\n    public static Method[] getDeclaredMethods(Class<?> clazz) {\n        Comparator<Method> comparator = getSorter(clazz.getAnnotation(FixMethodOrder.class));\n\n        Method[] methods = clazz.getDeclaredMethods();\n        if (comparator != null) {\n            Arrays.sort(methods, comparator);\n        }\n\n        return methods;\n    }\n\n    private MethodSorter() {\n    }\n\n    private static Comparator<Method> getSorter(FixMethodOrder fixMethodOrder) {\n        if (fixMethodOrder == null) {\n            return DEFAULT;\n        }\n\n        return fixMethodOrder.value().getComparator();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/RealSystem.java",
    "content": "package org.junit.internal;\n\nimport java.io.PrintStream;\n\npublic class RealSystem implements JUnitSystem {\n\n    /**\n     * Will be removed in the next major release\n     */\n    @Deprecated\n    public void exit(int code) {\n        System.exit(code);\n    }\n\n    public PrintStream out() {\n        return System.out;\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/SerializableMatcherDescription.java",
    "content": "package org.junit.internal;\n\nimport java.io.Serializable;\n\nimport org.hamcrest.BaseMatcher;\nimport org.hamcrest.Description;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.StringDescription;\n\n/**\n * This class exists solely to provide a serializable description of a matcher to be serialized as a field in\n * {@link AssumptionViolatedException}. Being a {@link Throwable}, it is required to be {@link Serializable}, but most\n * implementations of {@link Matcher} are not. This class works around that limitation as\n * {@link AssumptionViolatedException} only every uses the description of the {@link Matcher}, while still retaining\n * backwards compatibility with classes compiled against its class signature before 4.14 and/or deserialization of\n * previously serialized instances.\n */\nclass SerializableMatcherDescription<T> extends BaseMatcher<T> implements Serializable {\n\n    private final String matcherDescription;\n\n    private SerializableMatcherDescription(Matcher<T> matcher) {\n        matcherDescription = StringDescription.asString(matcher);\n    }\n\n    public boolean matches(Object o) {\n        throw new UnsupportedOperationException(\"This Matcher implementation only captures the description\");\n    }\n\n    public void describeTo(Description description) {\n        description.appendText(matcherDescription);\n    }\n\n    /**\n     * Factory method that checks to see if the matcher is already serializable.\n     * @param matcher the matcher to make serializable\n     * @return The provided matcher if it is null or already serializable,\n     * the SerializableMatcherDescription representation of it if it is not.\n     */\n    static <T> Matcher<T> asSerializableMatcher(Matcher<T> matcher) {\n        if (matcher == null || matcher instanceof Serializable) {\n            return matcher;\n        } else {\n            return new SerializableMatcherDescription<T>(matcher);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/SerializableValueDescription.java",
    "content": "package org.junit.internal;\n\nimport java.io.Serializable;\n\n/**\n * This class exists solely to provide a serializable description of a value to be serialized as a field in\n * {@link AssumptionViolatedException}. Being a {@link Throwable}, it is required to be {@link Serializable}, but a\n * value of type Object provides no guarantee to be serializable. This class works around that limitation as\n * {@link AssumptionViolatedException} only every uses the string representation of the value, while still retaining\n * backwards compatibility with classes compiled against its class signature before 4.14 and/or deserialization of\n * previously serialized instances.\n */\nclass SerializableValueDescription implements Serializable {\n    private final String value;\n\n    private SerializableValueDescription(Object value) {\n        this.value = String.valueOf(value);\n    }\n\n    /**\n     * Factory method that checks to see if the value is already serializable.\n     * @param value the value to make serializable\n     * @return The provided value if it is null or already serializable,\n     * the SerializableValueDescription representation of it if it is not.\n     */\n    static Object asSerializableValue(Object value) {\n        if (value == null || value instanceof Serializable) {\n            return value;\n        } else {\n            return new SerializableValueDescription(value);\n        }\n    }\n\n    @Override\n    public String toString() {\n        return value;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/TextListener.java",
    "content": "package org.junit.internal;\n\nimport java.io.PrintStream;\nimport java.text.NumberFormat;\nimport java.util.List;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\n\npublic class TextListener extends RunListener {\n\n    private final PrintStream writer;\n\n    public TextListener(JUnitSystem system) {\n        this(system.out());\n    }\n\n    public TextListener(PrintStream writer) {\n        this.writer = writer;\n    }\n\n    @Override\n    public void testRunFinished(Result result) {\n        printHeader(result.getRunTime());\n        printFailures(result);\n        printFooter(result);\n    }\n\n    @Override\n    public void testStarted(Description description) {\n        writer.append('.');\n    }\n\n    @Override\n    public void testFailure(Failure failure) {\n        writer.append('E');\n    }\n\n    @Override\n    public void testIgnored(Description description) {\n        writer.append('I');\n    }\n\n    /*\n      * Internal methods\n      */\n\n    private PrintStream getWriter() {\n        return writer;\n    }\n\n    protected void printHeader(long runTime) {\n        getWriter().println();\n        getWriter().println(\"Time: \" + elapsedTimeAsString(runTime));\n    }\n\n    protected void printFailures(Result result) {\n        List<Failure> failures = result.getFailures();\n        if (failures.isEmpty()) {\n            return;\n        }\n        if (failures.size() == 1) {\n            getWriter().println(\"There was \" + failures.size() + \" failure:\");\n        } else {\n            getWriter().println(\"There were \" + failures.size() + \" failures:\");\n        }\n        int i = 1;\n        for (Failure each : failures) {\n            printFailure(each, \"\" + i++);\n        }\n    }\n\n    protected void printFailure(Failure each, String prefix) {\n        getWriter().println(prefix + \") \" + each.getTestHeader());\n        getWriter().print(each.getTrimmedTrace());\n    }\n\n    protected void printFooter(Result result) {\n        if (result.wasSuccessful()) {\n            getWriter().println();\n            getWriter().print(\"OK\");\n            getWriter().println(\" (\" + result.getRunCount() + \" test\" + (result.getRunCount() == 1 ? \"\" : \"s\") + \")\");\n\n        } else {\n            getWriter().println();\n            getWriter().println(\"FAILURES!!!\");\n            getWriter().println(\"Tests run: \" + result.getRunCount() + \",  Failures: \" + result.getFailureCount());\n        }\n        getWriter().println();\n    }\n\n    /**\n     * Returns the formatted string of the elapsed time. Duplicated from\n     * BaseTestRunner. Fix it.\n     */\n    protected String elapsedTimeAsString(long runTime) {\n        return NumberFormat.getInstance().format((double) runTime / 1000);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/Throwables.java",
    "content": "package org.junit.internal;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.io.StringReader;\nimport java.io.StringWriter;\nimport java.lang.reflect.Method;\nimport java.util.AbstractList;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.List;\n\n/**\n * Miscellaneous functions dealing with {@code Throwable}.\n *\n * @author kcooney@google.com (Kevin Cooney)\n * @since 4.12\n */\npublic final class Throwables {\n\n    private Throwables() {\n    }\n\n    /**\n     * Rethrows the given {@code Throwable}, allowing the caller to\n     * declare that it throws {@code Exception}. This is useful when\n     * your callers have nothing reasonable they can do when a\n     * {@code Throwable} is thrown. This is declared to return {@code Exception}\n     * so it can be used in a {@code throw} clause:\n     * <pre>\n     * try {\n     *   doSomething();\n     * } catch (Throwable e} {\n     *   throw Throwables.rethrowAsException(e);\n     * }\n     * doSomethingLater();\n     * </pre>\n     *\n     * @param e exception to rethrow\n     * @return does not return anything\n     * @since 4.12\n     */\n    public static Exception rethrowAsException(Throwable e) throws Exception {\n        Throwables.<Exception>rethrow(e);\n        return null; // we never get here\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static <T extends Throwable> void rethrow(Throwable e) throws T {\n        throw (T) e;\n    }\n\n    /**\n     * Returns the stacktrace of the given Throwable as a String.\n     *\n     * @since 4.13\n     */\n    public static String getStacktrace(Throwable exception) {\n        StringWriter stringWriter = new StringWriter();\n        PrintWriter writer = new PrintWriter(stringWriter);\n        exception.printStackTrace(writer);\n        return stringWriter.toString();\n    }\n\n    /**\n     * Gets a trimmed version of the stack trace of the given exception. Stack trace\n     * elements that are below the test method are filtered out.\n     *\n     * @return a trimmed stack trace, or the original trace if trimming wasn't possible\n     */\n    public static String getTrimmedStackTrace(Throwable exception) {\n        List<String> trimmedStackTraceLines = getTrimmedStackTraceLines(exception);\n        if (trimmedStackTraceLines.isEmpty()) {\n            return getFullStackTrace(exception);\n        }\n\n        StringBuilder result = new StringBuilder(exception.toString());\n        appendStackTraceLines(trimmedStackTraceLines, result);\n        appendStackTraceLines(getCauseStackTraceLines(exception), result);\n        return result.toString();\n    }\n\n    private static List<String> getTrimmedStackTraceLines(Throwable exception) {\n        List<StackTraceElement> stackTraceElements = Arrays.asList(exception.getStackTrace());\n        int linesToInclude = stackTraceElements.size();\n\n        State state = State.PROCESSING_OTHER_CODE;\n        for (StackTraceElement stackTraceElement : asReversedList(stackTraceElements)) {\n            state = state.processStackTraceElement(stackTraceElement);\n            if (state == State.DONE) {\n                List<String> trimmedLines = new ArrayList<String>(linesToInclude + 2);\n                trimmedLines.add(\"\");\n                for (StackTraceElement each : stackTraceElements.subList(0, linesToInclude)) {\n                    trimmedLines.add(\"\\tat \" + each);\n                }\n                if (exception.getCause() != null) {\n                    trimmedLines.add(\"\\t... \" + (stackTraceElements.size() - trimmedLines.size()) + \" trimmed\");\n                }\n                return trimmedLines;\n            }\n            linesToInclude--;\n        }\n        return Collections.emptyList();\n    }\n\n    private static final Method getSuppressed = initGetSuppressed();\n\n    private static Method initGetSuppressed() {\n        try {\n            return Throwable.class.getMethod(\"getSuppressed\");\n        } catch (Throwable e) {\n            return null;\n        }\n    }\n\n    private static boolean hasSuppressed(Throwable exception) {\n        if (getSuppressed == null) {\n            return false;\n        }\n        try {\n            Throwable[] suppressed = (Throwable[]) getSuppressed.invoke(exception);\n            return suppressed.length != 0;\n        } catch (Throwable e) {\n            return false;\n        }\n    }\n\n    private static List<String> getCauseStackTraceLines(Throwable exception) {\n        if (exception.getCause() != null || hasSuppressed(exception)) {\n            String fullTrace = getFullStackTrace(exception);\n            BufferedReader reader = new BufferedReader(\n                    new StringReader(fullTrace.substring(exception.toString().length())));\n            List<String> causedByLines = new ArrayList<String>();\n    \n            try {\n                String line;\n                while ((line = reader.readLine()) != null) {\n                    if (line.startsWith(\"Caused by: \") || line.trim().startsWith(\"Suppressed: \")) {\n                        causedByLines.add(line);\n                        while ((line = reader.readLine()) != null) {\n                            causedByLines.add(line);\n                        }\n                        return causedByLines;\n                    }\n                }\n            } catch (IOException e) {\n                // We should never get here, because we are reading from a StringReader\n            }\n        }\n\n        return Collections.emptyList();\n    }\n\n    private static String getFullStackTrace(Throwable exception) {\n        StringWriter stringWriter = new StringWriter();\n        PrintWriter writer = new PrintWriter(stringWriter);\n        exception.printStackTrace(writer);\n        return stringWriter.toString();\n    }\n\n    private static void appendStackTraceLines(\n            List<String> stackTraceLines, StringBuilder destBuilder) {\n        for (String stackTraceLine : stackTraceLines) {\n            destBuilder.append(String.format(\"%s%n\", stackTraceLine));\n        }\n    }\n\n    private static <T> List<T> asReversedList(final List<T> list) {\n        return new AbstractList<T>() {\n\n            @Override\n            public T get(int index) {\n                return list.get(list.size() - index - 1);\n            }\n\n            @Override\n            public int size() {\n                return list.size();\n            }\n        };\n    }\n\n    private enum State {\n        PROCESSING_OTHER_CODE {\n            @Override public State processLine(String methodName) {\n                if (isTestFrameworkMethod(methodName)) {\n                    return PROCESSING_TEST_FRAMEWORK_CODE;\n                }\n                return this;\n            }\n        },\n        PROCESSING_TEST_FRAMEWORK_CODE {\n            @Override public State processLine(String methodName) {\n                if (isReflectionMethod(methodName)) {\n                    return PROCESSING_REFLECTION_CODE;\n                } else if (isTestFrameworkMethod(methodName)) {\n                    return this;\n                }\n                return PROCESSING_OTHER_CODE;\n            } \n        },\n        PROCESSING_REFLECTION_CODE {\n            @Override public State processLine(String methodName) {\n                if (isReflectionMethod(methodName)) {\n                    return this;\n                } else if (isTestFrameworkMethod(methodName)) {\n                    // This is here to handle TestCase.runBare() calling TestCase.runTest().\n                    return PROCESSING_TEST_FRAMEWORK_CODE;\n                }\n                return DONE;\n            } \n        },\n        DONE {\n            @Override public State processLine(String methodName) {\n                return this;\n            } \n        };\n\n        /** Processes a stack trace element method name, possibly moving to a new state. */\n        protected abstract State processLine(String methodName);\n        \n        /** Processes a stack trace element, possibly moving to a new state. */\n        public final State processStackTraceElement(StackTraceElement element) {\n            return processLine(element.getClassName() + \".\" + element.getMethodName() + \"()\");\n        }\n    }\n\n    private static final String[] TEST_FRAMEWORK_METHOD_NAME_PREFIXES = {\n        \"org.junit.runner.\",\n        \"org.junit.runners.\",\n        \"org.junit.experimental.runners.\",\n        \"org.junit.internal.\",\n        \"junit.extensions\",\n        \"junit.framework\",\n        \"junit.runner\",\n        \"junit.textui\",\n    };\n\n    private static final String[] TEST_FRAMEWORK_TEST_METHOD_NAME_PREFIXES = {\n        \"org.junit.internal.StackTracesTest\",\n    };\n\n    private static boolean isTestFrameworkMethod(String methodName) {\n        return isMatchingMethod(methodName, TEST_FRAMEWORK_METHOD_NAME_PREFIXES) &&\n                !isMatchingMethod(methodName, TEST_FRAMEWORK_TEST_METHOD_NAME_PREFIXES);\n    }\n    \n    private static final String[] REFLECTION_METHOD_NAME_PREFIXES = {\n        \"sun.reflect.\",\n        \"java.lang.reflect.\",\n        \"jdk.internal.reflect.\",\n        \"org.junit.rules.RunRules.<init>(\",\n        \"org.junit.rules.RunRules.applyAll(\", // calls TestRules\n        \"org.junit.runners.RuleContainer.apply(\", // calls MethodRules & TestRules\n        \"junit.framework.TestCase.runBare(\", // runBare() directly calls setUp() and tearDown()\n   };\n    \n    private static boolean isReflectionMethod(String methodName) {\n        return isMatchingMethod(methodName, REFLECTION_METHOD_NAME_PREFIXES);\n    }\n\n    private static boolean isMatchingMethod(String methodName, String[] methodNamePrefixes) {\n        for (String methodNamePrefix : methodNamePrefixes) {\n            if (methodName.startsWith(methodNamePrefix)) {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java",
    "content": "package org.junit.internal.builders;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class AllDefaultPossibilitiesBuilder extends RunnerBuilder {\n    private final boolean canUseSuiteMethod;\n\n    /**\n     * @since 4.13\n     */\n    public AllDefaultPossibilitiesBuilder() {\n        canUseSuiteMethod = true;\n    }\n\n    /**\n     * @deprecated used {@link #AllDefaultPossibilitiesBuilder()}.\n     */\n    @Deprecated\n    public AllDefaultPossibilitiesBuilder(boolean canUseSuiteMethod) {\n        this.canUseSuiteMethod = canUseSuiteMethod;\n    }\n\n    @Override\n    public Runner runnerForClass(Class<?> testClass) throws Throwable {\n        List<RunnerBuilder> builders = Arrays.asList(\n                ignoredBuilder(),\n                annotatedBuilder(),\n                suiteMethodBuilder(),\n                junit3Builder(),\n                junit4Builder());\n\n        for (RunnerBuilder each : builders) {\n            Runner runner = each.safeRunnerForClass(testClass);\n            if (runner != null) {\n                return runner;\n            }\n        }\n        return null;\n    }\n\n    protected JUnit4Builder junit4Builder() {\n        return new JUnit4Builder();\n    }\n\n    protected JUnit3Builder junit3Builder() {\n        return new JUnit3Builder();\n    }\n\n    protected AnnotatedBuilder annotatedBuilder() {\n        return new AnnotatedBuilder(this);\n    }\n\n    protected IgnoredBuilder ignoredBuilder() {\n        return new IgnoredBuilder();\n    }\n\n    protected RunnerBuilder suiteMethodBuilder() {\n        if (canUseSuiteMethod) {\n            return new SuiteMethodBuilder();\n        }\n        return new NullBuilder();\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/AnnotatedBuilder.java",
    "content": "package org.junit.internal.builders;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerBuilder;\n\nimport java.lang.reflect.Modifier;\n\n\n/**\n * The {@code AnnotatedBuilder} is a strategy for constructing runners for test class that have been annotated with the\n * {@code @RunWith} annotation. All tests within this class will be executed using the runner that was specified within\n * the annotation.\n * <p>\n * If a runner supports inner member classes, the member classes will inherit the runner from the enclosing class, e.g.:\n * <pre>\n * &#064;RunWith(MyRunner.class)\n * public class MyTest {\n *     // some tests might go here\n *\n *     public class MyMemberClass {\n *         &#064;Test\n *         public void thisTestRunsWith_MyRunner() {\n *             // some test logic\n *         }\n *\n *         // some more tests might go here\n *     }\n *\n *     &#064;RunWith(AnotherRunner.class)\n *     public class AnotherMemberClass {\n *         // some tests might go here\n *\n *         public class DeepInnerClass {\n *             &#064;Test\n *             public void thisTestRunsWith_AnotherRunner() {\n *                 // some test logic\n *             }\n *         }\n *\n *         public class DeepInheritedClass extends SuperTest {\n *             &#064;Test\n *             public void thisTestRunsWith_SuperRunner() {\n *                 // some test logic\n *             }\n *         }\n *     }\n * }\n *\n * &#064;RunWith(SuperRunner.class)\n * public class SuperTest {\n *     // some tests might go here\n * }\n * </pre>\n * The key points to note here are:\n * <ul>\n *     <li>If there is no RunWith annotation, no runner will be created.</li>\n *     <li>The resolve step is inside-out, e.g. the closest RunWith annotation wins</li>\n *     <li>RunWith annotations are inherited and work as if the class was annotated itself.</li>\n *     <li>The default JUnit runner does not support inner member classes,\n *         so this is only valid for custom runners that support inner member classes.</li>\n *     <li>Custom runners with support for inner classes may or may not support RunWith annotations for member\n *         classes. Please refer to the custom runner documentation.</li>\n * </ul>\n *\n * @see org.junit.runners.model.RunnerBuilder\n * @see org.junit.runner.RunWith\n * @since 4.0\n */\npublic class AnnotatedBuilder extends RunnerBuilder {\n    private static final String CONSTRUCTOR_ERROR_FORMAT = \"Custom runner class %s should have a public constructor with signature %s(Class testClass)\";\n\n    private final RunnerBuilder suiteBuilder;\n\n    public AnnotatedBuilder(RunnerBuilder suiteBuilder) {\n        this.suiteBuilder = suiteBuilder;\n    }\n\n    @Override\n    public Runner runnerForClass(Class<?> testClass) throws Exception {\n        for (Class<?> currentTestClass = testClass; currentTestClass != null;\n             currentTestClass = getEnclosingClassForNonStaticMemberClass(currentTestClass)) {\n            RunWith annotation = currentTestClass.getAnnotation(RunWith.class);\n            if (annotation != null) {\n                return buildRunner(annotation.value(), testClass);\n            }\n        }\n\n        return null;\n    }\n\n    private Class<?> getEnclosingClassForNonStaticMemberClass(Class<?> currentTestClass) {\n        if (currentTestClass.isMemberClass() && !Modifier.isStatic(currentTestClass.getModifiers())) {\n            return currentTestClass.getEnclosingClass();\n        } else {\n            return null;\n        }\n    }\n\n    public Runner buildRunner(Class<? extends Runner> runnerClass,\n            Class<?> testClass) throws Exception {\n        try {\n            return runnerClass.getConstructor(Class.class).newInstance(testClass);\n        } catch (NoSuchMethodException e) {\n            try {\n                return runnerClass.getConstructor(Class.class,\n                        RunnerBuilder.class).newInstance(testClass, suiteBuilder);\n            } catch (NoSuchMethodException e2) {\n                String simpleName = runnerClass.getSimpleName();\n                throw new InitializationError(String.format(\n                        CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName));\n            }\n        }\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/IgnoredBuilder.java",
    "content": "package org.junit.internal.builders;\n\nimport org.junit.Ignore;\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class IgnoredBuilder extends RunnerBuilder {\n    @Override\n    public Runner runnerForClass(Class<?> testClass) {\n        if (testClass.getAnnotation(Ignore.class) != null) {\n            return new IgnoredClassRunner(testClass);\n        }\n        return null;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/IgnoredClassRunner.java",
    "content": "package org.junit.internal.builders;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.RunNotifier;\n\npublic class IgnoredClassRunner extends Runner {\n    private final Class<?> clazz;\n\n    public IgnoredClassRunner(Class<?> testClass) {\n        clazz = testClass;\n    }\n\n    @Override\n    public void run(RunNotifier notifier) {\n        notifier.fireTestIgnored(getDescription());\n    }\n\n    @Override\n    public Description getDescription() {\n        return Description.createSuiteDescription(clazz);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/JUnit3Builder.java",
    "content": "package org.junit.internal.builders;\n\nimport org.junit.internal.runners.JUnit38ClassRunner;\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class JUnit3Builder extends RunnerBuilder {\n    @Override\n    public Runner runnerForClass(Class<?> testClass) throws Throwable {\n        if (isPre4Test(testClass)) {\n            return new JUnit38ClassRunner(testClass);\n        }\n        return null;\n    }\n\n    boolean isPre4Test(Class<?> testClass) {\n        return junit.framework.TestCase.class.isAssignableFrom(testClass);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/JUnit4Builder.java",
    "content": "package org.junit.internal.builders;\n\nimport org.junit.runner.Runner;\nimport org.junit.runners.JUnit4;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class JUnit4Builder extends RunnerBuilder {\n    @Override\n    public Runner runnerForClass(Class<?> testClass) throws Throwable {\n        return new JUnit4(testClass);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/NullBuilder.java",
    "content": "package org.junit.internal.builders;\n\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class NullBuilder extends RunnerBuilder {\n    @Override\n    public Runner runnerForClass(Class<?> each) throws Throwable {\n        return null;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/builders/SuiteMethodBuilder.java",
    "content": "package org.junit.internal.builders;\n\nimport org.junit.internal.runners.SuiteMethod;\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class SuiteMethodBuilder extends RunnerBuilder {\n    @Override\n    public Runner runnerForClass(Class<?> each) throws Throwable {\n        if (hasSuiteMethod(each)) {\n            return new SuiteMethod(each);\n        }\n        return null;\n    }\n\n    public boolean hasSuiteMethod(Class<?> testClass) {\n        try {\n            testClass.getMethod(\"suite\");\n        } catch (NoSuchMethodException e) {\n            return false;\n        }\n        return true;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/management/FakeRuntimeMXBean.java",
    "content": "package org.junit.internal.management;\n\nimport java.util.Collections;\nimport java.util.List;\n\n/**\n * No-op implementation of RuntimeMXBean when the platform doesn't provide it.\n */\nclass FakeRuntimeMXBean implements RuntimeMXBean {\n\n  /**\n   * {@inheritDoc}\n   *\n   * <p>Always returns an empty list.\n   */\n  public List<String> getInputArguments() {\n    return Collections.emptyList();\n  }\n\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/internal/management/FakeThreadMXBean.java",
    "content": "package org.junit.internal.management;\n\n/**\n * No-op implementation of ThreadMXBean when the platform doesn't provide it.\n */\nfinal class FakeThreadMXBean implements ThreadMXBean {\n\n  /**\n   * {@inheritDoc}\n   *\n   * <p>Always throws an {@link UnsupportedOperationException}\n   */\n  public long getThreadCpuTime(long id) {\n    throw new UnsupportedOperationException();\n  }\n\n  /**\n   * {@inheritDoc}\n   *\n   * <p>Always returns false.\n   */\n  public boolean isThreadCpuTimeSupported() {\n    return false;\n  }\n\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/internal/management/ManagementFactory.java",
    "content": "package org.junit.internal.management;\n\nimport org.junit.internal.Classes;\n\nimport java.lang.reflect.InvocationTargetException;\n\n/**\n * Reflective wrapper around {@link java.lang.management.ManagementFactory}\n */\npublic class ManagementFactory {\n  private static final class FactoryHolder {\n    private static final Class<?> MANAGEMENT_FACTORY_CLASS;\n\n    static {\n      Class<?> managementFactoryClass = null;\n      try {\n        managementFactoryClass = Classes.getClass(\"java.lang.management.ManagementFactory\");\n      } catch (ClassNotFoundException e) {\n        // do nothing, managementFactoryClass will be none on failure\n      }\n      MANAGEMENT_FACTORY_CLASS = managementFactoryClass;\n    }\n\n    static Object getBeanObject(String methodName) {\n      if (MANAGEMENT_FACTORY_CLASS != null) {\n        try {\n          return MANAGEMENT_FACTORY_CLASS.getMethod(methodName).invoke(null);\n        } catch (IllegalAccessException e) {\n          // fallthrough\n        } catch (IllegalArgumentException e) {\n          // fallthrough\n        } catch (InvocationTargetException e) {\n          // fallthrough\n        } catch (NoSuchMethodException e) {\n          // fallthrough\n        } catch (SecurityException e) {\n          // fallthrough\n        }\n      }\n      return null;\n    }\n  }\n\n  private static final class RuntimeHolder {\n    private static final RuntimeMXBean RUNTIME_MX_BEAN =\n        getBean(FactoryHolder.getBeanObject(\"getRuntimeMXBean\"));\n\n    private static final RuntimeMXBean getBean(Object runtimeMxBean) {\n      return runtimeMxBean != null\n          ? new ReflectiveRuntimeMXBean(runtimeMxBean) : new FakeRuntimeMXBean();\n    }\n  }\n\n  private static final class ThreadHolder {\n    private static final ThreadMXBean THREAD_MX_BEAN =\n        getBean(FactoryHolder.getBeanObject(\"getThreadMXBean\"));\n\n    private static final ThreadMXBean getBean(Object threadMxBean) {\n      return threadMxBean != null\n          ? new ReflectiveThreadMXBean(threadMxBean) : new FakeThreadMXBean();\n    }\n  }\n\n  /**\n   * @see java.lang.management.ManagementFactory#getRuntimeMXBean()\n   */\n  public static RuntimeMXBean getRuntimeMXBean() {\n    return RuntimeHolder.RUNTIME_MX_BEAN;\n  }\n\n  /**\n   * @see java.lang.management.ManagementFactory#getThreadMXBean()\n   */\n  public static ThreadMXBean getThreadMXBean() {\n    return ThreadHolder.THREAD_MX_BEAN;\n  }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/management/ReflectiveRuntimeMXBean.java",
    "content": "package org.junit.internal.management;\n\nimport org.junit.internal.Classes;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.util.Collections;\nimport java.util.List;\n\n/**\n * Implementation of {@link RuntimeMXBean} using the JVM reflectively.\n */\nfinal class ReflectiveRuntimeMXBean implements RuntimeMXBean {\n  private final Object runtimeMxBean;\n\n  private static final class Holder {\n    private static final Method getInputArgumentsMethod;\n    static {\n      Method inputArguments = null;\n      try {\n        Class<?> threadMXBeanClass = Classes.getClass(\"java.lang.management.RuntimeMXBean\");\n        inputArguments = threadMXBeanClass.getMethod(\"getInputArguments\");\n      } catch (ClassNotFoundException e) {\n        // do nothing, input arguments will be null on failure\n      } catch (NoSuchMethodException e) {\n        // do nothing, input arguments will be null on failure\n      } catch (SecurityException e) {\n        // do nothing, input arguments will be null on failure\n      }\n      getInputArgumentsMethod = inputArguments;\n    }\n  }\n\n  ReflectiveRuntimeMXBean(Object runtimeMxBean) {\n    super();\n    this.runtimeMxBean = runtimeMxBean;\n  }\n\n  /**\n   * {@inheritDoc}\n   */\n  @SuppressWarnings(\"unchecked\")\n  public List<String> getInputArguments() {\n    if (Holder.getInputArgumentsMethod != null) {\n      try {\n        return (List<String>) Holder.getInputArgumentsMethod.invoke(runtimeMxBean);\n      } catch (ClassCastException e) { // no multi-catch with source level 6\n        // fallthrough\n      } catch (IllegalAccessException e) {\n        // fallthrough\n      } catch (IllegalArgumentException e) {\n        // fallthrough\n      } catch (InvocationTargetException e) {\n        // fallthrough\n      }\n    }\n    return Collections.emptyList();\n  }\n\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/internal/management/ReflectiveThreadMXBean.java",
    "content": "package org.junit.internal.management;\n\nimport org.junit.internal.Classes;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\n\n/**\n * Implementation of {@link ThreadMXBean} using the JVM reflectively.\n */\nfinal class ReflectiveThreadMXBean implements ThreadMXBean {\n  private final Object threadMxBean;\n\n\n  private static final class Holder {\n    static final Method getThreadCpuTimeMethod;\n    static final Method isThreadCpuTimeSupportedMethod;\n\n    private static final String FAILURE_MESSAGE = \"Unable to access ThreadMXBean\";\n\n    static {\n      Method threadCpuTime = null;\n      Method threadCpuTimeSupported = null;\n      try {\n        Class<?> threadMXBeanClass = Classes.getClass(\"java.lang.management.ThreadMXBean\");\n        threadCpuTime = threadMXBeanClass.getMethod(\"getThreadCpuTime\", long.class);\n        threadCpuTimeSupported = threadMXBeanClass.getMethod(\"isThreadCpuTimeSupported\");\n      } catch (ClassNotFoundException e) {\n        // do nothing, the methods will be null on failure\n      } catch (NoSuchMethodException e) {\n        // do nothing, the methods will be null on failure\n      } catch (SecurityException e) {\n        // do nothing, the methods will be null on failure\n      }\n      getThreadCpuTimeMethod = threadCpuTime;\n      isThreadCpuTimeSupportedMethod = threadCpuTimeSupported;\n    }\n  }\n\n  ReflectiveThreadMXBean(Object threadMxBean) {\n    super();\n    this.threadMxBean = threadMxBean;\n  }\n\n  /**\n   * {@inheritDoc}\n   */\n  public long getThreadCpuTime(long id) {\n    if (Holder.getThreadCpuTimeMethod != null) {\n      Exception error = null;\n      try {\n        return (Long) Holder.getThreadCpuTimeMethod.invoke(threadMxBean, id);\n      } catch (ClassCastException e) {\n        error = e;\n        // fallthrough\n      } catch (IllegalAccessException e) {\n        error = e;\n        // fallthrough\n      } catch (IllegalArgumentException e) {\n        error = e;\n        // fallthrough\n      } catch (InvocationTargetException e) {\n        error = e;\n        // fallthrough\n      }\n      throw new UnsupportedOperationException(Holder.FAILURE_MESSAGE, error);\n    }\n    throw new UnsupportedOperationException(Holder.FAILURE_MESSAGE);\n  }\n\n  /**\n   * {@inheritDoc}\n   */\n  public boolean isThreadCpuTimeSupported() {\n    if (Holder.isThreadCpuTimeSupportedMethod != null) {\n      try {\n        return (Boolean) Holder.isThreadCpuTimeSupportedMethod.invoke(threadMxBean);\n      } catch (ClassCastException e) {\n        // fallthrough\n      } catch (IllegalAccessException e) {\n        // fallthrough\n      } catch (IllegalArgumentException e) {\n        // fallthrough\n      } catch (InvocationTargetException e) {\n        // fallthrough\n      }\n    }\n    return false;\n  }\n\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/internal/management/RuntimeMXBean.java",
    "content": "package org.junit.internal.management;\n\nimport java.util.List;\n\n/**\n * Wrapper for {@link java.lang.management.RuntimeMXBean}.\n */\npublic interface RuntimeMXBean {\n\n  /**\n   * @see java.lang.management.RuntimeMXBean#getInputArguments()\n   */\n  List<String> getInputArguments();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/management/ThreadMXBean.java",
    "content": "package org.junit.internal.management;\n\n/**\n * Wrapper for {@link java.lang.management.ThreadMXBean}.\n */\npublic interface ThreadMXBean {\n  /**\n   * @see java.lang.management.ThreadMXBean#getThreadCpuTime(long)\n   */\n  long getThreadCpuTime(long id);\n\n  /**\n   * @see java.lang.management.ThreadMXBean#isThreadCpuTimeSupported()\n   */\n  boolean isThreadCpuTimeSupported();\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/internal/matchers/StacktracePrintingMatcher.java",
    "content": "package org.junit.internal.matchers;\n\nimport org.hamcrest.Description;\nimport org.hamcrest.Factory;\nimport org.hamcrest.Matcher;\n\nimport org.junit.internal.Throwables;\n\n/**\n * A matcher that delegates to throwableMatcher and in addition appends the\n * stacktrace of the actual Throwable in case of a mismatch.\n */\npublic class StacktracePrintingMatcher<T extends Throwable> extends\n        org.hamcrest.TypeSafeMatcher<T> {\n\n    private final Matcher<T> throwableMatcher;\n\n    public StacktracePrintingMatcher(Matcher<T> throwableMatcher) {\n        this.throwableMatcher = throwableMatcher;\n    }\n\n    public void describeTo(Description description) {\n        throwableMatcher.describeTo(description);\n    }\n\n    @Override\n    protected boolean matchesSafely(T item) {\n        return throwableMatcher.matches(item);\n    }\n\n    @Override\n    protected void describeMismatchSafely(T item, Description description) {\n        throwableMatcher.describeMismatch(item, description);\n        description.appendText(\"\\nStacktrace was: \");\n        description.appendText(readStacktrace(item));\n    }\n\n    private String readStacktrace(Throwable throwable) {\n        return Throwables.getStacktrace(throwable);\n    }\n\n    @Factory\n    public static <T extends Throwable> Matcher<T> isThrowable(\n            Matcher<T> throwableMatcher) {\n        return new StacktracePrintingMatcher<T>(throwableMatcher);\n    }\n\n    @Factory\n    public static <T extends Exception> Matcher<T> isException(\n            Matcher<T> exceptionMatcher) {\n        return new StacktracePrintingMatcher<T>(exceptionMatcher);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/matchers/ThrowableCauseMatcher.java",
    "content": "package org.junit.internal.matchers;\n\nimport org.hamcrest.Description;\nimport org.hamcrest.Factory;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.TypeSafeMatcher;\n\n/**\n * A matcher that applies a delegate matcher to the cause of the current Throwable, returning the result of that\n * match.\n *\n * @param <T> the type of the throwable being matched\n */\npublic class ThrowableCauseMatcher<T extends Throwable> extends\n        TypeSafeMatcher<T> {\n\n    private final Matcher<?> causeMatcher;\n\n    public ThrowableCauseMatcher(Matcher<?> causeMatcher) {\n        this.causeMatcher = causeMatcher;\n    }\n\n    public void describeTo(Description description) {\n        description.appendText(\"exception with cause \");\n        description.appendDescriptionOf(causeMatcher);\n    }\n\n    @Override\n    protected boolean matchesSafely(T item) {\n        return causeMatcher.matches(item.getCause());\n    }\n\n    @Override\n    protected void describeMismatchSafely(T item, Description description) {\n        description.appendText(\"cause \");\n        causeMatcher.describeMismatch(item.getCause(), description);\n    }\n\n    /**\n     * Returns a matcher that verifies that the outer exception has a cause for which the supplied matcher\n     * evaluates to true.\n     *\n     * @param matcher to apply to the cause of the outer exception\n     * @param <T> type of the outer exception\n     */\n    @Factory\n    public static <T extends Throwable> Matcher<T> hasCause(final Matcher<?> matcher) {\n        return new ThrowableCauseMatcher<T>(matcher);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/matchers/ThrowableMessageMatcher.java",
    "content": "package org.junit.internal.matchers;\n\nimport org.hamcrest.Description;\nimport org.hamcrest.Factory;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.TypeSafeMatcher;\n\npublic class ThrowableMessageMatcher<T extends Throwable> extends\n        TypeSafeMatcher<T> {\n\n    private final Matcher<String> matcher;\n\n    public ThrowableMessageMatcher(Matcher<String> matcher) {\n        this.matcher = matcher;\n    }\n\n    public void describeTo(Description description) {\n        description.appendText(\"exception with message \");\n        description.appendDescriptionOf(matcher);\n    }\n\n    @Override\n    protected boolean matchesSafely(T item) {\n        return matcher.matches(item.getMessage());\n    }\n\n    @Override\n    protected void describeMismatchSafely(T item, Description description) {\n        description.appendText(\"message \");\n        matcher.describeMismatch(item.getMessage(), description);\n    }\n\n    @Factory\n    public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) {\n        return new ThrowableMessageMatcher<T>(matcher);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/matchers/TypeSafeMatcher.java",
    "content": "package org.junit.internal.matchers;\n\nimport java.lang.reflect.Method;\n\nimport org.hamcrest.BaseMatcher;\nimport org.junit.internal.MethodSorter;\n\n/**\n * Convenient base class for Matchers that require a non-null value of a specific type.\n * This simply implements the null check, checks the type and then casts.\n *\n * @author Joe Walnes\n * @deprecated Please use {@link org.hamcrest.TypeSafeMatcher}.\n */\n@Deprecated\npublic abstract class TypeSafeMatcher<T> extends BaseMatcher<T> {\n\n    private Class<?> expectedType;\n\n    /**\n     * Subclasses should implement this. The item will already have been checked for\n     * the specific type and will never be null.\n     */\n    public abstract boolean matchesSafely(T item);\n\n    protected TypeSafeMatcher() {\n        expectedType = findExpectedType(getClass());\n    }\n\n    private static Class<?> findExpectedType(Class<?> fromClass) {\n        for (Class<?> c = fromClass; c != Object.class; c = c.getSuperclass()) {\n            for (Method method : MethodSorter.getDeclaredMethods(c)) {\n                if (isMatchesSafelyMethod(method)) {\n                    return method.getParameterTypes()[0];\n                }\n            }\n        }\n\n        throw new Error(\"Cannot determine correct type for matchesSafely() method.\");\n    }\n\n    private static boolean isMatchesSafelyMethod(Method method) {\n        return \"matchesSafely\".equals(method.getName())\n                && method.getParameterTypes().length == 1\n                && !method.isSynthetic();\n    }\n\n    protected TypeSafeMatcher(Class<T> expectedType) {\n        this.expectedType = expectedType;\n    }\n\n    /**\n     * Method made final to prevent accidental override.\n     * If you need to override this, there's no point on extending TypeSafeMatcher.\n     * Instead, extend the {@link BaseMatcher}.\n     */\n    @SuppressWarnings({\"unchecked\"})\n    public final boolean matches(Object item) {\n        return item != null\n                && expectedType.isInstance(item)\n                && matchesSafely((T) item);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/requests/ClassRequest.java",
    "content": "package org.junit.internal.requests;\n\nimport org.junit.internal.builders.AllDefaultPossibilitiesBuilder;\nimport org.junit.internal.builders.SuiteMethodBuilder;\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class ClassRequest extends MemoizingRequest {\n    /*\n     * We have to use the f prefix, because IntelliJ's JUnit4IdeaTestRunner uses\n     * reflection to access this field. See\n     * https://github.com/junit-team/junit4/issues/960\n     */\n    private final Class<?> fTestClass;\n    private final boolean canUseSuiteMethod;\n\n    public ClassRequest(Class<?> testClass, boolean canUseSuiteMethod) {\n        this.fTestClass = testClass;\n        this.canUseSuiteMethod = canUseSuiteMethod;\n    }\n\n    public ClassRequest(Class<?> testClass) {\n        this(testClass, true);\n    }\n\n    @Override\n    protected Runner createRunner() {\n        return new CustomAllDefaultPossibilitiesBuilder().safeRunnerForClass(fTestClass);\n    }\n\n    private class CustomAllDefaultPossibilitiesBuilder extends AllDefaultPossibilitiesBuilder {\n\n        @Override\n        protected RunnerBuilder suiteMethodBuilder() {\n            return new CustomSuiteMethodBuilder();\n        }\n    }\n\n    /*\n     * Customization of {@link SuiteMethodBuilder} that prevents use of the\n     * suite method when creating a runner for fTestClass when canUseSuiteMethod\n     * is false.\n     */\n    private class CustomSuiteMethodBuilder extends SuiteMethodBuilder {\n\n        @Override\n        public Runner runnerForClass(Class<?> testClass) throws Throwable {\n            if (testClass == fTestClass && !canUseSuiteMethod) {\n                return null;\n            }\n            return super.runnerForClass(testClass);\n        }\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/requests/FilterRequest.java",
    "content": "package org.junit.internal.requests;\n\nimport org.junit.internal.runners.ErrorReportingRunner;\nimport org.junit.runner.Request;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.NoTestsRemainException;\n\n/**\n * A filtered {@link Request}.\n */\npublic final class FilterRequest extends Request {\n    private final Request request;\n    /*\n     * We have to use the f prefix, because IntelliJ's JUnit4IdeaTestRunner uses\n     * reflection to access this field. See\n     * https://github.com/junit-team/junit4/issues/960\n     */\n    private final Filter fFilter;\n\n    /**\n     * Creates a filtered Request\n     *\n     * @param request a {@link Request} describing your Tests\n     * @param filter {@link Filter} to apply to the Tests described in\n     * <code>request</code>\n     */\n    public FilterRequest(Request request, Filter filter) {\n        this.request = request;\n        this.fFilter = filter;\n    }\n\n    @Override\n    public Runner getRunner() {\n        try {\n            Runner runner = request.getRunner();\n            fFilter.apply(runner);\n            return runner;\n        } catch (NoTestsRemainException e) {\n            return new ErrorReportingRunner(Filter.class, new Exception(String\n                    .format(\"No tests found matching %s from %s\", fFilter\n                            .describe(), request.toString())));\n        }\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/requests/MemoizingRequest.java",
    "content": "package org.junit.internal.requests;\n\nimport java.util.concurrent.locks.Lock;\nimport java.util.concurrent.locks.ReentrantLock;\n\nimport org.junit.runner.Request;\nimport org.junit.runner.Runner;\n\nabstract class MemoizingRequest extends Request {\n    private final Lock runnerLock = new ReentrantLock();\n    private volatile Runner runner;\n\n    @Override\n    public final Runner getRunner() {\n        if (runner == null) {\n            runnerLock.lock();\n            try {\n                if (runner == null) {\n                    runner = createRunner();\n                }\n            } finally {\n                runnerLock.unlock();\n            }\n        }\n        return runner;\n    }\n\n    /** Creates the {@link Runner} to return from {@link #getRunner()}. Called at most once. */\n    protected abstract Runner createRunner();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/requests/OrderingRequest.java",
    "content": "package org.junit.internal.requests;\n\nimport org.junit.internal.runners.ErrorReportingRunner;\nimport org.junit.runner.Request;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.InvalidOrderingException;\nimport org.junit.runner.manipulation.Ordering;\n\n/** @since 4.13 */\npublic class OrderingRequest extends MemoizingRequest {\n    private final Request request;\n    private final Ordering ordering;\n\n    public OrderingRequest(Request request, Ordering ordering) {\n        this.request = request;\n        this.ordering = ordering;\n    }\n\n    @Override\n    protected Runner createRunner() {\n        Runner runner = request.getRunner();\n        try {\n            ordering.apply(runner);\n        } catch (InvalidOrderingException e) {\n            return new ErrorReportingRunner(ordering.getClass(), e);\n        }\n        return runner;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/requests/SortingRequest.java",
    "content": "package org.junit.internal.requests;\n\nimport java.util.Comparator;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Request;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Sorter;\n\npublic class SortingRequest extends Request {\n    private final Request request;\n    private final Comparator<Description> comparator;\n\n    public SortingRequest(Request request, Comparator<Description> comparator) {\n        this.request = request;\n        this.comparator = comparator;\n    }\n\n    @Override\n    public Runner getRunner() {\n        Runner runner = request.getRunner();\n        new Sorter(comparator).apply(runner);\n        return runner;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/requests/package-info.java",
    "content": "/**\n * Provides implementations of {@link org.junit.runner.Request}.\n *\n * @since 4.0\n */\npackage org.junit.internal.requests;"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/ClassRoadie.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.util.List;\n\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\n/**\n * @deprecated Included for backwards compatibility with JUnit 4.4. Will be\n *             removed in the next major release. Please use\n *             {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.\n */\n@Deprecated\npublic class ClassRoadie {\n    private RunNotifier notifier;\n    private TestClass testClass;\n    private Description description;\n    private final Runnable runnable;\n\n    public ClassRoadie(RunNotifier notifier, TestClass testClass,\n            Description description, Runnable runnable) {\n        this.notifier = notifier;\n        this.testClass = testClass;\n        this.description = description;\n        this.runnable = runnable;\n    }\n\n    protected void runUnprotected() {\n        runnable.run();\n    }\n\n    protected void addFailure(Throwable targetException) {\n        notifier.fireTestFailure(new Failure(description, targetException));\n    }\n\n    public void runProtected() {\n        try {\n            runBefores();\n            runUnprotected();\n        } catch (FailedBefore e) {\n        } finally {\n            runAfters();\n        }\n    }\n\n    private void runBefores() throws FailedBefore {\n        try {\n            try {\n                List<Method> befores = testClass.getBefores();\n                for (Method before : befores) {\n                    before.invoke(null);\n                }\n            } catch (InvocationTargetException e) {\n                throw e.getTargetException();\n            }\n        } catch (AssumptionViolatedException e) {\n            throw new FailedBefore();\n        } catch (Throwable e) {\n            addFailure(e);\n            throw new FailedBefore();\n        }\n    }\n\n    private void runAfters() {\n        List<Method> afters = testClass.getAfters();\n        for (Method after : afters) {\n            try {\n                after.invoke(null);\n            } catch (InvocationTargetException e) {\n                addFailure(e.getTargetException());\n            } catch (Throwable e) {\n                addFailure(e); // Untested, but seems impossible\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/ErrorReportingRunner.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.List;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.InvalidTestClassError;\nimport org.junit.runners.model.InitializationError;\n\nimport static java.util.Collections.singletonList;\n\npublic class ErrorReportingRunner extends Runner {\n    private final List<Throwable> causes;\n\n    private final String classNames;\n\n    public ErrorReportingRunner(Class<?> testClass, Throwable cause) {\n        this(cause, testClass);\n    }\n    \n    public ErrorReportingRunner(Throwable cause, Class<?>... testClasses) {\n        if (testClasses == null || testClasses.length == 0) {\n            throw new NullPointerException(\"Test classes cannot be null or empty\");\n        }\n        for (Class<?> testClass : testClasses) {\n            if (testClass == null) {\n                throw new NullPointerException(\"Test class cannot be null\");\n            }\n        }\n        classNames = getClassNames(testClasses);\n        causes = getCauses(cause);\n    }\n    \n    @Override\n    public Description getDescription() {\n        Description description = Description.createSuiteDescription(classNames);\n        /*\n         * Use an indexed loop instead of a foreach: That avoids declaring a variable that some\n         * tools will see as \"unused.\"\n         */\n        for (int i = 0; i < causes.size(); i++) {\n            description.addChild(describeCause());\n        }\n        return description;\n    }\n\n    @Override\n    public void run(RunNotifier notifier) {\n        for (Throwable each : causes) {\n            runCause(each, notifier);\n        }\n    }\n\n    private String getClassNames(Class<?>... testClasses) {\n        final StringBuilder builder = new StringBuilder();\n        for (Class<?> testClass : testClasses) {\n            if (builder.length() != 0) {\n                builder.append(\", \");\n            }\n            builder.append(testClass.getName());\n        }\n        return builder.toString();\n    }\n\n    @SuppressWarnings(\"deprecation\")\n    private List<Throwable> getCauses(Throwable cause) {\n        if (cause instanceof InvocationTargetException) {\n            return getCauses(cause.getCause());\n        }\n        if (cause instanceof InvalidTestClassError) {\n            return singletonList(cause);\n        }\n        if (cause instanceof InitializationError) {\n            return ((InitializationError) cause).getCauses();\n        }\n        if (cause instanceof org.junit.internal.runners.InitializationError) {\n            return ((org.junit.internal.runners.InitializationError) cause)\n                    .getCauses();\n        }\n        return singletonList(cause);\n    }\n\n    private Description describeCause() {\n        return Description.createTestDescription(classNames, \"initializationError\");\n    }\n\n    private void runCause(Throwable child, RunNotifier notifier) {\n        Description description = describeCause();\n        notifier.fireTestStarted(description);\n        notifier.fireTestFailure(new Failure(description, child));\n        notifier.fireTestFinished(description);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/FailedBefore.java",
    "content": "package org.junit.internal.runners;\n\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\n/**\n * @deprecated Included for backwards compatibility with JUnit 4.4. Will be\n *             removed in the next major release. Please use\n *             {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.\n */\n@Deprecated\nclass FailedBefore extends Exception {\n    private static final long serialVersionUID = 1L;\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/InitializationError.java",
    "content": "package org.junit.internal.runners;\n\nimport java.util.Arrays;\nimport java.util.List;\n\n/**\n * Use the published version:\n * {@link org.junit.runners.model.InitializationError}\n * This may disappear as soon as 1 April 2009\n */\n@Deprecated\npublic class InitializationError extends Exception {\n    private static final long serialVersionUID = 1L;\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final List<Throwable> fErrors;\n\n    public InitializationError(List<Throwable> errors) {\n        this.fErrors = errors;\n    }\n\n    public InitializationError(Throwable... errors) {\n        this(Arrays.asList(errors));\n    }\n\n    public InitializationError(String string) {\n        this(new Exception(string));\n    }\n\n    public List<Throwable> getCauses() {\n        return fErrors;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/JUnit38ClassRunner.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Method;\n\nimport junit.extensions.TestDecorator;\nimport junit.framework.AssertionFailedError;\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestListener;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\nimport org.junit.runner.Describable;\nimport org.junit.runner.Description;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.Filterable;\nimport org.junit.runner.manipulation.Orderer;\nimport org.junit.runner.manipulation.InvalidOrderingException;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runner.manipulation.Orderable;\nimport org.junit.runner.manipulation.Sortable;\nimport org.junit.runner.manipulation.Sorter;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\n\npublic class JUnit38ClassRunner extends Runner implements Filterable, Orderable {\n    private static final class OldTestClassAdaptingListener implements\n            TestListener {\n        private final RunNotifier notifier;\n\n        private OldTestClassAdaptingListener(RunNotifier notifier) {\n            this.notifier = notifier;\n        }\n\n        public void endTest(Test test) {\n            notifier.fireTestFinished(asDescription(test));\n        }\n\n        public void startTest(Test test) {\n            notifier.fireTestStarted(asDescription(test));\n        }\n\n        // Implement junit.framework.TestListener\n        public void addError(Test test, Throwable e) {\n            Failure failure = new Failure(asDescription(test), e);\n            notifier.fireTestFailure(failure);\n        }\n\n        private Description asDescription(Test test) {\n            if (test instanceof Describable) {\n                Describable facade = (Describable) test;\n                return facade.getDescription();\n            }\n            return Description.createTestDescription(getEffectiveClass(test), getName(test));\n        }\n\n        private Class<? extends Test> getEffectiveClass(Test test) {\n            return test.getClass();\n        }\n\n        private String getName(Test test) {\n            if (test instanceof TestCase) {\n                return ((TestCase) test).getName();\n            } else {\n                return test.toString();\n            }\n        }\n\n        public void addFailure(Test test, AssertionFailedError t) {\n            addError(test, t);\n        }\n    }\n\n    private volatile Test test;\n\n    public JUnit38ClassRunner(Class<?> klass) {\n        this(new TestSuite(klass.asSubclass(TestCase.class)));\n    }\n\n    public JUnit38ClassRunner(Test test) {\n        super();\n        setTest(test);\n    }\n\n    @Override\n    public void run(RunNotifier notifier) {\n        TestResult result = new TestResult();\n        result.addListener(createAdaptingListener(notifier));\n        getTest().run(result);\n    }\n\n    public TestListener createAdaptingListener(final RunNotifier notifier) {\n        return new OldTestClassAdaptingListener(notifier);\n    }\n\n    @Override\n    public Description getDescription() {\n        return makeDescription(getTest());\n    }\n\n    private static Description makeDescription(Test test) {\n        if (test instanceof TestCase) {\n            TestCase tc = (TestCase) test;\n            return Description.createTestDescription(tc.getClass(), tc.getName(),\n                    getAnnotations(tc));\n        } else if (test instanceof TestSuite) {\n            TestSuite ts = (TestSuite) test;\n            String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();\n            Description description = Description.createSuiteDescription(name);\n            int n = ts.testCount();\n            for (int i = 0; i < n; i++) {\n                Description made = makeDescription(ts.testAt(i));\n                description.addChild(made);\n            }\n            return description;\n        } else if (test instanceof Describable) {\n            Describable adapter = (Describable) test;\n            return adapter.getDescription();\n        } else if (test instanceof TestDecorator) {\n            TestDecorator decorator = (TestDecorator) test;\n            return makeDescription(decorator.getTest());\n        } else {\n            // This is the best we can do in this case\n            return Description.createSuiteDescription(test.getClass());\n        }\n    }\n\n    /**\n     * Get the annotations associated with given TestCase.\n     * @param test the TestCase.\n     */\n    private static Annotation[] getAnnotations(TestCase test) {\n        try {\n            Method m = test.getClass().getMethod(test.getName());\n            return m.getDeclaredAnnotations();\n        } catch (SecurityException e) {\n        } catch (NoSuchMethodException e) {\n        }\n        return new Annotation[0];\n    }\n\n    private static String createSuiteDescription(TestSuite ts) {\n        int count = ts.countTestCases();\n        String example = count == 0 ? \"\" : String.format(\" [example: %s]\", ts.testAt(0));\n        return String.format(\"TestSuite with %s tests%s\", count, example);\n    }\n\n    public void filter(Filter filter) throws NoTestsRemainException {\n        if (getTest() instanceof Filterable) {\n            Filterable adapter = (Filterable) getTest();\n            adapter.filter(filter);\n        } else if (getTest() instanceof TestSuite) {\n            TestSuite suite = (TestSuite) getTest();\n            TestSuite filtered = new TestSuite(suite.getName());\n            int n = suite.testCount();\n            for (int i = 0; i < n; i++) {\n                Test test = suite.testAt(i);\n                if (filter.shouldRun(makeDescription(test))) {\n                    filtered.addTest(test);\n                }\n            }\n            setTest(filtered);\n            if (filtered.testCount() == 0) {\n                throw new NoTestsRemainException();\n            }\n        }\n    }\n\n    public void sort(Sorter sorter) {\n        if (getTest() instanceof Sortable) {\n            Sortable adapter = (Sortable) getTest();\n            adapter.sort(sorter);\n        }\n    }\n\n    /**\n     * {@inheritDoc}\n     *\n     * @since 4.13\n     */\n    public void order(Orderer orderer) throws InvalidOrderingException {\n        if (getTest() instanceof Orderable) {\n            Orderable adapter = (Orderable) getTest();\n            adapter.order(orderer);\n        }\n    }\n\n    private void setTest(Test test) {\n        this.test = test;\n    }\n\n    private Test getTest() {\n        return test;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/JUnit4ClassRunner.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.Filterable;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runner.manipulation.Sortable;\nimport org.junit.runner.manipulation.Sorter;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\n/**\n * @deprecated Included for backwards compatibility with JUnit 4.4. Will be\n *             removed in the next major release. Please use\n *             {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.\n */\n@Deprecated\npublic class JUnit4ClassRunner extends Runner implements Filterable, Sortable {\n    private final List<Method> testMethods;\n    private TestClass testClass;\n\n    public JUnit4ClassRunner(Class<?> klass) throws InitializationError {\n        testClass = new TestClass(klass);\n        testMethods = getTestMethods();\n        validate();\n    }\n\n    protected List<Method> getTestMethods() {\n        return testClass.getTestMethods();\n    }\n\n    protected void validate() throws InitializationError {\n        MethodValidator methodValidator = new MethodValidator(testClass);\n        methodValidator.validateMethodsForDefaultRunner();\n        methodValidator.assertValid();\n    }\n\n    @Override\n    public void run(final RunNotifier notifier) {\n        new ClassRoadie(notifier, testClass, getDescription(), new Runnable() {\n            public void run() {\n                runMethods(notifier);\n            }\n        }).runProtected();\n    }\n\n    protected void runMethods(final RunNotifier notifier) {\n        for (Method method : testMethods) {\n            invokeTestMethod(method, notifier);\n        }\n    }\n\n    @Override\n    public Description getDescription() {\n        Description spec = Description.createSuiteDescription(getName(), classAnnotations());\n        List<Method> testMethods = this.testMethods;\n        for (Method method : testMethods) {\n            spec.addChild(methodDescription(method));\n        }\n        return spec;\n    }\n\n    protected Annotation[] classAnnotations() {\n        return testClass.getJavaClass().getAnnotations();\n    }\n\n    protected String getName() {\n        return getTestClass().getName();\n    }\n\n    protected Object createTest() throws Exception {\n        return getTestClass().getConstructor().newInstance();\n    }\n\n    protected void invokeTestMethod(Method method, RunNotifier notifier) {\n        Description description = methodDescription(method);\n        Object test;\n        try {\n            test = createTest();\n        } catch (InvocationTargetException e) {\n            testAborted(notifier, description, e.getCause());\n            return;\n        } catch (Exception e) {\n            testAborted(notifier, description, e);\n            return;\n        }\n        TestMethod testMethod = wrapMethod(method);\n        new MethodRoadie(test, testMethod, notifier, description).run();\n    }\n\n    private void testAborted(RunNotifier notifier, Description description,\n            Throwable e) {\n        notifier.fireTestStarted(description);\n        notifier.fireTestFailure(new Failure(description, e));\n        notifier.fireTestFinished(description);\n    }\n\n    protected TestMethod wrapMethod(Method method) {\n        return new TestMethod(method, testClass);\n    }\n\n    protected String testName(Method method) {\n        return method.getName();\n    }\n\n    protected Description methodDescription(Method method) {\n        return Description.createTestDescription(getTestClass().getJavaClass(), testName(method), testAnnotations(method));\n    }\n\n    protected Annotation[] testAnnotations(Method method) {\n        return method.getAnnotations();\n    }\n\n    public void filter(Filter filter) throws NoTestsRemainException {\n        for (Iterator<Method> iter = testMethods.iterator(); iter.hasNext(); ) {\n            Method method = iter.next();\n            if (!filter.shouldRun(methodDescription(method))) {\n                iter.remove();\n            }\n        }\n        if (testMethods.isEmpty()) {\n            throw new NoTestsRemainException();\n        }\n    }\n\n    public void sort(final Sorter sorter) {\n        Collections.sort(testMethods, new Comparator<Method>() {\n            public int compare(Method o1, Method o2) {\n                return sorter.compare(methodDescription(o1), methodDescription(o2));\n            }\n        });\n    }\n\n    protected TestClass getTestClass() {\n        return testClass;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/MethodRoadie.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.util.List;\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.Future;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.TimeoutException;\n\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.model.TestTimedOutException;\n\n/**\n * @deprecated Included for backwards compatibility with JUnit 4.4. Will be\n *             removed in the next major release. Please use\n *             {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.\n */\n@Deprecated\npublic class MethodRoadie {\n    private final Object test;\n    private final RunNotifier notifier;\n    private final Description description;\n    private TestMethod testMethod;\n\n    public MethodRoadie(Object test, TestMethod method, RunNotifier notifier, Description description) {\n        this.test = test;\n        this.notifier = notifier;\n        this.description = description;\n        testMethod = method;\n    }\n\n    public void run() {\n        if (testMethod.isIgnored()) {\n            notifier.fireTestIgnored(description);\n            return;\n        }\n        notifier.fireTestStarted(description);\n        try {\n            long timeout = testMethod.getTimeout();\n            if (timeout > 0) {\n                runWithTimeout(timeout);\n            } else {\n                runTest();\n            }\n        } finally {\n            notifier.fireTestFinished(description);\n        }\n    }\n\n    private void runWithTimeout(final long timeout) {\n        runBeforesThenTestThenAfters(new Runnable() {\n\n            public void run() {\n                ExecutorService service = Executors.newSingleThreadExecutor();\n                Callable<Object> callable = new Callable<Object>() {\n                    public Object call() throws Exception {\n                        runTestMethod();\n                        return null;\n                    }\n                };\n                Future<Object> result = service.submit(callable);\n                service.shutdown();\n                try {\n                    boolean terminated = service.awaitTermination(timeout,\n                            TimeUnit.MILLISECONDS);\n                    if (!terminated) {\n                        service.shutdownNow();\n                    }\n                    result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation\n                } catch (TimeoutException e) {\n                    addFailure(new TestTimedOutException(timeout, TimeUnit.MILLISECONDS));\n                } catch (Exception e) {\n                    addFailure(e);\n                }\n            }\n        });\n    }\n\n    public void runTest() {\n        runBeforesThenTestThenAfters(new Runnable() {\n            public void run() {\n                runTestMethod();\n            }\n        });\n    }\n\n    public void runBeforesThenTestThenAfters(Runnable test) {\n        try {\n            runBefores();\n            test.run();\n        } catch (FailedBefore e) {\n        } catch (Exception e) {\n            throw new RuntimeException(\"test should never throw an exception to this level\");\n        } finally {\n            runAfters();\n        }\n    }\n\n    protected void runTestMethod() {\n        try {\n            testMethod.invoke(test);\n            if (testMethod.expectsException()) {\n                addFailure(new AssertionError(\"Expected exception: \" + testMethod.getExpectedException().getName()));\n            }\n        } catch (InvocationTargetException e) {\n            Throwable actual = e.getTargetException();\n            if (actual instanceof AssumptionViolatedException) {\n                return;\n            } else if (!testMethod.expectsException()) {\n                addFailure(actual);\n            } else if (testMethod.isUnexpected(actual)) {\n                String message = \"Unexpected exception, expected<\" + testMethod.getExpectedException().getName() + \"> but was<\"\n                        + actual.getClass().getName() + \">\";\n                addFailure(new Exception(message, actual));\n            }\n        } catch (Throwable e) {\n            addFailure(e);\n        }\n    }\n\n    private void runBefores() throws FailedBefore {\n        try {\n            try {\n                List<Method> befores = testMethod.getBefores();\n                for (Method before : befores) {\n                    before.invoke(test);\n                }\n            } catch (InvocationTargetException e) {\n                throw e.getTargetException();\n            }\n        } catch (AssumptionViolatedException e) {\n            throw new FailedBefore();\n        } catch (Throwable e) {\n            addFailure(e);\n            throw new FailedBefore();\n        }\n    }\n\n    private void runAfters() {\n        List<Method> afters = testMethod.getAfters();\n        for (Method after : afters) {\n            try {\n                after.invoke(test);\n            } catch (InvocationTargetException e) {\n                addFailure(e.getTargetException());\n            } catch (Throwable e) {\n                addFailure(e); // Untested, but seems impossible\n            }\n        }\n    }\n\n    protected void addFailure(Throwable e) {\n        notifier.fireTestFailure(new Failure(description, e));\n    }\n}\n\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/MethodValidator.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\n/**\n * @deprecated Included for backwards compatibility with JUnit 4.4. Will be\n *             removed in the next major release. Please use\n *             {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.\n */\n@Deprecated\npublic class MethodValidator {\n\n    private final List<Throwable> errors = new ArrayList<Throwable>();\n\n    private TestClass testClass;\n\n    public MethodValidator(TestClass testClass) {\n        this.testClass = testClass;\n    }\n\n    public void validateInstanceMethods() {\n        validateTestMethods(After.class, false);\n        validateTestMethods(Before.class, false);\n        validateTestMethods(Test.class, false);\n\n        List<Method> methods = testClass.getAnnotatedMethods(Test.class);\n        if (methods.size() == 0) {\n            errors.add(new Exception(\"No runnable methods\"));\n        }\n    }\n\n    public void validateStaticMethods() {\n        validateTestMethods(BeforeClass.class, true);\n        validateTestMethods(AfterClass.class, true);\n    }\n\n    public List<Throwable> validateMethodsForDefaultRunner() {\n        validateNoArgConstructor();\n        validateStaticMethods();\n        validateInstanceMethods();\n        return errors;\n    }\n\n    public void assertValid() throws InitializationError {\n        if (!errors.isEmpty()) {\n            throw new InitializationError(errors);\n        }\n    }\n\n    public void validateNoArgConstructor() {\n        try {\n            testClass.getConstructor();\n        } catch (Exception e) {\n            errors.add(new Exception(\"Test class should have public zero-argument constructor\", e));\n        }\n    }\n\n    private void validateTestMethods(Class<? extends Annotation> annotation,\n            boolean isStatic) {\n        List<Method> methods = testClass.getAnnotatedMethods(annotation);\n\n        for (Method each : methods) {\n            if (Modifier.isStatic(each.getModifiers()) != isStatic) {\n                String state = isStatic ? \"should\" : \"should not\";\n                errors.add(new Exception(\"Method \" + each.getName() + \"() \"\n\t\t\t\t\t\t+ state + \" be static\"));\n            }\n            if (!Modifier.isPublic(each.getDeclaringClass().getModifiers())) {\n                errors.add(new Exception(\"Class \" + each.getDeclaringClass().getName()\n\t\t\t\t\t\t+ \" should be public\"));\n            }\n            if (!Modifier.isPublic(each.getModifiers())) {\n                errors.add(new Exception(\"Method \" + each.getName()\n\t\t\t\t\t\t+ \" should be public\"));\n            }\n            if (each.getReturnType() != Void.TYPE) {\n                errors.add(new Exception(\"Method \" + each.getName()\n\t\t\t\t\t\t+ \"should have a return type of void\"));\n            }\n            if (each.getParameterTypes().length != 0) {\n                errors.add(new Exception(\"Method \" + each.getName()\n\t\t\t\t\t\t+ \" should have no parameters\"));\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/SuiteMethod.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\n\nimport junit.framework.Test;\n\n/**\n * Runner for use with JUnit 3.8.x-style AllTests classes\n * (those that only implement a static <code>suite()</code>\n * method). For example:\n * <pre>\n * &#064;RunWith(AllTests.class)\n * public class ProductTests {\n *    public static junit.framework.Test suite() {\n *       ...\n *    }\n * }\n * </pre>\n */\npublic class SuiteMethod extends JUnit38ClassRunner {\n    public SuiteMethod(Class<?> klass) throws Throwable {\n        super(testFromSuiteMethod(klass));\n    }\n\n    public static Test testFromSuiteMethod(Class<?> klass) throws Throwable {\n        Method suiteMethod = null;\n        Test suite = null;\n        try {\n            suiteMethod = klass.getMethod(\"suite\");\n            if (!Modifier.isStatic(suiteMethod.getModifiers())) {\n                throw new Exception(klass.getName() + \".suite() must be static\");\n            }\n            suite = (Test) suiteMethod.invoke(null); // static method\n        } catch (InvocationTargetException e) {\n            throw e.getCause();\n        }\n        return suite;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/TestClass.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.internal.MethodSorter;\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\n/**\n * @deprecated Included for backwards compatibility with JUnit 4.4. Will be\n *             removed in the next major release. Please use\n *             {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.\n */\n@Deprecated\npublic class TestClass {\n    private final Class<?> klass;\n\n    public TestClass(Class<?> klass) {\n        this.klass = klass;\n    }\n\n    public List<Method> getTestMethods() {\n        return getAnnotatedMethods(Test.class);\n    }\n\n    List<Method> getBefores() {\n        return getAnnotatedMethods(BeforeClass.class);\n    }\n\n    List<Method> getAfters() {\n        return getAnnotatedMethods(AfterClass.class);\n    }\n\n    public List<Method> getAnnotatedMethods(Class<? extends Annotation> annotationClass) {\n        List<Method> results = new ArrayList<Method>();\n        for (Class<?> eachClass : getSuperClasses(klass)) {\n            Method[] methods = MethodSorter.getDeclaredMethods(eachClass);\n            for (Method eachMethod : methods) {\n                Annotation annotation = eachMethod.getAnnotation(annotationClass);\n                if (annotation != null && !isShadowed(eachMethod, results)) {\n                    results.add(eachMethod);\n                }\n            }\n        }\n        if (runsTopToBottom(annotationClass)) {\n            Collections.reverse(results);\n        }\n        return results;\n    }\n\n    private boolean runsTopToBottom(Class<? extends Annotation> annotation) {\n        return annotation.equals(Before.class) || annotation.equals(BeforeClass.class);\n    }\n\n    private boolean isShadowed(Method method, List<Method> results) {\n        for (Method each : results) {\n            if (isShadowed(method, each)) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    private boolean isShadowed(Method current, Method previous) {\n        if (!previous.getName().equals(current.getName())) {\n            return false;\n        }\n        if (previous.getParameterTypes().length != current.getParameterTypes().length) {\n            return false;\n        }\n        for (int i = 0; i < previous.getParameterTypes().length; i++) {\n            if (!previous.getParameterTypes()[i].equals(current.getParameterTypes()[i])) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    private List<Class<?>> getSuperClasses(Class<?> testClass) {\n        List<Class<?>> results = new ArrayList<Class<?>>();\n        Class<?> current = testClass;\n        while (current != null) {\n            results.add(current);\n            current = current.getSuperclass();\n        }\n        return results;\n    }\n\n    public Constructor<?> getConstructor() throws SecurityException, NoSuchMethodException {\n        return klass.getConstructor();\n    }\n\n    public Class<?> getJavaClass() {\n        return klass;\n    }\n\n    public String getName() {\n        return klass.getName();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/TestMethod.java",
    "content": "package org.junit.internal.runners;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.util.List;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.Test.None;\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\n/**\n * @deprecated Included for backwards compatibility with JUnit 4.4. Will be\n *             removed in the next major release. Please use\n *             {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.\n */\n@Deprecated\npublic class TestMethod {\n    private final Method method;\n    private TestClass testClass;\n\n    public TestMethod(Method method, TestClass testClass) {\n        this.method = method;\n        this.testClass = testClass;\n    }\n\n    public boolean isIgnored() {\n        return method.getAnnotation(Ignore.class) != null;\n    }\n\n    public long getTimeout() {\n        Test annotation = method.getAnnotation(Test.class);\n        if (annotation == null) {\n            return 0;\n        }\n        long timeout = annotation.timeout();\n        return timeout;\n    }\n\n    protected Class<? extends Throwable> getExpectedException() {\n        Test annotation = method.getAnnotation(Test.class);\n        if (annotation == null || annotation.expected() == None.class) {\n            return null;\n        } else {\n            return annotation.expected();\n        }\n    }\n\n    boolean isUnexpected(Throwable exception) {\n        return !getExpectedException().isAssignableFrom(exception.getClass());\n    }\n\n    boolean expectsException() {\n        return getExpectedException() != null;\n    }\n\n    List<Method> getBefores() {\n        return testClass.getAnnotatedMethods(Before.class);\n    }\n\n    List<Method> getAfters() {\n        return testClass.getAnnotatedMethods(After.class);\n    }\n\n    public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {\n        method.invoke(test);\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/model/EachTestNotifier.java",
    "content": "package org.junit.internal.runners.model;\n\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.MultipleFailureException;\n\npublic class EachTestNotifier {\n    private final RunNotifier notifier;\n\n    private final Description description;\n\n    public EachTestNotifier(RunNotifier notifier, Description description) {\n        this.notifier = notifier;\n        this.description = description;\n    }\n\n    public void addFailure(Throwable targetException) {\n        if (targetException instanceof MultipleFailureException) {\n            addMultipleFailureException((MultipleFailureException) targetException);\n        } else {\n            notifier.fireTestFailure(new Failure(description, targetException));\n        }\n    }\n\n    private void addMultipleFailureException(MultipleFailureException mfe) {\n        for (Throwable each : mfe.getFailures()) {\n            addFailure(each);\n        }\n    }\n\n    public void addFailedAssumption(AssumptionViolatedException e) {\n        notifier.fireTestAssumptionFailed(new Failure(description, e));\n    }\n\n    public void fireTestFinished() {\n        notifier.fireTestFinished(description);\n    }\n\n    public void fireTestStarted() {\n        notifier.fireTestStarted(description);\n    }\n\n    public void fireTestIgnored() {\n        notifier.fireTestIgnored(description);\n    }\n\n    /**\n     * Calls {@link RunNotifier#fireTestSuiteStarted(Description)}, passing the\n     * {@link Description} that was passed to the {@code EachTestNotifier} constructor.\n     * This should be called when a test suite is about to be started.\n     * @see RunNotifier#fireTestSuiteStarted(Description)\n     * @since 4.13\n     */\n    public void fireTestSuiteStarted() {\n        notifier.fireTestSuiteStarted(description);\n    }\n\n    /**\n     * Calls {@link RunNotifier#fireTestSuiteFinished(Description)}, passing the\n     * {@link Description} that was passed to the {@code EachTestNotifier} constructor.\n     * This should be called when a test suite has finished, whether the test suite succeeds\n     * or fails.\n     * @see RunNotifier#fireTestSuiteFinished(Description)\n     * @since 4.13\n     */\n    public void fireTestSuiteFinished() {\n        notifier.fireTestSuiteFinished(description);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/model/MultipleFailureException.java",
    "content": "package org.junit.internal.runners.model;\n\nimport java.util.List;\n\n@Deprecated\npublic class MultipleFailureException extends org.junit.runners.model.MultipleFailureException {\n    private static final long serialVersionUID = 1L;\n\n    public MultipleFailureException(List<Throwable> errors) {\n        super(errors);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/model/ReflectiveCallable.java",
    "content": "package org.junit.internal.runners.model;\n\nimport java.lang.reflect.InvocationTargetException;\n\n/**\n * When invoked, throws the exception from the reflected method, rather than\n * wrapping it in an InvocationTargetException.\n */\npublic abstract class ReflectiveCallable {\n    public Object run() throws Throwable {\n        try {\n            return runReflectiveCall();\n        } catch (InvocationTargetException e) {\n            throw e.getTargetException();\n        }\n    }\n\n    protected abstract Object runReflectiveCall() throws Throwable;\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/package-info.java",
    "content": "/**\n * Provides implementations of {@link org.junit.runner.Runner}\n *\n * @since 4.0\n */\npackage org.junit.internal.runners;"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/rules/RuleMemberValidator.java",
    "content": "package org.junit.internal.runners.rules;\n\nimport org.junit.ClassRule;\nimport org.junit.Rule;\nimport org.junit.rules.MethodRule;\nimport org.junit.rules.TestRule;\nimport org.junit.runners.model.FrameworkMember;\nimport org.junit.runners.model.TestClass;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * A RuleMemberValidator validates the rule fields/methods of a\n * {@link org.junit.runners.model.TestClass}. All reasons for rejecting the\n * {@code TestClass} are written to a list of errors.\n *\n * <p>There are four slightly different validators. The {@link #CLASS_RULE_VALIDATOR}\n * validates fields with a {@link ClassRule} annotation and the\n * {@link #RULE_VALIDATOR} validates fields with a {@link Rule} annotation.</p>\n *\n * <p>The {@link #CLASS_RULE_METHOD_VALIDATOR}\n * validates methods with a {@link ClassRule} annotation and the\n * {@link #RULE_METHOD_VALIDATOR} validates methods with a {@link Rule} annotation.</p>\n */\npublic class RuleMemberValidator {\n    /**\n     * Validates fields with a {@link ClassRule} annotation.\n     */\n    public static final RuleMemberValidator CLASS_RULE_VALIDATOR =\n            classRuleValidatorBuilder()\n            .withValidator(new DeclaringClassMustBePublic())\n            .withValidator(new MemberMustBeStatic())\n            .withValidator(new MemberMustBePublic())\n            .withValidator(new FieldMustBeATestRule())\n            .build();\n    /**\n     * Validates fields with a {@link Rule} annotation.\n     */\n    public static final RuleMemberValidator RULE_VALIDATOR =\n            testRuleValidatorBuilder()\n            .withValidator(new MemberMustBeNonStaticOrAlsoClassRule())\n            .withValidator(new MemberMustBePublic())\n            .withValidator(new FieldMustBeARule())\n            .build();\n    /**\n     * Validates methods with a {@link ClassRule} annotation.\n     */\n    public static final RuleMemberValidator CLASS_RULE_METHOD_VALIDATOR =\n            classRuleValidatorBuilder()\n            .forMethods()\n            .withValidator(new DeclaringClassMustBePublic())\n            .withValidator(new MemberMustBeStatic())\n            .withValidator(new MemberMustBePublic())\n            .withValidator(new MethodMustBeATestRule())\n            .build();\n\n    /**\n     * Validates methods with a {@link Rule} annotation.\n     */\n    public static final RuleMemberValidator RULE_METHOD_VALIDATOR =\n            testRuleValidatorBuilder()\n            .forMethods()\n            .withValidator(new MemberMustBeNonStaticOrAlsoClassRule())\n            .withValidator(new MemberMustBePublic())\n            .withValidator(new MethodMustBeARule())\n            .build();\n\n    private final Class<? extends Annotation> annotation;\n    private final boolean methods;\n    private final List<RuleValidator> validatorStrategies;\n\n    RuleMemberValidator(Builder builder) {\n        this.annotation = builder.annotation;\n        this.methods = builder.methods;\n        this.validatorStrategies = builder.validators;\n    }\n\n    /**\n     * Validate the {@link org.junit.runners.model.TestClass} and adds reasons\n     * for rejecting the class to a list of errors.\n     *\n     * @param target the {@code TestClass} to validate.\n     * @param errors the list of errors.\n     */\n    public void validate(TestClass target, List<Throwable> errors) {\n        List<? extends FrameworkMember<?>> members = methods ? target.getAnnotatedMethods(annotation)\n                : target.getAnnotatedFields(annotation);\n\n        for (FrameworkMember<?> each : members) {\n            validateMember(each, errors);\n        }\n    }\n\n    private void validateMember(FrameworkMember<?> member, List<Throwable> errors) {\n        for (RuleValidator strategy : validatorStrategies) {\n            strategy.validate(member, annotation, errors);\n        }\n    }\n\n    private static Builder classRuleValidatorBuilder() {\n        return new Builder(ClassRule.class);\n    }\n\n    private static Builder testRuleValidatorBuilder() {\n        return new Builder(Rule.class);\n    }\n\n    private static class Builder {\n        private final Class<? extends Annotation> annotation;\n        private boolean methods;\n        private final List<RuleValidator> validators;\n\n        private Builder(Class<? extends Annotation> annotation) {\n            this.annotation = annotation;\n            this.methods = false;\n            this.validators = new ArrayList<RuleValidator>();\n        }\n\n        Builder forMethods() {\n            methods = true;\n            return this;\n        }\n\n        Builder withValidator(RuleValidator validator) {\n            validators.add(validator);\n            return this;\n        }\n\n        RuleMemberValidator build() {\n            return new RuleMemberValidator(this);\n        }\n    }\n\n    private static boolean isRuleType(FrameworkMember<?> member) {\n        return isMethodRule(member) || isTestRule(member);\n    }\n\n    private static boolean isTestRule(FrameworkMember<?> member) {\n        return TestRule.class.isAssignableFrom(member.getType());\n    }\n\n    private static boolean isMethodRule(FrameworkMember<?> member) {\n        return MethodRule.class.isAssignableFrom(member.getType());\n    }\n\n    /**\n     * Encapsulates a single piece of validation logic, used to determine if {@link org.junit.Rule} and\n     * {@link org.junit.ClassRule} annotations have been used correctly\n     */\n    interface RuleValidator {\n        /**\n         * Examine the given member and add any violations of the strategy's validation logic to the given list of errors\n         * @param member The member (field or member) to examine\n         * @param annotation The type of rule annotation on the member\n         * @param errors The list of errors to add validation violations to\n         */\n        void validate(FrameworkMember<?> member, Class<? extends Annotation> annotation, List<Throwable> errors);\n    }\n\n    /**\n     * Requires the validated member to be non-static\n     */\n    private static final class MemberMustBeNonStaticOrAlsoClassRule implements RuleValidator {\n        public void validate(FrameworkMember<?> member, Class<? extends Annotation> annotation, List<Throwable> errors) {\n            boolean isMethodRuleMember = isMethodRule(member);\n            boolean isClassRuleAnnotated = (member.getAnnotation(ClassRule.class) != null);\n\n            // We disallow:\n            //  - static MethodRule members\n            //  - static @Rule annotated members\n            //    - UNLESS they're also @ClassRule annotated\n            // Note that MethodRule cannot be annotated with @ClassRule\n            if (member.isStatic() && (isMethodRuleMember || !isClassRuleAnnotated)) {\n                String message;\n                if (isMethodRule(member)) {\n                    message = \"must not be static.\";\n                } else {\n                    message = \"must not be static or it must be annotated with @ClassRule.\";\n                }\n                errors.add(new ValidationError(member, annotation, message));\n            }\n        }\n    }\n\n    /**\n     * Requires the member to be static\n     */\n    private static final class MemberMustBeStatic implements RuleValidator {\n        public void validate(FrameworkMember<?> member, Class<? extends Annotation> annotation, List<Throwable> errors) {\n            if (!member.isStatic()) {\n                errors.add(new ValidationError(member, annotation,\n                        \"must be static.\"));\n            }\n        }\n    }\n\n    /**\n     * Requires the member's declaring class to be public\n     */\n    private static final class DeclaringClassMustBePublic implements RuleValidator {\n        public void validate(FrameworkMember<?> member, Class<? extends Annotation> annotation, List<Throwable> errors) {\n            if (!isDeclaringClassPublic(member)) {\n                errors.add(new ValidationError(member, annotation,\n                        \"must be declared in a public class.\"));\n            }\n        }\n\n        private boolean isDeclaringClassPublic(FrameworkMember<?> member) {\n            return Modifier.isPublic(member.getDeclaringClass().getModifiers());\n        }\n    }\n\n    /**\n     * Requires the member to be public\n     */\n    private static final class MemberMustBePublic implements RuleValidator {\n        public void validate(FrameworkMember<?> member, Class<? extends Annotation> annotation, List<Throwable> errors) {\n            if (!member.isPublic()) {\n                errors.add(new ValidationError(member, annotation,\n                        \"must be public.\"));\n            }\n        }\n    }\n\n    /**\n     * Requires the member is a field implementing {@link org.junit.rules.MethodRule} or {@link org.junit.rules.TestRule}\n     */\n    private static final class FieldMustBeARule implements RuleValidator {\n        public void validate(FrameworkMember<?> member, Class<? extends Annotation> annotation, List<Throwable> errors) {\n            if (!isRuleType(member)) {\n                errors.add(new ValidationError(member, annotation,\n                        \"must implement MethodRule or TestRule.\"));\n            }\n        }\n    }\n\n    /**\n     * Require the member to return an implementation of {@link org.junit.rules.MethodRule} or\n     * {@link org.junit.rules.TestRule}\n     */\n    private static final class MethodMustBeARule implements RuleValidator {\n        public void validate(FrameworkMember<?> member, Class<? extends Annotation> annotation, List<Throwable> errors) {\n            if (!isRuleType(member)) {\n                errors.add(new ValidationError(member, annotation,\n                        \"must return an implementation of MethodRule or TestRule.\"));\n            }\n        }\n    }\n    \n    /**\n     * Require the member to return an implementation of {@link org.junit.rules.TestRule}\n     */\n    private static final class MethodMustBeATestRule implements RuleValidator {\n        public void validate(FrameworkMember<?> member,\n                Class<? extends Annotation> annotation, List<Throwable> errors) {\n            if (!isTestRule(member)) {\n                errors.add(new ValidationError(member, annotation, \n                        \"must return an implementation of TestRule.\"));\n            }\n        }\n    }\n    \n    /**\n     * Requires the member is a field implementing {@link org.junit.rules.TestRule}\n     */\n    private static final class FieldMustBeATestRule implements RuleValidator {\n\n        public void validate(FrameworkMember<?> member,\n                Class<? extends Annotation> annotation, List<Throwable> errors) {\n            if (!isTestRule(member)) {\n                errors.add(new ValidationError(member, annotation,\n                        \"must implement TestRule.\"));\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/rules/ValidationError.java",
    "content": "package org.junit.internal.runners.rules;\n\nimport org.junit.runners.model.FrameworkMember;\n\nimport java.lang.annotation.Annotation;\n\nclass ValidationError extends Exception {\n\n    private static final long serialVersionUID = 3176511008672645574L;\n\n    public ValidationError(FrameworkMember<?> member, Class<? extends Annotation> annotation, String suffix) {\n        super(String.format(\"The @%s '%s' %s\", annotation.getSimpleName(), member.getName(), suffix));\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/statements/ExpectException.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runners.model.Statement;\n\npublic class ExpectException extends Statement {\n    private final Statement next;\n    private final Class<? extends Throwable> expected;\n\n    public ExpectException(Statement next, Class<? extends Throwable> expected) {\n        this.next = next;\n        this.expected = expected;\n    }\n\n    @Override\n    public void evaluate() throws Exception {\n        boolean complete = false;\n        try {\n            next.evaluate();\n            complete = true;\n        } catch (AssumptionViolatedException e) {\n            if (!expected.isAssignableFrom(e.getClass())) {\n                throw e;\n            }\n        } catch (Throwable e) {\n            if (!expected.isAssignableFrom(e.getClass())) {\n                String message = \"Unexpected exception, expected<\"\n                        + expected.getName() + \"> but was<\"\n                        + e.getClass().getName() + \">\";\n                throw new Exception(message, e);\n            }\n        }\n        if (complete) {\n            throw new AssertionError(\"Expected exception: \"\n                    + expected.getName());\n        }\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/statements/Fail.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport org.junit.runners.model.Statement;\n\npublic class Fail extends Statement {\n    private final Throwable error;\n\n    public Fail(Throwable e) {\n        error = e;\n    }\n\n    @Override\n    public void evaluate() throws Throwable {\n        throw error;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.ExecutionException;\nimport java.util.concurrent.FutureTask;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.TimeoutException;\n\nimport org.junit.internal.management.ManagementFactory;\nimport org.junit.internal.management.ThreadMXBean;\nimport org.junit.runners.model.MultipleFailureException;\nimport org.junit.runners.model.Statement;\nimport org.junit.runners.model.TestTimedOutException;\n\npublic class FailOnTimeout extends Statement {\n    private final Statement originalStatement;\n    private final TimeUnit timeUnit;\n    private final long timeout;\n    private final boolean lookForStuckThread;\n\n    /**\n     * Returns a new builder for building an instance.\n     *\n     * @since 4.12\n     */\n    public static Builder builder() {\n        return new Builder();\n    }\n\n    /**\n     * Creates an instance wrapping the given statement with the given timeout in milliseconds.\n     *\n     * @param statement the statement to wrap\n     * @param timeoutMillis the timeout in milliseconds\n     * @deprecated use {@link #builder()} instead.\n     */\n    @Deprecated\n    public FailOnTimeout(Statement statement, long timeoutMillis) {\n        this(builder().withTimeout(timeoutMillis, TimeUnit.MILLISECONDS), statement);\n    }\n\n    private FailOnTimeout(Builder builder, Statement statement) {\n        originalStatement = statement;\n        timeout = builder.timeout;\n        timeUnit = builder.unit;\n        lookForStuckThread = builder.lookForStuckThread;\n    }\n\n    /**\n     * Builder for {@link FailOnTimeout}.\n     *\n     * @since 4.12\n     */\n    public static class Builder {\n        private boolean lookForStuckThread = false;\n        private long timeout = 0;\n        private TimeUnit unit = TimeUnit.SECONDS;\n\n        private Builder() {\n        }\n\n        /**\n         * Specifies the time to wait before timing out the test.\n         *\n         * <p>If this is not called, or is called with a {@code timeout} of\n         * {@code 0}, the returned {@code Statement} will wait forever for the\n         * test to complete, however the test will still launch from a separate\n         * thread. This can be useful for disabling timeouts in environments\n         * where they are dynamically set based on some property.\n         *\n         * @param timeout the maximum time to wait\n         * @param unit the time unit of the {@code timeout} argument\n         * @return {@code this} for method chaining.\n         */\n        public Builder withTimeout(long timeout, TimeUnit unit) {\n            if (timeout < 0) {\n                throw new IllegalArgumentException(\"timeout must be non-negative\");\n            }\n            if (unit == null) {\n                throw new NullPointerException(\"TimeUnit cannot be null\");\n            }\n            this.timeout = timeout;\n            this.unit = unit;\n            return this;\n        }\n\n        /**\n         * Specifies whether to look for a stuck thread.  If a timeout occurs and this\n         * feature is enabled, the test will look for a thread that appears to be stuck\n         * and dump its backtrace.  This feature is experimental.  Behavior may change\n         * after the 4.12 release in response to feedback.\n         *\n         * @param enable {@code true} to enable the feature\n         * @return {@code this} for method chaining.\n         */\n        public Builder withLookingForStuckThread(boolean enable) {\n            this.lookForStuckThread = enable;\n            return this;\n        }\n\n        /**\n         * Builds a {@link FailOnTimeout} instance using the values in this builder,\n         * wrapping the given statement.\n         *\n         * @param statement statement to build\n         */\n        public FailOnTimeout build(Statement statement) {\n            if (statement == null) {\n                throw new NullPointerException(\"statement cannot be null\");\n            }\n            return new FailOnTimeout(this, statement);\n        }\n    }\n\n    @Override\n    public void evaluate() throws Throwable {\n        CallableStatement callable = new CallableStatement();\n        FutureTask<Throwable> task = new FutureTask<Throwable>(callable);\n        ThreadGroup threadGroup = threadGroupForNewThread();\n        Thread thread = new Thread(threadGroup, task, \"Time-limited test\");\n        thread.setDaemon(true);\n        thread.start();\n        callable.awaitStarted();\n        Throwable throwable = getResult(task, thread);\n        if (throwable != null) {\n            throw throwable;\n        }\n    }\n\n    private ThreadGroup threadGroupForNewThread() {\n        if (!lookForStuckThread) {\n            // Use the default ThreadGroup (usually the one from the current\n            // thread).\n            return null;\n        }\n\n        // Create the thread in a new ThreadGroup, so if the time-limited thread\n        // becomes stuck, getStuckThread() can find the thread likely to be the\n        // culprit.\n        ThreadGroup threadGroup = new ThreadGroup(\"FailOnTimeoutGroup\");\n        if (!threadGroup.isDaemon()) {\n            // Mark the new ThreadGroup as a daemon thread group, so it will be\n            // destroyed after the time-limited thread completes. By ensuring the\n            // ThreadGroup is destroyed, any data associated with the ThreadGroup\n            // (ex: via java.beans.ThreadGroupContext) is destroyed.\n            try {\n                threadGroup.setDaemon(true);\n            } catch (SecurityException e) {\n                // Swallow the exception to keep the same behavior as in JUnit 4.12.\n            }\n        }\n        return threadGroup;\n    }\n\n    /**\n     * Wait for the test task, returning the exception thrown by the test if the\n     * test failed, an exception indicating a timeout if the test timed out, or\n     * {@code null} if the test passed.\n     */\n    private Throwable getResult(FutureTask<Throwable> task, Thread thread) {\n        try {\n            if (timeout > 0) {\n                return task.get(timeout, timeUnit);\n            } else {\n                return task.get();\n            }\n        } catch (InterruptedException e) {\n            return e; // caller will re-throw; no need to call Thread.interrupt()\n        } catch (ExecutionException e) {\n            // test failed; have caller re-throw the exception thrown by the test\n            return e.getCause();\n        } catch (TimeoutException e) {\n            return createTimeoutException(thread);\n        }\n    }\n\n    private Exception createTimeoutException(Thread thread) {\n        StackTraceElement[] stackTrace = thread.getStackTrace();\n        final Thread stuckThread = lookForStuckThread ? getStuckThread(thread) : null;\n        Exception currThreadException = new TestTimedOutException(timeout, timeUnit);\n        if (stackTrace != null) {\n            currThreadException.setStackTrace(stackTrace);\n            thread.interrupt();\n        }\n        if (stuckThread != null) {\n            Exception stuckThreadException = \n                new Exception(\"Appears to be stuck in thread \" +\n                               stuckThread.getName());\n            stuckThreadException.setStackTrace(getStackTrace(stuckThread));\n            return new MultipleFailureException(\n                Arrays.<Throwable>asList(currThreadException, stuckThreadException));\n        } else {\n            return currThreadException;\n        }\n    }\n\n    /**\n     * Retrieves the stack trace for a given thread.\n     * @param thread The thread whose stack is to be retrieved.\n     * @return The stack trace; returns a zero-length array if the thread has \n     * terminated or the stack cannot be retrieved for some other reason.\n     */\n    private StackTraceElement[] getStackTrace(Thread thread) {\n        try {\n            return thread.getStackTrace();\n        } catch (SecurityException e) {\n            return new StackTraceElement[0];\n        }\n    }\n\n    /**\n     * Determines whether the test appears to be stuck in some thread other than\n     * the \"main thread\" (the one created to run the test).  This feature is experimental.\n     * Behavior may change after the 4.12 release in response to feedback.\n     * @param mainThread The main thread created by {@code evaluate()}\n     * @return The thread which appears to be causing the problem, if different from\n     * {@code mainThread}, or {@code null} if the main thread appears to be the\n     * problem or if the thread cannot be determined.  The return value is never equal \n     * to {@code mainThread}.\n     */\n    private Thread getStuckThread(Thread mainThread) {\n        List<Thread> threadsInGroup = getThreadsInGroup(mainThread.getThreadGroup());\n        if (threadsInGroup.isEmpty()) {\n            return null;\n        }\n\n        // Now that we have all the threads in the test's thread group: Assume that\n        // any thread we're \"stuck\" in is RUNNABLE.  Look for all RUNNABLE threads. \n        // If just one, we return that (unless it equals threadMain).  If there's more\n        // than one, pick the one that's using the most CPU time, if this feature is\n        // supported.\n        Thread stuckThread = null;\n        long maxCpuTime = 0;\n        for (Thread thread : threadsInGroup) {\n            if (thread.getState() == Thread.State.RUNNABLE) {\n                long threadCpuTime = cpuTime(thread);\n                if (stuckThread == null || threadCpuTime > maxCpuTime) {\n                    stuckThread = thread;\n                    maxCpuTime = threadCpuTime;\n                }\n            }               \n        }\n        return (stuckThread == mainThread) ? null : stuckThread;\n    }\n\n    /**\n     * Returns all active threads belonging to a thread group.  \n     * @param group The thread group.\n     * @return The active threads in the thread group.  The result should be a\n     * complete list of the active threads at some point in time.  Returns an empty list\n     * if this cannot be determined, e.g. because new threads are being created at an\n     * extremely fast rate.\n     */\n    private List<Thread> getThreadsInGroup(ThreadGroup group) {\n        final int activeThreadCount = group.activeCount(); // this is just an estimate\n        int threadArraySize = Math.max(activeThreadCount * 2, 100);\n        for (int loopCount = 0; loopCount < 5; loopCount++) {\n            Thread[] threads = new Thread[threadArraySize];\n            int enumCount = group.enumerate(threads);\n            if (enumCount < threadArraySize) {\n                return Arrays.asList(threads).subList(0, enumCount);\n            }\n            // if there are too many threads to fit into the array, enumerate's result\n            // is >= the array's length; therefore we can't trust that it returned all\n            // the threads.  Try again.\n            threadArraySize += 100;\n        }\n        // threads are proliferating too fast for us.  Bail before we get into \n        // trouble.\n        return Collections.emptyList();\n    }\n\n    /**\n     * Returns the CPU time used by a thread, if possible.\n     * @param thr The thread to query.\n     * @return The CPU time used by {@code thr}, or 0 if it cannot be determined.\n     */\n    private long cpuTime(Thread thr) {\n        ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();\n        if (mxBean.isThreadCpuTimeSupported()) {\n            try {\n                return mxBean.getThreadCpuTime(thr.getId());\n            } catch (UnsupportedOperationException e) {\n            }\n        }\n        return 0;\n    }\n\n    private class CallableStatement implements Callable<Throwable> {\n        private final CountDownLatch startLatch = new CountDownLatch(1);\n\n        public Throwable call() throws Exception {\n            try {\n                startLatch.countDown();\n                originalStatement.evaluate();\n            } catch (Exception e) {\n                throw e;\n            } catch (Throwable e) {\n                return e;\n            }\n            return null;\n        }\n\n        public void awaitStarted() throws InterruptedException {\n            startLatch.await();\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/statements/InvokeMethod.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\npublic class InvokeMethod extends Statement {\n    private final FrameworkMethod testMethod;\n    private final Object target;\n\n    public InvokeMethod(FrameworkMethod testMethod, Object target) {\n        this.testMethod = testMethod;\n        this.target = target;\n    }\n\n    @Override\n    public void evaluate() throws Throwable {\n        testMethod.invokeExplosively(target);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/statements/RunAfters.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.MultipleFailureException;\nimport org.junit.runners.model.Statement;\n\npublic class RunAfters extends Statement {\n    private final Statement next;\n\n    private final Object target;\n\n    private final List<FrameworkMethod> afters;\n\n    public RunAfters(Statement next, List<FrameworkMethod> afters, Object target) {\n        this.next = next;\n        this.afters = afters;\n        this.target = target;\n    }\n\n    @Override\n    public void evaluate() throws Throwable {\n        List<Throwable> errors = new ArrayList<Throwable>();\n        try {\n            next.evaluate();\n        } catch (Throwable e) {\n            errors.add(e);\n        } finally {\n            for (FrameworkMethod each : afters) {\n                try {\n                    invokeMethod(each);\n                } catch (Throwable e) {\n                    errors.add(e);\n                }\n            }\n        }\n        MultipleFailureException.assertEmpty(errors);\n    }\n\n    /**\n     * @since 4.13\n     */\n    protected void invokeMethod(FrameworkMethod method) throws Throwable {\n        method.invokeExplosively(target);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/internal/runners/statements/RunBefores.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport java.util.List;\n\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\npublic class RunBefores extends Statement {\n    private final Statement next;\n\n    private final Object target;\n\n    private final List<FrameworkMethod> befores;\n\n    public RunBefores(Statement next, List<FrameworkMethod> befores, Object target) {\n        this.next = next;\n        this.befores = befores;\n        this.target = target;\n    }\n\n    @Override\n    public void evaluate() throws Throwable {\n        for (FrameworkMethod before : befores) {\n            invokeMethod(before);\n        }\n        next.evaluate();\n    }\n\n    /**\n     * @since 4.13\n     */\n    protected void invokeMethod(FrameworkMethod method) throws Throwable {\n        method.invokeExplosively(target);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/matchers/JUnitMatchers.java",
    "content": "package org.junit.matchers;\n\nimport org.hamcrest.CoreMatchers;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.core.CombinableMatcher.CombinableBothMatcher;\nimport org.hamcrest.core.CombinableMatcher.CombinableEitherMatcher;\nimport org.junit.internal.matchers.StacktracePrintingMatcher;\n\n/**\n * Convenience import class: these are useful matchers for use with the assertThat method, but they are\n * not currently included in the basic CoreMatchers class from hamcrest.\n *\n * @since 4.4\n */\npublic class JUnitMatchers {\n    /**\n     * @return A matcher matching any collection containing element\n     * @deprecated Please use {@link CoreMatchers#hasItem(Object)} instead.\n     */\n    @Deprecated\n    public static <T> Matcher<Iterable<? super T>> hasItem(T element) {\n        return CoreMatchers.hasItem(element);\n    }\n\n    /**\n     * @return A matcher matching any collection containing an element matching elementMatcher\n     * @deprecated Please use {@link CoreMatchers#hasItem(Matcher)} instead.\n     */\n    @Deprecated\n    public static <T> Matcher<Iterable<? super T>> hasItem(Matcher<? super T> elementMatcher) {\n        return CoreMatchers.<T>hasItem(elementMatcher);\n    }\n\n    /**\n     * @return A matcher matching any collection containing every element in elements\n     * @deprecated Please use {@link CoreMatchers#hasItems(Object...)} instead.\n     */\n    @Deprecated\n    public static <T> Matcher<Iterable<T>> hasItems(T... elements) {\n        return CoreMatchers.hasItems(elements);\n    }\n\n    /**\n     * @return A matcher matching any collection containing at least one element that matches\n     *         each matcher in elementMatcher (this may be one element matching all matchers,\n     *         or different elements matching each matcher)\n     * @deprecated Please use {@link CoreMatchers#hasItems(Matcher...)} instead.\n     */\n    @Deprecated\n    public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... elementMatchers) {\n        return CoreMatchers.hasItems(elementMatchers);\n    }\n\n    /**\n     * @return A matcher matching any collection in which every element matches elementMatcher\n     * @deprecated Please use {@link CoreMatchers#everyItem(Matcher)} instead.\n     */\n    @Deprecated\n    public static <T> Matcher<Iterable<T>> everyItem(final Matcher<T> elementMatcher) {\n        return CoreMatchers.everyItem(elementMatcher);\n    }\n\n    /**\n     * @return a matcher matching any string that contains substring\n     * @deprecated Please use {@link CoreMatchers#containsString(String)} instead.\n     */\n    @Deprecated\n    public static Matcher<java.lang.String> containsString(java.lang.String substring) {\n        return CoreMatchers.containsString(substring);\n    }\n\n    /**\n     * This is useful for fluently combining matchers that must both pass.  For example:\n     * <pre>\n     *   assertThat(string, both(containsString(\"a\")).and(containsString(\"b\")));\n     * </pre>\n     *\n     * @deprecated Please use {@link CoreMatchers#both(Matcher)} instead.\n     */\n    @Deprecated\n    public static <T> CombinableBothMatcher<T> both(Matcher<? super T> matcher) {\n        return CoreMatchers.both(matcher);\n    }\n\n    /**\n     * This is useful for fluently combining matchers where either may pass, for example:\n     * <pre>\n     *   assertThat(string, either(containsString(\"a\")).or(containsString(\"b\")));\n     * </pre>\n     *\n     * @deprecated Please use {@link CoreMatchers#either(Matcher)} instead.\n     */\n    @Deprecated\n    public static <T> CombinableEitherMatcher<T> either(Matcher<? super T> matcher) {\n        return CoreMatchers.either(matcher);\n    }\n\n    /**\n     * @return A matcher that delegates to throwableMatcher and in addition\n     *         appends the stacktrace of the actual Throwable in case of a mismatch.\n     */\n    public static <T extends Throwable> Matcher<T> isThrowable(Matcher<T> throwableMatcher) {\n        return StacktracePrintingMatcher.isThrowable(throwableMatcher);\n    }\n\n    /**\n     * @return A matcher that delegates to exceptionMatcher and in addition\n     *         appends the stacktrace of the actual Exception in case of a mismatch.\n     */\n    public static <T extends Exception> Matcher<T> isException(Matcher<T> exceptionMatcher) {\n        return StacktracePrintingMatcher.isException(exceptionMatcher);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/matchers/package-info.java",
    "content": "/**\n * Provides useful additional {@link org.hamcrest.Matcher}s for use with\n * the {@link org.junit.Assert#assertThat(Object, org.hamcrest.Matcher)}\n * statement\n *\n * @since 4.0\n * @see org.junit.matchers.JUnitMatchers\n */\npackage org.junit.matchers;"
  },
  {
    "path": "src/main/java/org/junit/package-info.java",
    "content": "/**\n * Provides JUnit core classes and annotations. \n *\n * Corresponds to junit.framework in Junit 3.x.\n *\n * @since 4.0\n */\npackage org.junit;"
  },
  {
    "path": "src/main/java/org/junit/rules/DisableOnDebug.java",
    "content": "package org.junit.rules;\n\nimport java.util.List;\n\nimport org.junit.internal.management.ManagementFactory;\nimport org.junit.internal.management.RuntimeMXBean;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\n/**\n * The {@code DisableOnDebug} Rule allows you to label certain rules to be\n * disabled when debugging.\n * <p>\n * The most illustrative use case is for tests that make use of the\n * {@link Timeout} rule, when ran in debug mode the test may terminate on\n * timeout abruptly during debugging. Developers may disable the timeout, or\n * increase the timeout by making a code change on tests that need debugging and\n * remember revert the change afterwards or rules such as {@link Timeout} that\n * may be disabled during debugging may be wrapped in a {@code DisableOnDebug}.\n * <p>\n * The important benefit of this feature is that you can disable such rules\n * without any making any modifications to your test class to remove them during\n * debugging.\n * <p>\n * This does nothing to tackle timeouts or time sensitive code under test when\n * debugging and may make this less useful in such circumstances.\n * <p>\n * Example usage:\n * \n * <pre>\n * public static class DisableTimeoutOnDebugSampleTest {\n * \n *     &#064;Rule\n *     public TestRule timeout = new DisableOnDebug(new Timeout(20));\n * \n *     &#064;Test\n *     public void myTest() {\n *         int i = 0;\n *         assertEquals(0, i); // suppose you had a break point here to inspect i\n *     }\n * }\n * </pre>\n * \n * @since 4.12\n */\npublic class DisableOnDebug implements TestRule {\n    private final TestRule rule;\n    private final boolean debugging;\n\n    /**\n     * Create a {@code DisableOnDebug} instance with the timeout specified in\n     * milliseconds.\n     * \n     * @param rule to disable during debugging\n     */\n    public DisableOnDebug(TestRule rule) {\n        this(rule, ManagementFactory.getRuntimeMXBean()\n                .getInputArguments());\n    }\n\n    /**\n     * Visible for testing purposes only.\n     * \n     * @param rule the rule to disable during debugging\n     * @param inputArguments\n     *            arguments provided to the Java runtime\n     */\n    DisableOnDebug(TestRule rule, List<String> inputArguments) {\n        this.rule = rule;\n        debugging = isDebugging(inputArguments);\n    }\n\n    /**\n     * @see TestRule#apply(Statement, Description)\n     */\n    public Statement apply(Statement base, Description description) {\n        if (debugging) {\n            return base;\n        } else {\n            return rule.apply(base, description);\n        }\n    }\n\n    /**\n     * Parses arguments passed to the runtime environment for debug flags\n     * <p>\n     * Options specified in:\n     * <ul>\n     * <li>\n     * <a href=\"http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/conninv.html#Invocation\"\n     * >javase-6</a></li>\n     * <li><a href=\"http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/conninv.html#Invocation\"\n     * >javase-7</a></li>\n     * <li><a href=\"http://docs.oracle.com/javase/8/docs/technotes/guides/jpda/conninv.html#Invocation\"\n     * >javase-8</a></li>\n     * \n     * \n     * @param arguments\n     *            the arguments passed to the runtime environment, usually this\n     *            will be {@link RuntimeMXBean#getInputArguments()}\n     * @return true if the current JVM was started in debug mode, false\n     *         otherwise.\n     */\n    private static boolean isDebugging(List<String> arguments) {\n        for (final String argument : arguments) {\n            if (\"-Xdebug\".equals(argument) || argument.startsWith(\"-agentlib:jdwp\")) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    /**\n     * Returns {@code true} if the JVM is in debug mode. This method may be used\n     * by test classes to take additional action to disable code paths that\n     * interfere with debugging if required.\n     * \n     * @return {@code true} if the current JVM is in debug mode, {@code false}\n     *         otherwise\n     */\n    public boolean isDebugging() {\n        return debugging;\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/ErrorCollector.java",
    "content": "package org.junit.rules;\n\nimport static org.junit.Assert.assertThrows;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.Callable;\n\nimport org.junit.function.ThrowingRunnable;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.MatcherAssert;\nimport org.junit.runners.model.MultipleFailureException;\n\n/**\n * The ErrorCollector rule allows execution of a test to continue after the\n * first problem is found (for example, to collect _all_ the incorrect rows in a\n * table, and report them all at once):\n *\n * <pre>\n * public static class UsesErrorCollectorTwice {\n * \t&#064;Rule\n * \tpublic ErrorCollector collector= new ErrorCollector();\n *\n * &#064;Test\n * public void example() {\n *      collector.addError(new Throwable(&quot;first thing went wrong&quot;));\n *      collector.addError(new Throwable(&quot;second thing went wrong&quot;));\n *      collector.checkThat(getResult(), not(containsString(&quot;ERROR!&quot;)));\n *      // all lines will run, and then a combined failure logged at the end.\n *     }\n * }\n * </pre>\n *\n * @since 4.7\n */\npublic class ErrorCollector extends Verifier {\n    private List<Throwable> errors = new ArrayList<Throwable>();\n\n    @Override\n    protected void verify() throws Throwable {\n        MultipleFailureException.assertEmpty(errors);\n    }\n\n    /**\n     * Adds a Throwable to the table.  Execution continues, but the test will fail at the end.\n     */\n    public void addError(Throwable error) {\n        if (error == null) {\n            throw new NullPointerException(\"Error cannot be null\");\n        }\n        if (error instanceof AssumptionViolatedException) {\n            AssertionError e = new AssertionError(error.getMessage());\n            e.initCause(error);\n            errors.add(e);\n        } else {\n            errors.add(error);\n        }\n    }\n\n    /**\n     * Adds a failure to the table if {@code matcher} does not match {@code value}.\n     * Execution continues, but the test will fail at the end if the match fails.\n     */\n    public <T> void checkThat(final T value, final Matcher<T> matcher) {\n        checkThat(\"\", value, matcher);\n    }\n\n    /**\n     * Adds a failure with the given {@code reason}\n     * to the table if {@code matcher} does not match {@code value}.\n     * Execution continues, but the test will fail at the end if the match fails.\n     */\n    public <T> void checkThat(final String reason, final T value, final Matcher<T> matcher) {\n        checkSucceeds(new Callable<Object>() {\n            public Object call() throws Exception {\n                MatcherAssert.assertThat(reason, value, matcher);\n                return value;\n            }\n        });\n    }\n\n    /**\n     * Adds to the table the exception, if any, thrown from {@code callable}.\n     * Execution continues, but the test will fail at the end if\n     * {@code callable} threw an exception.\n     */\n    public <T> T checkSucceeds(Callable<T> callable) {\n        try {\n            return callable.call();\n        } catch (AssumptionViolatedException e) {\n            AssertionError error = new AssertionError(\"Callable threw AssumptionViolatedException\");\n            error.initCause(e);\n            addError(error);\n            return null;\n        } catch (Throwable e) {\n            addError(e);\n            return null;\n        }\n    }\n\n    /**\n     * Adds a failure to the table if {@code runnable} does not throw an\n     * exception of type {@code expectedThrowable} when executed.\n     * Execution continues, but the test will fail at the end if the runnable\n     * does not throw an exception, or if it throws a different exception.\n     *\n     * @param expectedThrowable the expected type of the exception\n     * @param runnable       a function that is expected to throw an exception when executed\n     * @since 4.13\n     */\n    public void checkThrows(Class<? extends Throwable> expectedThrowable, ThrowingRunnable runnable) {\n        try {\n            assertThrows(expectedThrowable, runnable);\n        } catch (AssertionError e) {\n            addError(e);\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/ExpectedException.java",
    "content": "package org.junit.rules;\n\nimport static java.lang.String.format;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.junit.Assert.fail;\nimport static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause;\nimport static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.MatcherAssert;\nimport org.hamcrest.StringDescription;\nimport org.junit.AssumptionViolatedException;\nimport org.junit.runners.model.Statement;\n\n/**\n * The {@code ExpectedException} rule allows you to verify that your code\n * throws a specific exception.\n *\n * <h3>Usage</h3>\n *\n * <pre> public class SimpleExpectedExceptionTest {\n *     &#064;Rule\n *     public ExpectedException thrown = ExpectedException.none();\n *\n *     &#064;Test\n *     public void throwsNothing() {\n *         // no exception expected, none thrown: passes.\n *     }\n *\n *     &#064;Test\n *     public void throwsExceptionWithSpecificType() {\n *         thrown.expect(NullPointerException.class);\n *         throw new NullPointerException();\n *     }\n * }</pre>\n * \n * <p>You have to add the {@code ExpectedException} rule to your test.\n * This doesn't affect your existing tests (see {@code throwsNothing()}).\n * After specifying the type of the expected exception your test is\n * successful when such an exception is thrown and it fails if a\n * different or no exception is thrown.\n *\n * <p>This rule does not perform any special magic to make execution continue\n * as if the exception had not been thrown. So it is nearly always a mistake\n * for a test method to have statements after the one that is expected to\n * throw the exception.\n *\n * <p>Instead of specifying the exception's type you can characterize the\n * expected exception based on other criteria, too:\n *\n * <ul>\n *   <li>The exception's message contains a specific text: {@link #expectMessage(String)}</li>\n *   <li>The exception's message complies with a Hamcrest matcher: {@link #expectMessage(Matcher)}</li>\n *   <li>The exception's cause complies with a Hamcrest matcher: {@link #expectCause(Matcher)}</li>\n *   <li>The exception itself complies with a Hamcrest matcher: {@link #expect(Matcher)}</li>\n * </ul>\n *\n * <p>You can combine any of the presented expect-methods. The test is\n * successful if all specifications are met.\n * <pre> &#064;Test\n * public void throwsException() {\n *     thrown.expect(NullPointerException.class);\n *     thrown.expectMessage(&quot;happened&quot;);\n *     throw new NullPointerException(&quot;What happened?&quot;);\n * }</pre>\n *\n * <p>It is recommended to set the {@link org.junit.Rule#order() order} of the\n * {@code ExpectedException} to {@code Integer.MAX_VALUE} if it is used together\n * with another rule that handles exceptions, e.g. {@link ErrorCollector}.\n * Otherwise failing tests may be successful.\n * <pre> &#064;Rule(order = Integer.MAX_VALUE)\n * public ExpectedException thrown = ExpectedException.none();</pre>\n *\n * <h3>AssumptionViolatedExceptions</h3>\n * <p>JUnit uses {@link AssumptionViolatedException}s for indicating that a test\n * provides no useful information. (See {@link org.junit.Assume} for more\n * information.) You have to call {@code assume} methods before you set\n * expectations of the {@code ExpectedException} rule. In this case the rule\n * will not handle consume the exceptions and it can be handled by the\n * framework. E.g. the following test is ignored by JUnit's default runner.\n *\n * <pre> &#064;Test\n * public void ignoredBecauseOfFailedAssumption() {\n *     assumeTrue(false); // throws AssumptionViolatedException\n *     thrown.expect(NullPointerException.class);\n * }</pre>\n *\n * <h3>AssertionErrors</h3>\n *\n * <p>JUnit uses {@link AssertionError}s for indicating that a test is failing. You\n * have to call {@code assert} methods before you set expectations of the\n * {@code ExpectedException} rule, if they should be handled by the framework.\n * E.g. the following test fails because of the {@code assertTrue} statement.\n *\n * <pre> &#064;Test\n * public void throwsUnhandled() {\n *     assertTrue(false); // throws AssertionError\n *     thrown.expect(NullPointerException.class);\n * }</pre>\n *\n * <h3>Missing Exceptions</h3>\n * <p>By default missing exceptions are reported with an error message\n * like \"Expected test to throw an instance of foo\". You can configure a different\n * message by means of {@link #reportMissingExceptionWithMessage(String)}. You\n * can use a {@code %s} placeholder for the description of the expected\n * exception. E.g. \"Test doesn't throw %s.\" will fail with the error message\n * \"Test doesn't throw an instance of foo.\".\n *\n * @since 4.7\n */\npublic class ExpectedException implements TestRule {\n    /**\n     * Returns a {@linkplain TestRule rule} that expects no exception to\n     * be thrown (identical to behavior without this rule).\n     *\n     * @deprecated Since 4.13\n     * {@link org.junit.Assert#assertThrows(Class, org.junit.function.ThrowingRunnable)\n     * Assert.assertThrows} can be used to verify that your code throws a specific\n     * exception.\n     */\n    @Deprecated\n    public static ExpectedException none() {\n        return new ExpectedException();\n    }\n\n    private final ExpectedExceptionMatcherBuilder matcherBuilder = new ExpectedExceptionMatcherBuilder();\n\n    private String missingExceptionMessage= \"Expected test to throw %s\";\n\n    private ExpectedException() {\n    }\n\n    /**\n     * This method does nothing. Don't use it.\n     * @deprecated AssertionErrors are handled by default since JUnit 4.12. Just\n     *             like in JUnit &lt;= 4.10.\n     */\n    @Deprecated\n    public ExpectedException handleAssertionErrors() {\n        return this;\n    }\n\n    /**\n     * This method does nothing. Don't use it.\n     * @deprecated AssumptionViolatedExceptions are handled by default since\n     *             JUnit 4.12. Just like in JUnit &lt;= 4.10.\n     */\n    @Deprecated\n    public ExpectedException handleAssumptionViolatedExceptions() {\n        return this;\n    }\n\n    /**\n     * Specifies the failure message for tests that are expected to throw \n     * an exception but do not throw any. You can use a {@code %s} placeholder for\n     * the description of the expected exception. E.g. \"Test doesn't throw %s.\"\n     * will fail with the error message\n     * \"Test doesn't throw an instance of foo.\".\n     *\n     * @param message exception detail message\n     * @return the rule itself\n     */\n    public ExpectedException reportMissingExceptionWithMessage(String message) {\n        missingExceptionMessage = message;\n        return this;\n    }\n\n    public Statement apply(Statement base,\n            org.junit.runner.Description description) {\n        return new ExpectedExceptionStatement(base);\n    }\n\n    /**\n     * Verify that your code throws an exception that is matched by\n     * a Hamcrest matcher.\n     * <pre> &#064;Test\n     * public void throwsExceptionThatCompliesWithMatcher() {\n     *     NullPointerException e = new NullPointerException();\n     *     thrown.expect(is(e));\n     *     throw e;\n     * }</pre>\n     */\n    public void expect(Matcher<?> matcher) {\n        matcherBuilder.add(matcher);\n    }\n\n    /**\n     * Verify that your code throws an exception that is an\n     * instance of specific {@code type}.\n     * <pre> &#064;Test\n     * public void throwsExceptionWithSpecificType() {\n     *     thrown.expect(NullPointerException.class);\n     *     throw new NullPointerException();\n     * }</pre>\n     */\n    public void expect(Class<? extends Throwable> type) {\n        expect(instanceOf(type));\n    }\n\n    /**\n     * Verify that your code throws an exception whose message contains\n     * a specific text.\n     * <pre> &#064;Test\n     * public void throwsExceptionWhoseMessageContainsSpecificText() {\n     *     thrown.expectMessage(&quot;happened&quot;);\n     *     throw new NullPointerException(&quot;What happened?&quot;);\n     * }</pre>\n     */\n    public void expectMessage(String substring) {\n        expectMessage(containsString(substring));\n    }\n\n    /**\n     * Verify that your code throws an exception whose message is matched \n     * by a Hamcrest matcher.\n     * <pre> &#064;Test\n     * public void throwsExceptionWhoseMessageCompliesWithMatcher() {\n     *     thrown.expectMessage(startsWith(&quot;What&quot;));\n     *     throw new NullPointerException(&quot;What happened?&quot;);\n     * }</pre>\n     */\n    public void expectMessage(Matcher<String> matcher) {\n        expect(hasMessage(matcher));\n    }\n\n    /**\n     * Verify that your code throws an exception whose cause is matched by \n     * a Hamcrest matcher.\n     * <pre> &#064;Test\n     * public void throwsExceptionWhoseCauseCompliesWithMatcher() {\n     *     NullPointerException expectedCause = new NullPointerException();\n     *     thrown.expectCause(is(expectedCause));\n     *     throw new IllegalArgumentException(&quot;What happened?&quot;, cause);\n     * }</pre>\n     */\n    public void expectCause(Matcher<?> expectedCause) {\n        expect(hasCause(expectedCause));\n    }\n\n    /**\n     * Check if any Exception is expected.\n     * @since 4.13\n     */\n    public final boolean isAnyExceptionExpected() {\n        return matcherBuilder.expectsThrowable();\n    }\n\n    private class ExpectedExceptionStatement extends Statement {\n        private final Statement next;\n\n        public ExpectedExceptionStatement(Statement base) {\n            next = base;\n        }\n\n        @Override\n        public void evaluate() throws Throwable {\n            try {\n                next.evaluate();\n            } catch (Throwable e) {\n                handleException(e);\n                return;\n            }\n            if (isAnyExceptionExpected()) {\n                failDueToMissingException();\n            }\n        }\n    }\n\n    private void handleException(Throwable e) throws Throwable {\n        if (isAnyExceptionExpected()) {\n            MatcherAssert.assertThat(e, matcherBuilder.build());\n        } else {\n            throw e;\n        }\n    }\n\n    private void failDueToMissingException() throws AssertionError {\n        fail(missingExceptionMessage());\n    }\n    \n    private String missingExceptionMessage() {\n        String expectation= StringDescription.toString(matcherBuilder.build());\n        return format(missingExceptionMessage, expectation);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/ExpectedExceptionMatcherBuilder.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.junit.matchers.JUnitMatchers.isThrowable;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.hamcrest.Matcher;\n\n/**\n * Builds special matcher used by {@link ExpectedException}.\n */\nclass ExpectedExceptionMatcherBuilder {\n\n    private final List<Matcher<?>> matchers = new ArrayList<Matcher<?>>();\n\n    void add(Matcher<?> matcher) {\n        matchers.add(matcher);\n    }\n\n    boolean expectsThrowable() {\n        return !matchers.isEmpty();\n    }\n\n    Matcher<Throwable> build() {\n        return isThrowable(allOfTheMatchers());\n    }\n\n    private Matcher<Throwable> allOfTheMatchers() {\n        if (matchers.size() == 1) {\n            return cast(matchers.get(0));\n        }\n        return allOf(castedMatchers());\n    }\n\n    @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n    private List<Matcher<? super Throwable>> castedMatchers() {\n        return new ArrayList<Matcher<? super Throwable>>((List) matchers);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private Matcher<Throwable> cast(Matcher<?> singleMatcher) {\n        return (Matcher<Throwable>) singleMatcher;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/ExternalResource.java",
    "content": "package org.junit.rules;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.runner.Description;\nimport org.junit.runners.model.MultipleFailureException;\nimport org.junit.runners.model.Statement;\n\n/**\n * A base class for Rules (like TemporaryFolder) that set up an external\n * resource before a test (a file, socket, server, database connection, etc.),\n * and guarantee to tear it down afterward:\n *\n * <pre>\n * public static class UsesExternalResource {\n *  Server myServer= new Server();\n *\n *  &#064;Rule\n *  public ExternalResource resource= new ExternalResource() {\n *      &#064;Override\n *      protected void before() throws Throwable {\n *          myServer.connect();\n *         };\n *\n *      &#064;Override\n *      protected void after() {\n *          myServer.disconnect();\n *         };\n *     };\n *\n *  &#064;Test\n *  public void testFoo() {\n *      new Client().run(myServer);\n *     }\n * }\n * </pre>\n *\n * @since 4.7\n */\npublic abstract class ExternalResource implements TestRule {\n    public Statement apply(Statement base, Description description) {\n        return statement(base);\n    }\n\n    private Statement statement(final Statement base) {\n        return new Statement() {\n            @Override\n            public void evaluate() throws Throwable {\n                before();\n\n                List<Throwable> errors = new ArrayList<Throwable>();\n                try {\n                    base.evaluate();\n                } catch (Throwable t) {\n                    errors.add(t);\n                } finally {\n                    try {\n                        after();\n                    } catch (Throwable t) {\n                        errors.add(t);\n                    }\n                }\n                MultipleFailureException.assertEmpty(errors);\n            }\n        };\n    }\n\n    /**\n     * Override to set up your specific external resource.\n     *\n     * @throws Throwable if setup fails (which will disable {@code after}\n     */\n    protected void before() throws Throwable {\n        // do nothing\n    }\n\n    /**\n     * Override to tear down your specific external resource.\n     */\n    protected void after() {\n        // do nothing\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/MethodRule.java",
    "content": "package org.junit.rules;\n\nimport org.junit.Rule;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\n/**\n * A MethodRule is an alteration in how a test method is run and reported.\n * Multiple {@link MethodRule}s can be applied to a test method. The\n * {@link Statement} that executes the method is passed to each annotated\n * {@link Rule} in turn, and each may return a substitute or modified\n * {@link Statement}, which is passed to the next {@link Rule}, if any. For\n * an example of how this can be useful, see {@link TestWatchman}.\n *\n * <p>Note that {@link MethodRule} has been replaced by {@link TestRule},\n * which has the added benefit of supporting class rules.\n *\n * @since 4.7\n */\npublic interface MethodRule {\n    /**\n     * Modifies the method-running {@link Statement} to implement an additional\n     * test-running rule.\n     *\n     * @param base The {@link Statement} to be modified\n     * @param method The method to be run\n     * @param target The object on which the method will be run.\n     * @return a new statement, which may be the same as {@code base},\n     *         a wrapper around {@code base}, or a completely new Statement.\n     */\n    Statement apply(Statement base, FrameworkMethod method, Object target);\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/RuleChain.java",
    "content": "package org.junit.rules;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.Rule;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\n/**\n * The {@code RuleChain} can be used for creating composite rules. You create a\n * {@code RuleChain} with {@link #outerRule(TestRule)} and subsequent calls of\n * {@link #around(TestRule)}:\n *\n * <pre>\n * public abstract class CompositeRules {\n *   public static TestRule extendedLogging() {\n *     return RuleChain.outerRule(new LoggingRule(\"outer rule\"))\n *                     .around(new LoggingRule(\"middle rule\"))\n *                     .around(new LoggingRule(\"inner rule\"));\n *   }\n * }\n * </pre>\n *\n * <pre>\n * public class UseRuleChain {\n *   &#064;Rule\n *   public final TestRule extendedLogging = CompositeRules.extendedLogging();\n *\n *   &#064;Test\n *   public void example() {\n *     assertTrue(true);\n *   }\n * }\n * </pre>\n *\n * writes the log\n *\n * <pre>\n * starting outer rule\n * starting middle rule\n * starting inner rule\n * finished inner rule\n * finished middle rule\n * finished outer rule\n * </pre>\n *\n * In older versions of JUnit (before 4.13) {@code RuleChain} was used for\n * ordering rules. We recommend to not use it for this purpose anymore. You can\n * use the attribute {@code order} of the annotation {@link Rule#order() Rule}\n * or {@link org.junit.ClassRule#order() ClassRule} for ordering rules.\n *\n * @see org.junit.Rule#order()\n * @see org.junit.ClassRule#order()\n * @since 4.10\n */\npublic class RuleChain implements TestRule {\n    private static final RuleChain EMPTY_CHAIN = new RuleChain(\n            Collections.<TestRule>emptyList());\n\n    private List<TestRule> rulesStartingWithInnerMost;\n\n    /**\n     * Returns a {@code RuleChain} without a {@link TestRule}. This method may\n     * be the starting point of a {@code RuleChain}.\n     *\n     * @return a {@code RuleChain} without a {@link TestRule}.\n     */\n    public static RuleChain emptyRuleChain() {\n        return EMPTY_CHAIN;\n    }\n\n    /**\n     * Returns a {@code RuleChain} with a single {@link TestRule}. This method\n     * is the usual starting point of a {@code RuleChain}.\n     *\n     * @param outerRule the outer rule of the {@code RuleChain}.\n     * @return a {@code RuleChain} with a single {@link TestRule}.\n     */\n    public static RuleChain outerRule(TestRule outerRule) {\n        return emptyRuleChain().around(outerRule);\n    }\n\n    private RuleChain(List<TestRule> rules) {\n        this.rulesStartingWithInnerMost = rules;\n    }\n\n    /**\n     * Create a new {@code RuleChain}, which encloses the given {@link TestRule} with\n     * the rules of the current {@code RuleChain}.\n     *\n     * @param enclosedRule the rule to enclose; must not be {@code null}.\n     * @return a new {@code RuleChain}.\n     * @throws NullPointerException if the argument {@code enclosedRule} is {@code null}\n     */\n    public RuleChain around(TestRule enclosedRule) {\n        if (enclosedRule == null) {\n            throw new NullPointerException(\"The enclosed rule must not be null\");\n        }\n        List<TestRule> rulesOfNewChain = new ArrayList<TestRule>();\n        rulesOfNewChain.add(enclosedRule);\n        rulesOfNewChain.addAll(rulesStartingWithInnerMost);\n        return new RuleChain(rulesOfNewChain);\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    public Statement apply(Statement base, Description description) {\n        return new RunRules(base, rulesStartingWithInnerMost, description);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/rules/RunRules.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\n/**\n * Runs a collection of rules on a statement.\n *\n * @since 4.9\n */\npublic class RunRules extends Statement {\n    private final Statement statement;\n\n    public RunRules(Statement base, Iterable<TestRule> rules, Description description) {\n        statement = applyAll(base, rules, description);\n    }\n\n    @Override\n    public void evaluate() throws Throwable {\n        statement.evaluate();\n    }\n\n    private static Statement applyAll(Statement result, Iterable<TestRule> rules,\n            Description description) {\n        for (TestRule each : rules) {\n            result = each.apply(result, description);\n        }\n        return result;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/Stopwatch.java",
    "content": "package org.junit.rules;\n\nimport org.junit.AssumptionViolatedException;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\nimport java.util.concurrent.TimeUnit;\n\n/**\n * The Stopwatch Rule notifies one of its own protected methods of the time spent by a test.\n *\n * <p>Override them to get the time in nanoseconds. For example, this class will keep logging the\n * time spent by each passed, failed, skipped, and finished test:\n *\n * <pre>\n * public static class StopwatchTest {\n *     private static final Logger logger = Logger.getLogger(&quot;&quot;);\n *\n *     private static void logInfo(Description description, String status, long nanos) {\n *         String testName = description.getMethodName();\n *         logger.info(String.format(&quot;Test %s %s, spent %d microseconds&quot;,\n *                                   testName, status, TimeUnit.NANOSECONDS.toMicros(nanos)));\n *     }\n *\n *     &#064;Rule\n *     public Stopwatch stopwatch = new Stopwatch() {\n *         &#064;Override\n *         protected void succeeded(long nanos, Description description) {\n *             logInfo(description, &quot;succeeded&quot;, nanos);\n *         }\n *\n *         &#064;Override\n *         protected void failed(long nanos, Throwable e, Description description) {\n *             logInfo(description, &quot;failed&quot;, nanos);\n *         }\n *\n *         &#064;Override\n *         protected void skipped(long nanos, AssumptionViolatedException e, Description description) {\n *             logInfo(description, &quot;skipped&quot;, nanos);\n *         }\n *\n *         &#064;Override\n *         protected void finished(long nanos, Description description) {\n *             logInfo(description, &quot;finished&quot;, nanos);\n *         }\n *     };\n *\n *     &#064;Test\n *     public void succeeds() {\n *     }\n *\n *     &#064;Test\n *     public void fails() {\n *         fail();\n *     }\n *\n *     &#064;Test\n *     public void skips() {\n *         assumeTrue(false);\n *     }\n * }\n * </pre>\n *\n * An example to assert runtime:\n * <pre>\n * &#064;Test\n * public void performanceTest() throws InterruptedException {\n *     long delta = 30;\n *     Thread.sleep(300L);\n *     assertEquals(300d, stopwatch.runtime(MILLISECONDS), delta);\n *     Thread.sleep(500L);\n *     assertEquals(800d, stopwatch.runtime(MILLISECONDS), delta);\n * }\n * </pre>\n *\n * @author tibor17\n * @since 4.12\n */\npublic class Stopwatch implements TestRule {\n    private final Clock clock;\n    private volatile long startNanos;\n    private volatile long endNanos;\n\n    public Stopwatch() {\n        this(new Clock());\n    }\n\n    Stopwatch(Clock clock) {\n        this.clock = clock;\n    }\n\n    /**\n     * Gets the runtime for the test.\n     *\n     * @param unit time unit for returned runtime\n     * @return runtime measured during the test\n     */\n    public long runtime(TimeUnit unit) {\n        return unit.convert(getNanos(), TimeUnit.NANOSECONDS);\n    }\n\n    /**\n     * Invoked when a test succeeds\n     */\n    protected void succeeded(long nanos, Description description) {\n    }\n\n    /**\n     * Invoked when a test fails\n     */\n    protected void failed(long nanos, Throwable e, Description description) {\n    }\n\n    /**\n     * Invoked when a test is skipped due to a failed assumption.\n     */\n    protected void skipped(long nanos, AssumptionViolatedException e, Description description) {\n    }\n\n    /**\n     * Invoked when a test method finishes (whether passing or failing)\n     */\n    protected void finished(long nanos, Description description) {\n    }\n\n    private long getNanos() {\n        if (startNanos == 0) {\n            throw new IllegalStateException(\"Test has not started\");\n        }\n        long currentEndNanos = endNanos; // volatile read happens here\n        if (currentEndNanos == 0) {\n          currentEndNanos = clock.nanoTime();\n        }\n\n        return currentEndNanos - startNanos;\n    }\n\n    private void starting() {\n        startNanos = clock.nanoTime();\n        endNanos = 0;\n    }\n\n    private void stopping() {\n        endNanos = clock.nanoTime();\n    }\n\n    public final Statement apply(Statement base, Description description) {\n        return new InternalWatcher().apply(base, description);\n    }\n\n    private class InternalWatcher extends TestWatcher {\n\n        @Override protected void starting(Description description) {\n            Stopwatch.this.starting();\n        }\n\n        @Override protected void finished(Description description) {\n            Stopwatch.this.finished(getNanos(), description);\n        }\n\n        @Override protected void succeeded(Description description) {\n            Stopwatch.this.stopping();\n            Stopwatch.this.succeeded(getNanos(), description);\n        }\n\n        @Override protected void failed(Throwable e, Description description) {\n            Stopwatch.this.stopping();\n            Stopwatch.this.failed(getNanos(), e, description);\n        }\n\n        @Override protected void skipped(AssumptionViolatedException e, Description description) {\n            Stopwatch.this.stopping();\n            Stopwatch.this.skipped(getNanos(), e, description);\n        }\n    }\n\n    static class Clock {\n\n        public long nanoTime() {\n            return System.nanoTime();\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/TemporaryFolder.java",
    "content": "package org.junit.rules;\n\nimport static org.junit.Assert.fail;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.lang.reflect.Array;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\n\nimport org.junit.Rule;\n\n/**\n * The TemporaryFolder Rule allows creation of files and folders that should\n * be deleted when the test method finishes (whether it passes or\n * fails).\n * By default no exception will be thrown in case the deletion fails.\n *\n * <p>Example of usage:\n * <pre>\n * public static class HasTempFolder {\n *  &#064;Rule\n *  public TemporaryFolder folder= new TemporaryFolder();\n *\n *  &#064;Test\n *  public void testUsingTempFolder() throws IOException {\n *      File createdFile= folder.newFile(&quot;myfile.txt&quot;);\n *      File createdFolder= folder.newFolder(&quot;subfolder&quot;);\n *      // ...\n *     }\n * }\n * </pre>\n *\n * <p>TemporaryFolder rule supports assured deletion mode, which\n * will fail the test in case deletion fails with {@link AssertionError}.\n *\n * <p>Creating TemporaryFolder with assured deletion:\n * <pre>\n *  &#064;Rule\n *  public TemporaryFolder folder= TemporaryFolder.builder().assureDeletion().build();\n * </pre>\n *\n * @since 4.7\n */\npublic class TemporaryFolder extends ExternalResource {\n    private final File parentFolder;\n    private final boolean assureDeletion;\n    private File folder;\n\n    private static final int TEMP_DIR_ATTEMPTS = 10000;\n    private static final String TMP_PREFIX = \"junit\";\n\n    /**\n     * Create a temporary folder which uses system default temporary-file \n     * directory to create temporary resources.\n     */\n    public TemporaryFolder() {\n        this((File) null);\n    }\n\n    /**\n     * Create a temporary folder which uses the specified directory to create\n     * temporary resources.\n     *\n     * @param parentFolder folder where temporary resources will be created.\n     * If {@code null} then system default temporary-file directory is used.\n     */\n    public TemporaryFolder(File parentFolder) {\n        this.parentFolder = parentFolder;\n        this.assureDeletion = false;\n    }\n\n    /**\n     * Create a {@link TemporaryFolder} initialized with\n     * values from a builder.\n     */\n    protected TemporaryFolder(Builder builder) {\n        this.parentFolder = builder.parentFolder;\n        this.assureDeletion = builder.assureDeletion;\n    }\n\n    /**\n     * Returns a new builder for building an instance of {@link TemporaryFolder}.\n     *\n     * @since 4.13\n     */\n    public static Builder builder() {\n        return new Builder();\n    }\n\n    /**\n     * Builds an instance of {@link TemporaryFolder}.\n     * \n     * @since 4.13\n     */\n    public static class Builder {\n        private File parentFolder;\n        private boolean assureDeletion;\n\n        protected Builder() {}\n\n        /**\n         * Specifies which folder to use for creating temporary resources.\n         * If {@code null} then system default temporary-file directory is\n         * used.\n         *\n         * @return this\n         */\n        public Builder parentFolder(File parentFolder) {\n            this.parentFolder = parentFolder;\n            return this;\n        }\n\n        /**\n         * Setting this flag assures that no resources are left undeleted. Failure\n         * to fulfill the assurance results in failure of tests with an\n         * {@link AssertionError}.\n         *\n         * @return this\n         */\n        public Builder assureDeletion() {\n            this.assureDeletion = true;\n            return this;\n        }\n\n        /**\n         * Builds a {@link TemporaryFolder} instance using the values in this builder.\n         */\n        public TemporaryFolder build() {\n            return new TemporaryFolder(this);\n        }\n    }\n\n    @Override\n    protected void before() throws Throwable {\n        create();\n    }\n\n    @Override\n    protected void after() {\n        delete();\n    }\n\n    // testing purposes only\n\n    /**\n     * for testing purposes only. Do not use.\n     */\n    public void create() throws IOException {\n        folder = createTemporaryFolderIn(parentFolder);\n    }\n\n    /**\n     * Returns a new fresh file with the given name under the temporary folder.\n     */\n    public File newFile(String fileName) throws IOException {\n        File file = new File(getRoot(), fileName);\n        if (!file.createNewFile()) {\n            throw new IOException(\n                    \"a file with the name \\'\" + fileName + \"\\' already exists in the test folder\");\n        }\n        return file;\n    }\n\n    /**\n     * Returns a new fresh file with a random name under the temporary folder.\n     */\n    public File newFile() throws IOException {\n        return File.createTempFile(TMP_PREFIX, null, getRoot());\n    }\n\n    /**\n     * Returns a new fresh folder with the given path under the temporary\n     * folder.\n     */\n    public File newFolder(String path) throws IOException {\n        return newFolder(new String[]{path});\n    }\n\n    /**\n     * Returns a new fresh folder with the given paths under the temporary\n     * folder. For example, if you pass in the strings {@code \"parent\"} and {@code \"child\"}\n     * then a directory named {@code \"parent\"} will be created under the temporary folder\n     * and a directory named {@code \"child\"} will be created under the newly-created\n     * {@code \"parent\"} directory.\n     */\n    public File newFolder(String... paths) throws IOException {\n        if (paths.length == 0) {\n            throw new IllegalArgumentException(\"must pass at least one path\");\n        }\n\n        /*\n         * Before checking if the paths are absolute paths, check if create() was ever called,\n         * and if it wasn't, throw IllegalStateException.\n         */\n        File root = getRoot();\n        for (String path : paths) {\n            if (new File(path).isAbsolute()) {\n                throw new IOException(\"folder path \\'\" + path + \"\\' is not a relative path\");\n            }\n        }\n\n        File relativePath = null;\n        File file = root;\n        boolean lastMkdirsCallSuccessful = true;\n        for (String path : paths) {\n            relativePath = new File(relativePath, path);\n            file = new File(root, relativePath.getPath());\n\n            lastMkdirsCallSuccessful = file.mkdirs();\n            if (!lastMkdirsCallSuccessful && !file.isDirectory()) {\n                if (file.exists()) {\n                    throw new IOException(\n                            \"a file with the path \\'\" + relativePath.getPath() + \"\\' exists\");\n                } else {\n                    throw new IOException(\n                            \"could not create a folder with the path \\'\" + relativePath.getPath() + \"\\'\");\n                }\n            }\n        }\n        if (!lastMkdirsCallSuccessful) {\n            throw new IOException(\n                    \"a folder with the path \\'\" + relativePath.getPath() + \"\\' already exists\");\n        }\n        return file;\n    }\n\n    /**\n     * Returns a new fresh folder with a random name under the temporary folder.\n     */\n    public File newFolder() throws IOException {\n        return createTemporaryFolderIn(getRoot());\n    }\n\n    private static File createTemporaryFolderIn(File parentFolder) throws IOException {\n        try {\n            return createTemporaryFolderWithNioApi(parentFolder);\n        } catch (ClassNotFoundException ignore) {\n            // Fallback for Java 5 and 6\n            return createTemporaryFolderWithFileApi(parentFolder);\n        } catch (InvocationTargetException e) {\n            Throwable cause = e.getCause();\n            if (cause instanceof IOException) {\n                throw (IOException) cause;\n            }\n            if (cause instanceof RuntimeException) {\n                throw (RuntimeException) cause;\n            }\n            IOException exception = new IOException(\"Failed to create temporary folder in \" + parentFolder);\n            exception.initCause(cause);\n            throw exception;\n        } catch (Exception e) {\n            throw new RuntimeException(\"Failed to create temporary folder in \" + parentFolder, e);\n        }\n    }\n\n    private static File createTemporaryFolderWithNioApi(File parentFolder) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {\n        Class<?> filesClass = Class.forName(\"java.nio.file.Files\");\n        Object fileAttributeArray = Array.newInstance(Class.forName(\"java.nio.file.attribute.FileAttribute\"), 0);\n        Class<?> pathClass = Class.forName(\"java.nio.file.Path\");\n        Object tempDir;\n        if (parentFolder != null) {\n            Method createTempDirectoryMethod = filesClass.getDeclaredMethod(\"createTempDirectory\", pathClass, String.class, fileAttributeArray.getClass());\n            Object parentPath = File.class.getDeclaredMethod(\"toPath\").invoke(parentFolder);\n            tempDir = createTempDirectoryMethod.invoke(null, parentPath, TMP_PREFIX, fileAttributeArray);\n        } else {\n            Method createTempDirectoryMethod = filesClass.getDeclaredMethod(\"createTempDirectory\", String.class, fileAttributeArray.getClass());\n            tempDir = createTempDirectoryMethod.invoke(null, TMP_PREFIX, fileAttributeArray);\n        }\n        return (File) pathClass.getDeclaredMethod(\"toFile\").invoke(tempDir);\n    }\n\n    private static File createTemporaryFolderWithFileApi(File parentFolder) throws IOException {\n        File createdFolder = null;\n        for (int i = 0; i < TEMP_DIR_ATTEMPTS; ++i) {\n            // Use createTempFile to get a suitable folder name.\n            String suffix = \".tmp\";\n            File tmpFile = File.createTempFile(TMP_PREFIX, suffix, parentFolder);\n            String tmpName = tmpFile.toString();\n            // Discard .tmp suffix of tmpName.\n            String folderName = tmpName.substring(0, tmpName.length() - suffix.length());\n            createdFolder = new File(folderName);\n            if (createdFolder.mkdir()) {\n                tmpFile.delete();\n                return createdFolder;\n            }\n            tmpFile.delete();\n        }\n        throw new IOException(\"Unable to create temporary directory in: \"\n            + parentFolder.toString() + \". Tried \" + TEMP_DIR_ATTEMPTS + \" times. \"\n            + \"Last attempted to create: \" + createdFolder.toString());\n    }\n\n    /**\n     * @return the location of this temporary folder.\n     */\n    public File getRoot() {\n        if (folder == null) {\n            throw new IllegalStateException(\n                    \"the temporary folder has not yet been created\");\n        }\n        return folder;\n    }\n\n    /**\n     * Delete all files and folders under the temporary folder. Usually not\n     * called directly, since it is automatically applied by the {@link Rule}.\n     *\n     * @throws AssertionError if unable to clean up resources\n     * and deletion of resources is assured.\n     */\n    public void delete() {\n        if (!tryDelete()) {\n            if (assureDeletion) {\n                fail(\"Unable to clean up temporary folder \" + folder);\n            }\n        }\n    }\n\n    /**\n     * Tries to delete all files and folders under the temporary folder and\n     * returns whether deletion was successful or not.\n     *\n     * @return {@code true} if all resources are deleted successfully,\n     *         {@code false} otherwise.\n     */\n    private boolean tryDelete() {\n        if (folder == null) {\n            return true;\n        }\n        \n        return recursiveDelete(folder);\n    }\n\n    private boolean recursiveDelete(File file) {\n        // Try deleting file before assuming file is a directory\n        // to prevent following symbolic links.\n        if (file.delete()) {\n            return true;\n        }\n        File[] files = file.listFiles();\n        if (files != null) {\n            for (File each : files) {\n                if (!recursiveDelete(each)) {\n                    return false;\n                }\n            }\n        }\n        return file.delete();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/TestName.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runner.Description;\n\n/**\n * The TestName Rule makes the current test name available inside test methods:\n *\n * <pre>\n * public class TestNameTest {\n *  &#064;Rule\n *  public TestName name= new TestName();\n *\n *  &#064;Test\n *  public void testA() {\n *      assertEquals(&quot;testA&quot;, name.getMethodName());\n *     }\n *\n *  &#064;Test\n *  public void testB() {\n *      assertEquals(&quot;testB&quot;, name.getMethodName());\n *     }\n * }\n * </pre>\n *\n * @since 4.7\n */\npublic class TestName extends TestWatcher {\n    private volatile String name;\n\n    @Override\n    protected void starting(Description d) {\n        name = d.getMethodName();\n    }\n\n    /**\n     * @return the name of the currently-running test method\n     */\n    public String getMethodName() {\n        return name;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/TestRule.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\n/**\n * A TestRule is an alteration in how a test method, or set of test methods,\n * is run and reported.  A {@link TestRule} may add additional checks that cause\n * a test that would otherwise fail to pass, or it may perform necessary setup or\n * cleanup for tests, or it may observe test execution to report it elsewhere.\n * {@link TestRule}s can do everything that could be done previously with\n * methods annotated with {@link org.junit.Before},\n * {@link org.junit.After}, {@link org.junit.BeforeClass}, or\n * {@link org.junit.AfterClass}, but they are more powerful, and more easily\n * shared\n * between projects and classes.\n *\n * The default JUnit test runners for suites and\n * individual test cases recognize {@link TestRule}s introduced in two different\n * ways.  {@link org.junit.Rule} annotates method-level\n * {@link TestRule}s, and {@link org.junit.ClassRule}\n * annotates class-level {@link TestRule}s.  See Javadoc for those annotations\n * for more information.\n *\n * Multiple {@link TestRule}s can be applied to a test or suite execution. The\n * {@link Statement} that executes the method or suite is passed to each annotated\n * {@link org.junit.Rule} in turn, and each may return a substitute or modified\n * {@link Statement}, which is passed to the next {@link org.junit.Rule}, if any. For\n * examples of how this can be useful, see these provided TestRules,\n * or write your own:\n *\n * <ul>\n *   <li>{@link ErrorCollector}: collect multiple errors in one test method</li>\n *   <li>{@link ExpectedException}: make flexible assertions about thrown exceptions</li>\n *   <li>{@link ExternalResource}: start and stop a server, for example</li>\n *   <li>{@link TemporaryFolder}: create fresh files, and delete after test</li>\n *   <li>{@link TestName}: remember the test name for use during the method</li>\n *   <li>{@link TestWatcher}: add logic at events during method execution</li>\n *   <li>{@link Timeout}: cause test to fail after a set time</li>\n *   <li>{@link Verifier}: fail test if object state ends up incorrect</li>\n * </ul>\n *\n * @since 4.9\n */\npublic interface TestRule {\n    /**\n     * Modifies the method-running {@link Statement} to implement this\n     * test-running rule.\n     *\n     * @param base The {@link Statement} to be modified\n     * @param description A {@link Description} of the test implemented in {@code base}\n     * @return a new statement, which may be the same as {@code base},\n     *         a wrapper around {@code base}, or a completely new Statement.\n     */\n    Statement apply(Statement base, Description description);\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/TestWatcher.java",
    "content": "package org.junit.rules;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.AssumptionViolatedException;\nimport org.junit.Rule;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.MultipleFailureException;\nimport org.junit.runners.model.Statement;\n\n/**\n * TestWatcher is a base class for Rules that take note of the testing\n * action, without modifying it. For example, this class will keep a log of each\n * passing and failing test:\n *\n * <pre>\n * public static class WatchmanTest {\n *  private static String watchedLog;\n *\n *  &#064;Rule(order = Integer.MIN_VALUE)\n *  public TestWatcher watchman= new TestWatcher() {\n *      &#064;Override\n *      protected void failed(Throwable e, Description description) {\n *          watchedLog+= description + &quot;\\n&quot;;\n *      }\n *\n *      &#064;Override\n *      protected void succeeded(Description description) {\n *          watchedLog+= description + &quot; &quot; + &quot;success!\\n&quot;;\n *         }\n *     };\n *\n *  &#064;Test\n *  public void fails() {\n *      fail();\n *  }\n *\n *  &#064;Test\n *  public void succeeds() {\n *     }\n * }\n * </pre>\n * <p>It is recommended to always set the {@link Rule#order() order} of the\n * {@code TestWatcher} to {@code Integer.MIN_VALUE} so that it encloses all\n * other rules. Otherwise it may see failed tests as successful and vice versa\n * if some rule changes the result of a test (e.g. {@link ErrorCollector} or\n * {@link ExpectedException}).\n *\n * @since 4.9\n */\npublic abstract class TestWatcher implements TestRule {\n    public Statement apply(final Statement base, final Description description) {\n        return new Statement() {\n            @Override\n            public void evaluate() throws Throwable {\n                List<Throwable> errors = new ArrayList<Throwable>();\n\n                startingQuietly(description, errors);\n                try {\n                    base.evaluate();\n                    succeededQuietly(description, errors);\n                } catch (org.junit.internal.AssumptionViolatedException  e) {\n                    errors.add(e);\n                    skippedQuietly(e, description, errors);\n                } catch (Throwable e) {\n                    errors.add(e);\n                    failedQuietly(e, description, errors);\n                } finally {\n                    finishedQuietly(description, errors);\n                }\n\n                MultipleFailureException.assertEmpty(errors);\n            }\n        };\n    }\n\n    private void succeededQuietly(Description description,\n            List<Throwable> errors) {\n        try {\n            succeeded(description);\n        } catch (Throwable e) {\n            errors.add(e);\n        }\n    }\n\n    private void failedQuietly(Throwable e, Description description,\n            List<Throwable> errors) {\n        try {\n            failed(e, description);\n        } catch (Throwable e1) {\n            errors.add(e1);\n        }\n    }\n\n    private void skippedQuietly(\n            org.junit.internal.AssumptionViolatedException e, Description description,\n            List<Throwable> errors) {\n        try {\n            if (e instanceof AssumptionViolatedException) {\n                skipped((AssumptionViolatedException) e, description);\n            } else {\n                skipped(e, description);\n            }\n        } catch (Throwable e1) {\n            errors.add(e1);\n        }\n    }\n\n    private void startingQuietly(Description description,\n            List<Throwable> errors) {\n        try {\n            starting(description);\n        } catch (Throwable e) {\n            errors.add(e);\n        }\n    }\n\n    private void finishedQuietly(Description description,\n            List<Throwable> errors) {\n        try {\n            finished(description);\n        } catch (Throwable e) {\n            errors.add(e);\n        }\n    }\n\n    /**\n     * Invoked when a test succeeds\n     */\n    protected void succeeded(Description description) {\n    }\n\n    /**\n     * Invoked when a test fails\n     */\n    protected void failed(Throwable e, Description description) {\n    }\n\n    /**\n     * Invoked when a test is skipped due to a failed assumption.\n     */\n    protected void skipped(AssumptionViolatedException e, Description description) {\n        // For backwards compatibility with JUnit 4.11 and earlier, call the legacy version\n        org.junit.internal.AssumptionViolatedException asInternalException = e;\n        skipped(asInternalException, description);\n    }\n\n    /**\n     * Invoked when a test is skipped due to a failed assumption.\n     *\n     * @deprecated use {@link #skipped(AssumptionViolatedException, Description)}\n     */\n    @Deprecated\n    protected void skipped(\n            org.junit.internal.AssumptionViolatedException e, Description description) {\n    }\n\n    /**\n     * Invoked when a test is about to start\n     */\n    protected void starting(Description description) {\n    }\n\n    /**\n     * Invoked when a test method finishes (whether passing or failing)\n     */\n    protected void finished(Description description) {\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/TestWatchman.java",
    "content": "package org.junit.rules;\n\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\n/**\n * TestWatchman is a base class for Rules that take note of the testing\n * action, without modifying it. For example, this class will keep a log of each\n * passing and failing test:\n *\n * <pre>\n * public static class WatchmanTest {\n *  private static String watchedLog;\n *\n *  &#064;Rule\n *  public MethodRule watchman= new TestWatchman() {\n *      &#064;Override\n *      public void failed(Throwable e, FrameworkMethod method) {\n *          watchedLog+= method.getName() + &quot; &quot; + e.getClass().getSimpleName()\n *                  + &quot;\\n&quot;;\n *         }\n *\n *      &#064;Override\n *      public void succeeded(FrameworkMethod method) {\n *          watchedLog+= method.getName() + &quot; &quot; + &quot;success!\\n&quot;;\n *         }\n *     };\n *\n *  &#064;Test\n *  public void fails() {\n *      fail();\n *     }\n *\n *  &#064;Test\n *  public void succeeds() {\n *     }\n * }\n * </pre>\n *\n * @since 4.7\n * @deprecated Use {@link TestWatcher} (which implements {@link TestRule}) instead.\n */\n@Deprecated\npublic class TestWatchman implements MethodRule {\n    public Statement apply(final Statement base, final FrameworkMethod method,\n            Object target) {\n        return new Statement() {\n            @Override\n            public void evaluate() throws Throwable {\n                starting(method);\n                try {\n                    base.evaluate();\n                    succeeded(method);\n                } catch (AssumptionViolatedException e) {\n                    throw e;\n                } catch (Throwable e) {\n                    failed(e, method);\n                    throw e;\n                } finally {\n                    finished(method);\n                }\n            }\n        };\n    }\n\n    /**\n     * Invoked when a test method succeeds\n     */\n    public void succeeded(FrameworkMethod method) {\n    }\n\n    /**\n     * Invoked when a test method fails\n     */\n    public void failed(Throwable e, FrameworkMethod method) {\n    }\n\n    /**\n     * Invoked when a test method is about to start\n     */\n    public void starting(FrameworkMethod method) {\n    }\n\n\n    /**\n     * Invoked when a test method finishes (whether passing or failing)\n     */\n    public void finished(FrameworkMethod method) {\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/Timeout.java",
    "content": "package org.junit.rules;\n\nimport org.junit.internal.runners.statements.FailOnTimeout;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\nimport java.util.concurrent.TimeUnit;\n\n/**\n * The Timeout Rule applies the same timeout to all test methods in a class:\n * <pre>\n * public static class HasGlobalLongTimeout {\n *\n *  &#064;Rule\n *  public Timeout globalTimeout = Timeout.millis(20);\n *\n *  &#064;Test\n *  public void run1() throws InterruptedException {\n *      Thread.sleep(100);\n *  }\n *\n *  &#064;Test\n *  public void infiniteLoop() {\n *      while (true) {}\n *  }\n * }\n * </pre>\n * <p>\n * Each test is run in a new thread. If the specified timeout elapses before\n * the test completes, its execution is interrupted via {@link Thread#interrupt()}.\n * This happens in interruptable I/O and locks, and methods in {@link Object}\n * and {@link Thread} throwing {@link InterruptedException}.\n * <p>\n * A specified timeout of 0 will be interpreted as not set, however tests will\n * still launch from separate threads. This can be useful for disabling timeouts\n * in environments where they are dynamically set based on some property.\n *\n * @since 4.7\n */\npublic class Timeout implements TestRule {\n    private final long timeout;\n    private final TimeUnit timeUnit;\n    private final boolean lookForStuckThread;\n\n    /**\n     * Returns a new builder for building an instance.\n     *\n     * @since 4.12\n     */\n    public static Builder builder() {\n        return new Builder();\n    }\n\n    /**\n     * Create a {@code Timeout} instance with the timeout specified\n     * in milliseconds.\n     * <p>\n     * This constructor is deprecated.\n     * <p>\n     * Instead use {@link #Timeout(long, java.util.concurrent.TimeUnit)},\n     * {@link Timeout#millis(long)}, or {@link Timeout#seconds(long)}.\n     *\n     * @param millis the maximum time in milliseconds to allow the\n     * test to run before it should timeout\n     */\n    @Deprecated\n    public Timeout(int millis) {\n        this(millis, TimeUnit.MILLISECONDS);\n    }\n\n    /**\n     * Create a {@code Timeout} instance with the timeout specified\n     * at the timeUnit of granularity of the provided {@code TimeUnit}.\n     *\n     * @param timeout the maximum time to allow the test to run\n     * before it should timeout\n     * @param timeUnit the time unit for the {@code timeout}\n     * @since 4.12\n     */\n    public Timeout(long timeout, TimeUnit timeUnit) {\n        this.timeout = timeout;\n        this.timeUnit = timeUnit;\n        lookForStuckThread = false;\n    }\n\n    /**\n     * Create a {@code Timeout} instance initialized with values from\n     * a builder.\n     *\n     * @since 4.12\n     */\n    protected Timeout(Builder builder) {\n        timeout = builder.getTimeout();\n        timeUnit = builder.getTimeUnit();\n        lookForStuckThread = builder.getLookingForStuckThread();\n    }\n\n    /**\n     * Creates a {@link Timeout} that will timeout a test after the\n     * given duration, in milliseconds.\n     *\n     * @since 4.12\n     */\n    public static Timeout millis(long millis) {\n        return new Timeout(millis, TimeUnit.MILLISECONDS);\n    }\n\n    /**\n     * Creates a {@link Timeout} that will timeout a test after the\n     * given duration, in seconds.\n     *\n     * @since 4.12\n     */\n    public static Timeout seconds(long seconds) {\n        return new Timeout(seconds, TimeUnit.SECONDS);\n    }\n\n    /**\n     * Gets the timeout configured for this rule, in the given units.\n     *\n     * @since 4.12\n     */\n    protected final long getTimeout(TimeUnit unit) {\n        return unit.convert(timeout, timeUnit);\n    }\n\n    /**\n     * Gets whether this {@code Timeout} will look for a stuck thread\n     * when the test times out.\n     *\n     * @since 4.12\n     */\n    protected final boolean getLookingForStuckThread() {\n        return lookForStuckThread;\n    }\n\n    /**\n     * Creates a {@link Statement} that will run the given\n     * {@code statement}, and timeout the operation based\n     * on the values configured in this rule. Subclasses\n     * can override this method for different behavior.\n     *\n     * @since 4.12\n     */\n    protected Statement createFailOnTimeoutStatement(\n            Statement statement) throws Exception {\n        return FailOnTimeout.builder()\n            .withTimeout(timeout, timeUnit)\n            .withLookingForStuckThread(lookForStuckThread)\n            .build(statement);\n    }\n\n    public Statement apply(Statement base, Description description) {\n        try {\n            return createFailOnTimeoutStatement(base);\n        } catch (final Exception e) {\n            return new Statement() {\n                @Override public void evaluate() throws Throwable {\n                    throw new RuntimeException(\"Invalid parameters for Timeout\", e);\n                }\n            };\n        }\n    }\n\n    /**\n     * Builder for {@link Timeout}.\n     *\n     * @since 4.12\n     */\n    public static class Builder {\n        private boolean lookForStuckThread = false;\n        private long timeout = 0;\n        private TimeUnit timeUnit = TimeUnit.SECONDS;\n\n        protected Builder() {\n        }\n\n        /**\n         * Specifies the time to wait before timing out the test.\n         *\n         * <p>If this is not called, or is called with a\n         * {@code timeout} of {@code 0}, the returned {@code Timeout}\n         * rule instance will cause the tests to wait forever to\n         * complete, however the tests will still launch from a\n         * separate thread. This can be useful for disabling timeouts\n         * in environments where they are dynamically set based on\n         * some property.\n         *\n         * @param timeout the maximum time to wait\n         * @param unit the time unit of the {@code timeout} argument\n         * @return {@code this} for method chaining.\n         */\n        public Builder withTimeout(long timeout, TimeUnit unit) {\n            this.timeout = timeout;\n            this.timeUnit = unit;\n            return this;\n        }\n\n        protected long getTimeout() {\n            return timeout;\n        }\n\n        protected TimeUnit getTimeUnit()  {\n            return timeUnit;\n        }\n\n        /**\n         * Specifies whether to look for a stuck thread.  If a timeout occurs and this\n         * feature is enabled, the rule will look for a thread that appears to be stuck\n         * and dump its backtrace.  This feature is experimental.  Behavior may change\n         * after the 4.12 release in response to feedback.\n         *\n         * @param enable {@code true} to enable the feature\n         * @return {@code this} for method chaining.\n         */\n        public Builder withLookingForStuckThread(boolean enable) {\n            this.lookForStuckThread = enable;\n            return this;\n        }\n\n        protected boolean getLookingForStuckThread() {\n            return lookForStuckThread;\n        }\n\n\n        /**\n         * Builds a {@link Timeout} instance using the values in this builder.,\n         */\n        public Timeout build() {\n            return new Timeout(this);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/rules/Verifier.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\n/**\n * Verifier is a base class for Rules like ErrorCollector, which can turn\n * otherwise passing test methods into failing tests if a verification check is\n * failed\n *\n * <pre>\n *     public static class ErrorLogVerifier {\n *        private ErrorLog errorLog = new ErrorLog();\n *\n *        &#064;Rule\n *        public Verifier verifier = new Verifier() {\n *           &#064;Override public void verify() {\n *              assertTrue(errorLog.isEmpty());\n *           }\n *        }\n *\n *        &#064;Test public void testThatMightWriteErrorLog() {\n *           // ...\n *        }\n *     }\n * </pre>\n *\n * @since 4.7\n */\npublic abstract class Verifier implements TestRule {\n    public Statement apply(final Statement base, Description description) {\n        return new Statement() {\n            @Override\n            public void evaluate() throws Throwable {\n                base.evaluate();\n                verify();\n            }\n        };\n    }\n\n    /**\n     * Override this to add verification logic. Overrides should throw an\n     * exception to indicate that verification failed.\n     */\n    protected void verify() throws Throwable {\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/Computer.java",
    "content": "package org.junit.runner;\n\nimport org.junit.runners.Suite;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerBuilder;\n\n/**\n * Represents a strategy for computing runners and suites.\n * WARNING: this class is very likely to undergo serious changes in version 4.8 and\n * beyond.\n *\n * @since 4.6\n */\npublic class Computer {\n    /**\n     * Returns a new default computer, which runs tests in serial order\n     */\n    public static Computer serial() {\n        return new Computer();\n    }\n\n    /**\n     * Create a suite for {@code classes}, building Runners with {@code builder}.\n     * Throws an InitializationError if Runner construction fails\n     */\n    public Runner getSuite(final RunnerBuilder builder,\n            Class<?>[] classes) throws InitializationError {\n        return new Suite(new RunnerBuilder() {\n            @Override\n            public Runner runnerForClass(Class<?> testClass) throws Throwable {\n                return getRunner(builder, testClass);\n            }\n        }, classes) {\n            @Override\n            protected String getName() {\n                /*\n                 * #1320 The generated suite is not based on a real class so\n                 * only a 'null' description can be generated from it. This name\n                 * will be overridden here.\n                 */\n                return \"classes\";\n            }\n        };\n    }\n\n    /**\n     * Create a single-class runner for {@code testClass}, using {@code builder}\n     */\n    protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable {\n        return builder.runnerForClass(testClass);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/Describable.java",
    "content": "package org.junit.runner;\n\n\n/**\n * Represents an object that can describe itself\n *\n * @since 4.5\n */\npublic interface Describable {\n    /**\n     * @return a {@link Description} showing the tests to be run by the receiver\n     */\n    Description getDescription();\n}"
  },
  {
    "path": "src/main/java/org/junit/runner/Description.java",
    "content": "package org.junit.runner;\n\nimport java.io.Serializable;\nimport java.lang.annotation.Annotation;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.concurrent.ConcurrentLinkedQueue;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * A <code>Description</code> describes a test which is to be run or has been run. <code>Descriptions</code>\n * can be atomic (a single test) or compound (containing children tests). <code>Descriptions</code> are used\n * to provide feedback about the tests that are about to run (for example, the tree view\n * visible in many IDEs) or tests that have been run (for example, the failures view).\n * <p>\n * <code>Descriptions</code> are implemented as a single class rather than a Composite because\n * they are entirely informational. They contain no logic aside from counting their tests.\n * <p>\n * In the past, we used the raw {@link junit.framework.TestCase}s and {@link junit.framework.TestSuite}s\n * to display the tree of tests. This was no longer viable in JUnit 4 because atomic tests no longer have\n * a superclass below {@link Object}. We needed a way to pass a class and name together. Description\n * emerged from this.\n *\n * @see org.junit.runner.Request\n * @see org.junit.runner.Runner\n * @since 4.0\n */\npublic class Description implements Serializable {\n    private static final long serialVersionUID = 1L;\n\n    private static final Pattern METHOD_AND_CLASS_NAME_PATTERN = Pattern\n            .compile(\"([\\\\s\\\\S]*)\\\\((.*)\\\\)\");\n\n    /**\n     * Create a <code>Description</code> named <code>name</code>.\n     * Generally, you will add children to this <code>Description</code>.\n     *\n     * @param name the name of the <code>Description</code>\n     * @param annotations meta-data about the test, for downstream interpreters\n     * @return a <code>Description</code> named <code>name</code>\n     */\n    public static Description createSuiteDescription(String name, Annotation... annotations) {\n        return new Description(null, name, annotations);\n    }\n\n    /**\n     * Create a <code>Description</code> named <code>name</code>.\n     * Generally, you will add children to this <code>Description</code>.\n     *\n     * @param name the name of the <code>Description</code>\n     * @param uniqueId an arbitrary object used to define uniqueness (in {@link #equals(Object)}\n     * @param annotations meta-data about the test, for downstream interpreters\n     * @return a <code>Description</code> named <code>name</code>\n     */\n    public static Description createSuiteDescription(String name, Serializable uniqueId, Annotation... annotations) {\n        return new Description(null, name, uniqueId, annotations);\n    }\n\n    /**\n     * Create a <code>Description</code> of a single test named <code>name</code> in the 'class' named\n     * <code>className</code>. Generally, this will be a leaf <code>Description</code>. This method is a better choice\n     * than {@link #createTestDescription(Class, String, Annotation...)} for test runners whose test cases are not\n     * defined in an actual Java <code>Class</code>.\n     *\n     * @param className the class name of the test\n     * @param name the name of the test (a method name for test annotated with {@link org.junit.Test})\n     * @param annotations meta-data about the test, for downstream interpreters\n     * @return a <code>Description</code> named <code>name</code>\n     */\n    public static Description createTestDescription(String className, String name, Annotation... annotations) {\n        return new Description(null, formatDisplayName(name, className), annotations);\n    }\n\n    /**\n     * Create a <code>Description</code> of a single test named <code>name</code> in the class <code>clazz</code>.\n     * Generally, this will be a leaf <code>Description</code>.\n     *\n     * @param clazz the class of the test\n     * @param name the name of the test (a method name for test annotated with {@link org.junit.Test})\n     * @param annotations meta-data about the test, for downstream interpreters\n     * @return a <code>Description</code> named <code>name</code>\n     */\n    public static Description createTestDescription(Class<?> clazz, String name, Annotation... annotations) {\n        return new Description(clazz, formatDisplayName(name, clazz.getName()), annotations);\n    }\n\n    /**\n     * Create a <code>Description</code> of a single test named <code>name</code> in the class <code>clazz</code>.\n     * Generally, this will be a leaf <code>Description</code>.\n     * (This remains for binary compatibility with clients of JUnit 4.3)\n     *\n     * @param clazz the class of the test\n     * @param name the name of the test (a method name for test annotated with {@link org.junit.Test})\n     * @return a <code>Description</code> named <code>name</code>\n     */\n    public static Description createTestDescription(Class<?> clazz, String name) {\n        return new Description(clazz, formatDisplayName(name, clazz.getName()));\n    }\n\n    /**\n     * Create a <code>Description</code> of a single test named <code>name</code> in the class <code>clazz</code>.\n     * Generally, this will be a leaf <code>Description</code>.\n     *\n     * @param name the name of the test (a method name for test annotated with {@link org.junit.Test})\n     * @return a <code>Description</code> named <code>name</code>\n     */\n    public static Description createTestDescription(String className, String name, Serializable uniqueId) {\n        return new Description(null, formatDisplayName(name, className), uniqueId);\n    }\n\n    private static String formatDisplayName(String name, String className) {\n        return String.format(\"%s(%s)\", name, className);\n    }\n\n    /**\n     * Create a <code>Description</code> named after <code>testClass</code>\n     *\n     * @param testClass A {@link Class} containing tests\n     * @return a <code>Description</code> of <code>testClass</code>\n     */\n    public static Description createSuiteDescription(Class<?> testClass) {\n        return new Description(testClass, testClass.getName(), testClass.getAnnotations());\n    }\n\n    /**\n     * Create a <code>Description</code> named after <code>testClass</code>\n     *\n     * @param testClass A not null {@link Class} containing tests\n     * @param annotations meta-data about the test, for downstream interpreters\n     * @return a <code>Description</code> of <code>testClass</code>\n     */\n    public static Description createSuiteDescription(Class<?> testClass, Annotation... annotations) {\n        return new Description(testClass, testClass.getName(), annotations);\n    }\n\n    /**\n     * Describes a Runner which runs no tests\n     */\n    public static final Description EMPTY = new Description(null, \"No Tests\");\n\n    /**\n     * Describes a step in the test-running mechanism that goes so wrong no\n     * other description can be used (for example, an exception thrown from a Runner's\n     * constructor\n     */\n    public static final Description TEST_MECHANISM = new Description(null, \"Test mechanism\");\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final Collection<Description> fChildren = new ConcurrentLinkedQueue<Description>();\n    private final String fDisplayName;\n    private final Serializable fUniqueId;\n    private final Annotation[] fAnnotations;\n    private volatile /* write-once */ Class<?> fTestClass;\n\n    private Description(Class<?> clazz, String displayName, Annotation... annotations) {\n        this(clazz, displayName, displayName, annotations);\n    }\n\n    private Description(Class<?> testClass, String displayName, Serializable uniqueId, Annotation... annotations) {\n        if ((displayName == null) || (displayName.length() == 0)) {\n            throw new IllegalArgumentException(\n                    \"The display name must not be empty.\");\n        }\n        if ((uniqueId == null)) {\n            throw new IllegalArgumentException(\n                    \"The unique id must not be null.\");\n        }\n        this.fTestClass = testClass;\n        this.fDisplayName = displayName;\n        this.fUniqueId = uniqueId;\n        this.fAnnotations = annotations;\n    }\n\n    /**\n     * @return a user-understandable label\n     */\n    public String getDisplayName() {\n        return fDisplayName;\n    }\n\n    /**\n     * Add <code>Description</code> as a child of the receiver.\n     *\n     * @param description the soon-to-be child.\n     */\n    public void addChild(Description description) {\n        fChildren.add(description);\n    }\n\n    /**\n     * Gets the copy of the children of this {@code Description}.\n     * Returns an empty list if there are no children.\n     */\n    public ArrayList<Description> getChildren() {\n        return new ArrayList<Description>(fChildren);\n    }\n\n    /**\n     * @return <code>true</code> if the receiver is a suite\n     */\n    public boolean isSuite() {\n        return !isTest();\n    }\n\n    /**\n     * @return <code>true</code> if the receiver is an atomic test\n     */\n    public boolean isTest() {\n        return fChildren.isEmpty();\n    }\n\n    /**\n     * @return the total number of atomic tests in the receiver\n     */\n    public int testCount() {\n        if (isTest()) {\n            return 1;\n        }\n        int result = 0;\n        for (Description child : fChildren) {\n            result += child.testCount();\n        }\n        return result;\n    }\n\n    @Override\n    public int hashCode() {\n        return fUniqueId.hashCode();\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        if (!(obj instanceof Description)) {\n            return false;\n        }\n        Description d = (Description) obj;\n        return fUniqueId.equals(d.fUniqueId);\n    }\n\n    @Override\n    public String toString() {\n        return getDisplayName();\n    }\n\n    /**\n     * @return true if this is a description of a Runner that runs no tests\n     */\n    public boolean isEmpty() {\n        return equals(EMPTY);\n    }\n\n    /**\n     * @return a copy of this description, with no children (on the assumption that some of the\n     *         children will be added back)\n     */\n    public Description childlessCopy() {\n        return new Description(fTestClass, fDisplayName, fAnnotations);\n    }\n\n    /**\n     * @return the annotation of type annotationType that is attached to this description node,\n     *         or null if none exists\n     */\n    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {\n        for (Annotation each : fAnnotations) {\n            if (each.annotationType().equals(annotationType)) {\n                return annotationType.cast(each);\n            }\n        }\n        return null;\n    }\n\n    /**\n     * @return all of the annotations attached to this description node\n     */\n    public Collection<Annotation> getAnnotations() {\n        return Arrays.asList(fAnnotations);\n    }\n\n    /**\n     * @return If this describes a method invocation,\n     *         the class of the test instance.\n     */\n    public Class<?> getTestClass() {\n        if (fTestClass != null) {\n            return fTestClass;\n        }\n        String name = getClassName();\n        if (name == null) {\n            return null;\n        }\n        try {\n            fTestClass = Class.forName(name, false, getClass().getClassLoader());\n            return fTestClass;\n        } catch (ClassNotFoundException e) {\n            return null;\n        }\n    }\n\n    /**\n     * @return If this describes a method invocation,\n     *         the name of the class of the test instance\n     */\n    public String getClassName() {\n        return fTestClass != null ? fTestClass.getName() : methodAndClassNamePatternGroupOrDefault(2, toString());\n    }\n\n    /**\n     * @return If this describes a method invocation,\n     *         the name of the method (or null if not)\n     */\n    public String getMethodName() {\n        return methodAndClassNamePatternGroupOrDefault(1, null);\n    }\n\n    private String methodAndClassNamePatternGroupOrDefault(int group,\n            String defaultString) {\n        Matcher matcher = METHOD_AND_CLASS_NAME_PATTERN.matcher(toString());\n        return matcher.matches() ? matcher.group(group) : defaultString;\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/runner/FilterFactories.java",
    "content": "package org.junit.runner;\r\n\r\nimport org.junit.internal.Classes;\r\nimport org.junit.runner.FilterFactory.FilterNotCreatedException;\r\nimport org.junit.runner.manipulation.Filter;\r\n\r\n/**\r\n * Utility class whose methods create a {@link FilterFactory}.\r\n */\r\nclass FilterFactories {\r\n    /**\r\n     * Creates a {@link Filter}.\r\n     *\r\n     * A filter specification is of the form \"package.of.FilterFactory=args-to-filter-factory\" or\r\n     * \"package.of.FilterFactory\".\r\n     *\r\n     * @param request the request that will be filtered\r\n     * @param filterSpec the filter specification\r\n     */\r\n    public static Filter createFilterFromFilterSpec(Request request, String filterSpec)\r\n            throws FilterFactory.FilterNotCreatedException {\r\n        Description topLevelDescription = request.getRunner().getDescription();\r\n        String[] tuple;\r\n\r\n        if (filterSpec.contains(\"=\")) {\r\n            tuple = filterSpec.split(\"=\", 2);\r\n        } else {\r\n            tuple = new String[]{ filterSpec, \"\" };\r\n        }\r\n\r\n        return createFilter(tuple[0], new FilterFactoryParams(topLevelDescription, tuple[1]));\r\n    }\r\n\r\n    /**\r\n     * Creates a {@link Filter}.\r\n     *\r\n     * @param filterFactoryFqcn The fully qualified class name of the {@link FilterFactory}\r\n     * @param params The arguments to the {@link FilterFactory}\r\n     */\r\n    public static Filter createFilter(String filterFactoryFqcn, FilterFactoryParams params)\r\n            throws FilterFactory.FilterNotCreatedException {\r\n        FilterFactory filterFactory = createFilterFactory(filterFactoryFqcn);\r\n\r\n        return filterFactory.createFilter(params);\r\n    }\r\n\r\n    /**\r\n     * Creates a {@link Filter}.\r\n     *\r\n     * @param filterFactoryClass The class of the {@link FilterFactory}\r\n     * @param params             The arguments to the {@link FilterFactory}\r\n     *\r\n     */\r\n    public static Filter createFilter(Class<? extends FilterFactory> filterFactoryClass, FilterFactoryParams params)\r\n            throws FilterFactory.FilterNotCreatedException {\r\n        FilterFactory filterFactory = createFilterFactory(filterFactoryClass);\r\n\r\n        return filterFactory.createFilter(params);\r\n    }\r\n\r\n    static FilterFactory createFilterFactory(String filterFactoryFqcn) throws FilterNotCreatedException {\r\n        Class<? extends FilterFactory> filterFactoryClass;\r\n\r\n        try {\r\n            filterFactoryClass = Classes.getClass(filterFactoryFqcn).asSubclass(FilterFactory.class);\r\n        } catch (Exception e) {\r\n            throw new FilterNotCreatedException(e);\r\n        }\r\n\r\n        return createFilterFactory(filterFactoryClass);\r\n    }\r\n\r\n    static FilterFactory createFilterFactory(Class<? extends FilterFactory> filterFactoryClass)\r\n            throws FilterNotCreatedException {\r\n        try {\r\n            return filterFactoryClass.getConstructor().newInstance();\r\n        } catch (Exception e) {\r\n            throw new FilterNotCreatedException(e);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/runner/FilterFactory.java",
    "content": "package org.junit.runner;\r\n\r\nimport org.junit.runner.manipulation.Filter;\r\n\r\n/**\r\n * Extend this class to create a factory that creates {@link Filter}.\r\n */\r\npublic interface FilterFactory {\r\n    /**\r\n     * Creates a {@link Filter} given a {@link FilterFactoryParams} argument.\r\n     *\r\n     * @param params Parameters needed to create the {@link Filter}\r\n     */\r\n    Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException;\r\n\r\n    /**\r\n     * Exception thrown if the {@link Filter} cannot be created.\r\n     */\r\n    @SuppressWarnings(\"serial\")\r\n    class FilterNotCreatedException extends Exception {\r\n        public FilterNotCreatedException(Exception exception) {\r\n            super(exception.getMessage(), exception);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/runner/FilterFactoryParams.java",
    "content": "package org.junit.runner;\r\n\r\npublic final class FilterFactoryParams {\r\n    private final Description topLevelDescription;\r\n    private final String args;\r\n\r\n    public FilterFactoryParams(Description topLevelDescription, String args) {\r\n        if (args == null || topLevelDescription == null) {\r\n            throw new NullPointerException();\r\n        }\r\n\r\n        this.topLevelDescription = topLevelDescription;\r\n        this.args = args;\r\n    }\r\n\r\n    public String getArgs() {\r\n        return args;\r\n    }\r\n\r\n    public Description getTopLevelDescription() {\r\n        return topLevelDescription;\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/runner/JUnitCommandLineParseResult.java",
    "content": "package org.junit.runner;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.Collections;\r\nimport java.util.List;\r\n\r\nimport org.junit.internal.Classes;\r\nimport org.junit.runner.FilterFactory.FilterNotCreatedException;\r\nimport org.junit.runner.manipulation.Filter;\r\nimport org.junit.runners.model.InitializationError;\r\n\r\nclass JUnitCommandLineParseResult {\r\n    private final List<String> filterSpecs = new ArrayList<String>();\r\n    private final List<Class<?>> classes = new ArrayList<Class<?>>();\r\n    private final List<Throwable> parserErrors = new ArrayList<Throwable>();\r\n\r\n    /**\r\n     * Do not use. Testing purposes only.\r\n     */\r\n    JUnitCommandLineParseResult() {}\r\n\r\n    /**\r\n     * Returns filter specs parsed from command line.\r\n     */\r\n    public List<String> getFilterSpecs() {\r\n        return Collections.unmodifiableList(filterSpecs);\r\n    }\r\n\r\n    /**\r\n     * Returns test classes parsed from command line.\r\n     */\r\n    public List<Class<?>> getClasses() {\r\n        return Collections.unmodifiableList(classes);\r\n    }\r\n\r\n    /**\r\n     * Parses the arguments.\r\n     *\r\n     * @param args Arguments\r\n     */\r\n    public static JUnitCommandLineParseResult parse(String[] args) {\r\n        JUnitCommandLineParseResult result = new JUnitCommandLineParseResult();\r\n\r\n        result.parseArgs(args);\r\n\r\n        return result;\r\n    }\r\n\r\n    private void parseArgs(String[] args) {\r\n        parseParameters(parseOptions(args));\r\n    }\r\n\r\n    String[] parseOptions(String... args) {\r\n        for (int i = 0; i != args.length; ++i) {\r\n            String arg = args[i];\r\n\r\n            if (arg.equals(\"--\")) {\r\n                return copyArray(args, i + 1, args.length);\r\n            } else if (arg.startsWith(\"--\")) {\r\n                if (arg.startsWith(\"--filter=\") || arg.equals(\"--filter\")) {\r\n                    String filterSpec;\r\n                    if (arg.equals(\"--filter\")) {\r\n                        ++i;\r\n\r\n                        if (i < args.length) {\r\n                            filterSpec = args[i];\r\n                        } else {\r\n                            parserErrors.add(new CommandLineParserError(arg + \" value not specified\"));\r\n                            break;\r\n                        }\r\n                    } else {\r\n                        filterSpec = arg.substring(arg.indexOf('=') + 1);\r\n                    }\r\n\r\n                    filterSpecs.add(filterSpec);\r\n                } else {\r\n                    parserErrors.add(new CommandLineParserError(\"JUnit knows nothing about the \" + arg + \" option\"));\r\n                }\r\n            } else {\r\n                return copyArray(args, i, args.length);\r\n            }\r\n        }\r\n\r\n        return new String[]{};\r\n    }\r\n\r\n    private String[] copyArray(String[] args, int from, int to) {\r\n        String[] result = new String[to - from];\r\n        for (int j = from; j != to; ++j) {\r\n            result[j - from] = args[j];\r\n        }\r\n        return result;\r\n    }\r\n\r\n    void parseParameters(String[] args) {\r\n        for (String arg : args) {\r\n            try {\r\n                classes.add(Classes.getClass(arg));\r\n            } catch (ClassNotFoundException e) {\r\n                parserErrors.add(new IllegalArgumentException(\"Could not find class [\" + arg + \"]\", e));\r\n            }\r\n        }\r\n    }\r\n\r\n    private Request errorReport(Throwable cause) {\r\n        return Request.errorReport(JUnitCommandLineParseResult.class, cause);\r\n    }\r\n\r\n    /**\r\n     * Creates a {@link Request}.\r\n     *\r\n     * @param computer {@link Computer} to be used.\r\n     */\r\n    public Request createRequest(Computer computer) {\r\n        if (parserErrors.isEmpty()) {\r\n            Request request = Request.classes(\r\n                    computer, classes.toArray(new Class<?>[classes.size()]));\r\n            return applyFilterSpecs(request);\r\n        } else {\r\n            return errorReport(new InitializationError(parserErrors));\r\n        }\r\n    }\r\n\r\n    private Request applyFilterSpecs(Request request) {\r\n        try {\r\n            for (String filterSpec : filterSpecs) {\r\n                Filter filter = FilterFactories.createFilterFromFilterSpec(\r\n                        request, filterSpec);\r\n                request = request.filterWith(filter);\r\n            }\r\n            return request;\r\n        } catch (FilterNotCreatedException e) {\r\n            return errorReport(e);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Exception used if there's a problem parsing the command line.\r\n     */\r\n    public static class CommandLineParserError extends Exception {\r\n        private static final long serialVersionUID= 1L;\r\n\r\n        public CommandLineParserError(String message) {\r\n            super(message);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/main/java/org/junit/runner/JUnitCore.java",
    "content": "package org.junit.runner;\n\nimport junit.runner.Version;\nimport org.junit.internal.JUnitSystem;\nimport org.junit.internal.RealSystem;\nimport org.junit.internal.TextListener;\nimport org.junit.internal.runners.JUnit38ClassRunner;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runner.notification.RunNotifier;\n\n/**\n * <code>JUnitCore</code> is a facade for running tests. It supports running JUnit 4 tests,\n * JUnit 3.8.x tests, and mixtures. To run tests from the command line, run\n * <code>java org.junit.runner.JUnitCore TestClass1 TestClass2 ...</code>.\n * For one-shot test runs, use the static method {@link #runClasses(Class[])}.\n * If you want to add special listeners,\n * create an instance of {@link org.junit.runner.JUnitCore} first and use it to run the tests.\n *\n * @see org.junit.runner.Result\n * @see org.junit.runner.notification.RunListener\n * @see org.junit.runner.Request\n * @since 4.0\n */\npublic class JUnitCore {\n    private final RunNotifier notifier = new RunNotifier();\n\n    /**\n     * Run the tests contained in the classes named in the <code>args</code>.\n     * If all tests run successfully, exit with a status of 0. Otherwise exit with a status of 1.\n     * Write feedback while tests are running and write\n     * stack traces for all failed tests after the tests all complete.\n     *\n     * @param args names of classes in which to find tests to run\n     */\n    public static void main(String... args) {\n        System.exit(runMain(args));\n    }\n\n    static int runMain(String[] args) {\n        Result result = new JUnitCore().runMain(new RealSystem(), args);\n        return result.wasSuccessful() ? 0 : 1;\n    }\n\n    /**\n     * Run the tests contained in <code>classes</code>. Write feedback while the tests\n     * are running and write stack traces for all failed tests after all tests complete. This is\n     * similar to {@link #main(String[])}, but intended to be used programmatically.\n     *\n     * @param classes Classes in which to find tests\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public static Result runClasses(Class<?>... classes) {\n        return runClasses(defaultComputer(), classes);\n    }\n\n    /**\n     * Run the tests contained in <code>classes</code>. Write feedback while the tests\n     * are running and write stack traces for all failed tests after all tests complete. This is\n     * similar to {@link #main(String[])}, but intended to be used programmatically.\n     *\n     * @param computer Helps construct Runners from classes\n     * @param classes  Classes in which to find tests\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public static Result runClasses(Computer computer, Class<?>... classes) {\n        return new JUnitCore().run(computer, classes);\n    }\n\n    /**\n     * @param system system to run with\n     * @param args from main()\n     */\n    Result runMain(JUnitSystem system, String... args) {\n        system.out().println(\"JUnit version \" + Version.id());\n\n        JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args);\n\n        RunListener listener = new TextListener(system);\n        addListener(listener);\n\n        return run(jUnitCommandLineParseResult.createRequest(defaultComputer()));\n    }\n\n    /**\n     * @return the version number of this release\n     */\n    public String getVersion() {\n        return Version.id();\n    }\n\n    /**\n     * Run all the tests in <code>classes</code>.\n     *\n     * @param classes the classes containing tests\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public Result run(Class<?>... classes) {\n        return run(defaultComputer(), classes);\n    }\n\n    /**\n     * Run all the tests in <code>classes</code>.\n     *\n     * @param computer Helps construct Runners from classes\n     * @param classes the classes containing tests\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public Result run(Computer computer, Class<?>... classes) {\n        return run(Request.classes(computer, classes));\n    }\n\n    /**\n     * Run all the tests contained in <code>request</code>.\n     *\n     * @param request the request describing tests\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public Result run(Request request) {\n        return run(request.getRunner());\n    }\n\n    /**\n     * Run all the tests contained in JUnit 3.8.x <code>test</code>. Here for backward compatibility.\n     *\n     * @param test the old-style test\n     * @return a {@link Result} describing the details of the test run and the failed tests.\n     */\n    public Result run(junit.framework.Test test) {\n        return run(new JUnit38ClassRunner(test));\n    }\n\n    /**\n     * Do not use. Testing purposes only.\n     */\n    public Result run(Runner runner) {\n        Result result = new Result();\n        RunListener listener = result.createListener();\n        notifier.addFirstListener(listener);\n        try {\n            notifier.fireTestRunStarted(runner.getDescription());\n            runner.run(notifier);\n            notifier.fireTestRunFinished(result);\n        } finally {\n            removeListener(listener);\n        }\n        return result;\n    }\n\n    /**\n     * Add a listener to be notified as the tests run.\n     *\n     * @param listener the listener to add\n     * @see org.junit.runner.notification.RunListener\n     */\n    public void addListener(RunListener listener) {\n        notifier.addListener(listener);\n    }\n\n    /**\n     * Remove a listener.\n     *\n     * @param listener the listener to remove\n     */\n    public void removeListener(RunListener listener) {\n        notifier.removeListener(listener);\n    }\n\n    static Computer defaultComputer() {\n        return new Computer();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/OrderWith.java",
    "content": "package org.junit.runner;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\nimport org.junit.runner.manipulation.Ordering;\nimport org.junit.validator.ValidateWith;\n\n/**\n * When a test class is annotated with <code>&#064;OrderWith</code> or extends a class annotated\n * with <code>&#064;OrderWith</code>, JUnit will order the tests in the test class (and child\n * test classes, if any) using the ordering defined by the {@link Ordering} class.\n *\n * @since 4.13\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.TYPE)\n@Inherited\n@ValidateWith(OrderWithValidator.class)\npublic @interface OrderWith {\n    /**\n     * Gets a class that extends {@link Ordering}. The class must have a public no-arg constructor.\n     */\n    Class<? extends Ordering.Factory> value();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/OrderWithValidator.java",
    "content": "package org.junit.runner;\n\nimport static java.util.Collections.emptyList;\nimport static java.util.Collections.singletonList;\n\nimport java.util.List;\n\nimport org.junit.FixMethodOrder;\nimport org.junit.runners.model.TestClass;\nimport org.junit.validator.AnnotationValidator;\n\n/**\n * Validates that there are no errors in the use of the {@code OrderWith}\n * annotation. If there is, a {@code Throwable} object will be added to the list\n * of errors.\n *\n * @since 4.13\n */\npublic final class OrderWithValidator extends AnnotationValidator {\n\n    /**\n     * Adds to {@code errors} a throwable for each problem detected. Looks for\n     * {@code FixMethodOrder} annotations.\n     *\n     * @param testClass that is being validated\n     * @return A list of exceptions detected\n     *\n     * @since 4.13\n     */\n    @Override\n    public List<Exception> validateAnnotatedClass(TestClass testClass) {\n        if (testClass.getAnnotation(FixMethodOrder.class) != null) {\n            return singletonList(\n                    new Exception(\"@FixMethodOrder cannot be combined with @OrderWith\"));\n        }\n        return emptyList();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/Request.java",
    "content": "package org.junit.runner;\n\nimport java.util.Comparator;\n\nimport org.junit.internal.builders.AllDefaultPossibilitiesBuilder;\nimport org.junit.internal.requests.ClassRequest;\nimport org.junit.internal.requests.FilterRequest;\nimport org.junit.internal.requests.OrderingRequest;\nimport org.junit.internal.requests.SortingRequest;\nimport org.junit.internal.runners.ErrorReportingRunner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.Ordering;\nimport org.junit.runners.model.InitializationError;\n\n/**\n * A <code>Request</code> is an abstract description of tests to be run. Older versions of\n * JUnit did not need such a concept--tests to be run were described either by classes containing\n * tests or a tree of {@link  org.junit.Test}s. However, we want to support filtering and sorting,\n * so we need a more abstract specification than the tests themselves and a richer\n * specification than just the classes.\n *\n * <p>The flow when JUnit runs tests is that a <code>Request</code> specifies some tests to be run -&gt;\n * a {@link org.junit.runner.Runner} is created for each class implied by the <code>Request</code> -&gt;\n * the {@link org.junit.runner.Runner} returns a detailed {@link org.junit.runner.Description}\n * which is a tree structure of the tests to be run.\n *\n * @since 4.0\n */\npublic abstract class Request {\n    /**\n     * Create a <code>Request</code> that, when processed, will run a single test.\n     * This is done by filtering out all other tests. This method is used to support rerunning\n     * single tests.\n     *\n     * @param clazz the class of the test\n     * @param methodName the name of the test\n     * @return a <code>Request</code> that will cause a single test be run\n     */\n    public static Request method(Class<?> clazz, String methodName) {\n        Description method = Description.createTestDescription(clazz, methodName);\n        return Request.aClass(clazz).filterWith(method);\n    }\n\n    /**\n     * Create a <code>Request</code> that, when processed, will run all the tests\n     * in a class. The odd name is necessary because <code>class</code> is a reserved word.\n     *\n     * @param clazz the class containing the tests\n     * @return a <code>Request</code> that will cause all tests in the class to be run\n     */\n    public static Request aClass(Class<?> clazz) {\n        return new ClassRequest(clazz);\n    }\n\n    /**\n     * Create a <code>Request</code> that, when processed, will run all the tests\n     * in a class. If the class has a suite() method, it will be ignored.\n     *\n     * @param clazz the class containing the tests\n     * @return a <code>Request</code> that will cause all tests in the class to be run\n     */\n    public static Request classWithoutSuiteMethod(Class<?> clazz) {\n        return new ClassRequest(clazz, false);\n    }\n\n    /**\n     * Create a <code>Request</code> that, when processed, will run all the tests\n     * in a set of classes.\n     *\n     * @param computer Helps construct Runners from classes\n     * @param classes the classes containing the tests\n     * @return a <code>Request</code> that will cause all tests in the classes to be run\n     */\n    public static Request classes(Computer computer, Class<?>... classes) {\n        try {\n            AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder();\n            Runner suite = computer.getSuite(builder, classes);\n            return runner(suite);\n        } catch (InitializationError e) {\n            return runner(new ErrorReportingRunner(e, classes));\n        }\n    }\n\n    /**\n     * Create a <code>Request</code> that, when processed, will run all the tests\n     * in a set of classes with the default <code>Computer</code>.\n     *\n     * @param classes the classes containing the tests\n     * @return a <code>Request</code> that will cause all tests in the classes to be run\n     */\n    public static Request classes(Class<?>... classes) {\n        return classes(JUnitCore.defaultComputer(), classes);\n    }\n\n\n    /**\n     * Creates a {@link Request} that, when processed, will report an error for the given\n     * test class with the given cause.\n     */\n    public static Request errorReport(Class<?> klass, Throwable cause) {\n        return runner(new ErrorReportingRunner(klass, cause));\n    }\n\n    /**\n     * @param runner the runner to return\n     * @return a <code>Request</code> that will run the given runner when invoked\n     */\n    public static Request runner(final Runner runner) {\n        return new Request() {\n            @Override\n            public Runner getRunner() {\n                return runner;\n            }\n        };\n    }\n\n    /**\n     * Returns a {@link Runner} for this Request\n     *\n     * @return corresponding {@link Runner} for this Request\n     */\n    public abstract Runner getRunner();\n\n    /**\n     * Returns a Request that only contains those tests that should run when\n     * <code>filter</code> is applied\n     *\n     * @param filter The {@link Filter} to apply to this Request\n     * @return the filtered Request\n     */\n    public Request filterWith(Filter filter) {\n        return new FilterRequest(this, filter);\n    }\n\n    /**\n     * Returns a Request that only runs tests whose {@link Description}\n     * matches the given description.\n     *\n     * <p>Returns an empty {@code Request} if {@code desiredDescription} is not a single test and filters all but the single\n     * test if {@code desiredDescription} is a single test.</p>\n     *\n     * @param desiredDescription {@code Description} of those tests that should be run\n     * @return the filtered Request\n     */\n    public Request filterWith(Description desiredDescription) {\n        return filterWith(Filter.matchMethodDescription(desiredDescription));\n    }\n\n    /**\n     * Returns a Request whose Tests can be run in a certain order, defined by\n     * <code>comparator</code>\n     * <p>\n     * For example, here is code to run a test suite in alphabetical order:\n     * <pre>\n     * private static Comparator&lt;Description&gt; forward() {\n     *   return new Comparator&lt;Description&gt;() {\n     *     public int compare(Description o1, Description o2) {\n     *       return o1.getDisplayName().compareTo(o2.getDisplayName());\n     *     }\n     *   };\n     * }\n     *\n     * public static main() {\n     *   new JUnitCore().run(Request.aClass(AllTests.class).sortWith(forward()));\n     * }\n     * </pre>\n     *\n     * @param comparator definition of the order of the tests in this Request\n     * @return a Request with ordered Tests\n     */\n    public Request sortWith(Comparator<Description> comparator) {\n        return new SortingRequest(this, comparator);\n    }\n\n    /**\n     * Returns a Request whose Tests can be run in a certain order, defined by\n     * <code>ordering</code>\n     * <p>\n     * For example, here is code to run a test suite in reverse order:\n     * <pre>\n     * private static Ordering reverse() {\n     *   return new Ordering() {\n     *     public List&lt;Description&gt; orderItems(Collection&lt;Description&gt; descriptions) {\n     *       List&lt;Description&gt; ordered = new ArrayList&lt;&gt;(descriptions);\n     *       Collections.reverse(ordered);\n     *       return ordered;\n     *     }\n     *   }\n     * }\n     *     \n     * public static main() {\n     *   new JUnitCore().run(Request.aClass(AllTests.class).orderWith(reverse()));\n     * }\n     * </pre>\n     *\n     * @return a Request with ordered Tests\n     * @since 4.13\n     */\n    public Request orderWith(Ordering ordering) {\n        return new OrderingRequest(this, ordering);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/Result.java",
    "content": "package org.junit.runner;\n\nimport java.io.IOException;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\nimport java.io.ObjectStreamClass;\nimport java.io.ObjectStreamField;\nimport java.io.Serializable;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.concurrent.CopyOnWriteArrayList;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport java.util.concurrent.atomic.AtomicLong;\n\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\n\n/**\n * A <code>Result</code> collects and summarizes information from running multiple tests.\n * All tests are counted -- additional information is collected from tests that fail.\n *\n * @since 4.0\n */\npublic class Result implements Serializable {\n    private static final long serialVersionUID = 1L;\n    private static final ObjectStreamField[] serialPersistentFields =\n            ObjectStreamClass.lookup(SerializedForm.class).getFields();\n    private final AtomicInteger count;\n    private final AtomicInteger ignoreCount;\n    private final AtomicInteger assumptionFailureCount;\n    private final CopyOnWriteArrayList<Failure> failures;\n    private final AtomicLong runTime;\n    private final AtomicLong startTime;\n\n    /** Only set during deserialization process. */\n    private SerializedForm serializedForm;\n\n    public Result() {\n        count = new AtomicInteger();\n        ignoreCount = new AtomicInteger();\n        assumptionFailureCount = new AtomicInteger();\n        failures = new CopyOnWriteArrayList<Failure>();\n        runTime = new AtomicLong();\n        startTime = new AtomicLong();\n    }\n\n    private Result(SerializedForm serializedForm) {\n        count = serializedForm.fCount;\n        ignoreCount = serializedForm.fIgnoreCount;\n        assumptionFailureCount = serializedForm.assumptionFailureCount;\n        failures = new CopyOnWriteArrayList<Failure>(serializedForm.fFailures);\n        runTime = new AtomicLong(serializedForm.fRunTime);\n        startTime = new AtomicLong(serializedForm.fStartTime);\n    }\n\n    /**\n     * Returns the number of tests run\n     */\n    public int getRunCount() {\n        return count.get();\n    }\n\n    /**\n     * Returns the number of tests that failed during the run\n     */\n    public int getFailureCount() {\n        return failures.size();\n    }\n\n    /**\n     * Returns the number of milliseconds it took to run the entire suite to run\n     */\n    public long getRunTime() {\n        return runTime.get();\n    }\n\n    /**\n     * Returns the {@link Failure}s describing tests that failed and the problems they encountered\n     */\n    public List<Failure> getFailures() {\n        return failures;\n    }\n\n    /**\n     * @return the number of tests ignored during the run\n     */\n    public int getIgnoreCount() {\n        return ignoreCount.get();\n    }\n\n    /**\n     * Returns the number of tests skipped because of an assumption failure\n     *\n     * @throws UnsupportedOperationException if the result was serialized in a version before JUnit 4.13\n     * @since 4.13\n     */\n    public int getAssumptionFailureCount() {\n        if (assumptionFailureCount == null) {\n            throw new UnsupportedOperationException(\n                    \"Result was serialized from a version of JUnit that doesn't support this method\");\n        }\n        return assumptionFailureCount.get();\n    }\n\n    /**\n     * @return <code>true</code> if all tests succeeded\n     */\n    public boolean wasSuccessful() {\n        return getFailureCount() == 0;\n    }\n\n    private void writeObject(ObjectOutputStream s) throws IOException {\n        SerializedForm serializedForm = new SerializedForm(this);\n        serializedForm.serialize(s);\n    }\n\n    private void readObject(ObjectInputStream s)\n            throws ClassNotFoundException, IOException {\n        serializedForm = SerializedForm.deserialize(s);\n    }\n\n    private Object readResolve()  {\n        return new Result(serializedForm);\n    }\n\n    @RunListener.ThreadSafe\n    private class Listener extends RunListener {\n        @Override\n        public void testRunStarted(Description description) throws Exception {\n            startTime.set(System.currentTimeMillis());\n        }\n\n        @Override\n        public void testRunFinished(Result result) throws Exception {\n            long endTime = System.currentTimeMillis();\n            runTime.addAndGet(endTime - startTime.get());\n        }\n\n        @Override\n        public void testFinished(Description description) throws Exception {\n            count.getAndIncrement();\n        }\n\n        @Override\n        public void testFailure(Failure failure) throws Exception {\n            failures.add(failure);\n        }\n\n        @Override\n        public void testIgnored(Description description) throws Exception {\n            ignoreCount.getAndIncrement();\n        }\n\n        @Override\n        public void testAssumptionFailure(Failure failure) {\n            assumptionFailureCount.getAndIncrement();\n        }\n    }\n\n    /**\n     * Internal use only.\n     */\n    public RunListener createListener() {\n        return new Listener();\n    }\n\n    /**\n     * Represents the serialized output of {@code Result}. The fields on this\n     * class match the files that {@code Result} had in JUnit 4.11.\n     */\n    private static class SerializedForm implements Serializable {\n        private static final long serialVersionUID = 1L;\n        private final AtomicInteger fCount;\n        private final AtomicInteger fIgnoreCount;\n        private final AtomicInteger assumptionFailureCount;\n        private final List<Failure> fFailures;\n        private final long fRunTime;\n        private final long fStartTime;\n\n        public SerializedForm(Result result) {\n            fCount = result.count;\n            fIgnoreCount = result.ignoreCount;\n            assumptionFailureCount = result.assumptionFailureCount;\n            fFailures = Collections.synchronizedList(new ArrayList<Failure>(result.failures));\n            fRunTime = result.runTime.longValue();\n            fStartTime = result.startTime.longValue();\n        }\n\n        @SuppressWarnings(\"unchecked\")\n        private SerializedForm(ObjectInputStream.GetField fields) throws IOException, ClassNotFoundException {\n            fCount = (AtomicInteger) fields.get(\"fCount\", null);\n            fIgnoreCount = (AtomicInteger) fields.get(\"fIgnoreCount\", null);\n            assumptionFailureCount = (AtomicInteger) fields.get(\"assumptionFailureCount\", null);\n            fFailures = (List<Failure>) fields.get(\"fFailures\", null);\n            fRunTime = fields.get(\"fRunTime\", 0L);\n            fStartTime = fields.get(\"fStartTime\", 0L);\n        }\n\n        public void serialize(ObjectOutputStream s) throws IOException {\n            ObjectOutputStream.PutField fields = s.putFields();\n            fields.put(\"fCount\", fCount);\n            fields.put(\"fIgnoreCount\", fIgnoreCount);\n            fields.put(\"fFailures\", fFailures);\n            fields.put(\"fRunTime\", fRunTime);\n            fields.put(\"fStartTime\", fStartTime);\n            fields.put(\"assumptionFailureCount\", assumptionFailureCount);\n            s.writeFields();\n        }\n\n        public static SerializedForm deserialize(ObjectInputStream s)\n                throws ClassNotFoundException, IOException {\n            ObjectInputStream.GetField fields = s.readFields();\n            return new SerializedForm(fields);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/RunWith.java",
    "content": "package org.junit.runner;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * When a class is annotated with <code>&#064;RunWith</code> or extends a class annotated\n * with <code>&#064;RunWith</code>, JUnit will invoke the class it references to run the\n * tests in that class instead of the runner built into JUnit. We added this feature late\n * in development. While it seems powerful we expect the runner API to change as we learn\n * how people really use it. Some of the classes that are currently internal will likely\n * be refined and become public.\n *\n * For example, suites in JUnit 4 are built using RunWith, and a custom runner named Suite:\n *\n * <pre>\n * &#064;RunWith(Suite.class)\n * &#064;SuiteClasses({ATest.class, BTest.class, CTest.class})\n * public class ABCSuite {\n * }\n * </pre>\n *\n * @since 4.0\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.TYPE)\n@Inherited\npublic @interface RunWith {\n    /**\n     * @return a Runner class (must have a constructor that takes a single Class to run)\n     */\n    Class<? extends Runner> value();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/Runner.java",
    "content": "package org.junit.runner;\n\nimport org.junit.runner.notification.RunNotifier;\n\n/**\n * A <code>Runner</code> runs tests and notifies a {@link org.junit.runner.notification.RunNotifier}\n * of significant events as it does so. You will need to subclass <code>Runner</code>\n * when using {@link org.junit.runner.RunWith} to invoke a custom runner. When creating\n * a custom runner, in addition to implementing the abstract methods here you must\n * also provide a constructor that takes as an argument the {@link Class} containing\n * the tests.\n *\n * <p>The default runner implementation guarantees that the instances of the test case\n * class will be constructed immediately before running the test and that the runner\n * will retain no reference to the test case instances, generally making them\n * available for garbage collection.\n *\n * @see org.junit.runner.Description\n * @see org.junit.runner.RunWith\n * @since 4.0\n */\npublic abstract class Runner implements Describable {\n    /*\n     * (non-Javadoc)\n     * @see org.junit.runner.Describable#getDescription()\n     */\n    public abstract Description getDescription();\n\n    /**\n     * Run the tests for this runner.\n     *\n     * @param notifier will be notified of events while tests are being run--tests being\n     * started, finishing, and failing\n     */\n    public abstract void run(RunNotifier notifier);\n\n    /**\n     * @return the number of tests to be run by the receiver\n     */\n    public int testCount() {\n        return getDescription().testCount();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Alphanumeric.java",
    "content": "package org.junit.runner.manipulation;\n\nimport java.util.Comparator;\n\nimport org.junit.runner.Description;\n\n/**\n * A sorter that orders tests alphanumerically by test name.\n *\n * @since 4.13\n */\npublic final class Alphanumeric extends Sorter implements Ordering.Factory {\n\n    public Alphanumeric() {\n        super(COMPARATOR);\n    }\n\n    public Ordering create(Context context) {\n        return this;\n    }\n\n    private static final Comparator<Description> COMPARATOR = new Comparator<Description>() {\n        public int compare(Description o1, Description o2) {\n            return o1.getDisplayName().compareTo(o2.getDisplayName());\n        }\n    };\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Filter.java",
    "content": "package org.junit.runner.manipulation;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Request;\n\n/**\n * The canonical case of filtering is when you want to run a single test method in a class. Rather\n * than introduce runner API just for that one case, JUnit provides a general filtering mechanism.\n * If you want to filter the tests to be run, extend <code>Filter</code> and apply an instance of\n * your filter to the {@link org.junit.runner.Request} before running it (see\n * {@link org.junit.runner.JUnitCore#run(Request)}. Alternatively, apply a <code>Filter</code> to\n * a {@link org.junit.runner.Runner} before running tests (for example, in conjunction with\n * {@link org.junit.runner.RunWith}.\n *\n * @since 4.0\n */\npublic abstract class Filter {\n    /**\n     * A null <code>Filter</code> that passes all tests through.\n     */\n    public static final Filter ALL = new Filter() {\n        @Override\n        public boolean shouldRun(Description description) {\n            return true;\n        }\n\n        @Override\n        public String describe() {\n            return \"all tests\";\n        }\n\n        @Override\n        public void apply(Object child) throws NoTestsRemainException {\n            // do nothing\n        }\n\n        @Override\n        public Filter intersect(Filter second) {\n            return second;\n        }\n    };\n\n    /**\n     * Returns a {@code Filter} that only runs the single method described by\n     * {@code desiredDescription}\n     */\n    public static Filter matchMethodDescription(final Description desiredDescription) {\n        return new Filter() {\n            @Override\n            public boolean shouldRun(Description description) {\n                if (description.isTest()) {\n                    return desiredDescription.equals(description);\n                }\n\n                // explicitly check if any children want to run\n                for (Description each : description.getChildren()) {\n                    if (shouldRun(each)) {\n                        return true;\n                    }\n                }\n                return false;\n            }\n\n            @Override\n            public String describe() {\n                return String.format(\"Method %s\", desiredDescription.getDisplayName());\n            }\n        };\n    }\n\n\n    /**\n     * @param description the description of the test to be run\n     * @return <code>true</code> if the test should be run\n     */\n    public abstract boolean shouldRun(Description description);\n\n    /**\n     * Returns a textual description of this Filter\n     *\n     * @return a textual description of this Filter\n     */\n    public abstract String describe();\n\n    /**\n     * Invoke with a {@link org.junit.runner.Runner} to cause all tests it intends to run\n     * to first be checked with the filter. Only those that pass the filter will be run.\n     *\n     * @param child the runner to be filtered by the receiver\n     * @throws NoTestsRemainException if the receiver removes all tests\n     */\n    public void apply(Object child) throws NoTestsRemainException {\n        if (!(child instanceof Filterable)) {\n            return;\n        }\n        Filterable filterable = (Filterable) child;\n        filterable.filter(this);\n    }\n\n    /**\n     * Returns a new Filter that accepts the intersection of the tests accepted\n     * by this Filter and {@code second}\n     */\n    public Filter intersect(final Filter second) {\n        if (second == this || second == ALL) {\n            return this;\n        }\n        final Filter first = this;\n        return new Filter() {\n            @Override\n            public boolean shouldRun(Description description) {\n                return first.shouldRun(description)\n                        && second.shouldRun(description);\n            }\n\n            @Override\n            public String describe() {\n                return first.describe() + \" and \" + second.describe();\n            }\n        };\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Filterable.java",
    "content": "package org.junit.runner.manipulation;\n\n/**\n * Runners that allow filtering should implement this interface. Implement {@link #filter(Filter)}\n * to remove tests that don't pass the filter.\n *\n * @since 4.0\n */\npublic interface Filterable {\n\n    /**\n     * Remove tests that don't pass the parameter <code>filter</code>.\n     *\n     * @param filter the {@link Filter} to apply\n     * @throws NoTestsRemainException if all tests are filtered out\n     */\n    void filter(Filter filter) throws NoTestsRemainException;\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/InvalidOrderingException.java",
    "content": "package org.junit.runner.manipulation;\n\n/**\n * Thrown when an ordering does something invalid (like remove or add children)\n *\n * @since 4.13\n */\npublic class InvalidOrderingException extends Exception {\n    private static final long serialVersionUID = 1L;\n\n    public InvalidOrderingException() {\n    }\n\n    public InvalidOrderingException(String message) {\n        super(message);\n    }\n\n    public InvalidOrderingException(String message, Throwable cause) {\n        super(message, cause);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/NoTestsRemainException.java",
    "content": "package org.junit.runner.manipulation;\n\n/**\n * Thrown when a filter removes all tests from a runner.\n *\n * @since 4.0\n */\npublic class NoTestsRemainException extends Exception {\n    private static final long serialVersionUID = 1L;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Orderable.java",
    "content": "package org.junit.runner.manipulation;\n\n/**\n * Interface for runners that allow ordering of tests.\n *\n * <p>Beware of using this interface to cope with order dependencies between tests.\n * Tests that are isolated from each other are less expensive to maintain and\n * can be run individually.\n *\n * @since 4.13\n */\npublic interface Orderable extends Sortable {\n\n    /**\n     * Orders the tests using <code>orderer</code>\n     *\n     * @throws InvalidOrderingException if orderer does something invalid (like remove or add\n     * children)\n     */\n    void order(Orderer orderer) throws InvalidOrderingException;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Orderer.java",
    "content": "package org.junit.runner.manipulation;\n\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.junit.runner.Description;\n\n/**\n * Orders tests.\n *\n * @since 4.13\n */\npublic final class Orderer  {\n    private final Ordering ordering;\n\n    Orderer(Ordering delegate) {\n        this.ordering = delegate;\n    }\n\n    /**\n     * Orders the descriptions.\n     *\n     * @return descriptions in order\n     */\n    public List<Description> order(Collection<Description> descriptions)\n            throws InvalidOrderingException {\n        List<Description> inOrder = ordering.orderItems(\n                Collections.unmodifiableCollection(descriptions));\n        if (!ordering.validateOrderingIsCorrect()) {\n            return inOrder;\n        }\n\n        Set<Description> uniqueDescriptions = new HashSet<Description>(descriptions);\n        if (!uniqueDescriptions.containsAll(inOrder)) {\n            throw new InvalidOrderingException(\"Ordering added items\");\n        }\n        Set<Description> resultAsSet = new HashSet<Description>(inOrder);\n        if (resultAsSet.size() != inOrder.size()) {\n            throw new InvalidOrderingException(\"Ordering duplicated items\");\n        } else if (!resultAsSet.containsAll(uniqueDescriptions)) {\n            throw new InvalidOrderingException(\"Ordering removed items\");\n        }\n\n        return inOrder;\n    }\n\n    /**\n     * Order the tests in <code>target</code>.\n     *\n     * @throws InvalidOrderingException if ordering does something invalid (like remove or add\n     * children)\n     */\n    public void apply(Object target) throws InvalidOrderingException {\n        if (target instanceof Orderable) {\n            Orderable orderable = (Orderable) target;\n            orderable.order(this);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Ordering.java",
    "content": "package org.junit.runner.manipulation;\n\nimport java.lang.reflect.Constructor;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Random;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.OrderWith;\n\n/**\n * Reorders tests. An {@code Ordering} can reverse the order of tests, sort the\n * order or even shuffle the order.\n *\n * <p>In general you will not need to use a <code>Ordering</code> directly.\n * Instead, use {@link org.junit.runner.Request#orderWith(Ordering)}.\n *\n * @since 4.13\n */\npublic abstract class Ordering {\n    private static final String CONSTRUCTOR_ERROR_FORMAT\n            = \"Ordering class %s should have a public constructor with signature \"\n                    + \"%s(Ordering.Context context)\";\n\n    /**\n     * Creates an {@link Ordering} that shuffles the items using the given\n     * {@link Random} instance.\n     */\n    public static Ordering shuffledBy(final Random random) {\n        return new Ordering() {\n            @Override\n            boolean validateOrderingIsCorrect() {\n                return false;\n            }\n\n            @Override\n            protected List<Description> orderItems(Collection<Description> descriptions) {\n                List<Description> shuffled = new ArrayList<Description>(descriptions);\n                Collections.shuffle(shuffled, random);\n                return shuffled;\n            }\n        };\n    }\n\n    /**\n     * Creates an {@link Ordering} from the given factory class. The class must have a public no-arg\n     * constructor.\n     *\n     * @param factoryClass class to use to create the ordering\n     * @param annotatedTestClass test class that is annotated with {@link OrderWith}.\n     * @throws InvalidOrderingException if the instance could not be created\n     */\n    public static Ordering definedBy(\n            Class<? extends Ordering.Factory> factoryClass, Description annotatedTestClass)\n            throws InvalidOrderingException {\n        if (factoryClass == null) {\n            throw new NullPointerException(\"factoryClass cannot be null\");\n        }\n        if (annotatedTestClass == null) {\n            throw new NullPointerException(\"annotatedTestClass cannot be null\");\n        }\n\n        Ordering.Factory factory;\n        try {\n            Constructor<? extends Ordering.Factory> constructor = factoryClass.getConstructor();\n            factory = constructor.newInstance();\n        } catch (NoSuchMethodException e) {\n            throw new InvalidOrderingException(String.format(\n                    CONSTRUCTOR_ERROR_FORMAT,\n                    getClassName(factoryClass),\n                    factoryClass.getSimpleName()));\n        } catch (Exception e) {\n            throw new InvalidOrderingException(\n                    \"Could not create ordering for \" + annotatedTestClass, e);\n        }\n        return definedBy(factory, annotatedTestClass);\n    }\n\n    /**\n     * Creates an {@link Ordering} from the given factory.\n     *\n     * @param factory factory to use to create the ordering\n     * @param annotatedTestClass test class that is annotated with {@link OrderWith}.\n     * @throws InvalidOrderingException if the instance could not be created\n     */\n    public static Ordering definedBy(\n            Ordering.Factory factory, Description annotatedTestClass)\n            throws InvalidOrderingException {\n        if (factory == null) {\n            throw new NullPointerException(\"factory cannot be null\");\n        }\n        if (annotatedTestClass == null) {\n            throw new NullPointerException(\"annotatedTestClass cannot be null\");\n        }\n\n        return factory.create(new Ordering.Context(annotatedTestClass));\n    }\n\n    private static String getClassName(Class<?> clazz) {\n        String name = clazz.getCanonicalName();\n        if (name == null) {\n            return clazz.getName();\n        }\n        return name;\n    }\n\n    /**\n     * Order the tests in <code>target</code> using this ordering.\n     *\n     * @throws InvalidOrderingException if ordering does something invalid (like remove or add\n     * children)\n     */\n    public void apply(Object target) throws InvalidOrderingException {\n        /*\n         * Note that some subclasses of Ordering override apply(). The Sorter\n         * subclass of Ordering overrides apply() to apply the sort (this is\n         * done because sorting is more efficient than ordering).\n         */\n        if (target instanceof Orderable) {\n            Orderable orderable = (Orderable) target;\n            orderable.order(new Orderer(this));\n        }\n    }\n\n    /**\n     * Returns {@code true} if this ordering could produce invalid results (i.e.\n     * if it could add or remove values).\n     */\n    boolean validateOrderingIsCorrect() {\n        return true;\n    }\n\n    /**\n     * Implemented by sub-classes to order the descriptions.\n     *\n     * @return descriptions in order\n     */\n    protected abstract List<Description> orderItems(Collection<Description> descriptions);\n\n    /** Context about the ordering being applied. */\n    public static class Context {\n        private final Description description;\n\n        /**\n         * Gets the description for the top-level target being ordered.\n         */\n        public Description getTarget() {\n            return description;\n        }\n\n        private Context(Description description) {\n            this.description = description;\n        }\n    }\n\n    /**\n     * Factory for creating {@link Ordering} instances.\n     *\n     * <p>For a factory to be used with {@code @OrderWith} it needs to have a public no-arg\n     * constructor.\n     */\n    public interface Factory {\n        /**\n         * Creates an Ordering instance using the given context. Implementations\n         * of this method that do not need to use the context can return the\n         * same instance every time.\n         */\n        Ordering create(Context context);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Sortable.java",
    "content": "package org.junit.runner.manipulation;\n\n/**\n * Interface for runners that allow sorting of tests. By sorting tests based on when they last failed, most recently\n * failed first, you can reduce the average time to the first test failing. Test sorting should not be used to\n * cope with order dependencies between tests. Tests that are isolated from each other are less\n * expensive to maintain and can be run individually.\n *\n * @since 4.0\n */\npublic interface Sortable {\n\n    /**\n     * Sorts the tests using <code>sorter</code>\n     *\n     * @param sorter the {@link Sorter} to use for sorting the tests\n     */\n    void sort(Sorter sorter);\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/Sorter.java",
    "content": "package org.junit.runner.manipulation;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.List;\n\nimport org.junit.runner.Description;\n\n/**\n * A <code>Sorter</code> orders tests. In general you will not need\n * to use a <code>Sorter</code> directly. Instead, use\n * {@link org.junit.runner.Request#sortWith(Comparator)}.\n *\n * @since 4.0\n */\npublic class Sorter extends Ordering implements Comparator<Description> {\n    /**\n     * NULL is a <code>Sorter</code> that leaves elements in an undefined order\n     */\n    public static final Sorter NULL = new Sorter(new Comparator<Description>() {\n        public int compare(Description o1, Description o2) {\n            return 0;\n        }\n    });\n\n    private final Comparator<Description> comparator;\n\n    /**\n     * Creates a <code>Sorter</code> that uses <code>comparator</code>\n     * to sort tests\n     *\n     * @param comparator the {@link Comparator} to use when sorting tests\n     * @since 4.0\n     */\n    public Sorter(Comparator<Description> comparator) {\n        this.comparator = comparator;\n    }\n\n    /**\n     * Sorts the tests in <code>target</code> using <code>comparator</code>.\n     *\n     * @since 4.0\n     */\n    @Override\n    public void apply(Object target) {\n        /*\n         * Note that all runners that are Orderable are also Sortable (because\n         * Orderable extends Sortable). Sorting is more efficient than ordering,\n         * so we override the parent behavior so we sort instead.\n         */\n        if (target instanceof Sortable) {\n            Sortable sortable = (Sortable) target;\n            sortable.sort(this);\n        }\n    }\n\n    public int compare(Description o1, Description o2) {\n        return comparator.compare(o1, o2);\n    }\n \n    /**\n     * {@inheritDoc}\n     *\n     * @since 4.13\n     */\n    @Override\n    protected final List<Description> orderItems(Collection<Description> descriptions) {\n        /*\n         * In practice, we will never get here--Sorters do their work in the\n         * compare() method--but the Liskov substitution principle demands that\n         * we obey the general contract of Orderable. Luckily, it's trivial to\n         * implement.\n         */\n        List<Description> sorted = new ArrayList<Description>(descriptions);\n        Collections.sort(sorted, this); // Note: it would be incorrect to pass in \"comparator\"\n        return sorted;\n    }\n\n    /**\n     * {@inheritDoc}\n     *\n     * @since 4.13\n     */\n    @Override\n    boolean validateOrderingIsCorrect() {\n        return false;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/manipulation/package-info.java",
    "content": "/**\n * Provides classes to {@link org.junit.runner.manipulation.Filter filter} or {@link org.junit.runner.manipulation.Sorter sort} tests.\n *\n * @since 4.0\n * @see org.junit.runner.Runner\n */\npackage org.junit.runner.manipulation;"
  },
  {
    "path": "src/main/java/org/junit/runner/notification/Failure.java",
    "content": "package org.junit.runner.notification;\n\nimport java.io.Serializable;\n\nimport org.junit.internal.Throwables;\nimport org.junit.runner.Description;\n\n/**\n * A <code>Failure</code> holds a description of the failed test and the\n * exception that was thrown while running it. In most cases the {@link org.junit.runner.Description}\n * will be of a single test. However, if problems are encountered while constructing the\n * test (for example, if a {@link org.junit.BeforeClass} method is not static), it may describe\n * something other than a single test.\n *\n * @since 4.0\n */\npublic class Failure implements Serializable {\n    private static final long serialVersionUID = 1L;\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final Description fDescription;\n    private final Throwable fThrownException;\n\n    /**\n     * Constructs a <code>Failure</code> with the given description and exception.\n     *\n     * @param description a {@link org.junit.runner.Description} of the test that failed\n     * @param thrownException the exception that was thrown while running the test\n     */\n    public Failure(Description description, Throwable thrownException) {\n        this.fThrownException = thrownException;\n        this.fDescription = description;\n    }\n\n    /**\n     * @return a user-understandable label for the test\n     */\n    public String getTestHeader() {\n        return fDescription.getDisplayName();\n    }\n\n    /**\n     * @return the raw description of the context of the failure.\n     */\n    public Description getDescription() {\n        return fDescription;\n    }\n\n    /**\n     * @return the exception thrown\n     */\n\n    public Throwable getException() {\n        return fThrownException;\n    }\n\n    @Override\n    public String toString() {\n        return getTestHeader() + \": \" + fThrownException.getMessage();\n    }\n\n    /**\n     * Gets the printed form of the exception and its stack trace.\n     */\n    public String getTrace() {\n        return Throwables.getStacktrace(getException());\n    }\n\n    /**\n     * Gets a the printed form of the exception, with a trimmed version of the stack trace.\n     * This method will attempt to filter out frames of the stack trace that are below\n     * the test method call.\n     */\n    public String getTrimmedTrace() {\n        return Throwables.getTrimmedStackTrace(getException());\n    }\n\n    /**\n     * Convenience method\n     *\n     * @return the message of the thrown exception\n     */\n    public String getMessage() {\n        return getException().getMessage();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/notification/RunListener.java",
    "content": "package org.junit.runner.notification;\n\nimport java.lang.annotation.Documented;\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\n\n/**\n * Register an instance of this class with {@link RunNotifier} to be notified\n * of events that occur during a test run. All of the methods in this class\n * are abstract and have no implementation; override one or more methods to\n * receive events.\n * <p>\n * For example, suppose you have a <code>Cowbell</code>\n * class that you want to make a noise whenever a test fails. You could write:\n * <pre>\n * public class RingingListener extends RunListener {\n *    public void testFailure(Failure failure) {\n *       Cowbell.ring();\n *    }\n * }\n * </pre>\n * <p>\n * To invoke your listener, you need to run your tests through <code>JUnitCore</code>.\n * <pre>\n * public void main(String... args) {\n *    JUnitCore core= new JUnitCore();\n *    core.addListener(new RingingListener());\n *    core.run(MyTestClass.class);\n * }\n * </pre>\n * <p>\n * If a listener throws an exception for a test event, the other listeners will\n * have their {@link RunListener#testFailure(Failure)} called with a {@code Description}\n * of {@link Description#TEST_MECHANISM} to indicate the failure.\n * <p>\n * By default, JUnit will synchronize calls to your listener. If your listener\n * is thread-safe and you want to allow JUnit to call your listener from\n * multiple threads when tests are run in parallel, you can annotate your\n * test class with {@link RunListener.ThreadSafe}.\n * <p>\n * Listener methods will be called from the same thread as is running\n * the test, unless otherwise indicated by the method Javadoc\n *\n * @see org.junit.runner.JUnitCore\n * @since 4.0\n */\npublic class RunListener {\n\n    /**\n     * Called before any tests have been run. This may be called on an\n     * arbitrary thread.\n     *\n     * @param description describes the tests to be run\n     */\n    public void testRunStarted(Description description) throws Exception {\n    }\n\n    /**\n     * Called when all tests have finished. This may be called on an\n     * arbitrary thread.\n     *\n     * @param result the summary of the test run, including all the tests that failed\n     */\n    public void testRunFinished(Result result) throws Exception {\n    }\n\n    /**\n     * Called when a test suite is about to be started. If this method is\n     * called for a given {@link Description}, then {@link #testSuiteFinished(Description)}\n     * will also be called for the same {@code Description}.\n     *\n     * <p>Note that not all runners will call this method, so runners should\n     * be prepared to handle {@link #testStarted(Description)} calls for tests\n     * where there was no corresponding {@code testSuiteStarted()} call for\n     * the parent {@code Description}.\n     *\n     * @param description the description of the test suite that is about to be run\n     *                    (generally a class name)\n     * @since 4.13\n     */\n    public void testSuiteStarted(Description description) throws Exception {\n    }\n\n    /**\n     * Called when a test suite has finished, whether the test suite succeeds or fails.\n     * This method will not be called for a given {@link Description} unless\n     * {@link #testSuiteStarted(Description)} was called for the same @code Description}.\n     *\n     * @param description the description of the test suite that just ran\n     * @since 4.13\n     */\n    public void testSuiteFinished(Description description) throws Exception {\n    }\n\n    /**\n     * Called when an atomic test is about to be started.\n     *\n     * @param description the description of the test that is about to be run\n     * (generally a class and method name)\n     */\n    public void testStarted(Description description) throws Exception {\n    }\n\n    /**\n     * Called when an atomic test has finished, whether the test succeeds or fails.\n     *\n     * @param description the description of the test that just ran\n     */\n    public void testFinished(Description description) throws Exception {\n    }\n\n    /**\n     * Called when an atomic test fails, or when a listener throws an exception.\n     *\n     * <p>In the case of a failure of an atomic test, this method will be called\n     * with the same {@code Description} passed to\n     * {@link #testStarted(Description)}, from the same thread that called\n     * {@link #testStarted(Description)}.\n     *\n     * <p>In the case of a listener throwing an exception, this will be called with\n     * a {@code Description} of {@link Description#TEST_MECHANISM}, and may be called\n     * on an arbitrary thread.\n     *\n     * @param failure describes the test that failed and the exception that was thrown\n     */\n    public void testFailure(Failure failure) throws Exception {\n    }\n\n    /**\n     * Called when an atomic test flags that it assumes a condition that is\n     * false\n     *\n     * @param failure describes the test that failed and the\n     * {@link org.junit.AssumptionViolatedException} that was thrown\n     */\n    public void testAssumptionFailure(Failure failure) {\n    }\n\n    /**\n     * Called when a test will not be run, generally because a test method is annotated\n     * with {@link org.junit.Ignore}.\n     *\n     * @param description describes the test that will not be run\n     */\n    public void testIgnored(Description description) throws Exception {\n    }\n\n\n    /**\n     * Indicates a {@code RunListener} that can have its methods called\n     * concurrently. This implies that the class is thread-safe (i.e. no set of\n     * listener calls can put the listener into an invalid state, even if those\n     * listener calls are being made by multiple threads without\n     * synchronization).\n     *\n     * @since 4.12\n     */\n    @Documented\n    @Target(ElementType.TYPE)\n    @Retention(RetentionPolicy.RUNTIME)\n    public @interface ThreadSafe {\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/notification/RunNotifier.java",
    "content": "package org.junit.runner.notification;\n\nimport static java.util.Arrays.asList;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.CopyOnWriteArrayList;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\n\n/**\n * If you write custom runners, you may need to notify JUnit of your progress running tests.\n * Do this by invoking the <code>RunNotifier</code> passed to your implementation of\n * {@link org.junit.runner.Runner#run(RunNotifier)}. Future evolution of this class is likely to\n * move {@link #fireTestRunStarted(Description)} and {@link #fireTestRunFinished(Result)}\n * to a separate class since they should only be called once per run.\n *\n * @since 4.0\n */\npublic class RunNotifier {\n    private final List<RunListener> listeners = new CopyOnWriteArrayList<RunListener>();\n    private volatile boolean pleaseStop = false;\n\n    /**\n     * Internal use only\n     */\n    public void addListener(RunListener listener) {\n        if (listener == null) {\n            throw new NullPointerException(\"Cannot add a null listener\");\n        }\n        listeners.add(wrapIfNotThreadSafe(listener));\n    }\n\n    /**\n     * Internal use only\n     */\n    public void removeListener(RunListener listener) {\n        if (listener == null) {\n            throw new NullPointerException(\"Cannot remove a null listener\");\n        }\n        listeners.remove(wrapIfNotThreadSafe(listener));\n    }\n\n    /**\n     * Wraps the given listener with {@link SynchronizedRunListener} if\n     * it is not annotated with {@link RunListener.ThreadSafe}.\n     */\n    RunListener wrapIfNotThreadSafe(RunListener listener) {\n        return listener.getClass().isAnnotationPresent(RunListener.ThreadSafe.class) ?\n                listener : new SynchronizedRunListener(listener, this);\n    }\n\n\n    private abstract class SafeNotifier {\n        private final List<RunListener> currentListeners;\n\n        SafeNotifier() {\n            this(listeners);\n        }\n\n        SafeNotifier(List<RunListener> currentListeners) {\n            this.currentListeners = currentListeners;\n        }\n\n        void run() {\n            int capacity = currentListeners.size();\n            List<RunListener> safeListeners = new ArrayList<RunListener>(capacity);\n            List<Failure> failures = new ArrayList<Failure>(capacity);\n            for (RunListener listener : currentListeners) {\n                try {\n                    notifyListener(listener);\n                    safeListeners.add(listener);\n                } catch (Exception e) {\n                    failures.add(new Failure(Description.TEST_MECHANISM, e));\n                }\n            }\n            fireTestFailures(safeListeners, failures);\n        }\n\n        protected abstract void notifyListener(RunListener each) throws Exception;\n    }\n\n    /**\n     * Do not invoke.\n     */\n    public void fireTestRunStarted(final Description description) {\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testRunStarted(description);\n            }\n        }.run();\n    }\n\n    /**\n     * Do not invoke.\n     */\n    public void fireTestRunFinished(final Result result) {\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testRunFinished(result);\n            }\n        }.run();\n    }\n\n    /**\n     * Invoke to tell listeners that a test suite is about to start. Runners are strongly\n     * encouraged--but not required--to call this method. If this method is called for\n     * a given {@link Description} then {@link #fireTestSuiteFinished(Description)} MUST\n     * be called for the same {@code Description}.\n     *\n     * @param description the description of the suite test (generally a class name)\n     * @since 4.13\n     */\n    public void fireTestSuiteStarted(final Description description) {\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testSuiteStarted(description);\n            }\n        }.run();\n    }\n\n    /**\n     * Invoke to tell listeners that a test suite is about to finish. Always invoke\n     * this method if you invoke {@link #fireTestSuiteStarted(Description)}\n     * as listeners are likely to expect them to come in pairs.\n     *\n     * @param description the description of the suite test (generally a class name)\n     * @since 4.13\n     */\n    public void fireTestSuiteFinished(final Description description) {\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testSuiteFinished(description);\n            }\n        }.run();\n    }\n\n    /**\n     * Invoke to tell listeners that an atomic test is about to start.\n     *\n     * @param description the description of the atomic test (generally a class and method name)\n     * @throws StoppedByUserException thrown if a user has requested that the test run stop\n     */\n    public void fireTestStarted(final Description description) throws StoppedByUserException {\n        if (pleaseStop) {\n            throw new StoppedByUserException();\n        }\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testStarted(description);\n            }\n        }.run();\n    }\n\n    /**\n     * Invoke to tell listeners that an atomic test failed.\n     *\n     * @param failure the description of the test that failed and the exception thrown\n     */\n    public void fireTestFailure(Failure failure) {\n        fireTestFailures(listeners, asList(failure));\n    }\n\n    private void fireTestFailures(List<RunListener> listeners,\n            final List<Failure> failures) {\n        if (!failures.isEmpty()) {\n            new SafeNotifier(listeners) {\n                @Override\n                protected void notifyListener(RunListener listener) throws Exception {\n                    for (Failure each : failures) {\n                        listener.testFailure(each);\n                    }\n                }\n            }.run();\n        }\n    }\n\n    /**\n     * Invoke to tell listeners that an atomic test flagged that it assumed\n     * something false.\n     *\n     * @param failure the description of the test that failed and the\n     * {@link org.junit.AssumptionViolatedException} thrown\n     */\n    public void fireTestAssumptionFailed(final Failure failure) {\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testAssumptionFailure(failure);\n            }\n        }.run();\n    }\n\n    /**\n     * Invoke to tell listeners that an atomic test was ignored.\n     *\n     * @param description the description of the ignored test\n     */\n    public void fireTestIgnored(final Description description) {\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testIgnored(description);\n            }\n        }.run();\n    }\n\n    /**\n     * Invoke to tell listeners that an atomic test finished. Always invoke\n     * this method if you invoke {@link #fireTestStarted(Description)}\n     * as listeners are likely to expect them to come in pairs.\n     *\n     * @param description the description of the test that finished\n     */\n    public void fireTestFinished(final Description description) {\n        new SafeNotifier() {\n            @Override\n            protected void notifyListener(RunListener each) throws Exception {\n                each.testFinished(description);\n            }\n        }.run();\n    }\n\n    /**\n     * Ask that the tests run stop before starting the next test. Phrased politely because\n     * the test currently running will not be interrupted. It seems a little odd to put this\n     * functionality here, but the <code>RunNotifier</code> is the only object guaranteed\n     * to be shared amongst the many runners involved.\n     */\n    public void pleaseStop() {\n        pleaseStop = true;\n    }\n\n    /**\n     * Internal use only. The Result's listener must be first.\n     */\n    public void addFirstListener(RunListener listener) {\n        if (listener == null) {\n            throw new NullPointerException(\"Cannot add a null listener\");\n        }\n        listeners.add(0, wrapIfNotThreadSafe(listener));\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/notification/StoppedByUserException.java",
    "content": "package org.junit.runner.notification;\n\n/**\n * Thrown when a user has requested that the test run stop. Writers of\n * test running GUIs should be prepared to catch a <code>StoppedByUserException</code>.\n *\n * @see org.junit.runner.notification.RunNotifier\n * @since 4.0\n */\npublic class StoppedByUserException extends RuntimeException {\n    private static final long serialVersionUID = 1L;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/notification/SynchronizedRunListener.java",
    "content": "package org.junit.runner.notification;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\n\n/**\n * Thread-safe decorator for {@link RunListener} implementations that synchronizes\n * calls to the delegate.\n *\n * <p>This class synchronizes all listener calls on a RunNotifier instance. This is done because\n * prior to JUnit 4.12, all listeners were called in a synchronized block in RunNotifier,\n * so no two listeners were ever called concurrently. If we instead made the methods here\n * synchronized, clients that added multiple listeners that called common code might see\n * issues due to the reduced synchronization.\n *\n * @author Tibor Digana (tibor17)\n * @author Kevin Cooney (kcooney)\n * @since 4.12\n *\n * @see RunNotifier\n */\n@RunListener.ThreadSafe\nfinal class SynchronizedRunListener extends RunListener {\n    private final RunListener listener;\n    private final Object monitor;\n\n    SynchronizedRunListener(RunListener listener, Object monitor) {\n        this.listener = listener;\n        this.monitor = monitor;\n    }\n\n    @Override\n    public void testRunStarted(Description description) throws Exception {\n        synchronized (monitor) {\n            listener.testRunStarted(description);\n        }\n    }\n\n    @Override\n    public void testRunFinished(Result result) throws Exception {\n        synchronized (monitor) {\n            listener.testRunFinished(result);\n        }\n    }\n\n    /**\n     * {@inheritDoc}\n     * <p/>\n     * Synchronized decorator for {@link RunListener#testSuiteStarted(Description)}.\n     * @param description the description of the test suite that is about to be run\n     *                    (generally a class name).\n     * @throws Exception if any occurs.\n     * @since 4.13\n     */\n    @Override\n    public void testSuiteStarted(Description description) throws Exception {\n        synchronized (monitor) {\n            listener.testSuiteStarted(description);\n        }\n    }\n\n    /**\n     * {@inheritDoc}\n     * <p/>\n     * Synchronized decorator for {@link RunListener#testSuiteFinished(Description)}.\n     * @param description the description of the test suite that just ran.\n     * @since 4.13\n     */\n    @Override\n    public void testSuiteFinished(Description description) throws Exception {\n        synchronized (monitor) {\n            listener.testSuiteFinished(description);\n        }\n    }\n\n    @Override\n    public void testStarted(Description description) throws Exception {\n        synchronized (monitor) {\n            listener.testStarted(description);\n        }\n    }\n\n    @Override\n    public void testFinished(Description description) throws Exception {\n        synchronized (monitor) {\n            listener.testFinished(description);\n        }\n    }\n\n    @Override\n    public void testFailure(Failure failure) throws Exception {\n        synchronized (monitor) {\n            listener.testFailure(failure);\n        }\n    }\n\n    @Override\n    public void testAssumptionFailure(Failure failure) {\n        synchronized (monitor) {\n            listener.testAssumptionFailure(failure);\n        }\n    }\n\n    @Override\n    public void testIgnored(Description description) throws Exception {\n        synchronized (monitor) {\n            listener.testIgnored(description);\n        }\n    }\n\n    @Override\n    public int hashCode() {\n        return listener.hashCode();\n    }\n\n    @Override\n    public boolean equals(Object other) {\n        if (this == other) {\n            return true;\n        }\n        if (!(other instanceof SynchronizedRunListener)) {\n            return false;\n        }\n        SynchronizedRunListener that = (SynchronizedRunListener) other;\n        \n        return listener.equals(that.listener);\n    }\n\n    @Override\n    public String toString() {\n        return listener.toString() + \" (with synchronization wrapper)\";\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runner/notification/package-info.java",
    "content": "/**\n * Provides information about a test run.\n *\n * @since 4.0\n */\npackage org.junit.runner.notification;"
  },
  {
    "path": "src/main/java/org/junit/runner/package-info.java",
    "content": "/**\n * Provides classes used to describe, collect, run and analyze multiple tests.\n *\n * @since 4.0\n */\npackage org.junit.runner;"
  },
  {
    "path": "src/main/java/org/junit/runners/AllTests.java",
    "content": "package org.junit.runners;\n\nimport org.junit.internal.runners.SuiteMethod;\n\n/**\n * Runner for use with JUnit 3.8.x-style AllTests classes\n * (those that only implement a static <code>suite()</code>\n * method). For example:\n * <pre>\n * &#064;RunWith(AllTests.class)\n * public class ProductTests {\n *    public static junit.framework.Test suite() {\n *       ...\n *    }\n * }\n * </pre>\n *\n * @since 4.0\n */\npublic class AllTests extends SuiteMethod {\n    /**\n     * Only called reflectively. Do not use programmatically.\n     */\n    public AllTests(Class<?> klass) throws Throwable {\n        super(klass);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java",
    "content": "package org.junit.runners;\n\nimport static org.junit.internal.runners.rules.RuleMemberValidator.RULE_METHOD_VALIDATOR;\nimport static org.junit.internal.runners.rules.RuleMemberValidator.RULE_VALIDATOR;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.concurrent.ConcurrentMap;\nimport java.util.concurrent.TimeUnit;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Ignore;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.Test.None;\nimport org.junit.internal.runners.model.ReflectiveCallable;\nimport org.junit.internal.runners.statements.ExpectException;\nimport org.junit.internal.runners.statements.Fail;\nimport org.junit.internal.runners.statements.FailOnTimeout;\nimport org.junit.internal.runners.statements.InvokeMethod;\nimport org.junit.internal.runners.statements.RunAfters;\nimport org.junit.internal.runners.statements.RunBefores;\nimport org.junit.rules.MethodRule;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.FrameworkMember;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.MemberValueConsumer;\nimport org.junit.runners.model.MultipleFailureException;\nimport org.junit.runners.model.Statement;\nimport org.junit.runners.model.TestClass;\nimport org.junit.validator.PublicClassValidator;\nimport org.junit.validator.TestClassValidator;\n\n/**\n * Implements the JUnit 4 standard test case class model, as defined by the\n * annotations in the org.junit package. Many users will never notice this\n * class: it is now the default test class runner, but it should have exactly\n * the same behavior as the old test class runner ({@code JUnit4ClassRunner}).\n * <p>\n * BlockJUnit4ClassRunner has advantages for writers of custom JUnit runners\n * that are slight changes to the default behavior, however:\n *\n * <ul>\n * <li>It has a much simpler implementation based on {@link Statement}s,\n * allowing new operations to be inserted into the appropriate point in the\n * execution flow.\n *\n * <li>It is published, and extension and reuse are encouraged, whereas {@code\n * JUnit4ClassRunner} was in an internal package, and is now deprecated.\n * </ul>\n * <p>\n * In turn, in 2009 we introduced {@link Rule}s.  In many cases where extending\n * BlockJUnit4ClassRunner was necessary to add new behavior, {@link Rule}s can\n * be used, which makes the extension more reusable and composable.\n *\n * @since 4.5\n */\npublic class BlockJUnit4ClassRunner extends ParentRunner<FrameworkMethod> {\n    private static TestClassValidator PUBLIC_CLASS_VALIDATOR = new PublicClassValidator();\n\n    private final ConcurrentMap<FrameworkMethod, Description> methodDescriptions = new ConcurrentHashMap<FrameworkMethod, Description>();\n\n    /**\n     * Creates a BlockJUnit4ClassRunner to run {@code testClass}\n     *\n     * @throws InitializationError if the test class is malformed.\n     */\n    public BlockJUnit4ClassRunner(Class<?> testClass) throws InitializationError {\n        super(testClass);\n    }\n\n    /**\n     * Creates a BlockJUnit4ClassRunner to run {@code testClass}.\n     *\n     * @throws InitializationError if the test class is malformed.\n     * @since 4.13\n     */\n    protected BlockJUnit4ClassRunner(TestClass testClass) throws InitializationError {\n        super(testClass);\n    }\n\n    //\n    // Implementation of ParentRunner\n    //\n\n    @Override\n    protected void runChild(final FrameworkMethod method, RunNotifier notifier) {\n        Description description = describeChild(method);\n        if (isIgnored(method)) {\n            notifier.fireTestIgnored(description);\n        } else {\n            Statement statement = new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    methodBlock(method).evaluate();\n                }\n            };\n            runLeaf(statement, description, notifier);\n        }\n    }\n\n    /**\n     * Evaluates whether {@link FrameworkMethod}s are ignored based on the\n     * {@link Ignore} annotation.\n     */\n    @Override\n    protected boolean isIgnored(FrameworkMethod child) {\n        return child.getAnnotation(Ignore.class) != null;\n    }\n\n    @Override\n    protected Description describeChild(FrameworkMethod method) {\n        Description description = methodDescriptions.get(method);\n\n        if (description == null) {\n            description = Description.createTestDescription(getTestClass().getJavaClass(),\n                    testName(method), method.getAnnotations());\n            methodDescriptions.putIfAbsent(method, description);\n        }\n\n        return description;\n    }\n\n    @Override\n    protected List<FrameworkMethod> getChildren() {\n        return computeTestMethods();\n    }\n\n    //\n    // Override in subclasses\n    //\n\n    /**\n     * Returns the methods that run tests. Default implementation returns all\n     * methods annotated with {@code @Test} on this class and superclasses that\n     * are not overridden.\n     */\n    protected List<FrameworkMethod> computeTestMethods() {\n        return getTestClass().getAnnotatedMethods(Test.class);\n    }\n\n    @Override\n    protected void collectInitializationErrors(List<Throwable> errors) {\n        super.collectInitializationErrors(errors);\n\n        validatePublicConstructor(errors);\n        validateNoNonStaticInnerClass(errors);\n        validateConstructor(errors);\n        validateInstanceMethods(errors);\n        validateFields(errors);\n        validateMethods(errors);\n    }\n\n    private void validatePublicConstructor(List<Throwable> errors) {\n        if (getTestClass().getJavaClass() != null) {\n            errors.addAll(PUBLIC_CLASS_VALIDATOR.validateTestClass(getTestClass()));\n        }\n    }\n\n    protected void validateNoNonStaticInnerClass(List<Throwable> errors) {\n        if (getTestClass().isANonStaticInnerClass()) {\n            String gripe = \"The inner class \" + getTestClass().getName()\n                    + \" is not static.\";\n            errors.add(new Exception(gripe));\n        }\n    }\n\n    /**\n     * Adds to {@code errors} if the test class has more than one constructor,\n     * or if the constructor takes parameters. Override if a subclass requires\n     * different validation rules.\n     */\n    protected void validateConstructor(List<Throwable> errors) {\n        validateOnlyOneConstructor(errors);\n        validateZeroArgConstructor(errors);\n    }\n\n    /**\n     * Adds to {@code errors} if the test class has more than one constructor\n     * (do not override)\n     */\n    protected void validateOnlyOneConstructor(List<Throwable> errors) {\n        if (!hasOneConstructor()) {\n            String gripe = \"Test class should have exactly one public constructor\";\n            errors.add(new Exception(gripe));\n        }\n    }\n\n    /**\n     * Adds to {@code errors} if the test class's single constructor takes\n     * parameters (do not override)\n     */\n    protected void validateZeroArgConstructor(List<Throwable> errors) {\n        if (!getTestClass().isANonStaticInnerClass()\n                && hasOneConstructor()\n                && (getTestClass().getOnlyConstructor().getParameterTypes().length != 0)) {\n            String gripe = \"Test class should have exactly one public zero-argument constructor\";\n            errors.add(new Exception(gripe));\n        }\n    }\n\n    private boolean hasOneConstructor() {\n        return getTestClass().getJavaClass().getConstructors().length == 1;\n    }\n\n    /**\n     * Adds to {@code errors} for each method annotated with {@code @Test},\n     * {@code @Before}, or {@code @After} that is not a public, void instance\n     * method with no arguments.\n     * @deprecated\n     */\n    @Deprecated\n    protected void validateInstanceMethods(List<Throwable> errors) {\n        validatePublicVoidNoArgMethods(After.class, false, errors);\n        validatePublicVoidNoArgMethods(Before.class, false, errors);\n        validateTestMethods(errors);\n\n        if (computeTestMethods().isEmpty()) {\n            errors.add(new Exception(\"No runnable methods\"));\n        }\n    }\n\n    protected void validateFields(List<Throwable> errors) {\n        RULE_VALIDATOR.validate(getTestClass(), errors);\n    }\n\n    private void validateMethods(List<Throwable> errors) {\n        RULE_METHOD_VALIDATOR.validate(getTestClass(), errors);\n    }\n\n    /**\n     * Adds to {@code errors} for each method annotated with {@code @Test}that\n     * is not a public, void instance method with no arguments.\n     */\n    protected void validateTestMethods(List<Throwable> errors) {\n        validatePublicVoidNoArgMethods(Test.class, false, errors);\n    }\n\n    /**\n     * Returns a new fixture for running a test. Default implementation executes\n     * the test class's no-argument constructor (validation should have ensured\n     * one exists).\n     */\n    protected Object createTest() throws Exception {\n        return getTestClass().getOnlyConstructor().newInstance();\n    }\n\n    /**\n     * Returns a new fixture to run a particular test {@code method} against.\n     * Default implementation executes the no-argument {@link #createTest()} method.\n     *\n     * @since 4.13\n     */\n    protected Object createTest(FrameworkMethod method) throws Exception {\n        return createTest();\n    }\n\n    /**\n     * Returns the name that describes {@code method} for {@link Description}s.\n     * Default implementation is the method's name\n     */\n    protected String testName(FrameworkMethod method) {\n        return method.getName();\n    }\n\n    /**\n     * Returns a Statement that, when executed, either returns normally if\n     * {@code method} passes, or throws an exception if {@code method} fails.\n     *\n     * Here is an outline of the default implementation:\n     *\n     * <ul>\n     * <li>Invoke {@code method} on the result of {@link #createTest(org.junit.runners.model.FrameworkMethod)}, and\n     * throw any exceptions thrown by either operation.\n     * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@link Test#expected()}\n     * attribute, return normally only if the previous step threw an\n     * exception of the correct type, and throw an exception otherwise.\n     * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code\n     * timeout} attribute, throw an exception if the previous step takes more\n     * than the specified number of milliseconds.\n     * <li>ALWAYS run all non-overridden {@code @Before} methods on this class\n     * and superclasses before any of the previous steps; if any throws an\n     * Exception, stop execution and pass the exception on.\n     * <li>ALWAYS run all non-overridden {@code @After} methods on this class\n     * and superclasses after any of the previous steps; all After methods are\n     * always executed: exceptions thrown by previous steps are combined, if\n     * necessary, with exceptions from After methods into a\n     * {@link MultipleFailureException}.\n     * <li>ALWAYS allow {@code @Rule} fields to modify the execution of the\n     * above steps. A {@code Rule} may prevent all execution of the above steps,\n     * or add additional behavior before and after, or modify thrown exceptions.\n     * For more information, see {@link TestRule}\n     * </ul>\n     *\n     * This can be overridden in subclasses, either by overriding this method,\n     * or the implementations creating each sub-statement.\n     */\n    protected Statement methodBlock(final FrameworkMethod method) {\n        Object test;\n        try {\n            test = new ReflectiveCallable() {\n                @Override\n                protected Object runReflectiveCall() throws Throwable {\n                    return createTest(method);\n                }\n            }.run();\n        } catch (Throwable e) {\n            return new Fail(e);\n        }\n\n        Statement statement = methodInvoker(method, test);\n        statement = possiblyExpectingExceptions(method, test, statement);\n        statement = withPotentialTimeout(method, test, statement);\n        statement = withBefores(method, test, statement);\n        statement = withAfters(method, test, statement);\n        statement = withRules(method, test, statement);\n        statement = withInterruptIsolation(statement);\n        return statement;\n    }\n\n    //\n    // Statement builders\n    //\n\n    /**\n     * Returns a {@link Statement} that invokes {@code method} on {@code test}\n     */\n    protected Statement methodInvoker(FrameworkMethod method, Object test) {\n        return new InvokeMethod(method, test);\n    }\n\n    /**\n     * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation\n     * has the {@link Test#expected()} attribute, return normally only if {@code next}\n     * throws an exception of the correct type, and throw an exception\n     * otherwise.\n     */\n    protected Statement possiblyExpectingExceptions(FrameworkMethod method,\n            Object test, Statement next) {\n        Test annotation = method.getAnnotation(Test.class);\n        Class<? extends Throwable> expectedExceptionClass = getExpectedException(annotation);\n        return expectedExceptionClass != null ? new ExpectException(next, expectedExceptionClass) : next;\n    }\n\n    /**\n     * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation\n     * has the {@code timeout} attribute, throw an exception if {@code next}\n     * takes more than the specified number of milliseconds.\n     * @deprecated\n     */\n    @Deprecated\n    protected Statement withPotentialTimeout(FrameworkMethod method,\n            Object test, Statement next) {\n        long timeout = getTimeout(method.getAnnotation(Test.class));\n        if (timeout <= 0) {\n            return next;\n        }\n        return FailOnTimeout.builder()\n               .withTimeout(timeout, TimeUnit.MILLISECONDS)\n               .build(next);\n    }\n\n    /**\n     * Returns a {@link Statement}: run all non-overridden {@code @Before}\n     * methods on this class and superclasses before running {@code next}; if\n     * any throws an Exception, stop execution and pass the exception on.\n     */\n    protected Statement withBefores(FrameworkMethod method, Object target,\n            Statement statement) {\n        List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(\n                Before.class);\n        return befores.isEmpty() ? statement : new RunBefores(statement,\n                befores, target);\n    }\n\n    /**\n     * Returns a {@link Statement}: run all non-overridden {@code @After}\n     * methods on this class and superclasses before running {@code next}; all\n     * After methods are always executed: exceptions thrown by previous steps\n     * are combined, if necessary, with exceptions from After methods into a\n     * {@link MultipleFailureException}.\n     */\n    protected Statement withAfters(FrameworkMethod method, Object target,\n            Statement statement) {\n        List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(\n                After.class);\n        return afters.isEmpty() ? statement : new RunAfters(statement, afters,\n                target);\n    }\n\n    private Statement withRules(FrameworkMethod method, Object target, Statement statement) {\n        RuleContainer ruleContainer = new RuleContainer();\n        CURRENT_RULE_CONTAINER.set(ruleContainer);\n        try {\n            List<TestRule> testRules = getTestRules(target);\n            for (MethodRule each : rules(target)) {\n                if (!(each instanceof TestRule && testRules.contains(each))) {\n                    ruleContainer.add(each);\n                }\n            }\n            for (TestRule rule : testRules) {\n                ruleContainer.add(rule);\n            }\n        } finally {\n            CURRENT_RULE_CONTAINER.remove();\n        }\n        return ruleContainer.apply(method, describeChild(method), target, statement);\n    }\n\n    /**\n     * @param target the test case instance\n     * @return a list of MethodRules that should be applied when executing this\n     *         test\n     */\n    protected List<MethodRule> rules(Object target) {\n        RuleCollector<MethodRule> collector = new RuleCollector<MethodRule>();\n        getTestClass().collectAnnotatedMethodValues(target, Rule.class, MethodRule.class,\n                collector);\n        getTestClass().collectAnnotatedFieldValues(target, Rule.class, MethodRule.class,\n                collector);\n        return collector.result;\n    }\n\n    /**\n     * @param target the test case instance\n     * @return a list of TestRules that should be applied when executing this\n     *         test\n     */\n    protected List<TestRule> getTestRules(Object target) {\n        RuleCollector<TestRule> collector = new RuleCollector<TestRule>();\n        getTestClass().collectAnnotatedMethodValues(target, Rule.class, TestRule.class, collector);\n        getTestClass().collectAnnotatedFieldValues(target, Rule.class, TestRule.class, collector);\n        return collector.result;\n    }\n\n    private Class<? extends Throwable> getExpectedException(Test annotation) {\n        if (annotation == null || annotation.expected() == None.class) {\n            return null;\n        } else {\n            return annotation.expected();\n        }\n    }\n\n    private long getTimeout(Test annotation) {\n        if (annotation == null) {\n            return 0;\n        }\n        return annotation.timeout();\n    }\n\n    private static final ThreadLocal<RuleContainer> CURRENT_RULE_CONTAINER =\n            new ThreadLocal<RuleContainer>();\n\n    private static class RuleCollector<T> implements MemberValueConsumer<T> {\n        final List<T> result = new ArrayList<T>();\n\n        public void accept(FrameworkMember<?> member, T value) {\n            Rule rule = member.getAnnotation(Rule.class);\n            if (rule != null) {\n                RuleContainer container = CURRENT_RULE_CONTAINER.get();\n                if (container != null) {\n                    container.setOrder(value, rule.order());\n                }\n            }\n            result.add(value);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/JUnit4.java",
    "content": "package org.junit.runners;\n\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.TestClass;\n\n/**\n * Aliases the current default JUnit 4 class runner, for future-proofing. If\n * future versions of JUnit change the default Runner class, they will also\n * change the definition of this class. Developers wanting to explicitly tag a\n * class as a JUnit 4 class should use {@code @RunWith(JUnit4.class)}, not,\n * for example in JUnit 4.5, {@code @RunWith(BlockJUnit4ClassRunner.class)}.\n * This is the only way this class should be used--any extension that\n * depends on the implementation details of this class is likely to break\n * in future versions.\n *\n * @since 4.5\n */\npublic final class JUnit4 extends BlockJUnit4ClassRunner {\n    /**\n     * Constructs a new instance of the default runner\n     */\n    public JUnit4(Class<?> klass) throws InitializationError {\n        super(new TestClass(klass));\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/MethodSorters.java",
    "content": "package org.junit.runners;\n\nimport java.lang.reflect.Method;\nimport java.util.Comparator;\n\nimport org.junit.internal.MethodSorter;\n\n/**\n * Sort the methods into a specified execution order.\n * Defines common {@link MethodSorter} implementations.\n *\n * @since 4.11\n */\npublic enum MethodSorters {\n    /**\n     * Sorts the test methods by the method name, in lexicographic order,\n     * with {@link Method#toString()} used as a tiebreaker\n     */\n    NAME_ASCENDING(MethodSorter.NAME_ASCENDING),\n\n    /**\n     * Leaves the test methods in the order returned by the JVM.\n     * Note that the order from the JVM may vary from run to run\n     */\n    JVM(null),\n\n    /**\n     * Sorts the test methods in a deterministic, but not predictable, order\n     */\n    DEFAULT(MethodSorter.DEFAULT);\n\n    private final Comparator<Method> comparator;\n\n    private MethodSorters(Comparator<Method> comparator) {\n        this.comparator = comparator;\n    }\n\n    public Comparator<Method> getComparator() {\n        return comparator;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/Parameterized.java",
    "content": "package org.junit.runners;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\nimport java.text.MessageFormat;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InvalidTestClassError;\nimport org.junit.runners.model.TestClass;\nimport org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParametersFactory;\nimport org.junit.runners.parameterized.ParametersRunnerFactory;\nimport org.junit.runners.parameterized.TestWithParameters;\n\n/**\n * The custom runner <code>Parameterized</code> implements parameterized tests.\n * When running a parameterized test class, instances are created for the\n * cross-product of the test methods and the test data elements.\n * <p>\n * For example, to test the <code>+</code> operator, write:\n * <pre>\n * &#064;RunWith(Parameterized.class)\n * public class AdditionTest {\n *     &#064;Parameters(name = &quot;{index}: {0} + {1} = {2}&quot;)\n *     public static Iterable&lt;Object[]&gt; data() {\n *         return Arrays.asList(new Object[][] { { 0, 0, 0 }, { 1, 1, 2 },\n *                 { 3, 2, 5 }, { 4, 3, 7 } });\n *     }\n *\n *     private int firstSummand;\n *\n *     private int secondSummand;\n *\n *     private int sum;\n *\n *     public AdditionTest(int firstSummand, int secondSummand, int sum) {\n *         this.firstSummand = firstSummand;\n *         this.secondSummand = secondSummand;\n *         this.sum = sum;\n *     }\n *\n *     &#064;Test\n *     public void test() {\n *         assertEquals(sum, firstSummand + secondSummand);\n *     }\n * }\n * </pre>\n * <p>\n * Each instance of <code>AdditionTest</code> will be constructed using the\n * three-argument constructor and the data values in the\n * <code>&#064;Parameters</code> method.\n * <p>\n * In order that you can easily identify the individual tests, you may provide a\n * name for the <code>&#064;Parameters</code> annotation. This name is allowed\n * to contain placeholders, which are replaced at runtime. The placeholders are\n * <dl>\n * <dt>{index}</dt>\n * <dd>the current parameter index</dd>\n * <dt>{0}</dt>\n * <dd>the first parameter value</dd>\n * <dt>{1}</dt>\n * <dd>the second parameter value</dd>\n * <dt>...</dt>\n * <dd>...</dd>\n * </dl>\n * <p>\n * In the example given above, the <code>Parameterized</code> runner creates\n * names like <code>[2: 3 + 2 = 5]</code>. If you don't use the name parameter,\n * then the current parameter index is used as name.\n * <p>\n * You can also write:\n * <pre>\n * &#064;RunWith(Parameterized.class)\n * public class AdditionTest {\n *     &#064;Parameters(name = &quot;{index}: {0} + {1} = {2}&quot;)\n *     public static Iterable&lt;Object[]&gt; data() {\n *         return Arrays.asList(new Object[][] { { 0, 0, 0 }, { 1, 1, 2 },\n *                 { 3, 2, 5 }, { 4, 3, 7 } });\n *     }\n *\n *     &#064;Parameter(0)\n *     public int firstSummand;\n *\n *     &#064;Parameter(1)\n *     public int secondSummand;\n *\n *     &#064;Parameter(2)\n *     public int sum;\n *\n *     &#064;Test\n *     public void test() {\n *         assertEquals(sum, firstSummand + secondSummand);\n *     }\n * }\n * </pre>\n * <p>\n * Each instance of <code>AdditionTest</code> will be constructed with the default constructor\n * and fields annotated by <code>&#064;Parameter</code>  will be initialized\n * with the data values in the <code>&#064;Parameters</code> method.\n *\n * <p>\n * The parameters can be provided as an array, too:\n * \n * <pre>\n * &#064;Parameters\n * public static Object[][] data() {\n * \treturn new Object[][] { { 0, 0, 0 }, { 1, 1, 2 }, { 3, 2, 5 }, { 4, 3, 7 } } };\n * }\n * </pre>\n * \n * <h3>Tests with single parameter</h3>\n * <p>\n * If your test needs a single parameter only, you don't have to wrap it with an\n * array. Instead you can provide an <code>Iterable</code> or an array of\n * objects.\n * <pre>\n * &#064;Parameters\n * public static Iterable&lt;? extends Object&gt; data() {\n * \treturn Arrays.asList(&quot;first test&quot;, &quot;second test&quot;);\n * }\n * </pre>\n * <p>\n * or\n * <pre>\n * &#064;Parameters\n * public static Object[] data() {\n * \treturn new Object[] { &quot;first test&quot;, &quot;second test&quot; };\n * }\n * </pre>\n *\n * <h3>Executing code before/after executing tests for specific parameters</h3>\n * <p>\n * If your test needs to perform some preparation or cleanup based on the\n * parameters, this can be done by adding public static methods annotated with\n * {@code @BeforeParam}/{@code @AfterParam}. Such methods should either have no\n * parameters or the same parameters as the test.\n * <pre>\n * &#064;BeforeParam\n * public static void beforeTestsForParameter(String onlyParameter) {\n *     System.out.println(\"Testing \" + onlyParameter);\n * }\n * </pre>\n *\n * <h3>Create different runners</h3>\n * <p>\n * By default the {@code Parameterized} runner creates a slightly modified\n * {@link BlockJUnit4ClassRunner} for each set of parameters. You can build an\n * own {@code Parameterized} runner that creates another runner for each set of\n * parameters. Therefore you have to build a {@link ParametersRunnerFactory}\n * that creates a runner for each {@link TestWithParameters}. (\n * {@code TestWithParameters} are bundling the parameters and the test name.)\n * The factory must have a public zero-arg constructor.\n *\n * <pre>\n * public class YourRunnerFactory implements ParametersRunnerFactory {\n *     public Runner createRunnerForTestWithParameters(TestWithParameters test)\n *             throws InitializationError {\n *         return YourRunner(test);\n *     }\n * }\n * </pre>\n * <p>\n * Use the {@link UseParametersRunnerFactory} to tell the {@code Parameterized}\n * runner that it should use your factory.\n *\n * <pre>\n * &#064;RunWith(Parameterized.class)\n * &#064;UseParametersRunnerFactory(YourRunnerFactory.class)\n * public class YourTest {\n *     ...\n * }\n * </pre>\n *\n * <h3>Avoid creating parameters</h3>\n * <p>With {@link org.junit.Assume assumptions} you can dynamically skip tests.\n * Assumptions are also supported by the <code>&#064;Parameters</code> method.\n * Creating parameters is stopped when the assumption fails and none of the\n * tests in the test class is executed. JUnit reports a\n * {@link Result#getAssumptionFailureCount() single assumption failure} for the\n * whole test class in this case.\n * <pre>\n * &#064;Parameters\n * public static Iterable&lt;? extends Object&gt; data() {\n * \tString os = System.getProperty(\"os.name\").toLowerCase()\n * \tAssume.assumeTrue(os.contains(\"win\"));\n * \treturn Arrays.asList(&quot;first test&quot;, &quot;second test&quot;);\n * }\n * </pre>\n * @since 4.0\n */\npublic class Parameterized extends Suite {\n    /**\n     * Annotation for a method which provides parameters to be injected into the\n     * test class constructor by <code>Parameterized</code>. The method has to\n     * be public and static.\n     */\n    @Retention(RetentionPolicy.RUNTIME)\n    @Target(ElementType.METHOD)\n    public @interface Parameters {\n        /**\n         * Optional pattern to derive the test's name from the parameters. Use\n         * numbers in braces to refer to the parameters or the additional data\n         * as follows:\n         * <pre>\n         * {index} - the current parameter index\n         * {0} - the first parameter value\n         * {1} - the second parameter value\n         * etc...\n         * </pre>\n         * <p>\n         * Default value is \"{index}\" for compatibility with previous JUnit\n         * versions.\n         *\n         * @return {@link MessageFormat} pattern string, except the index\n         *         placeholder.\n         * @see MessageFormat\n         */\n        String name() default \"{index}\";\n    }\n\n    /**\n     * Annotation for fields of the test class which will be initialized by the\n     * method annotated by <code>Parameters</code>.\n     * By using directly this annotation, the test class constructor isn't needed.\n     * Index range must start at 0.\n     * Default value is 0.\n     */\n    @Retention(RetentionPolicy.RUNTIME)\n    @Target(ElementType.FIELD)\n    public @interface Parameter {\n        /**\n         * Method that returns the index of the parameter in the array\n         * returned by the method annotated by <code>Parameters</code>.\n         * Index range must start at 0.\n         * Default value is 0.\n         *\n         * @return the index of the parameter.\n         */\n        int value() default 0;\n    }\n\n    /**\n     * Add this annotation to your test class if you want to generate a special\n     * runner. You have to specify a {@link ParametersRunnerFactory} class that\n     * creates such runners. The factory must have a public zero-arg\n     * constructor.\n     */\n    @Retention(RetentionPolicy.RUNTIME)\n    @Inherited\n    @Target(ElementType.TYPE)\n    public @interface UseParametersRunnerFactory {\n        /**\n         * @return a {@link ParametersRunnerFactory} class (must have a default\n         *         constructor)\n         */\n        Class<? extends ParametersRunnerFactory> value() default BlockJUnit4ClassRunnerWithParametersFactory.class;\n    }\n\n    /**\n     * Annotation for {@code public static void} methods which should be executed before\n     * evaluating tests with particular parameters.\n     *\n     * @see org.junit.BeforeClass\n     * @see org.junit.Before\n     * @since 4.13\n     */\n    @Retention(RetentionPolicy.RUNTIME)\n    @Target(ElementType.METHOD)\n    public @interface BeforeParam {\n    }\n\n    /**\n     * Annotation for {@code public static void} methods which should be executed after\n     * evaluating tests with particular parameters.\n     *\n     * @see org.junit.AfterClass\n     * @see org.junit.After\n     * @since 4.13\n     */\n    @Retention(RetentionPolicy.RUNTIME)\n    @Target(ElementType.METHOD)\n    public @interface AfterParam {\n    }\n\n    /**\n     * Only called reflectively. Do not use programmatically.\n     */\n    public Parameterized(Class<?> klass) throws Throwable {\n        this(klass, new RunnersFactory(klass));\n    }\n\n    private Parameterized(Class<?> klass, RunnersFactory runnersFactory) throws Exception {\n        super(klass, runnersFactory.createRunners());\n        validateBeforeParamAndAfterParamMethods(runnersFactory.parameterCount);\n    }\n\n    private void validateBeforeParamAndAfterParamMethods(Integer parameterCount)\n            throws InvalidTestClassError {\n        List<Throwable> errors = new ArrayList<Throwable>();\n        validatePublicStaticVoidMethods(Parameterized.BeforeParam.class, parameterCount, errors);\n        validatePublicStaticVoidMethods(Parameterized.AfterParam.class, parameterCount, errors);\n        if (!errors.isEmpty()) {\n            throw new InvalidTestClassError(getTestClass().getJavaClass(), errors);\n        }\n    }\n\n    private void validatePublicStaticVoidMethods(\n            Class<? extends Annotation> annotation, Integer parameterCount,\n            List<Throwable> errors) {\n        List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);\n        for (FrameworkMethod fm : methods) {\n            fm.validatePublicVoid(true, errors);\n            if (parameterCount != null) {\n                int methodParameterCount = fm.getMethod().getParameterTypes().length;\n                if (methodParameterCount != 0 && methodParameterCount != parameterCount) {\n                    errors.add(new Exception(\"Method \" + fm.getName()\n                            + \"() should have 0 or \" + parameterCount + \" parameter(s)\"));\n                }\n            }\n        }\n    }\n\n    private static class AssumptionViolationRunner extends Runner {\n        private final Description description;\n        private final AssumptionViolatedException exception;\n\n        AssumptionViolationRunner(TestClass testClass, String methodName,\n                AssumptionViolatedException exception) {\n            this.description = Description\n                    .createTestDescription(testClass.getJavaClass(),\n                            methodName + \"() assumption violation\");\n            this.exception = exception;\n        }\n\n        @Override\n        public Description getDescription() {\n            return description;\n        }\n\n        @Override\n        public void run(RunNotifier notifier) {\n            notifier.fireTestAssumptionFailed(new Failure(description, exception));\n        }\n    }\n\n    private static class RunnersFactory {\n        private static final ParametersRunnerFactory DEFAULT_FACTORY = new BlockJUnit4ClassRunnerWithParametersFactory();\n\n        private final TestClass testClass;\n        private final FrameworkMethod parametersMethod;\n        private final List<Object> allParameters;\n        private final int parameterCount;\n        private final Runner runnerOverride;\n\n        private RunnersFactory(Class<?> klass) throws Throwable {\n            testClass = new TestClass(klass);\n            parametersMethod = getParametersMethod(testClass);\n            List<Object> allParametersResult;\n            AssumptionViolationRunner assumptionViolationRunner = null;\n            try {\n                allParametersResult = allParameters(testClass, parametersMethod);\n            } catch (AssumptionViolatedException e) {\n                allParametersResult = Collections.emptyList();\n                assumptionViolationRunner = new AssumptionViolationRunner(testClass,\n                        parametersMethod.getName(), e);\n            }\n            allParameters = allParametersResult;\n            runnerOverride = assumptionViolationRunner;\n            parameterCount =\n                    allParameters.isEmpty() ? 0 : normalizeParameters(allParameters.get(0)).length;\n        }\n\n        private List<Runner> createRunners() throws Exception {\n            if (runnerOverride != null) {\n                return Collections.singletonList(runnerOverride);\n            }\n            Parameters parameters = parametersMethod.getAnnotation(Parameters.class);\n            return Collections.unmodifiableList(createRunnersForParameters(\n                    allParameters, parameters.name(),\n                    getParametersRunnerFactory()));\n        }\n\n        private ParametersRunnerFactory getParametersRunnerFactory()\n                throws InstantiationException, IllegalAccessException {\n            UseParametersRunnerFactory annotation = testClass\n                    .getAnnotation(UseParametersRunnerFactory.class);\n            if (annotation == null) {\n                return DEFAULT_FACTORY;\n            } else {\n                Class<? extends ParametersRunnerFactory> factoryClass = annotation\n                        .value();\n                return factoryClass.newInstance();\n            }\n        }\n\n        private TestWithParameters createTestWithNotNormalizedParameters(\n                String pattern, int index, Object parametersOrSingleParameter) {\n            Object[] parameters = normalizeParameters(parametersOrSingleParameter);\n            return createTestWithParameters(testClass, pattern, index, parameters);\n        }\n\n        private static Object[] normalizeParameters(Object parametersOrSingleParameter) {\n            return (parametersOrSingleParameter instanceof Object[]) ? (Object[]) parametersOrSingleParameter\n                    : new Object[] { parametersOrSingleParameter };\n        }\n\n        @SuppressWarnings(\"unchecked\")\n        private static List<Object> allParameters(\n                TestClass testClass, FrameworkMethod parametersMethod) throws Throwable {\n            Object parameters = parametersMethod.invokeExplosively(null);\n            if (parameters instanceof List) {\n                return (List<Object>) parameters;\n            } else if (parameters instanceof Collection) {\n                return new ArrayList<Object>((Collection<Object>) parameters);\n            } else if (parameters instanceof Iterable) {\n                List<Object> result = new ArrayList<Object>();\n                for (Object entry : ((Iterable<Object>) parameters)) {\n                    result.add(entry);\n                }\n                return result;\n            } else if (parameters instanceof Object[]) {\n                return Arrays.asList((Object[]) parameters);\n            } else {\n                throw parametersMethodReturnedWrongType(testClass, parametersMethod);\n            }\n        }\n\n        private static FrameworkMethod getParametersMethod(TestClass testClass) throws Exception {\n            List<FrameworkMethod> methods = testClass\n                    .getAnnotatedMethods(Parameters.class);\n            for (FrameworkMethod each : methods) {\n                if (each.isStatic() && each.isPublic()) {\n                    return each;\n                }\n            }\n\n            throw new Exception(\"No public static parameters method on class \"\n                    + testClass.getName());\n        }\n\n        private List<Runner> createRunnersForParameters(\n                Iterable<Object> allParameters, String namePattern,\n                ParametersRunnerFactory runnerFactory) throws Exception {\n            try {\n                List<TestWithParameters> tests = createTestsForParameters(\n                        allParameters, namePattern);\n                List<Runner> runners = new ArrayList<Runner>();\n                for (TestWithParameters test : tests) {\n                    runners.add(runnerFactory\n                            .createRunnerForTestWithParameters(test));\n                }\n                return runners;\n            } catch (ClassCastException e) {\n                throw parametersMethodReturnedWrongType(testClass, parametersMethod);\n            }\n        }\n\n        private List<TestWithParameters> createTestsForParameters(\n                Iterable<Object> allParameters, String namePattern)\n                throws Exception {\n            int i = 0;\n            List<TestWithParameters> children = new ArrayList<TestWithParameters>();\n            for (Object parametersOfSingleTest : allParameters) {\n                children.add(createTestWithNotNormalizedParameters(namePattern,\n                        i++, parametersOfSingleTest));\n            }\n            return children;\n        }\n\n        private static Exception parametersMethodReturnedWrongType(\n                TestClass testClass, FrameworkMethod parametersMethod) throws Exception {\n            String className = testClass.getName();\n            String methodName = parametersMethod.getName();\n            String message = MessageFormat.format(\n                    \"{0}.{1}() must return an Iterable of arrays.\", className,\n                    methodName);\n            return new Exception(message);\n        }\n\n        private TestWithParameters createTestWithParameters(\n                TestClass testClass, String pattern, int index,\n                Object[] parameters) {\n            String finalPattern = pattern.replaceAll(\"\\\\{index\\\\}\",\n                    Integer.toString(index));\n            String name = MessageFormat.format(finalPattern, parameters);\n            return new TestWithParameters(\"[\" + name + \"]\", testClass,\n                    Arrays.asList(parameters));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/ParentRunner.java",
    "content": "package org.junit.runners;\n\nimport static org.junit.internal.Checks.notNull;\nimport static org.junit.internal.runners.rules.RuleMemberValidator.CLASS_RULE_METHOD_VALIDATOR;\nimport static org.junit.internal.runners.rules.RuleMemberValidator.CLASS_RULE_VALIDATOR;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Method;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Iterator;\nimport java.util.LinkedHashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.concurrent.locks.Lock;\nimport java.util.concurrent.locks.ReentrantLock;\n\nimport org.junit.AfterClass;\nimport org.junit.BeforeClass;\nimport org.junit.ClassRule;\nimport org.junit.FixMethodOrder;\nimport org.junit.Ignore;\nimport org.junit.Rule;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.internal.runners.model.EachTestNotifier;\nimport org.junit.internal.runners.statements.RunAfters;\nimport org.junit.internal.runners.statements.RunBefores;\nimport org.junit.rules.RunRules;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.Description;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.Filterable;\nimport org.junit.runner.manipulation.Orderer;\nimport org.junit.runner.manipulation.InvalidOrderingException;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runner.manipulation.Orderable;\nimport org.junit.runner.manipulation.Sorter;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runner.notification.StoppedByUserException;\nimport org.junit.runners.model.FrameworkMember;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.InvalidTestClassError;\nimport org.junit.runners.model.MemberValueConsumer;\nimport org.junit.runners.model.RunnerScheduler;\nimport org.junit.runners.model.Statement;\nimport org.junit.runners.model.TestClass;\nimport org.junit.validator.AnnotationsValidator;\nimport org.junit.validator.TestClassValidator;\n\n/**\n * Provides most of the functionality specific to a Runner that implements a\n * \"parent node\" in the test tree, with children defined by objects of some data\n * type {@code T}. (For {@link BlockJUnit4ClassRunner}, {@code T} is\n * {@link Method} . For {@link Suite}, {@code T} is {@link Class}.) Subclasses\n * must implement finding the children of the node, describing each child, and\n * running each child. ParentRunner will filter and sort children, handle\n * {@code @BeforeClass} and {@code @AfterClass} methods,\n * handle annotated {@link ClassRule}s, create a composite\n * {@link Description}, and run children sequentially.\n *\n * @since 4.5\n */\npublic abstract class ParentRunner<T> extends Runner implements Filterable,\n        Orderable {\n    private static final List<TestClassValidator> VALIDATORS = Collections.<TestClassValidator>singletonList(\n            new AnnotationsValidator());\n\n    private final Lock childrenLock = new ReentrantLock();\n    private final TestClass testClass;\n\n    // Guarded by childrenLock\n    private volatile List<T> filteredChildren = null;\n\n    private volatile RunnerScheduler scheduler = new RunnerScheduler() {\n        public void schedule(Runnable childStatement) {\n            childStatement.run();\n        }\n\n        public void finished() {\n            // do nothing\n        }\n    };\n\n    /**\n     * Constructs a new {@code ParentRunner} that will run {@code @TestClass}\n     */\n    protected ParentRunner(Class<?> testClass) throws InitializationError {\n        this.testClass = createTestClass(testClass);\n        validate();\n    }\n\n   /**\n    * Constructs a new {@code ParentRunner} that will run the {@code TestClass}.\n    *\n    * @since 4.13\n    */\n    protected ParentRunner(TestClass testClass) throws InitializationError {\n       this.testClass = notNull(testClass);\n       validate();\n    }\n\n    /**\n     * @deprecated Please use {@link #ParentRunner(org.junit.runners.model.TestClass)}.\n     * @since 4.12\n     */\n    @Deprecated\n    protected TestClass createTestClass(Class<?> testClass) {\n        return new TestClass(testClass);\n    }\n\n    //\n    // Must be overridden\n    //\n\n    /**\n     * Returns a list of objects that define the children of this Runner.\n     */\n    protected abstract List<T> getChildren();\n\n    /**\n     * Returns a {@link Description} for {@code child}, which can be assumed to\n     * be an element of the list returned by {@link ParentRunner#getChildren()}\n     */\n    protected abstract Description describeChild(T child);\n\n    /**\n     * Runs the test corresponding to {@code child}, which can be assumed to be\n     * an element of the list returned by {@link ParentRunner#getChildren()}.\n     * Subclasses are responsible for making sure that relevant test events are\n     * reported through {@code notifier}\n     */\n    protected abstract void runChild(T child, RunNotifier notifier);\n\n    //\n    // May be overridden\n    //\n\n    /**\n     * Adds to {@code errors} a throwable for each problem noted with the test class (available from {@link #getTestClass()}).\n     * Default implementation adds an error for each method annotated with\n     * {@code @BeforeClass} or {@code @AfterClass} that is not\n     * {@code public static void} with no arguments.\n     */\n    protected void collectInitializationErrors(List<Throwable> errors) {\n        validatePublicVoidNoArgMethods(BeforeClass.class, true, errors);\n        validatePublicVoidNoArgMethods(AfterClass.class, true, errors);\n        validateClassRules(errors);\n        applyValidators(errors);\n    }\n\n    private void applyValidators(List<Throwable> errors) {\n        if (getTestClass().getJavaClass() != null) {\n            for (TestClassValidator each : VALIDATORS) {\n                errors.addAll(each.validateTestClass(getTestClass()));\n            }\n        }\n    }\n\n    /**\n     * Adds to {@code errors} if any method in this class is annotated with\n     * {@code annotation}, but:\n     * <ul>\n     * <li>is not public, or\n     * <li>takes parameters, or\n     * <li>returns something other than void, or\n     * <li>is static (given {@code isStatic is false}), or\n     * <li>is not static (given {@code isStatic is true}).\n     * </ul>\n     */\n    protected void validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation,\n            boolean isStatic, List<Throwable> errors) {\n        List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);\n\n        for (FrameworkMethod eachTestMethod : methods) {\n            eachTestMethod.validatePublicVoidNoArg(isStatic, errors);\n        }\n    }\n\n    private void validateClassRules(List<Throwable> errors) {\n        CLASS_RULE_VALIDATOR.validate(getTestClass(), errors);\n        CLASS_RULE_METHOD_VALIDATOR.validate(getTestClass(), errors);\n    }\n\n    /**\n     * Constructs a {@code Statement} to run all of the tests in the test class.\n     * Override to add pre-/post-processing. Here is an outline of the\n     * implementation:\n     * <ol>\n     * <li>Determine the children to be run using {@link #getChildren()}\n     * (subject to any imposed filter and sort).</li>\n     * <li>If there are any children remaining after filtering and ignoring,\n     * construct a statement that will:\n     * <ol>\n     * <li>Apply all {@code ClassRule}s on the test-class and superclasses.</li>\n     * <li>Run all non-overridden {@code @BeforeClass} methods on the test-class\n     * and superclasses; if any throws an Exception, stop execution and pass the\n     * exception on.</li>\n     * <li>Run all remaining tests on the test-class.</li>\n     * <li>Run all non-overridden {@code @AfterClass} methods on the test-class\n     * and superclasses: exceptions thrown by previous steps are combined, if\n     * necessary, with exceptions from AfterClass methods into a\n     * {@link org.junit.runners.model.MultipleFailureException}.</li>\n     * </ol>\n     * </li>\n     * </ol>\n     *\n     * @return {@code Statement}\n     */\n    protected Statement classBlock(final RunNotifier notifier) {\n        Statement statement = childrenInvoker(notifier);\n        if (!areAllChildrenIgnored()) {\n            statement = withBeforeClasses(statement);\n            statement = withAfterClasses(statement);\n            statement = withClassRules(statement);\n            statement = withInterruptIsolation(statement);\n        }\n        return statement;\n    }\n\n    private boolean areAllChildrenIgnored() {\n        for (T child : getFilteredChildren()) {\n            if (!isIgnored(child)) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * Returns a {@link Statement}: run all non-overridden {@code @BeforeClass} methods on this class\n     * and superclasses before executing {@code statement}; if any throws an\n     * Exception, stop execution and pass the exception on.\n     */\n    protected Statement withBeforeClasses(Statement statement) {\n        List<FrameworkMethod> befores = testClass\n                .getAnnotatedMethods(BeforeClass.class);\n        return befores.isEmpty() ? statement :\n                new RunBefores(statement, befores, null);\n    }\n\n    /**\n     * Returns a {@link Statement}: run all non-overridden {@code @AfterClass} methods on this class\n     * and superclasses after executing {@code statement}; all AfterClass methods are\n     * always executed: exceptions thrown by previous steps are combined, if\n     * necessary, with exceptions from AfterClass methods into a\n     * {@link org.junit.runners.model.MultipleFailureException}.\n     */\n    protected Statement withAfterClasses(Statement statement) {\n        List<FrameworkMethod> afters = testClass\n                .getAnnotatedMethods(AfterClass.class);\n        return afters.isEmpty() ? statement :\n                new RunAfters(statement, afters, null);\n    }\n\n    /**\n     * Returns a {@link Statement}: apply all\n     * static fields assignable to {@link TestRule}\n     * annotated with {@link ClassRule}.\n     *\n     * @param statement the base statement\n     * @return a RunRules statement if any class-level {@link Rule}s are\n     *         found, or the base statement\n     */\n    private Statement withClassRules(Statement statement) {\n        List<TestRule> classRules = classRules();\n        return classRules.isEmpty() ? statement :\n                new RunRules(statement, classRules, getDescription());\n    }\n\n    /**\n     * @return the {@code ClassRule}s that can transform the block that runs\n     *         each method in the tested class.\n     */\n    protected List<TestRule> classRules() {\n        ClassRuleCollector collector = new ClassRuleCollector();\n        testClass.collectAnnotatedMethodValues(null, ClassRule.class, TestRule.class, collector);\n        testClass.collectAnnotatedFieldValues(null, ClassRule.class, TestRule.class, collector);\n        return collector.getOrderedRules();\n    }\n\n    /**\n     * Returns a {@link Statement}: Call {@link #runChild(Object, RunNotifier)}\n     * on each object returned by {@link #getChildren()} (subject to any imposed\n     * filter and sort)\n     */\n    protected Statement childrenInvoker(final RunNotifier notifier) {\n        return new Statement() {\n            @Override\n            public void evaluate() {\n                runChildren(notifier);\n            }\n        };\n    }\n\n    /**\n     * @return a {@link Statement}: clears interrupt status of current thread after execution of statement\n     */\n    protected final Statement withInterruptIsolation(final Statement statement) {\n        return new Statement() {\n            @Override\n            public void evaluate() throws Throwable {\n                try {\n                    statement.evaluate();\n                } finally {\n                    Thread.interrupted(); // clearing thread interrupted status for isolation\n                }\n            }\n        };\n    }\n\n    /**\n     * Evaluates whether a child is ignored. The default implementation always\n     * returns <code>false</code>.\n     * \n     * <p>{@link BlockJUnit4ClassRunner}, for example, overrides this method to\n     * filter tests based on the {@link Ignore} annotation.\n     */\n    protected boolean isIgnored(T child) {\n        return false;\n    }\n\n    private void runChildren(final RunNotifier notifier) {\n        final RunnerScheduler currentScheduler = scheduler;\n        try {\n            for (final T each : getFilteredChildren()) {\n                currentScheduler.schedule(new Runnable() {\n                    public void run() {\n                        ParentRunner.this.runChild(each, notifier);\n                    }\n                });\n            }\n        } finally {\n            currentScheduler.finished();\n        }\n    }\n\n    /**\n     * Returns a name used to describe this Runner\n     */\n    protected String getName() {\n        return testClass.getName();\n    }\n\n    //\n    // Available for subclasses\n    //\n\n    /**\n     * Returns a {@link TestClass} object wrapping the class to be executed.\n     */\n    public final TestClass getTestClass() {\n        return testClass;\n    }\n\n    /**\n     * Runs a {@link Statement} that represents a leaf (aka atomic) test.\n     */\n    protected final void runLeaf(Statement statement, Description description,\n            RunNotifier notifier) {\n        EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);\n        eachNotifier.fireTestStarted();\n        try {\n            statement.evaluate();\n        } catch (AssumptionViolatedException e) {\n            eachNotifier.addFailedAssumption(e);\n        } catch (Throwable e) {\n            eachNotifier.addFailure(e);\n        } finally {\n            eachNotifier.fireTestFinished();\n        }\n    }\n\n    /**\n     * @return the annotations that should be attached to this runner's\n     *         description.\n     */\n    protected Annotation[] getRunnerAnnotations() {\n        return testClass.getAnnotations();\n    }\n\n    //\n    // Implementation of Runner\n    //\n\n    @Override\n    public Description getDescription() {\n        Class<?> clazz = getTestClass().getJavaClass();\n        Description description;\n        // if subclass overrides `getName()` then we should use it\n        // to maintain backwards compatibility with JUnit 4.12\n        if (clazz == null || !clazz.getName().equals(getName())) {\n            description = Description.createSuiteDescription(getName(), getRunnerAnnotations());\n        } else {\n            description = Description.createSuiteDescription(clazz, getRunnerAnnotations());\n        }\n\n        for (T child : getFilteredChildren()) {\n            description.addChild(describeChild(child));\n        }\n        return description;\n    }\n\n    @Override\n    public void run(final RunNotifier notifier) {\n        EachTestNotifier testNotifier = new EachTestNotifier(notifier,\n                getDescription());\n        testNotifier.fireTestSuiteStarted();\n        try {\n            Statement statement = classBlock(notifier);\n            statement.evaluate();\n        } catch (AssumptionViolatedException e) {\n            testNotifier.addFailedAssumption(e);\n        } catch (StoppedByUserException e) {\n            throw e;\n        } catch (Throwable e) {\n            testNotifier.addFailure(e);\n        } finally {\n            testNotifier.fireTestSuiteFinished();\n        }\n    }\n\n    //\n    // Implementation of Filterable and Sortable\n    //\n\n    public void filter(Filter filter) throws NoTestsRemainException {\n        childrenLock.lock();\n        try {\n            List<T> children = new ArrayList<T>(getFilteredChildren());\n            for (Iterator<T> iter = children.iterator(); iter.hasNext(); ) {\n                T each = iter.next();\n                if (shouldRun(filter, each)) {\n                    try {\n                        filter.apply(each);\n                    } catch (NoTestsRemainException e) {\n                        iter.remove();\n                    }\n                } else {\n                    iter.remove();\n                }\n            }\n            filteredChildren = Collections.unmodifiableList(children);\n            if (filteredChildren.isEmpty()) {\n                throw new NoTestsRemainException();\n            }\n        } finally {\n            childrenLock.unlock();\n        }\n    }\n\n    public void sort(Sorter sorter) {\n        if (shouldNotReorder()) {\n            return;\n        }\n\n        childrenLock.lock();\n        try {\n            for (T each : getFilteredChildren()) {\n                sorter.apply(each);\n            }\n            List<T> sortedChildren = new ArrayList<T>(getFilteredChildren());\n            Collections.sort(sortedChildren, comparator(sorter));\n            filteredChildren = Collections.unmodifiableList(sortedChildren);\n        } finally {\n            childrenLock.unlock();\n        }\n    }\n\n    /**\n     * Implementation of {@link Orderable#order(Orderer)}.\n     *\n     * @since 4.13\n     */\n    public void order(Orderer orderer) throws InvalidOrderingException {\n        if (shouldNotReorder()) {\n            return;\n        }\n\n        childrenLock.lock();\n        try {\n            List<T> children = getFilteredChildren();\n            // In theory, we could have duplicate Descriptions. De-dup them before ordering,\n            // and add them back at the end.\n            Map<Description, List<T>> childMap = new LinkedHashMap<Description, List<T>>(\n                    children.size());\n            for (T child : children) {\n                Description description = describeChild(child);\n                List<T> childrenWithDescription = childMap.get(description);\n                if (childrenWithDescription == null) {\n                    childrenWithDescription = new ArrayList<T>(1);\n                    childMap.put(description, childrenWithDescription);\n                }\n                childrenWithDescription.add(child);\n                orderer.apply(child);\n            }\n\n            List<Description> inOrder = orderer.order(childMap.keySet());\n\n            children = new ArrayList<T>(children.size());\n            for (Description description : inOrder) {\n                children.addAll(childMap.get(description));\n            }\n            filteredChildren = Collections.unmodifiableList(children);\n        } finally {\n            childrenLock.unlock();\n        }\n    }\n\n    //\n    // Private implementation\n    //\n\n    private boolean shouldNotReorder() {\n        // If the test specifies a specific order, do not reorder.\n        return getDescription().getAnnotation(FixMethodOrder.class) != null;\n    }\n\n    private void validate() throws InitializationError {\n        List<Throwable> errors = new ArrayList<Throwable>();\n        collectInitializationErrors(errors);\n        if (!errors.isEmpty()) {\n            throw new InvalidTestClassError(testClass.getJavaClass(), errors);\n        }\n    }\n\n    private List<T> getFilteredChildren() {\n        if (filteredChildren == null) {\n            childrenLock.lock();\n            try {\n                if (filteredChildren == null) {\n                    filteredChildren = Collections.unmodifiableList(\n                            new ArrayList<T>(getChildren()));\n                }\n            } finally {\n                childrenLock.unlock();\n            }\n        }\n        return filteredChildren;\n    }\n\n    private boolean shouldRun(Filter filter, T each) {\n        return filter.shouldRun(describeChild(each));\n    }\n\n    private Comparator<? super T> comparator(final Sorter sorter) {\n        return new Comparator<T>() {\n            public int compare(T o1, T o2) {\n                return sorter.compare(describeChild(o1), describeChild(o2));\n            }\n        };\n    }\n\n    /**\n     * Sets a scheduler that determines the order and parallelization\n     * of children.  Highly experimental feature that may change.\n     */\n    public void setScheduler(RunnerScheduler scheduler) {\n        this.scheduler = scheduler;\n    }\n\n    private static class ClassRuleCollector implements MemberValueConsumer<TestRule> {\n        final List<RuleContainer.RuleEntry> entries = new ArrayList<RuleContainer.RuleEntry>();\n\n        public void accept(FrameworkMember<?> member, TestRule value) {\n            ClassRule rule = member.getAnnotation(ClassRule.class);\n            entries.add(new RuleContainer.RuleEntry(value, RuleContainer.RuleEntry.TYPE_TEST_RULE,\n                    rule != null ? rule.order() : null));\n        }\n\n        public List<TestRule> getOrderedRules() {\n            Collections.sort(entries, RuleContainer.ENTRY_COMPARATOR);\n            List<TestRule> result = new ArrayList<TestRule>(entries.size());\n            for (RuleContainer.RuleEntry entry : entries) {\n                result.add((TestRule) entry.rule);\n            }\n            return result;\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/RuleContainer.java",
    "content": "package org.junit.runners;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.IdentityHashMap;\nimport java.util.List;\n\nimport org.junit.Rule;\nimport org.junit.rules.MethodRule;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\n/**\n * Data structure for ordering of {@link TestRule}/{@link MethodRule} instances.\n *\n * @since 4.13\n */\nclass RuleContainer {\n    private final IdentityHashMap<Object, Integer> orderValues = new IdentityHashMap<Object, Integer>();\n    private final List<TestRule> testRules = new ArrayList<TestRule>();\n    private final List<MethodRule> methodRules = new ArrayList<MethodRule>();\n\n    /**\n     * Sets order value for the specified rule.\n     */\n    public void setOrder(Object rule, int order) {\n        orderValues.put(rule, order);\n    }\n\n    public void add(MethodRule methodRule) {\n        methodRules.add(methodRule);\n    }\n\n    public void add(TestRule testRule) {\n        testRules.add(testRule);\n    }\n\n    static final Comparator<RuleEntry> ENTRY_COMPARATOR = new Comparator<RuleEntry>() {\n        public int compare(RuleEntry o1, RuleEntry o2) {\n            int result = compareInt(o1.order, o2.order);\n            return result != 0 ? result : o1.type - o2.type;\n        }\n\n        private int compareInt(int a, int b) {\n            return (a < b) ? 1 : (a == b ? 0 : -1);\n        }\n    };\n\n    /**\n     * Returns entries in the order how they should be applied, i.e. inner-to-outer.\n     */\n    private List<RuleEntry> getSortedEntries() {\n        List<RuleEntry> ruleEntries = new ArrayList<RuleEntry>(\n                methodRules.size() + testRules.size());\n        for (MethodRule rule : methodRules) {\n            ruleEntries.add(new RuleEntry(rule, RuleEntry.TYPE_METHOD_RULE, orderValues.get(rule)));\n        }\n        for (TestRule rule : testRules) {\n            ruleEntries.add(new RuleEntry(rule, RuleEntry.TYPE_TEST_RULE, orderValues.get(rule)));\n        }\n        Collections.sort(ruleEntries, ENTRY_COMPARATOR);\n        return ruleEntries;\n    }\n\n    /**\n     * Applies all the rules ordered accordingly to the specified {@code statement}.\n     */\n    public Statement apply(FrameworkMethod method, Description description, Object target,\n            Statement statement) {\n        if (methodRules.isEmpty() && testRules.isEmpty()) {\n            return statement;\n        }\n        Statement result = statement;\n        for (RuleEntry ruleEntry : getSortedEntries()) {\n            if (ruleEntry.type == RuleEntry.TYPE_TEST_RULE) {\n                result = ((TestRule) ruleEntry.rule).apply(result, description);\n            } else {\n                result = ((MethodRule) ruleEntry.rule).apply(result, method, target);\n            }\n        }\n        return result;\n    }\n\n    /**\n     * Returns rule instances in the order how they should be applied, i.e. inner-to-outer.\n     * VisibleForTesting\n     */\n    List<Object> getSortedRules() {\n        List<Object> result = new ArrayList<Object>();\n        for (RuleEntry entry : getSortedEntries()) {\n            result.add(entry.rule);\n        }\n        return result;\n    }\n\n    static class RuleEntry {\n        static final int TYPE_TEST_RULE = 1;\n        static final int TYPE_METHOD_RULE = 0;\n\n        final Object rule;\n        final int type;\n        final int order;\n\n        RuleEntry(Object rule, int type, Integer order) {\n            this.rule = rule;\n            this.type = type;\n            this.order = order != null ? order.intValue() : Rule.DEFAULT_ORDER;\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/Suite.java",
    "content": "package org.junit.runners;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.internal.builders.AllDefaultPossibilitiesBuilder;\nimport org.junit.runner.Description;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerBuilder;\n\n/**\n * Using <code>Suite</code> as a runner allows you to manually\n * build a suite containing tests from many classes. It is the JUnit 4 equivalent of the JUnit 3.8.x\n * static {@link junit.framework.Test} <code>suite()</code> method. To use it, annotate a class\n * with <code>@RunWith(Suite.class)</code> and <code>@SuiteClasses({TestClass1.class, ...})</code>.\n * When you run this class, it will run all the tests in all the suite classes.\n *\n * @since 4.0\n */\npublic class Suite extends ParentRunner<Runner> {\n    /**\n     * Returns an empty suite.\n     */\n    public static Runner emptySuite() {\n        try {\n            return new Suite((Class<?>) null, new Class<?>[0]);\n        } catch (InitializationError e) {\n            throw new RuntimeException(\"This shouldn't be possible\");\n        }\n    }\n\n    /**\n     * The <code>SuiteClasses</code> annotation specifies the classes to be run when a class\n     * annotated with <code>@RunWith(Suite.class)</code> is run.\n     */\n    @Retention(RetentionPolicy.RUNTIME)\n    @Target(ElementType.TYPE)\n    @Inherited\n    public @interface SuiteClasses {\n        /**\n         * @return the classes to be run\n         */\n        Class<?>[] value();\n    }\n\n    private static Class<?>[] getAnnotatedClasses(Class<?> klass) throws InitializationError {\n        SuiteClasses annotation = klass.getAnnotation(SuiteClasses.class);\n        if (annotation == null) {\n            throw new InitializationError(String.format(\"class '%s' must have a SuiteClasses annotation\", klass.getName()));\n        }\n        return annotation.value();\n    }\n\n    private final List<Runner> runners;\n\n    /**\n     * Called reflectively on classes annotated with <code>@RunWith(Suite.class)</code>\n     *\n     * @param klass the root class\n     * @param builder builds runners for classes in the suite\n     */\n    public Suite(Class<?> klass, RunnerBuilder builder) throws InitializationError {\n        this(builder, klass, getAnnotatedClasses(klass));\n    }\n\n    /**\n     * Call this when there is no single root class (for example, multiple class names\n     * passed on the command line to {@link org.junit.runner.JUnitCore}\n     *\n     * @param builder builds runners for classes in the suite\n     * @param classes the classes in the suite\n     */\n    public Suite(RunnerBuilder builder, Class<?>[] classes) throws InitializationError {\n        this(null, builder.runners(null, classes));\n    }\n\n    /**\n     * Call this when the default builder is good enough. Left in for compatibility with JUnit 4.4.\n     *\n     * @param klass the root of the suite\n     * @param suiteClasses the classes in the suite\n     */\n    protected Suite(Class<?> klass, Class<?>[] suiteClasses) throws InitializationError {\n        this(new AllDefaultPossibilitiesBuilder(), klass, suiteClasses);\n    }\n\n    /**\n     * Called by this class and subclasses once the classes making up the suite have been determined\n     *\n     * @param builder builds runners for classes in the suite\n     * @param klass the root of the suite\n     * @param suiteClasses the classes in the suite\n     */\n    protected Suite(RunnerBuilder builder, Class<?> klass, Class<?>[] suiteClasses) throws InitializationError {\n        this(klass, builder.runners(klass, suiteClasses));\n    }\n\n    /**\n     * Called by this class and subclasses once the runners making up the suite have been determined\n     *\n     * @param klass root of the suite\n     * @param runners for each class in the suite, a {@link Runner}\n     */\n    protected Suite(Class<?> klass, List<Runner> runners) throws InitializationError {\n        super(klass);\n        this.runners = Collections.unmodifiableList(runners);\n    }\n\n    @Override\n    protected List<Runner> getChildren() {\n        return runners;\n    }\n\n    @Override\n    protected Description describeChild(Runner child) {\n        return child.getDescription();\n    }\n\n    @Override\n    protected void runChild(Runner runner, final RunNotifier notifier) {\n        runner.run(notifier);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/Annotatable.java",
    "content": "package org.junit.runners.model;\n\nimport java.lang.annotation.Annotation;\n\n/**\n * A model element that may have annotations.\n * \n * @since 4.12\n */\npublic interface Annotatable {\n    /**\n     * Returns the model elements' annotations.\n     */\n    Annotation[] getAnnotations();\n\n    /**\n     * Returns the annotation on the model element of the given type, or @code{null}\n     */\n    <T extends Annotation> T getAnnotation(Class<T> annotationType);\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/FrameworkField.java",
    "content": "package org.junit.runners.model;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Field;\n\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\n/**\n * Represents a field on a test class (currently used only for Rules in\n * {@link BlockJUnit4ClassRunner}, but custom runners can make other uses)\n *\n * @since 4.7\n */\npublic class FrameworkField extends FrameworkMember<FrameworkField> {\n    private final Field field;\n\n    /**\n     * Returns a new {@code FrameworkField} for {@code field}.\n     *\n     * <p>Access relaxed to {@code public} since version 4.13.1.\n     */\n    public FrameworkField(Field field) {\n        if (field == null) {\n            throw new NullPointerException(\n                    \"FrameworkField cannot be created without an underlying field.\");\n        }\n        this.field = field;\n\n        if (isPublic()) {\n            // This field could be a public field in a package-scope base class\n            try {\n                field.setAccessible(true);\n            } catch (SecurityException e) {\n                // We may get an IllegalAccessException when we try to access the field\n            }\n        }\n    }\n\n    @Override\n    public String getName() {\n        return getField().getName();\n    }\n\n    public Annotation[] getAnnotations() {\n        return field.getAnnotations();\n    }\n\n    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {\n        return field.getAnnotation(annotationType);\n    }\n\n    @Override\n    public boolean isShadowedBy(FrameworkField otherMember) {\n        return otherMember.getName().equals(getName());\n    }\n\n    @Override\n    boolean isBridgeMethod() {\n        return false;\n    }\n\n    @Override\n    protected int getModifiers() {\n        return field.getModifiers();\n    }\n\n    /**\n     * @return the underlying java Field\n     */\n    public Field getField() {\n        return field;\n    }\n\n    /**\n     * @return the underlying Java Field type\n     * @see java.lang.reflect.Field#getType()\n     */\n    @Override\n    public Class<?> getType() {\n        return field.getType();\n    }\n    \n    @Override\n    public Class<?> getDeclaringClass() {\n        return field.getDeclaringClass();\n    }\n\n    /**\n     * Attempts to retrieve the value of this field on {@code target}\n     */\n    public Object get(Object target) throws IllegalArgumentException, IllegalAccessException {\n        return field.get(target);\n    }\n\n    @Override\n    public String toString() {\n        return field.toString();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/FrameworkMember.java",
    "content": "package org.junit.runners.model;\n\nimport java.lang.reflect.Modifier;\nimport java.util.List;\n\n/**\n * Parent class for {@link FrameworkField} and {@link FrameworkMethod}\n *\n * @since 4.7\n */\npublic abstract class FrameworkMember<T extends FrameworkMember<T>> implements\n        Annotatable {\n    abstract boolean isShadowedBy(T otherMember);\n\n    T handlePossibleBridgeMethod(List<T> members) {\n        for (int i = members.size() - 1; i >=0; i--) {\n            T otherMember = members.get(i);\n            if (isShadowedBy(otherMember)) {\n                if (otherMember.isBridgeMethod()) {\n                    /*\n                     *  We need to return the previously-encountered bridge method\n                     *  because JUnit won't be able to call the parent method,\n                     *  because the parent class isn't public.\n                     */\n                    members.remove(i);\n                    return otherMember;\n                }\n                // We found a shadowed member that isn't a bridge method. Ignore it.\n                return null;\n            }\n        }\n        // No shadow or bridge method found. The caller should add *this* member.\n        FrameworkMember<? extends T> thisMember = this;\n        @SuppressWarnings(\"unchecked\")\n        T result = (T) thisMember;\n\n        return result;\n    }\n\n    abstract boolean isBridgeMethod();\n\n    protected abstract int getModifiers();\n\n    /**\n     * Returns true if this member is static, false if not.\n     */\n    public boolean isStatic() {\n        return Modifier.isStatic(getModifiers());\n    }\n\n    /**\n     * Returns true if this member is public, false if not.\n     */\n    public boolean isPublic() {\n        return Modifier.isPublic(getModifiers());\n    }\n\n    public abstract String getName();\n\n    public abstract Class<?> getType();\n\n    public abstract Class<?> getDeclaringClass();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/FrameworkMethod.java",
    "content": "package org.junit.runners.model;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Type;\nimport java.util.List;\n\nimport org.junit.internal.runners.model.ReflectiveCallable;\n\n/**\n * Represents a method on a test class to be invoked at the appropriate point in\n * test execution. These methods are usually marked with an annotation (such as\n * {@code @Test}, {@code @Before}, {@code @After}, {@code @BeforeClass},\n * {@code @AfterClass}, etc.)\n *\n * @since 4.5\n */\npublic class FrameworkMethod extends FrameworkMember<FrameworkMethod> {\n    private final Method method;\n\n    /**\n     * Returns a new {@code FrameworkMethod} for {@code method}\n     */\n    public FrameworkMethod(Method method) {\n        if (method == null) {\n            throw new NullPointerException(\n                    \"FrameworkMethod cannot be created without an underlying method.\");\n        }\n        this.method = method;\n\n        if (isPublic()) {\n            // This method could be a public method in a package-scope base class\n            try {\n                method.setAccessible(true);\n            } catch (SecurityException  e) {\n                // We may get an IllegalAccessException when we try to call the method\n            }\n        }\n    }\n\n    /**\n     * Returns the underlying Java method\n     */\n    public Method getMethod() {\n        return method;\n    }\n\n    /**\n     * Returns the result of invoking this method on {@code target} with\n     * parameters {@code params}. {@link InvocationTargetException}s thrown are\n     * unwrapped, and their causes rethrown.\n     */\n    public Object invokeExplosively(final Object target, final Object... params)\n            throws Throwable {\n        return new ReflectiveCallable() {\n            @Override\n            protected Object runReflectiveCall() throws Throwable {\n                return method.invoke(target, params);\n            }\n        }.run();\n    }\n\n    /**\n     * Returns the method's name\n     */\n    @Override\n    public String getName() {\n        return method.getName();\n    }\n\n    /**\n     * Adds to {@code errors} if this method:\n     * <ul>\n     * <li>is not public, or\n     * <li>takes parameters, or\n     * <li>returns something other than void, or\n     * <li>is static (given {@code isStatic is false}), or\n     * <li>is not static (given {@code isStatic is true}).\n     * </ul>\n     */\n    public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors) {\n        validatePublicVoid(isStatic, errors);\n        if (method.getParameterTypes().length != 0) {\n            errors.add(new Exception(\"Method \" + method.getName() + \" should have no parameters\"));\n        }\n    }\n\n\n    /**\n     * Adds to {@code errors} if this method:\n     * <ul>\n     * <li>is not public, or\n     * <li>returns something other than void, or\n     * <li>is static (given {@code isStatic is false}), or\n     * <li>is not static (given {@code isStatic is true}).\n     * </ul>\n     */\n    public void validatePublicVoid(boolean isStatic, List<Throwable> errors) {\n        if (isStatic() != isStatic) {\n            String state = isStatic ? \"should\" : \"should not\";\n            errors.add(new Exception(\"Method \" + method.getName() + \"() \" + state + \" be static\"));\n        }\n        if (!isPublic()) {\n            errors.add(new Exception(\"Method \" + method.getName() + \"() should be public\"));\n        }\n        if (method.getReturnType() != Void.TYPE) {\n            errors.add(new Exception(\"Method \" + method.getName() + \"() should be void\"));\n        }\n    }\n\n    @Override\n    protected int getModifiers() {\n        return method.getModifiers();\n    }\n\n    /**\n     * Returns the return type of the method\n     */\n    public Class<?> getReturnType() {\n        return method.getReturnType();\n    }\n\n    /**\n     * Returns the return type of the method\n     */\n    @Override\n    public Class<?> getType() {\n        return getReturnType();\n    }\n\n    /**\n     * Returns the class where the method is actually declared\n     */\n    @Override\n    public Class<?> getDeclaringClass() {\n        return method.getDeclaringClass();\n    }\n\n    public void validateNoTypeParametersOnArgs(List<Throwable> errors) {\n        new NoGenericTypeParametersValidator(method).validate(errors);\n    }\n\n    @Override\n    public boolean isShadowedBy(FrameworkMethod other) {\n        if (!other.getName().equals(getName())) {\n            return false;\n        }\n        if (other.getParameterTypes().length != getParameterTypes().length) {\n            return false;\n        }\n        for (int i = 0; i < other.getParameterTypes().length; i++) {\n            if (!other.getParameterTypes()[i].equals(getParameterTypes()[i])) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    @Override\n    boolean isBridgeMethod() {\n        return method.isBridge();\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        if (!FrameworkMethod.class.isInstance(obj)) {\n            return false;\n        }\n        return ((FrameworkMethod) obj).method.equals(method);\n    }\n\n    @Override\n    public int hashCode() {\n        return method.hashCode();\n    }\n\n    /**\n     * Returns true if this is a no-arg method that returns a value assignable\n     * to {@code type}\n     *\n     * @deprecated This is used only by the Theories runner, and does not\n     *             use all the generic type info that it ought to. It will be replaced\n     *             with a forthcoming ParameterSignature#canAcceptResultOf(FrameworkMethod)\n     *             once Theories moves to junit-contrib.\n     */\n    @Deprecated\n    public boolean producesType(Type type) {\n        return getParameterTypes().length == 0 && type instanceof Class<?>\n                && ((Class<?>) type).isAssignableFrom(method.getReturnType());\n    }\n\n    private Class<?>[] getParameterTypes() {\n        return method.getParameterTypes();\n    }\n\n    /**\n     * Returns the annotations on this method\n     */\n    public Annotation[] getAnnotations() {\n        return method.getAnnotations();\n    }\n\n    /**\n     * Returns the annotation of type {@code annotationType} on this method, if\n     * one exists.\n     */\n    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {\n        return method.getAnnotation(annotationType);\n    }\n\n    @Override\n    public String toString() {\n        return method.toString();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/InitializationError.java",
    "content": "package org.junit.runners.model;\n\nimport java.util.Arrays;\nimport java.util.List;\n\n/**\n * Represents one or more problems encountered while initializing a Runner\n *\n * @since 4.5\n */\npublic class InitializationError extends Exception {\n    private static final long serialVersionUID = 1L;\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final List<Throwable> fErrors;\n\n    /**\n     * Construct a new {@code InitializationError} with one or more\n     * errors {@code errors} as causes\n     */\n    public InitializationError(List<Throwable> errors) {\n        this.fErrors = errors;\n    }\n\n    public InitializationError(Throwable error) {\n        this(Arrays.asList(error));\n    }\n\n    /**\n     * Construct a new {@code InitializationError} with one cause\n     * with message {@code string}\n     */\n    public InitializationError(String string) {\n        this(new Exception(string));\n    }\n\n    /**\n     * Returns one or more Throwables that led to this initialization error.\n     */\n    public List<Throwable> getCauses() {\n        return fErrors;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/InvalidTestClassError.java",
    "content": "package org.junit.runners.model;\n\nimport java.util.List;\n\n/**\n * Thrown by {@link org.junit.runner.Runner}s in case the class under test is not valid.\n * <p>\n * Its message conveniently lists all of the validation errors.\n *\n * @since 4.13\n */\npublic class InvalidTestClassError extends InitializationError {\n    private static final long serialVersionUID = 1L;\n\n    private final String message;\n\n    public InvalidTestClassError(Class<?> offendingTestClass, List<Throwable> validationErrors) {\n        super(validationErrors);\n        this.message = createMessage(offendingTestClass, validationErrors);\n    }\n\n    private static String createMessage(Class<?> testClass, List<Throwable> validationErrors) {\n        StringBuilder sb = new StringBuilder();\n        sb.append(String.format(\"Invalid test class '%s':\", testClass.getName()));\n        int i = 1;\n        for (Throwable error : validationErrors) {\n            sb.append(\"\\n  \" + (i++) + \". \" + error.getMessage());\n        }\n        return sb.toString();\n    }\n\n    /**\n     * @return a message with a list of all of the validation errors\n     */\n    @Override\n    public String getMessage() {\n        return message;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/MemberValueConsumer.java",
    "content": "package org.junit.runners.model;\n\n/**\n * Represents a receiver for values of annotated fields/methods together with the declaring member.\n *\n * @see TestClass#collectAnnotatedFieldValues(Object, Class, Class, MemberValueConsumer)\n * @see TestClass#collectAnnotatedMethodValues(Object, Class, Class, MemberValueConsumer)\n * @since 4.13\n */\npublic interface MemberValueConsumer<T> {\n    /**\n     * Receives the next value and its declaring member.\n     *\n     * @param member declaring member ({@link FrameworkMethod} or {@link FrameworkField})\n     * @param value the value of the next member\n     */\n    void accept(FrameworkMember<?> member, T value);\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/MultipleFailureException.java",
    "content": "package org.junit.runners.model;\n\nimport java.io.PrintStream;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.TestCouldNotBeSkippedException;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.internal.Throwables;\n\n/**\n * Collects multiple {@code Throwable}s into one exception.\n *\n * @since 4.9\n */\npublic class MultipleFailureException extends Exception {\n    private static final long serialVersionUID = 1L;\n\n    /*\n     * We have to use the f prefix until the next major release to ensure\n     * serialization compatibility. \n     * See https://github.com/junit-team/junit4/issues/976\n     */\n    private final List<Throwable> fErrors;\n\n    public MultipleFailureException(List<Throwable> errors) {\n        if (errors.isEmpty()) {\n            throw new IllegalArgumentException(\n                    \"List of Throwables must not be empty\");\n        }\n        this.fErrors = new ArrayList<Throwable>(errors.size());\n        for (Throwable error : errors) {\n            if (error instanceof AssumptionViolatedException) {\n                error = new TestCouldNotBeSkippedException((AssumptionViolatedException) error);\n            }\n            fErrors.add(error);\n        }\n    }\n\n    public List<Throwable> getFailures() {\n        return Collections.unmodifiableList(fErrors);\n    }\n\n    @Override\n    public String getMessage() {\n        StringBuilder sb = new StringBuilder(\n                String.format(\"There were %d errors:\", fErrors.size()));\n        for (Throwable e : fErrors) {\n            sb.append(String.format(\"%n  %s(%s)\", e.getClass().getName(), e.getMessage()));\n        }\n        return sb.toString();\n    }\n\n    @Override\n    public void printStackTrace() {\n        for (Throwable e: fErrors) {\n            e.printStackTrace();\n        }\n    }\n    \n    @Override\n    public void printStackTrace(PrintStream s) {\n        for (Throwable e: fErrors) {\n            e.printStackTrace(s);\n        }\n    }\n    \n    @Override\n    public void printStackTrace(PrintWriter s) {\n        for (Throwable e: fErrors) {\n            e.printStackTrace(s);\n        }\n    }\n    \n    /**\n     * Asserts that a list of throwables is empty. If it isn't empty,\n     * will throw {@link MultipleFailureException} (if there are\n     * multiple throwables in the list) or the first element in the list\n     * (if there is only one element).\n     *\n     * @param errors list to check\n     * @throws Exception or Error if the list is not empty\n     */\n    @SuppressWarnings(\"deprecation\")\n    public static void assertEmpty(List<Throwable> errors) throws Exception {\n        if (errors.isEmpty()) {\n            return;\n        }\n        if (errors.size() == 1) {\n            throw Throwables.rethrowAsException(errors.get(0));\n        }\n\n        /*\n           * Many places in the code are documented to throw\n           * org.junit.internal.runners.model.MultipleFailureException.\n           * That class now extends this one, so we throw the internal\n           * exception in case developers have tests that catch\n           * MultipleFailureException.\n           */\n        throw new org.junit.internal.runners.model.MultipleFailureException(errors);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/NoGenericTypeParametersValidator.java",
    "content": "package org.junit.runners.model;\n\nimport java.lang.reflect.GenericArrayType;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.ParameterizedType;\nimport java.lang.reflect.Type;\nimport java.lang.reflect.TypeVariable;\nimport java.lang.reflect.WildcardType;\nimport java.util.List;\n\nclass NoGenericTypeParametersValidator {\n    private final Method method;\n\n    NoGenericTypeParametersValidator(Method method) {\n        this.method = method;\n    }\n\n    void validate(List<Throwable> errors) {\n        for (Type each : method.getGenericParameterTypes()) {\n            validateNoTypeParameterOnType(each, errors);\n        }\n    }\n\n    private void validateNoTypeParameterOnType(Type type, List<Throwable> errors) {\n        if (type instanceof TypeVariable<?>) {\n            errors.add(new Exception(\"Method \" + method.getName()\n                    + \"() contains unresolved type variable \" + type));\n        } else if (type instanceof ParameterizedType) {\n            validateNoTypeParameterOnParameterizedType((ParameterizedType) type, errors);\n        } else if (type instanceof WildcardType) {\n            validateNoTypeParameterOnWildcardType((WildcardType) type, errors);\n        } else if (type instanceof GenericArrayType) {\n            validateNoTypeParameterOnGenericArrayType((GenericArrayType) type, errors);\n        }\n    }\n\n    private void validateNoTypeParameterOnParameterizedType(ParameterizedType parameterized,\n            List<Throwable> errors) {\n        for (Type each : parameterized.getActualTypeArguments()) {\n            validateNoTypeParameterOnType(each, errors);\n        }\n    }\n\n    private void validateNoTypeParameterOnWildcardType(WildcardType wildcard,\n            List<Throwable> errors) {\n        for (Type each : wildcard.getUpperBounds()) {\n            validateNoTypeParameterOnType(each, errors);\n        }\n        for (Type each : wildcard.getLowerBounds()) {\n            validateNoTypeParameterOnType(each, errors);\n        }\n    }\n\n    private void validateNoTypeParameterOnGenericArrayType(\n            GenericArrayType arrayType, List<Throwable> errors) {\n        validateNoTypeParameterOnType(arrayType.getGenericComponentType(), errors);\n    }\n}"
  },
  {
    "path": "src/main/java/org/junit/runners/model/RunnerBuilder.java",
    "content": "package org.junit.runners.model;\n\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.junit.internal.runners.ErrorReportingRunner;\nimport org.junit.runner.Description;\nimport org.junit.runner.OrderWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.InvalidOrderingException;\nimport org.junit.runner.manipulation.Ordering;\n\n/**\n * A RunnerBuilder is a strategy for constructing runners for classes.\n *\n * Only writers of custom runners should use <code>RunnerBuilder</code>s.  A custom runner class with a constructor taking\n * a <code>RunnerBuilder</code> parameter will be passed the instance of <code>RunnerBuilder</code> used to build that runner itself.\n * For example,\n * imagine a custom runner that builds suites based on a list of classes in a text file:\n *\n * <pre>\n * \\@RunWith(TextFileSuite.class)\n * \\@SuiteSpecFile(\"mysuite.txt\")\n * class MySuite {}\n * </pre>\n *\n * The implementation of TextFileSuite might include:\n *\n * <pre>\n * public TextFileSuite(Class testClass, RunnerBuilder builder) {\n *   // ...\n *   for (String className : readClassNames())\n *     addRunner(builder.runnerForClass(Class.forName(className)));\n *   // ...\n * }\n * </pre>\n *\n * @see org.junit.runners.Suite\n * @since 4.5\n */\npublic abstract class RunnerBuilder {\n    private final Set<Class<?>> parents = new HashSet<Class<?>>();\n\n    /**\n     * Override to calculate the correct runner for a test class at runtime.\n     *\n     * @param testClass class to be run\n     * @return a Runner\n     * @throws Throwable if a runner cannot be constructed\n     */\n    public abstract Runner runnerForClass(Class<?> testClass) throws Throwable;\n\n    /**\n     * Always returns a runner for the given test class.\n     *\n     * <p>In case of an exception a runner will be returned that prints an error instead of running\n     * tests.\n     *\n     * <p>Note that some of the internal JUnit implementations of RunnerBuilder will return\n     * {@code null} from this method, but no RunnerBuilder passed to a Runner constructor will\n     * return {@code null} from this method.\n     *\n     * @param testClass class to be run\n     * @return a Runner\n     */\n    public Runner safeRunnerForClass(Class<?> testClass) {\n        try {\n            Runner runner = runnerForClass(testClass);\n            if (runner != null) {\n                configureRunner(runner);\n            }\n            return runner;\n        } catch (Throwable e) {\n            return new ErrorReportingRunner(testClass, e);\n        }\n    }\n\n    private void configureRunner(Runner runner) throws InvalidOrderingException {\n        Description description = runner.getDescription();\n        OrderWith orderWith = description.getAnnotation(OrderWith.class);\n        if (orderWith != null) {\n            Ordering ordering = Ordering.definedBy(orderWith.value(), description);\n            ordering.apply(runner);\n        }\n    }\n\n    Class<?> addParent(Class<?> parent) throws InitializationError {\n        if (!parents.add(parent)) {\n            throw new InitializationError(String.format(\"class '%s' (possibly indirectly) contains itself as a SuiteClass\", parent.getName()));\n        }\n        return parent;\n    }\n\n    void removeParent(Class<?> klass) {\n        parents.remove(klass);\n    }\n\n    /**\n     * Constructs and returns a list of Runners, one for each child class in\n     * {@code children}.  Care is taken to avoid infinite recursion:\n     * this builder will throw an exception if it is requested for another\n     * runner for {@code parent} before this call completes.\n     */\n    public List<Runner> runners(Class<?> parent, Class<?>[] children)\n            throws InitializationError {\n        addParent(parent);\n\n        try {\n            return runners(children);\n        } finally {\n            removeParent(parent);\n        }\n    }\n\n    public List<Runner> runners(Class<?> parent, List<Class<?>> children)\n            throws InitializationError {\n        return runners(parent, children.toArray(new Class<?>[0]));\n    }\n\n    private List<Runner> runners(Class<?>[] children) {\n        List<Runner> runners = new ArrayList<Runner>();\n        for (Class<?> each : children) {\n            Runner childRunner = safeRunnerForClass(each);\n            if (childRunner != null) {\n                runners.add(childRunner);\n            }\n        }\n        return runners;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/RunnerScheduler.java",
    "content": "package org.junit.runners.model;\n\n/**\n * Represents a strategy for scheduling when individual test methods\n * should be run (in serial or parallel)\n *\n * WARNING: still experimental, may go away.\n *\n * @since 4.7\n */\npublic interface RunnerScheduler {\n    /**\n     * Schedule a child statement to run\n     */\n    void schedule(Runnable childStatement);\n\n    /**\n     * Override to implement any behavior that must occur\n     * after all children have been scheduled (for example,\n     * waiting for them all to finish)\n     */\n    void finished();\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/Statement.java",
    "content": "package org.junit.runners.model;\n\n\n/**\n * Represents one or more actions to be taken at runtime in the course\n * of running a JUnit test suite.\n *\n * @since 4.5\n */\npublic abstract class Statement {\n    /**\n     * Run the action, throwing a {@code Throwable} if anything goes wrong.\n     */\n    public abstract void evaluate() throws Throwable;\n}"
  },
  {
    "path": "src/main/java/org/junit/runners/model/TestClass.java",
    "content": "package org.junit.runners.model;\n\nimport static java.lang.reflect.Modifier.isStatic;\nimport static org.junit.internal.MethodSorter.NAME_ASCENDING;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.LinkedHashMap;\nimport java.util.LinkedHashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\n\nimport org.junit.Assert;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.internal.MethodSorter;\n\n/**\n * Wraps a class to be run, providing method validation and annotation searching\n *\n * @since 4.5\n */\npublic class TestClass implements Annotatable {\n    private static final FieldComparator FIELD_COMPARATOR = new FieldComparator();\n    private static final MethodComparator METHOD_COMPARATOR = new MethodComparator();\n\n    private final Class<?> clazz;\n    private final Map<Class<? extends Annotation>, List<FrameworkMethod>> methodsForAnnotations;\n    private final Map<Class<? extends Annotation>, List<FrameworkField>> fieldsForAnnotations;\n\n    /**\n     * Creates a {@code TestClass} wrapping {@code clazz}. Each time this\n     * constructor executes, the class is scanned for annotations, which can be\n     * an expensive process (we hope in future JDK's it will not be.) Therefore,\n     * try to share instances of {@code TestClass} where possible.\n     */\n    public TestClass(Class<?> clazz) {\n        this.clazz = clazz;\n        if (clazz != null && clazz.getConstructors().length > 1) {\n            throw new IllegalArgumentException(\n                    \"Test class can only have one constructor\");\n        }\n\n        Map<Class<? extends Annotation>, List<FrameworkMethod>> methodsForAnnotations =\n                new LinkedHashMap<Class<? extends Annotation>, List<FrameworkMethod>>();\n        Map<Class<? extends Annotation>, List<FrameworkField>> fieldsForAnnotations =\n                new LinkedHashMap<Class<? extends Annotation>, List<FrameworkField>>();\n\n        scanAnnotatedMembers(methodsForAnnotations, fieldsForAnnotations);\n\n        this.methodsForAnnotations = makeDeeplyUnmodifiable(methodsForAnnotations);\n        this.fieldsForAnnotations = makeDeeplyUnmodifiable(fieldsForAnnotations);\n    }\n\n    protected void scanAnnotatedMembers(Map<Class<? extends Annotation>, List<FrameworkMethod>> methodsForAnnotations, Map<Class<? extends Annotation>, List<FrameworkField>> fieldsForAnnotations) {\n        for (Class<?> eachClass : getSuperClasses(clazz)) {\n            for (Method eachMethod : MethodSorter.getDeclaredMethods(eachClass)) {\n                addToAnnotationLists(new FrameworkMethod(eachMethod), methodsForAnnotations);\n            }\n            // ensuring fields are sorted to make sure that entries are inserted\n            // and read from fieldForAnnotations in a deterministic order\n            for (Field eachField : getSortedDeclaredFields(eachClass)) {\n                addToAnnotationLists(new FrameworkField(eachField), fieldsForAnnotations);\n            }\n        }\n    }\n\n    private static Field[] getSortedDeclaredFields(Class<?> clazz) {\n        Field[] declaredFields = clazz.getDeclaredFields();\n        Arrays.sort(declaredFields, FIELD_COMPARATOR);\n        return declaredFields;\n    }\n\n    protected static <T extends FrameworkMember<T>> void addToAnnotationLists(T member,\n            Map<Class<? extends Annotation>, List<T>> map) {\n        for (Annotation each : member.getAnnotations()) {\n            Class<? extends Annotation> type = each.annotationType();\n            List<T> members = getAnnotatedMembers(map, type, true);\n            T memberToAdd = member.handlePossibleBridgeMethod(members);\n            if (memberToAdd == null) {\n                return;\n            }\n            if (runsTopToBottom(type)) {\n                members.add(0, memberToAdd);\n            } else {\n                members.add(memberToAdd);\n            }\n        }\n    }\n\n    private static <T extends FrameworkMember<T>> Map<Class<? extends Annotation>, List<T>>\n            makeDeeplyUnmodifiable(Map<Class<? extends Annotation>, List<T>> source) {\n        Map<Class<? extends Annotation>, List<T>> copy =\n                new LinkedHashMap<Class<? extends Annotation>, List<T>>();\n        for (Map.Entry<Class<? extends Annotation>, List<T>> entry : source.entrySet()) {\n            copy.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));\n        }\n        return Collections.unmodifiableMap(copy);\n    }\n\n    /**\n     * Returns, efficiently, all the non-overridden methods in this class and\n     * its superclasses that are annotated}.\n     * \n     * @since 4.12\n     */\n    public List<FrameworkMethod> getAnnotatedMethods() {\n        List<FrameworkMethod> methods = collectValues(methodsForAnnotations);\n        Collections.sort(methods, METHOD_COMPARATOR);\n        return methods;\n    }\n\n    /**\n     * Returns, efficiently, all the non-overridden methods in this class and\n     * its superclasses that are annotated with {@code annotationClass}.\n     */\n    public List<FrameworkMethod> getAnnotatedMethods(\n            Class<? extends Annotation> annotationClass) {\n        return Collections.unmodifiableList(getAnnotatedMembers(methodsForAnnotations, annotationClass, false));\n    }\n\n    /**\n     * Returns, efficiently, all the non-overridden fields in this class and its\n     * superclasses that are annotated.\n     * \n     * @since 4.12\n     */\n    public List<FrameworkField> getAnnotatedFields() {\n        return collectValues(fieldsForAnnotations);\n    }\n\n    /**\n     * Returns, efficiently, all the non-overridden fields in this class and its\n     * superclasses that are annotated with {@code annotationClass}.\n     */\n    public List<FrameworkField> getAnnotatedFields(\n            Class<? extends Annotation> annotationClass) {\n        return Collections.unmodifiableList(getAnnotatedMembers(fieldsForAnnotations, annotationClass, false));\n    }\n\n    private <T> List<T> collectValues(Map<?, List<T>> map) {\n        Set<T> values = new LinkedHashSet<T>();\n        for (List<T> additionalValues : map.values()) {\n            values.addAll(additionalValues);\n        }\n        return new ArrayList<T>(values);\n    }\n\n    private static <T> List<T> getAnnotatedMembers(Map<Class<? extends Annotation>, List<T>> map,\n            Class<? extends Annotation> type, boolean fillIfAbsent) {\n        if (!map.containsKey(type) && fillIfAbsent) {\n            map.put(type, new ArrayList<T>());\n        }\n        List<T> members = map.get(type);\n        return members == null ? Collections.<T>emptyList() : members;\n    }\n\n    private static boolean runsTopToBottom(Class<? extends Annotation> annotation) {\n        return annotation.equals(Before.class)\n                || annotation.equals(BeforeClass.class);\n    }\n\n    private static List<Class<?>> getSuperClasses(Class<?> testClass) {\n        List<Class<?>> results = new ArrayList<Class<?>>();\n        Class<?> current = testClass;\n        while (current != null) {\n            results.add(current);\n            current = current.getSuperclass();\n        }\n        return results;\n    }\n\n    /**\n     * Returns the underlying Java class.\n     */\n    public Class<?> getJavaClass() {\n        return clazz;\n    }\n\n    /**\n     * Returns the class's name.\n     */\n    public String getName() {\n        if (clazz == null) {\n            return \"null\";\n        }\n        return clazz.getName();\n    }\n\n    /**\n     * Returns the only public constructor in the class, or throws an {@code\n     * AssertionError} if there are more or less than one.\n     */\n\n    public Constructor<?> getOnlyConstructor() {\n        Constructor<?>[] constructors = clazz.getConstructors();\n        Assert.assertEquals(1, constructors.length);\n        return constructors[0];\n    }\n\n    /**\n     * Returns the annotations on this class\n     */\n    public Annotation[] getAnnotations() {\n        if (clazz == null) {\n            return new Annotation[0];\n        }\n        return clazz.getAnnotations();\n    }\n\n    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {\n        if (clazz == null) {\n            return null;\n        }\n        return clazz.getAnnotation(annotationType);\n    }\n\n    public <T> List<T> getAnnotatedFieldValues(Object test,\n            Class<? extends Annotation> annotationClass, Class<T> valueClass) {\n        final List<T> results = new ArrayList<T>();\n        collectAnnotatedFieldValues(test, annotationClass, valueClass,\n                new MemberValueConsumer<T>() {\n                    public void accept(FrameworkMember<?> member, T value) {\n                        results.add(value);\n                    }\n                });\n        return results;\n    }\n\n    /**\n     * Finds the fields annotated with the specified annotation and having the specified type,\n     * retrieves the values and passes those to the specified consumer.\n     *\n     * @since 4.13\n     */\n    public <T> void collectAnnotatedFieldValues(Object test,\n            Class<? extends Annotation> annotationClass, Class<T> valueClass,\n            MemberValueConsumer<T> consumer) {\n        for (FrameworkField each : getAnnotatedFields(annotationClass)) {\n            try {\n                Object fieldValue = each.get(test);\n                if (valueClass.isInstance(fieldValue)) {\n                    consumer.accept(each, valueClass.cast(fieldValue));\n                }\n            } catch (IllegalAccessException e) {\n                throw new RuntimeException(\n                        \"How did getFields return a field we couldn't access?\", e);\n            }\n        }\n    }\n\n    public <T> List<T> getAnnotatedMethodValues(Object test,\n            Class<? extends Annotation> annotationClass, Class<T> valueClass) {\n        final List<T> results = new ArrayList<T>();\n        collectAnnotatedMethodValues(test, annotationClass, valueClass,\n                new MemberValueConsumer<T>() {\n                    public void accept(FrameworkMember<?> member, T value) {\n                        results.add(value);\n                    }\n                });\n        return results;\n    }\n\n    /**\n     * Finds the methods annotated with the specified annotation and returning the specified type,\n     * invokes it and pass the return value to the specified consumer.\n     *\n     * @since 4.13\n     */\n    public <T> void collectAnnotatedMethodValues(Object test,\n            Class<? extends Annotation> annotationClass, Class<T> valueClass,\n            MemberValueConsumer<T> consumer) {\n        for (FrameworkMethod each : getAnnotatedMethods(annotationClass)) {\n            try {\n                /*\n                 * A method annotated with @Rule may return a @TestRule or a @MethodRule,\n                 * we cannot call the method to check whether the return type matches our\n                 * expectation i.e. subclass of valueClass. If we do that then the method \n                 * will be invoked twice and we do not want to do that. So we first check\n                 * whether return type matches our expectation and only then call the method\n                 * to fetch the MethodRule\n                 */\n                if (valueClass.isAssignableFrom(each.getReturnType())) {\n                    Object fieldValue = each.invokeExplosively(test);\n                    consumer.accept(each, valueClass.cast(fieldValue));\n                }\n            } catch (Throwable e) {\n                throw new RuntimeException(\n                        \"Exception in \" + each.getName(), e);\n            }\n        }\n    }\n\n    public boolean isPublic() {\n        return Modifier.isPublic(clazz.getModifiers());\n    }\n\n    public boolean isANonStaticInnerClass() {\n        return clazz.isMemberClass() && !isStatic(clazz.getModifiers());\n    }\n\n    @Override\n    public int hashCode() {\n        return (clazz == null) ? 0 : clazz.hashCode();\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        if (this == obj) {\n            return true;\n        }\n        if (obj == null) {\n            return false;\n        }\n        if (getClass() != obj.getClass()) {\n            return false;\n        }\n        TestClass other = (TestClass) obj;\n        return clazz == other.clazz;\n    }\n\n    /**\n     * Compares two fields by its name.\n     */\n    private static class FieldComparator implements Comparator<Field> {\n        public int compare(Field left, Field right) {\n            return left.getName().compareTo(right.getName());\n        }\n    }\n\n    /**\n     * Compares two methods by its name.\n     */\n    private static class MethodComparator implements\n            Comparator<FrameworkMethod> {\n        public int compare(FrameworkMethod left, FrameworkMethod right) {\n            return NAME_ASCENDING.compare(left.getMethod(), right.getMethod());\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/model/TestTimedOutException.java",
    "content": "package org.junit.runners.model;\n\nimport java.util.concurrent.TimeUnit;\n\n/**\n * Exception thrown when a test fails on timeout.\n * \n * @since 4.12\n * \n */\npublic class TestTimedOutException extends Exception {\n\n    private static final long serialVersionUID = 31935685163547539L;\n\n    private final TimeUnit timeUnit;\n    private final long timeout;\n\n    /**\n     * Creates exception with a standard message \"test timed out after [timeout] [timeUnit]\"\n     * \n     * @param timeout the amount of time passed before the test was interrupted\n     * @param timeUnit the time unit for the timeout value\n     */\n    public TestTimedOutException(long timeout, TimeUnit timeUnit) {\n        super(String.format(\"test timed out after %d %s\", \n                timeout, timeUnit.name().toLowerCase()));\n        this.timeUnit = timeUnit;\n        this.timeout = timeout;\n    }\n\n    /**\n     * Gets the time passed before the test was interrupted\n     */\n    public long getTimeout() {\n        return timeout;\n    }\n\n    /**\n     * Gets the time unit for the timeout value\n     */\n    public TimeUnit getTimeUnit() {\n        return timeUnit;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/package-info.java",
    "content": "/**\n * Provides standard {@link org.junit.runner.Runner Runner} implementations.\n *\n * @since 4.0\n * @see org.junit.runner.Runner\n * @see org.junit.runners.BlockJUnit4ClassRunner\n */\npackage org.junit.runners;"
  },
  {
    "path": "src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParameters.java",
    "content": "package org.junit.runners.parameterized;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Field;\nimport java.util.List;\n\nimport org.junit.internal.runners.statements.RunAfters;\nimport org.junit.internal.runners.statements.RunBefores;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameter;\nimport org.junit.runners.model.FrameworkField;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.Statement;\n\n/**\n * A {@link BlockJUnit4ClassRunner} with parameters support. Parameters can be\n * injected via constructor or into annotated fields.\n */\npublic class BlockJUnit4ClassRunnerWithParameters extends\n        BlockJUnit4ClassRunner {\n    private enum InjectionType {\n        CONSTRUCTOR, FIELD\n    }\n\n    private final Object[] parameters;\n\n    private final String name;\n\n    public BlockJUnit4ClassRunnerWithParameters(TestWithParameters test)\n            throws InitializationError {\n        super(test.getTestClass());\n        parameters = test.getParameters().toArray(\n                new Object[test.getParameters().size()]);\n        name = test.getName();\n    }\n\n    @Override\n    public Object createTest() throws Exception {\n        InjectionType injectionType = getInjectionType();\n        switch (injectionType) {\n            case CONSTRUCTOR:\n                return createTestUsingConstructorInjection();\n            case FIELD:\n                return createTestUsingFieldInjection();\n            default:\n                throw new IllegalStateException(\"The injection type \"\n                        + injectionType + \" is not supported.\");\n        }\n    }\n\n    private Object createTestUsingConstructorInjection() throws Exception {\n        return getTestClass().getOnlyConstructor().newInstance(parameters);\n    }\n\n    private Object createTestUsingFieldInjection() throws Exception {\n        List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();\n        if (annotatedFieldsByParameter.size() != parameters.length) {\n            throw new Exception(\n                    \"Wrong number of parameters and @Parameter fields.\"\n                            + \" @Parameter fields counted: \"\n                            + annotatedFieldsByParameter.size()\n                            + \", available parameters: \" + parameters.length\n                            + \".\");\n        }\n        Object testClassInstance = getTestClass().getJavaClass().newInstance();\n        for (FrameworkField each : annotatedFieldsByParameter) {\n            Field field = each.getField();\n            Parameter annotation = field.getAnnotation(Parameter.class);\n            int index = annotation.value();\n            try {\n                field.set(testClassInstance, parameters[index]);\n            } catch (IllegalAccessException e) {\n                IllegalAccessException wrappedException = new IllegalAccessException(\n                        \"Cannot set parameter '\" + field.getName()\n                                + \"'. Ensure that the field '\" + field.getName()\n                                + \"' is public.\");\n                wrappedException.initCause(e);\n                throw wrappedException;\n            } catch (IllegalArgumentException iare) {\n                throw new Exception(getTestClass().getName()\n                        + \": Trying to set \" + field.getName()\n                        + \" with the value \" + parameters[index]\n                        + \" that is not the right type (\"\n                        + parameters[index].getClass().getSimpleName()\n                        + \" instead of \" + field.getType().getSimpleName()\n                        + \").\", iare);\n            }\n        }\n        return testClassInstance;\n    }\n\n    @Override\n    protected String getName() {\n        return name;\n    }\n\n    @Override\n    protected String testName(FrameworkMethod method) {\n        return method.getName() + getName();\n    }\n\n    @Override\n    protected void validateConstructor(List<Throwable> errors) {\n        validateOnlyOneConstructor(errors);\n        if (getInjectionType() != InjectionType.CONSTRUCTOR) {\n            validateZeroArgConstructor(errors);\n        }\n    }\n\n    @Override\n    protected void validateFields(List<Throwable> errors) {\n        super.validateFields(errors);\n        if (getInjectionType() == InjectionType.FIELD) {\n            List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();\n            int[] usedIndices = new int[annotatedFieldsByParameter.size()];\n            for (FrameworkField each : annotatedFieldsByParameter) {\n                int index = each.getField().getAnnotation(Parameter.class)\n                        .value();\n                if (index < 0 || index > annotatedFieldsByParameter.size() - 1) {\n                    errors.add(new Exception(\"Invalid @Parameter value: \"\n                            + index + \". @Parameter fields counted: \"\n                            + annotatedFieldsByParameter.size()\n                            + \". Please use an index between 0 and \"\n                            + (annotatedFieldsByParameter.size() - 1) + \".\"));\n                } else {\n                    usedIndices[index]++;\n                }\n            }\n            for (int index = 0; index < usedIndices.length; index++) {\n                int numberOfUse = usedIndices[index];\n                if (numberOfUse == 0) {\n                    errors.add(new Exception(\"@Parameter(\" + index\n                            + \") is never used.\"));\n                } else if (numberOfUse > 1) {\n                    errors.add(new Exception(\"@Parameter(\" + index\n                            + \") is used more than once (\" + numberOfUse + \").\"));\n                }\n            }\n        }\n    }\n\n    @Override\n    protected Statement classBlock(RunNotifier notifier) {\n        Statement statement = childrenInvoker(notifier);\n        statement = withBeforeParams(statement);\n        statement = withAfterParams(statement);\n        return statement;\n    }\n\n    private Statement withBeforeParams(Statement statement) {\n        List<FrameworkMethod> befores = getTestClass()\n                .getAnnotatedMethods(Parameterized.BeforeParam.class);\n        return befores.isEmpty() ? statement : new RunBeforeParams(statement, befores);\n    }\n\n    private class RunBeforeParams extends RunBefores {\n        RunBeforeParams(Statement next, List<FrameworkMethod> befores) {\n            super(next, befores, null);\n        }\n\n        @Override\n        protected void invokeMethod(FrameworkMethod method) throws Throwable {\n            int paramCount = method.getMethod().getParameterTypes().length;\n            method.invokeExplosively(null, paramCount == 0 ? (Object[]) null : parameters);\n        }\n    }\n\n    private Statement withAfterParams(Statement statement) {\n        List<FrameworkMethod> afters = getTestClass()\n                .getAnnotatedMethods(Parameterized.AfterParam.class);\n        return afters.isEmpty() ? statement : new RunAfterParams(statement, afters);\n    }\n\n    private class RunAfterParams extends RunAfters {\n        RunAfterParams(Statement next, List<FrameworkMethod> afters) {\n            super(next, afters, null);\n        }\n\n        @Override\n        protected void invokeMethod(FrameworkMethod method) throws Throwable {\n            int paramCount = method.getMethod().getParameterTypes().length;\n            method.invokeExplosively(null, paramCount == 0 ? (Object[]) null : parameters);\n        }\n    }\n\n    @Override\n    protected Annotation[] getRunnerAnnotations() {\n        Annotation[] allAnnotations = super.getRunnerAnnotations();\n        Annotation[] annotationsWithoutRunWith = new Annotation[allAnnotations.length - 1];\n        int i = 0;\n        for (Annotation annotation: allAnnotations) {\n            if (!annotation.annotationType().equals(RunWith.class)) {\n                annotationsWithoutRunWith[i] = annotation;\n                ++i;\n            }\n        }\n        return annotationsWithoutRunWith;\n    }\n\n    private List<FrameworkField> getAnnotatedFieldsByParameter() {\n        return getTestClass().getAnnotatedFields(Parameter.class);\n    }\n\n    private InjectionType getInjectionType() {\n        if (fieldsAreAnnotated()) {\n            return InjectionType.FIELD;\n        } else {\n            return InjectionType.CONSTRUCTOR;\n        }\n    }\n\n    private boolean fieldsAreAnnotated() {\n        return !getAnnotatedFieldsByParameter().isEmpty();\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParametersFactory.java",
    "content": "package org.junit.runners.parameterized;\n\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.InitializationError;\n\n/**\n * A {@link ParametersRunnerFactory} that creates\n * {@link BlockJUnit4ClassRunnerWithParameters}.\n * \n * @since 4.12\n */\npublic class BlockJUnit4ClassRunnerWithParametersFactory implements\n        ParametersRunnerFactory {\n    public Runner createRunnerForTestWithParameters(TestWithParameters test)\n            throws InitializationError {\n        return new BlockJUnit4ClassRunnerWithParameters(test);\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/parameterized/ParametersRunnerFactory.java",
    "content": "package org.junit.runners.parameterized;\n\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.InitializationError;\n\n/**\n * A {@code ParametersRunnerFactory} creates a runner for a single\n * {@link TestWithParameters}.\n * \n * @since 4.12\n */\npublic interface ParametersRunnerFactory {\n    /**\n     * Returns a runner for the specified {@link TestWithParameters}.\n     * \n     * @throws InitializationError\n     *             if the runner could not be created.\n     */\n    Runner createRunnerForTestWithParameters(TestWithParameters test)\n            throws InitializationError;\n}\n"
  },
  {
    "path": "src/main/java/org/junit/runners/parameterized/TestWithParameters.java",
    "content": "package org.junit.runners.parameterized;\n\nimport static java.util.Collections.unmodifiableList;\nimport static org.junit.internal.Checks.notNull;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.runners.model.TestClass;\n\n/**\n * A {@code TestWithParameters} keeps the data together that are needed for\n * creating a runner for a single data set of a parameterized test. It has a\n * name, the test class and a list of parameters.\n * \n * @since 4.12\n */\npublic class TestWithParameters {\n    private final String name;\n\n    private final TestClass testClass;\n\n    private final List<Object> parameters;\n\n    public TestWithParameters(String name, TestClass testClass,\n            List<Object> parameters) {\n        notNull(name, \"The name is missing.\");\n        notNull(testClass, \"The test class is missing.\");\n        notNull(parameters, \"The parameters are missing.\");\n        this.name = name;\n        this.testClass = testClass;\n        this.parameters = unmodifiableList(new ArrayList<Object>(parameters));\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public TestClass getTestClass() {\n        return testClass;\n    }\n\n    public List<Object> getParameters() {\n        return parameters;\n    }\n\n    @Override\n    public int hashCode() {\n        int prime = 14747;\n        int result = prime + name.hashCode();\n        result = prime * result + testClass.hashCode();\n        return prime * result + parameters.hashCode();\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        if (this == obj) {\n            return true;\n        }\n        if (obj == null) {\n            return false;\n        }\n        if (getClass() != obj.getClass()) {\n            return false;\n        }\n        TestWithParameters other = (TestWithParameters) obj;\n        return name.equals(other.name)\n                && parameters.equals(other.parameters)\n                && testClass.equals(other.testClass);\n    }\n\n    @Override\n    public String toString() {\n        return testClass.getName() + \" '\" + name + \"' with parameters \"\n                + parameters;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/validator/AnnotationValidator.java",
    "content": "package org.junit.validator;\n\nimport org.junit.runners.model.FrameworkField;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.TestClass;\n\nimport static java.util.Collections.emptyList;\n\nimport java.util.List;\n\n/**\n * Validates annotations on classes and methods. To be validated,\n * an annotation should be annotated with {@link ValidateWith}\n *\n * Instances of this class are shared by multiple test runners, so they should\n * be immutable and thread-safe.\n *\n * @since 4.12\n */\npublic abstract class AnnotationValidator {\n\n    private static final List<Exception> NO_VALIDATION_ERRORS = emptyList();\n\n    /**\n     * Validates annotation on the given class.\n     *\n     * @param testClass that is being validated\n     * @return A list of exceptions. Default behavior is to return an empty list.\n     *\n     * @since 4.12\n     */\n    public List<Exception> validateAnnotatedClass(TestClass testClass) {\n        return NO_VALIDATION_ERRORS;\n    }\n\n    /**\n     * Validates annotation on the given field.\n     *\n     * @param field that is being validated\n     * @return A list of exceptions. Default behavior is to return an empty list.\n     *\n     * @since 4.12\n     */\n    public List<Exception> validateAnnotatedField(FrameworkField field) {\n        return NO_VALIDATION_ERRORS;\n\n    }\n\n    /**\n     * Validates annotation on the given method.\n     *\n     * @param method that is being validated\n     * @return A list of exceptions. Default behavior is to return an empty list.\n     *\n     * @since 4.12\n     */\n    public List<Exception> validateAnnotatedMethod(FrameworkMethod method) {\n        return NO_VALIDATION_ERRORS;\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/validator/AnnotationValidatorFactory.java",
    "content": "package org.junit.validator;\n\nimport java.util.concurrent.ConcurrentHashMap;\n\n/**\n * Creates instances of Annotation Validators.\n *\n * @since 4.12\n */\npublic class AnnotationValidatorFactory {\n    private static final ConcurrentHashMap<ValidateWith, AnnotationValidator> VALIDATORS_FOR_ANNOTATION_TYPES =\n            new ConcurrentHashMap<ValidateWith, AnnotationValidator>();\n\n    /**\n     * Creates the AnnotationValidator specified by the value in\n     * {@link org.junit.validator.ValidateWith}. Instances are\n     * cached.\n     *\n     * @return An instance of the AnnotationValidator.\n     *\n     * @since 4.12\n     */\n    public AnnotationValidator createAnnotationValidator(ValidateWith validateWithAnnotation) {\n        AnnotationValidator validator = VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation);\n        if (validator != null) {\n            return validator;\n        }\n\n        Class<? extends AnnotationValidator> clazz = validateWithAnnotation.value();\n        try {\n            AnnotationValidator annotationValidator = clazz.newInstance();\n            VALIDATORS_FOR_ANNOTATION_TYPES.putIfAbsent(validateWithAnnotation, annotationValidator);\n            return VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Exception received when creating AnnotationValidator class \" + clazz.getName(), e);\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/org/junit/validator/AnnotationsValidator.java",
    "content": "package org.junit.validator;\n\nimport static java.util.Collections.singletonList;\n\nimport java.lang.annotation.Annotation;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.runners.model.Annotatable;\nimport org.junit.runners.model.FrameworkField;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.TestClass;\n\n/**\n * An {@code AnnotationsValidator} validates all annotations of a test class,\n * including its annotated fields and methods.\n * \n * @since 4.12\n */\npublic final class AnnotationsValidator implements TestClassValidator {\n    private static final List<AnnotatableValidator<?>> VALIDATORS = Arrays.<AnnotatableValidator<?>>asList(\n            new ClassValidator(), new MethodValidator(), new FieldValidator());\n\n    /**\n     * Validate all annotations of the specified test class that are be\n     * annotated with {@link ValidateWith}.\n     * \n     * @param testClass\n     *            the {@link TestClass} that is validated.\n     * @return the errors found by the validator.\n     */\n    public List<Exception> validateTestClass(TestClass testClass) {\n        List<Exception> validationErrors= new ArrayList<Exception>();\n        for (AnnotatableValidator<?> validator : VALIDATORS) {\n            List<Exception> additionalErrors= validator\n                    .validateTestClass(testClass);\n            validationErrors.addAll(additionalErrors);\n        }\n        return validationErrors;\n    }\n\n    private abstract static class AnnotatableValidator<T extends Annotatable> {\n        private static final AnnotationValidatorFactory ANNOTATION_VALIDATOR_FACTORY = new AnnotationValidatorFactory();\n\n        abstract Iterable<T> getAnnotatablesForTestClass(TestClass testClass);\n\n        abstract List<Exception> validateAnnotatable(\n                AnnotationValidator validator, T annotatable);\n\n        public List<Exception> validateTestClass(TestClass testClass) {\n            List<Exception> validationErrors= new ArrayList<Exception>();\n            for (T annotatable : getAnnotatablesForTestClass(testClass)) {\n                List<Exception> additionalErrors= validateAnnotatable(annotatable);\n                validationErrors.addAll(additionalErrors);\n            }\n            return validationErrors;\n        }\n\n        private List<Exception> validateAnnotatable(T annotatable) {\n            List<Exception> validationErrors= new ArrayList<Exception>();\n            for (Annotation annotation : annotatable.getAnnotations()) {\n                Class<? extends Annotation> annotationType = annotation\n                        .annotationType();\n                ValidateWith validateWith = annotationType\n                        .getAnnotation(ValidateWith.class);\n                if (validateWith != null) {\n                    AnnotationValidator annotationValidator = ANNOTATION_VALIDATOR_FACTORY\n                            .createAnnotationValidator(validateWith);\n                    List<Exception> errors= validateAnnotatable(\n                            annotationValidator, annotatable);\n                    validationErrors.addAll(errors);\n                }\n            }\n            return validationErrors;\n        }\n    }\n\n    private static class ClassValidator extends AnnotatableValidator<TestClass> {\n        @Override\n        Iterable<TestClass> getAnnotatablesForTestClass(TestClass testClass) {\n            return singletonList(testClass);\n        }\n\n        @Override\n        List<Exception> validateAnnotatable(\n                AnnotationValidator validator, TestClass testClass) {\n            return validator.validateAnnotatedClass(testClass);\n        }\n    }\n\n    private static class MethodValidator extends\n            AnnotatableValidator<FrameworkMethod> {\n        @Override\n        Iterable<FrameworkMethod> getAnnotatablesForTestClass(\n                TestClass testClass) {\n            return testClass.getAnnotatedMethods();\n        }\n\n        @Override\n        List<Exception> validateAnnotatable(\n                AnnotationValidator validator, FrameworkMethod method) {\n            return validator.validateAnnotatedMethod(method);\n        }\n    }\n\n    private static class FieldValidator extends\n            AnnotatableValidator<FrameworkField> {\n        @Override\n        Iterable<FrameworkField> getAnnotatablesForTestClass(TestClass testClass) {\n            return testClass.getAnnotatedFields();\n        }\n\n        @Override\n        List<Exception> validateAnnotatable(\n                AnnotationValidator validator, FrameworkField field) {\n            return validator.validateAnnotatedField(field);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/validator/PublicClassValidator.java",
    "content": "package org.junit.validator;\n\nimport static java.util.Collections.emptyList;\nimport static java.util.Collections.singletonList;\n\nimport java.util.List;\n\nimport org.junit.runners.model.TestClass;\n\n/**\n * Validates that a {@link TestClass} is public.\n * \n * @since 4.12\n */\npublic class PublicClassValidator implements TestClassValidator {\n    private static final List<Exception> NO_VALIDATION_ERRORS = emptyList();\n\n    /**\n     * Validate that the specified {@link TestClass} is public.\n     * \n     * @param testClass the {@link TestClass} that is validated.\n     * @return an empty list if the class is public or a list with a single\n     *         exception otherwise.\n     */\n    public List<Exception> validateTestClass(TestClass testClass) {\n        if (testClass.isPublic()) {\n            return NO_VALIDATION_ERRORS;\n        } else {\n            return singletonList(new Exception(\"The class \"\n                    + testClass.getName() + \" is not public.\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/org/junit/validator/TestClassValidator.java",
    "content": "package org.junit.validator;\n\nimport java.util.List;\n\nimport org.junit.runners.model.TestClass;\n\n/**\n * Validates a single facet of a test class.\n * \n * @since 4.12\n */\npublic interface TestClassValidator {\n    /**\n     * Validate a single facet of a test class.\n     * \n     * @param testClass\n     *            the {@link TestClass} that is validated.\n     * @return the validation errors found by the validator.\n     */\n    List<Exception> validateTestClass(TestClass testClass);\n}\n"
  },
  {
    "path": "src/main/java/org/junit/validator/ValidateWith.java",
    "content": "package org.junit.validator;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Allows for an {@link AnnotationValidator} to be attached to an annotation.\n *\n * <p>When attached to an annotation, the validator will be instantiated and invoked\n * by the {@link org.junit.runners.ParentRunner}.</p>\n *\n * @since 4.12\n */\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.ANNOTATION_TYPE)\n@Inherited\npublic @interface ValidateWith {\n    Class<? extends AnnotationValidator> value();\n}\n"
  },
  {
    "path": "src/main/javadoc/stylesheet.css",
    "content": "/* Javadoc style sheet */\r/* makes unvisited links red (red bad) */\rA {color:red;}\r/* makes visited links the same green as the toolbar (green good) */\rA:visited {color:#03A35D;}            \r/* Define colors, fonts and other style attributes here to override the defaults  */\r/* Page background color */\rbody { background-color: #FFFFFF }\r/* Table colors */\r.TableHeadingColor     { background: #03A35D} /* Green */\r.TableSubHeadingColor  { background: #03A35D } /* Green */\r.TableRowColor         { background: #FFFFFF } /* White */\r/* Font used in left-hand frame lists */\r.FrameTitleFont   { font-size: normal; font-family: normal }\r.FrameHeadingFont { font-size: normal; font-family: normal }\r.FrameItemFont    { font-size: normal; font-family: normal }\r/* Example of smaller, sans-serif font in frames */\r/* .FrameItemFont  { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */\r/* Navigation bar fonts and colors */\r.NavBarCell1    { background-color:#03A35D;}/* Green */\r.NavBarCell1Rev { background-color:#006400;}/* Dark green */\r.NavBarFont1    { font-family: Arial, Helvetica, sans-serif; color:#000000;}\r.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}\r.NavBarCell2    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}\r.NavBarCell3    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}\r"
  },
  {
    "path": "src/site/fml/faq.fml",
    "content": "<faqs title=\"Frequently Asked Questions\" xmlns=\"http://maven.apache.org/FML/1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/FML/1.0 http://maven.apache.org/xsd/fml-1.0.xsd\">\n    <part id=\"faqinfo\">\n        <title>About this frequently asked questions list</title>\n        <faq id=\"faqinfo_1\">\n            <question>Who is responsible for this FAQ?</question>\n            <answer>\n                <p>The current version of this FAQ is maintained\n      by <a href=\"mailto:mike@clarkware.com\">Mike Clark</a>.</p>\n                <p>Most of the wisdom contained in this FAQ comes from the\n      collective insights and hard-won experiences of the many good\n      folks who participate on the JUnit mailing list and the JUnit\n      community at large.</p>\n                <p>If you see your genius represented anywhere in this FAQ without\n      due credit to you, please send me an email and I'll make things\n      right.</p>\n            </answer>\n        </faq>\n        <faq id=\"faqinfo_2\">\n            <question>How can I contribute to this FAQ?</question>\n            <answer>\n                <p>Your contributions to this FAQ are greatly appreciated!  The\n      JUnit community thanks you in advance.</p>\n                <p>To contribute to this FAQ, simply write a JUnit-related question\n      and answer, then send the unformatted text\n      to \n                    \n                    <a href=\"mailto:mike@clarkware.com\">\n                        Mike Clark</a>.\n      Corrections to this FAQ are always appreciated, as well.</p>\n                <p>No reasonable contribution will be denied.  Your name will\n      always appear along with any contribution you make.</p>\n            </answer>\n        </faq>\n        <faq id=\"faqinfo_3\">\n            <question>Where do I get the latest version of this\n      FAQ?</question>\n            <answer>\n                <p>The latest copy of this FAQ is available\n      at \n                    \n                    <a href=\"https://junit.org/junit4/faq.html\">\n                        https://junit.org/junit4/faq.html</a>.</p>\n                <p>The JUnit distribution also includes this FAQ in\n      the \n                    \n                    <code>\n                        doc</code>directory.</p>\n            </answer>\n        </faq>\n    </part>\n    <part id=\"overview\">\n        <title>Overview</title>\n  <faq id=\"overview_1\"><question>What is JUnit?</question>    \n    <answer><p>\n      JUnit is a simple, open source framework to write and run\n      repeatable tests. It is an instance of the xUnit architecture\n      for unit testing frameworks.  JUnit features include:\n    </p>\n    <ul>\n      <li>Assertions for testing expected results</li>\n      <li>Test fixtures for sharing common test data</li>\n      <li>Test runners for running tests</li>\n    </ul>\n    <p>\n      JUnit was originally written by Erich Gamma and Kent Beck.\n    </p>\n</answer>\n  </faq>\n  <faq id=\"overview_2\"><question>Where is the JUnit home page?</question>\n  <answer>\n    <p>\n      The official JUnit home page is <a\n      href=\"http://junit.org\">http://junit.org</a>.\n    </p>\n</answer>\n</faq>\n<faq id=\"overview_3\"><question>Where are the JUnit mailing lists and\n      forums?</question>\n    <answer>\n    <p>\n      There are 3 mailing lists dedicated to everything JUnit:\n    </p>\n    <ul>\n      <li>\n    <a href=\"http://groups.yahoo.com/group/junit/\">JUnit user\n    list</a>.  (Search it for answers to frequently asked\n    questions not included here.)\n      </li>\n      <li>\n    <a\n    href=\"http://lists.sourceforge.net/lists/listinfo/junit-announce\">JUnit\n    announcements</a>\n      </li>\n      <li>\n    <a\n    href=\"http://lists.sourceforge.net/lists/listinfo/junit-devel\">JUnit\n    developer list</a>\n      </li>\n    </ul>\n</answer>\n</faq>\n<faq id=\"overview_4\"><question>Where is the JUnit\n      documentation?</question>\n<answer>\n    <p>\n      The following documents are included in the JUnit distribution\n      in the <code>doc</code> directory:\n    </p>\n    <ul>\n      <li>\n    <a\n    href=\"http://junit.sourceforge.net/doc/testinfected/testing.htm\">JUnit\n    Test Infected: Programmers Love Writing Tests</a>\n      </li> \n      <li>\n    <a\n    href=\"http://junit.sourceforge.net/doc/cookbook/cookbook.htm\">JUnit\n      Cookbook</a>\n      </li>\n      <li>\n    <a\n    href=\"http://junit.sourceforge.net/doc/cookstour/cookstour.htm\">JUnit\n    - A Cook's Tour</a>\n      </li>\n      <li>\n    <a href=\"http://junit.sourceforge.net/doc/faq/faq.htm\">JUnit\n    FAQ</a>\n      </li>\n    </ul>\n</answer>\n</faq>\n      <faq id=\"overview_7\"><question>How is JUnit licensed?</question>\n      <answer>\n    <p>\n      JUnit is <a href=\"http://www.opensource.org/\">Open Source\n      Software</a>, released\n      under the <a\n      href=\"http://opensource.org/licenses/eclipse-1.0.html\">\n      Eclipse Public License Version 1.0</a> and hosted\n      on <a\n      href=\"http://sourceforge.net/projects/junit/\">SourceForge</a>.\n    </p>\n</answer>\n</faq>\n  <faq id=\"overview_8\"><question>What awards has JUnit won?</question>\n<answer>\n    <ul>\n      <li>\n    <p> <a\n    href=\"http://www.javaworld.com/javaworld/jw-03-2002/jw-0326-awards.html\">2002\n    JavaWorld Editors' Choice Awards (ECA)</a>\n    </p>\n    <p>\n      Best Java Performance Monitoring/Testing Tool\n    </p>\n      </li>\n      <li>\n    <p>\n      <a\n      href=\"http://www.javaworld.com/javaworld/jw-06-2001/j1-01-awards.html\">2001\n      JavaWorld Editors' Choice Awards (ECA)</a>\n    </p>\n    <p>\n      Best Java Performance Monitoring/Testing Tool\n    </p>\n      </li>\n    </ul>\n</answer>\n</faq>\n    </part>\n    <part id=\"started\">\n        <title>Getting Started</title>\n        <faq id=\"started_1\">\n            <question>Where do I download JUnit?</question>\n            <answer><p>\n      The latest version of JUnit is available\n      on <a\n      href=\"http://sourceforge.net/project/showfiles.php?group_id=15278\">SourceForge</a>.\n    </p></answer>\n        </faq>\n        <faq id=\"started_2\">\n            <question>How do I install JUnit?</question>\n            <answer><ol>\n      <li>\n    <p>\n      First, <a\n            href=\"http://sourceforge.net/project/showfiles.php?group_id=15278\">download</a>\n      the\n      latest version of JUnit, referred to below\n      as <code>junit.zip</code>. \n    </p>\n      </li>\n      <li>\n    <p>\n      Then install JUnit on your platform of choice:\n    </p>\n    <p>\n      <u>Windows</u>\n    </p>\n    <p>\n      To install JUnit on Windows, follow these steps:\n    </p>\n    <ol>\n      <li>\n        <p>\n          Unzip the <code>junit.zip</code> distribution file to\n          a directory referred to as <code>%JUNIT_HOME%</code>.\n        </p>\n      </li>\n      <li>Add JUnit to the classpath:\n        <p>\n          <code>set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%\\junit.jar</code>\n        </p>\n      </li>\n    </ol>\n    <p>\n      <u>Unix (bash)</u>\n    </p>\n    <p>\n      To install JUnit on Unix, follow these steps:\n    </p>\n    <ol>\n      <li>\n        <p>\n          Unzip the <code>junit.zip</code> distribution file to\n          a directory referred to as <code>$JUNIT_HOME</code>.\n        </p>    \n      </li>\n      <li>\n        <p>\n          Add JUnit to the classpath:\n        </p>\n        <p>\n          <code>export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit.jar</code>\n        </p>\n      </li>\n    </ol>\n      </li>\n      <li>\n    <p>\n      <i>(Optional)</i> Unzip\n      the <code>$JUNIT_HOME/src.jar</code> file.\n    </p>\n      </li>\n      <li>\n    <p>\n      Test the installation by running the sample tests\n      distributed with JUnit.  Note that the sample tests are\n      located in the installation directory directly, not\n      the <code>junit.jar</code> file.  Therefore, make sure that\n      the JUnit installation directory is on your CLASSPATH.  Then\n      simply type:\n    </p>\n    <pre>java org.junit.runner.JUnitCore org.junit.tests.AllTests</pre>\n    <p>\n      All the tests should pass with an \"OK\" message.\n    </p>\n    <p>\n      <i> \n        If the tests don't pass, verify\n        that <code>junit.jar</code> is in the CLASSPATH.\n      </i>\n    </p>\n      </li>\n      <li>\n    <p>\n      Finally, <a href=\"#overview_4\">read</a> the documentation.\n    </p>\n      </li>\n    </ol></answer>\n        </faq>\n        <faq id=\"started_3\">\n            <question>How do I uninstall JUnit?</question>\n            <answer><ol>\n      <li>\n    <p> \n      Delete the directory structure where you unzipped the JUnit\n      distribution.\n    </p>\n      </li>\n      <li>\n    <p>\n      Remove <code>junit.jar</code> from the CLASSPATH.\n    </p>\n      </li>\n    </ol>\n    <p>\n      JUnit does not modify the registry so simply removing all the\n      files will fully uninstall it.\n    </p></answer>\n        </faq>\n        <faq id=\"started_4\">\n            <question>How do I ask questions?</question>\n            <answer><p>\n      Questions that are not answered in\n      the <a\n      href=\"http://junit.sourceforge.net/doc/faq/faq.htm\">FAQ</a> or\n      in the <a href=\"#overview_4\">documentation</a> should be posted\n      to\n      the <a\n      href=\"http://www.jguru.com/forums/home.jsp?topic=JUnit\">jGuru\n    discussion forum</a> or the <a\n    href=\"http://groups.yahoo.com/group/junit/\">JUnit user mailing\n    list</a>.\n    </p>\n    <p>\n      Please stick to technical issues on the discussion forum and\n      mailing lists. Keep in mind that these are public, so\n      do <b>not</b> include any confidential information in your\n      questions!\n    </p>\n    <p>\n      You should also\n      read <a\n      href=\"http://www.catb.org/~esr/faqs/smart-questions.html\">\"How\n      to ask questions the smart way\"</a> by Eric Raymond before\n      participating in the discussion forum and mailing lists.\n    </p>\n    <p>\n      <i> \n    NOTE: <br/> Please do NOT submit bugs, patches, or feature\n    requests to the discussion forum or mailing lists.  <br/>\n    Refer instead to <a href=\"#started_5\">\"How do I submit bugs,\n    patches, or feature requests?\"</a>.\n      </i>\n    </p></answer>\n        </faq>\n        <faq id=\"started_5\">\n            <question>How do I submit bugs, patches, or\n       feature requests?</question>\n            <answer>    <p>\n      JUnit celebrates programmers testing their own software. In this\n      spirit, bugs, patches, and feature requests that include JUnit\n      tests have a better chance of being addressed than those\n      without.\n    </p>\n    <p>\n      JUnit is hosted\n      on <a\n      href=\"https://github.com/junit-team/junit4\">GitHub</a>.\n      Please use the tools provided by GitHub for your\n      submissions.\n    </p>\n</answer>\n        </faq>\n    </part>\n    <part id=\"tests\">\n        <title>Writing Tests</title>\n      <faq id=\"#tests_1\"><question>How do I write and run a simple test?</question><answer>    <ol>\n      <li>\n    <p>\n      Create a class:\n    </p>\n<pre class=\"prettyprint linenums\">package junitfaq;\n      \nimport org.junit.*;\nimport static org.junit.Assert.*;\n\nimport java.util.*;\n\npublic class SimpleTest {</pre>      \n      </li>\n      <li>\n    <p>\n      Write a test method (annotated with <code>@Test</code>) that\n      asserts expected results on the object under test:\n    </p>\n    <pre class=\"prettyprint linenums\">    @Test\n    public void testEmptyCollection() {\n        Collection collection = new ArrayList();\n        assertTrue(collection.isEmpty());\n    }</pre>\n      </li>\n      <li>\n    <p>\n      If you are running your JUnit 4 tests with a JUnit 3.x runner,\n      write a <code>suite()</code> method that uses the \n      <code>JUnit4TestAdapter</code> class to create a suite\n      containing all of your test methods:\n    </p>\n    <pre class=\"prettyprint linenums\">    public static junit.framework.Test suite() {\n        return new junit.framework.JUnit4TestAdapter(SimpleTest.class);\n    }</pre>\n      </li>\n      <li>\n    <p>\n      Although writing a <code>main()</code> method to run the\n      test is much less important with the advent of IDE runners,\n      it's still possible:\n    </p>\n    <pre class=\"prettyprint linenums\">    public static void main(String args[]) {\n      org.junit.runner.JUnitCore.main(\"junitfaq.SimpleTest\");\n    }\n}</pre>\n      </li>\n      <li>\n    <p>\n      Run the test:\n    </p>\n    <ul>\n      <li>\n        <p>\n          To run the test from the console, type:\n        </p>\n        <pre>java org.junit.runner.JUnitCore junitfaq.SimpleTest</pre>\n      </li>\n      <li>\n        <p>\n          To run the test with the test runner used\n          in <code>main()</code>, type:\n        </p>\n        <pre>java junitfaq.SimpleTest</pre> \n      </li>\n    </ul>\n    <p>\n      The passing test results in the following textual output:\n    </p>\n    <pre>.\nTime: 0\n\nOK (1 tests)</pre>\n      </li>\n    </ol>\n</answer></faq>\n      <faq id=\"#tests_2\"><question>How do I use a test fixture?</question><answer><p>\n      <i>(Submitted by: Jeff Nielsen)</i>\n    </p>\n    <p>\n      A test fixture is useful if you have two or more tests for a\n      common set of objects.  Using a test fixture avoids duplicating\n      the code necessary to initialize (and cleanup) the common\n      objects.\n    </p>\n    <p>\n      Tests can use the objects (variables) in a test fixture, with\n      each test invoking different methods on objects in the fixture\n      and asserting different expected results.  Each test runs in its\n      own test fixture to isolate tests from the changes made by other\n      tests.  That is, <em>tests don't share the state of objects in\n      the test fixture</em>.  Because the tests are isolated, they can\n      be run in any order.\n    </p>\n    <p>\n      To create a test fixture, declare instance variables for the\n      common objects.  Initialize these objects in a <code>public\n      void</code> method annotated with <code>@Before</code>.  The\n      JUnit framework automatically invokes any <code>@Before</code>\n      methods before each test is run.\n    </p>\n    <p>\n      The following example shows a test fixture with a common\n      <code>Collection</code> object.\n    </p>\n    <pre class=\"prettyprint linenums\">package junitfaq;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport java.util.*;\n\npublic class SimpleTest {\n\n    private Collection&lt;Object&gt; collection;\n\n    @Before\n    public void setUp() {\n        collection = new ArrayList&lt;Object&gt;();\n    }\n\n    @Test\n    public void testEmptyCollection() {\n        assertTrue(collection.isEmpty());\n    }\n\n\n    @Test\n    public void testOneItemCollection() {\n        collection.add(\"itemA\");\n        assertEquals(1, collection.size());\n    }\n}</pre>\n\n    <p>\n      Given this test, the methods might execute in the following\n      order:\n    </p>\n      <pre class=\"prettyprint linenums\">setUp()\ntestEmptyCollection()\nsetUp()\ntestOneItemCollection()</pre>\n    <p>\n      The ordering of test-method invocations is not guaranteed, so\n      <code>testOneItemCollection()</code> might be executed before\n      <code>testEmptyCollection()</code>.  But it doesn't matter,\n      because each method gets its own instance of the\n      <code>collection</code>.\n    </p>\n\n    <p>\n      Although JUnit provides a new instance of the fixture objects\n      for each test method, if you allocate any <em>external</em>\n      resources in a <code>@Before</code> method, you should release\n      them after the test runs by annotating a method with\n      <code>@After</code>.  The JUnit framework automatically invokes\n      any <code>@After</code> methods after each test is run.  For\n      example:\n    </p>\n\n    <pre class=\"prettyprint linenums\">package junitfaq;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport java.io.*;\n\npublic class OutputTest {\n\n    private File output;\n\n    @Before\n    public void createOutputFile() {\n        output = new File(...);\n    }\n\n    @After\n    public void deleteOutputFile() {\n        output.delete();\n    }\n\n    @Test\n    public void testSomethingWithFile() {\n        ...\n    }\n}</pre>\n    <p>\n      With this test, the methods will execute in the following order:\n    </p>\n    <pre class=\"prettyprint linenums\">\ncreateOutputFile()\ntestSomethingWithFile()\ndeleteOutputFile()</pre></answer></faq>\n      <faq id=\"#tests_4\"><question>How do I test a method that doesn't\n      return anything?</question><answer><p>\n      <i>(Submitted by: Dave Astels)</i>\n    </p>\n    <p>\n      Often if a method doesn't return a value, it will have some side\n      effect. Actually, if it doesn't return a value AND doesn't have\n      a side effect, it isn't doing anything.\n    </p>\n    <p>\n      There may be a way to verify that the side effect actually\n      occurred as expected. For example, consider\n      the <code>add()</code> method in the Collection classes. There\n      are ways of verifying that the side effect happened (i.e. the\n      object was added). You can check the size and assert that it is\n      what is expected:\n    </p>\n    <pre class=\"prettyprint linenums\">\n    @Test\n    public void testCollectionAdd() {\n        Collection collection = new ArrayList();\n        assertEquals(0, collection.size());\n        collection.add(\"itemA\");\n        assertEquals(1, collection.size());\n        collection.add(\"itemB\");\n        assertEquals(2, collection.size());\n    }</pre>\n    <p>\n      Another approach is to make use of <a\n      href=\"http://www.mockobjects.com\">MockObjects</a>.\n    </p>\n    <p>\n      A related issue is to design for testing. For example, if you\n      have a method that is meant to output to a file, don't pass in a\n      filename, or even a <code>FileWriter</code>. Instead, pass in\n      a <code>Writer</code>. That way you can pass in\n      a <code>StringWriter</code> to capture the output for testing\n      purposes. Then you can add a method\n      (e.g. <code>writeToFileNamed(String filename)</code>) to\n      encapsulate the <code>FileWriter</code> creation.\n    </p></answer></faq>\n      <faq id=\"#tests_5\"><question>Under what conditions should I test get()\n      and set() methods?</question><answer><p>\n      Unit tests are intended to alleviate fear that something might\n      break.  If you think a <code>get()</code> or <code>set()</code>\n      method could reasonably break, or has in fact contributed to a\n      defect, then by all means write a test.\n    </p>\n    <p>\n      In short, test until you're confident.  What you choose to test\n      is subjective, based on your experiences and confidence level.\n      Remember to be practical and maximize your testing investment.\n    </p>\n    <p>  \n      Refer also to <a href=\"#best_3\">\"How simple is 'too simple to\n      break'?\"</a>.\n    </p></answer></faq>\n      <faq id=\"#tests_6\"><question>Under what conditions should I not test\n      get() and set() methods?</question><answer><p>\n      <i>(Submitted by: J. B. Rainsberger)</i>\n    </p>\n    <p>\n      Most of the time, get/set methods just can't break, and if they\n      can't break, then why test them? While it is usually better to\n      test more, there is a definite curve of diminishing returns on\n      test effort versus \"code coverage\".  Remember the maxim: \"Test\n      until fear turns to boredom.\"\n    </p>\n    <p>\n      Assume that the <code>getX()</code> method only does \"return x;\"\n      and that the <code>setX()</code> method only does \"this.x =\n      x;\". If you write this test:\n    </p>\n    <pre class=\"prettyprint linenums\">@Test\npublic void testGetSetX() {\n    setX(23);\n    assertEquals(23, getX());\n}</pre>\n    <p>\n      then you are testing the equivalent of the following:\n    </p>\n    <pre class=\"prettyprint linenums\">\n@Test\npublic void testGetSetX() {\n    x = 23;\n    assertEquals(23, x);\n}</pre>\n    <p>\n      or, if you prefer,\n    </p>\n    <pre class=\"prettyprint linenums\">@Test\npublic void testGetSetX() {\n    assertEquals(23, 23);\n}</pre>\n    <p>\n      At this point, you are testing the Java compiler, or possibly\n      the interpreter, and not your component or application. There is\n      generally no need for you to do Java's testing for them.\n    </p>\n    <p>\n      If you are concerned about whether a property has already been\n      set at the point you wish to call <code>getX()</code>, then you\n      want to test the constructor, and not the <code>getX()</code>\n      method. This kind of test is especially useful if you have\n      multiple constructors:\n    </p>\n    <pre class=\"prettyprint linenums\">@Test\npublic void testCreate() {\n    assertEquals(23, new MyClass(23).getX());\n}</pre>\n</answer></faq>\n      <faq id=\"#tests_7\"><question>How do I write a test that passes when an\n      expected exception is thrown?</question><answer><p>\n      Add the optional <code>expected</code> attribute to\n      the <code>@Test</code> annotation.  The following is an example\n      test that passes when the\n      expected <code>IndexOutOfBoundsException</code> is raised:\n    </p>\n    <pre class=\"prettyprint linenums\">@Test(expected=IndexOutOfBoundsException.class)\npublic void testIndexOutOfBoundsException() {\n    ArrayList emptyList = new ArrayList();\n    Object o = emptyList.get(0);\n}</pre>\n    </answer></faq>\n      <faq id=\"#tests_8\"><question>How do I write a test that fails when an\n      unexpected exception is thrown?</question><answer><p>\n      Declare the exception in the <code>throws</code> clause of the\n      test method and don't catch the exception within the test\n      method.  Uncaught exceptions will cause the test to fail with an\n      error.\n    </p>\n    <p>\n      The following is an example test that fails when\n      the <code>IndexOutOfBoundsException</code> is raised:\n    </p>\n    <pre class=\"prettyprint linenums\">@Test\npublic void testIndexOutOfBoundsExceptionNotRaised() \n    throws IndexOutOfBoundsException {\n\n    ArrayList emptyList = new ArrayList();\n    Object o = emptyList.get(0);\n}</pre></answer></faq>\n      <faq id=\"#tests_10\"><question>How do I test protected methods?</question><answer><p>\n      Place your tests in the same package as the classes under test.\n    </p>\n    <p>\n      Refer to <a href=\"#organize_1\">\"Where should I put my test\n      files?\"</a> for examples of how to organize tests for protected\n      method access.\n    </p></answer></faq>\n      <faq id=\"#tests_11\"><question>How do I test private methods?</question><answer><p>\n      Testing private methods may be an indication that those methods\n      should be moved into another class to promote reusability.\n    </p>\n    <p>\n      But if you must...\n    </p>\n    <p>\n      If you are using JDK 1.3 or higher, you can use reflection to\n      subvert the access control mechanism with the aid of\n      the <a\n      href=\"http://sourceforge.net/projects/privaccessor/\">PrivilegedAccessor</a>.\n      For details on how to use it,\n      read <a\n      href=\"http://www.onjava.com/pub/a/onjava/2003/11/12/reflection.html\">this\n      article</a>.\n    </p>\n    <p>\n      If you are using JDK 1.6 or higher and you annotate your tests with @Test,\n      you can use <a href=\"http://dp4j.com\">Dp4j</a> to inject reflection in your\n      test methods. For details on how to use it, see <a href=\"http://dp4j.com/testscript\">\n      this test script</a>.\n    </p></answer></faq>\n      <faq id=\"#tests_12\"><question>Why does JUnit only report the first\n      failure in a single test?</question><answer><p>\n      <i>(Submitted by: J. B. Rainsberger)</i>\n    </p>\n    <p>\n      Reporting multiple failures in a single test is generally a sign\n      that the test does too much, compared to what a unit test ought\n      to do. Usually this means either that the test is really a\n      functional/acceptance/customer test or, if it is a unit test,\n      then it is too big a unit test.\n    </p>\n    <p>\n      JUnit is designed to work best with a number of small tests. It\n      executes each test within a separate instance of the test\n      class. It reports failure on each test. Shared setup code is\n      most natural when sharing between tests. This is a design\n      decision that permeates JUnit, and when you decide to report\n      multiple failures per test, you begin to fight against\n      JUnit. This is not recommended.\n    </p>\n    <p>\n      Long tests are a design smell and indicate the likelihood of a\n      design problem. Kent Beck is fond of saying in this case that\n      \"there is an opportunity to learn something about your design.\"\n      We would like to see a pattern language develop around these\n      problems, but it has not yet been written down.\n    </p>\n    <p>\n      Finally, note that a single test with multiple assertions is\n      isomorphic to a test case with multiple tests:\n    </p>\n    <p>\n      One test method, three assertions:\n    </p>\n    <pre class=\"prettyprint linenums\">public class MyTestCase {\n    @Test\n    public void testSomething() {\n        // Set up for the test, manipulating local variables\n        assertTrue(condition1);\n        assertTrue(condition2);\n        assertTrue(condition3);\n    }\n}</pre>\n    <p>\n      Three test methods, one assertion each:\n    </p>\n    <pre class=\"prettyprint linenums\">\npublic class MyTestCase {\n    // Local variables become instance variables\n\n    @Before\n    public void setUp() {\n        // Set up for the test, manipulating instance variables\n    }\n    \n    @Test\n    public void testCondition1() {\n        assertTrue(condition1);\n    }\n\n    @Test\n    public void testCondition2() {\n        assertTrue(condition2);\n    }\n\n    @Test\n    public void testCondition3() {\n        assertTrue(condition3);\n    }\n}</pre>\n    <p>\n      The resulting tests use JUnit's natural execution and reporting\n      mechanism and, failure in one test does not affect the execution\n      of the other tests.  You generally want exactly one test to fail\n      for any given bug, if you can manage it.\n    </p></answer></faq>\n      <faq id=\"#tests_13\"><question>In Java 1.4, 'assert' is a\n      keyword. Won't this conflict with JUnit's assert()\n      method?</question><answer><p>\n      JUnit 3.7 deprecated <code>assert()</code> and replaced it\n      with <code>assertTrue()</code>, which works exactly the same\n      way.\n    </p>\n    <p>\n      JUnit 4 is compatible with the <code>assert</code> keyword.  If\n      you run with the <code>-ea</code> JVM switch, assertions that\n      fail will be reported by JUnit.\n    </p></answer></faq>\n      <faq id=\"#tests_14\"><question>How do I test things that must be run in\n      a J2EE container (e.g. servlets, EJBs)?</question><answer><p>\n      Refactoring J2EE components to delegate functionality to other\n      objects that don't have to be run in a J2EE container will\n      improve the design and testability of the software.\n    </p>\n    <p>\n      <a href=\"http://jakarta.apache.org/cactus/index.html\">Cactus</a>\n      is an open source JUnit extension that can be used to test J2EE\n      components in their natural environment.\n    </p></answer></faq>\n      <faq id=\"#tests_15\"><question>Do I need to write a test class for\n      every class I need to test?</question><answer><p>\n      <i>(Submitted by: J. B. Rainsberger)</i>\n    </p>\n    <p>\n      No. It is a convention to start with one test\n      class per class under test, but it is not necessary.\n    </p>\n    <p>\n      Test classes only provide a way to organize tests, nothing more.\n      Generally you will start with one test class per class under\n      test, but then you may find that a small group of tests belong\n      together with their own common test fixture.[1] In this case,\n      you may move those tests to a new test class.  This is a simple\n      object-oriented refactoring: separating responsibilities of an\n      object that does too much.\n    </p>\n    <p>\n      Another point to consider is that the <code>TestSuite</code> is\n      the smallest execution unit in JUnit: you cannot execute\n      anything smaller than a TestSuite at one time without changing\n      source code. In this case, you probably do not want to put tests\n      in the same test class unless they somehow \"belong together\".\n      If you have two groups of tests that you think you'd like to\n      execute separately from one another, it is wise to place them in\n      separate test classes.\n    </p>\n    <p>\n      <i>\n    [1] A test fixture is a common set of test data and\n    collaborating objects shared by many tests. Generally they are\n    implemented as instance variables in the test class.\n      </i>\n    </p></answer></faq>\n      <faq id=\"#tests_16\"><question>Is there a basic template I can use to\n      create a test?</question><answer><p>\n      <i>(Submitted by: Eric Armstrong)</i>\n    </p>\n    <p>\n      The following templates are a good starting point.  Copy/paste\n      and edit these templates to suit your coding style.\n    </p>\n    <p>\n      SampleTest is a basic test template:\n    </p>\n    <pre class=\"prettyprint linenums\">import org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class SampleTest {\n\n    private java.util.List emptyList;\n\n    /**\n     * Sets up the test fixture. \n     * (Called before every test case method.)\n     */\n    @Before\n    public void setUp() {\n        emptyList = new java.util.ArrayList();\n    }\n\n    /**\n     * Tears down the test fixture. \n     * (Called after every test case method.)\n     */\n    @After\n    public void tearDown() {\n        emptyList = null;\n    }\n    \n    @Test\n    public void testSomeBehavior() {\n        assertEquals(\"Empty list should have 0 elements\", 0, emptyList.size());\n    }\n\n    @Test(expected=IndexOutOfBoundsException.class)\n    public void testForException() {\n        Object o = emptyList.get(0);\n    }\n}</pre></answer></faq>\n      <faq id=\"#tests_17\"><question>How do I write a test for an abstract\n      class?</question><answer><p>\n      Refer to <a\n      href=\"http://c2.com/cgi/wiki?AbstractTestCases\">http://c2.com/cgi/wiki?AbstractTestCases</a>.\n    </p></answer></faq>\n      <faq id=\"#tests_18\"><question>When are tests garbage collected?</question><answer><p>\n      <i>(Submitted by: Timothy Wall and Kent Beck)</i>\n    </p>\n    <p>\n      By design, the tree of Test instances is built in one pass, then\n      the tests are executed in a second pass.  The test runner holds\n      strong references to all Test instances for the duration of the\n      test execution.  This means that for a very long test run with\n      many Test instances, none of the tests may be garbage collected\n      until the end of the entire test run.\n    </p>\n    <p>\n      Therefore, if you allocate external or limited resources in a\n      test, you are responsible for freeing those resources.\n      Explicitly setting an object to <code>null</code> in\n      the <code>tearDown()</code> method, for example, allows it to be\n      garbage collected before the end of the entire test run.\n    </p></answer></faq>\n    </part>\n    <part id=\"organize\">\n        <title>Organizing Tests</title>\n        <faq id=\"organize_1\">\n            <question>Where should I put my test files?</question>\n            <answer><p>\n      You can place your tests in the same package and directory as\n      the classes under test.\n    </p>\n    <p>\n      For example:\n    </p>\n    <pre>src\n   com\n      xyz\n         SomeClass.java\n         SomeClassTest.java</pre>\n    <p> \n      While adequate for small projects, many developers feel that\n      this approach clutters the source directory, and makes it hard\n      to package up client deliverables without also including\n      unwanted test code, or writing unnecessarily complex packaging\n      tasks.\n    </p>\n    <p>\n      An arguably better way is to place the tests in a separate\n      parallel directory structure with package alignment.\n    </p>\n    <p>\n      For example:\n    </p>\n    <pre>src\n   com\n      xyz\n         SomeClass.java\ntest\n   com\n      xyz\n         SomeClassTest.java</pre>\n    <p>\n      These approaches allow the tests to access to all the public and\n      package visible methods of the classes under test.\n    </p>\n    <p>\n      Some developers have argued in favor of putting the tests in a\n      sub-package of the classes under test (e.g. com.xyz.test). The\n      author of this FAQ sees no clear advantage to adopting this\n      approach and believes that said developers also put their curly\n      braces on the wrong line.  :-)\n    </p></answer>\n        </faq>\n        <faq id=\"organize_3\">\n            <question>How can I run setUp() and tearDown()\n      code once for all of my tests?</question>\n            <answer><p>\n      The desire to do this is usually a symptom of excessive coupling\n      in your design.  If two or more tests must share the same test\n      fixture state, then the tests may be trying to tell you that the\n      classes under test have some undesirable dependencies.\n    </p>\n    <p>\n      Refactoring the design to further decouple the classes under\n      test and eliminate code duplication is usually a better\n      investment than setting up a shared test fixture.\n    </p>\n    <p>\n      But if you must...\n    </p>\n    <p>\n      You can add a <code>@BeforeClass</code> annotation to a method\n      to be run before all the tests in a class, and\n      a <code>@AfterClass</code> annotation to a method to be run\n      after all the tests in a class.  Here's an example:\n    </p>\n    <pre class=\"prettyprint linenums\">package junitfaq;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport java.util.*;\n\npublic class SimpleTest {\n\n    private Collection collection;\n    \n    @BeforeClass\n    public static void oneTimeSetUp() {\n        // one-time initialization code        \n    }\n\n    @AfterClass\n    public static void oneTimeTearDown() {\n        // one-time cleanup code\n    }\n\n    @Before\n    public void setUp() {\n        collection = new ArrayList();\n    }\n    \n    @After\n    public void tearDown() {\n        collection.clear();\n    }\n\n    @Test\n    public void testEmptyCollection() {\n        assertTrue(collection.isEmpty());\n    }\n    \n    @Test\n    public void testOneItemCollection() {\n        collection.add(\"itemA\");\n        assertEquals(1, collection.size());\n    }\n}</pre>\n    <p>\n      Given this test, the methods will execute in the following\n      order:\n    </p>\n    <pre class=\"prettyprint linenums\">oneTimeSetUp()\nsetUp()\ntestEmptyCollection()\ntearDown()\nsetUp()\ntestOneItemCollection()\ntearDown()\noneTimeTearDown()</pre>\n</answer>\n        </faq>\n    </part>\n    <part id=\"running-tests\">\n        <title>Running Tests</title>\n        <faq id=\"running_1\">\n            <question>What CLASSPATH settings are needed to\n      run JUnit?</question>\n            <answer><p>\n      <i>(Submitted by: Eric Armstrong)</i>\n    </p>\n    <p>\n      To run your JUnit tests, you'll need the following elements in\n      your CLASSPATH:\n    </p>\n    <ul>\n      <li>JUnit class files</li>\n      <li>Your class files, including your JUnit test classes</li>\n      <li>Libraries your class files depend on</li>\n    </ul>\n    <p>\n      If attempting to run your tests results in\n      a <code>NoClassDefFoundError</code>, then something is missing\n      from your CLASSPATH.\n    </p>\n    <p>\n      <u>Windows Example:</u>\n    </p>\n    <pre>set CLASSPATH=%JUNIT_HOME%\\junit.jar;c:\\myproject\\classes;c:\\myproject\\lib\\something.jar</pre>\n    <p>\n      <u>Unix (bash) Example:</u>\n    </p>\n    <pre>export CLASSPATH=$JUNIT_HOME/junit.jar:/myproject/classes:/myproject/lib/something.jar</pre>\n</answer>\n        </faq>\n        <faq id=\"running_2\">\n            <question>Why do I get\n        a <code>NoClassDefFoundError</code> when trying to test JUnit\n        or run the samples?</question>\n            <answer><p>\n      <i>(Submitted by: J.B. Rainsberger and Jason Rogers)</i>\n    </p>\n    <p>\n      Most likely your CLASSPATH doesn't include the JUnit\n      installation directory.\n    </p>\n    <p>\n      Refer to <a href=\"#running_1\">\"What CLASSPATH settings are\n      needed to run JUnit?\"</a> for more guidance.\n    </p>\n    <p>\n      Also consider running <a\n                               href=\"http://www.clarkware.com/software/WhichJUnit.zip\">WhichJunit</a>\n      to print the absolute location of the JUnit class files required\n      to run and test JUnit and its samples.\n    </p>\n    <p>\n      If the CLASSPATH seems mysterious, read <a\n      href=\"http://java.sun.com/j2se/1.4/docs/tooldocs/findingclasses.html\">this</a>!\n    </p></answer>\n        </faq>\n        <faq id=\"running_4\">\n            <question>How do I run JUnit from my command window?</question>\n            <answer><p>\n      <i>(Submitted by: Eric Armstrong)</i>\n    </p>\n    <ol>\n      <li>\n        <p>\n          <a href=\"#running_1\">Set your CLASSPATH</a>\n        </p>\n      </li>\n      <li>\n        <p>\n          Invoke the runner:\n        </p>\n        <p>\n          <code>\n            java org.junit.runner.JUnitCore &lt;test class name&gt; \n          </code>\n        </p>\n      </li>\n    </ol></answer>\n        </faq>\n        <faq id=\"running_5\">\n            <question>How do I run JUnit using Ant?</question>\n            <answer><p>\n      <i>(Submitted by: Eric Armstrong)</i>\n    </p>\n    <ol>\n      <li>\n        <p>\n          Define any necessary Ant properties:\n        </p>\n          <pre class=\"prettyprint linenums\">&lt;property name=\"src\" value=\"./src\" /&gt;\n&lt;property name=\"lib\" value=\"./lib\" /&gt;\n&lt;property name=\"classes\" value=\"./classes\" /&gt;\n&lt;property name=\"test.class.name\" value=\"com.xyz.MyTestSuite\" /&gt;</pre>\n      </li>\n      <li>\n        <p>\n          Set up the CLASSPATH to be used by JUnit:\n        </p>\n          <pre class=\"prettyprint linenums\">&lt;path id=\"test.classpath\"&gt;\n  &lt;pathelement location=\"${classes}\" /&gt;\n  &lt;pathelement location=\"/path/to/junit.jar\" /&gt;\n  &lt;fileset dir=\"${lib}\">\n    &lt;include name=\"**/*.jar\"/&gt;\n  &lt;/fileset&gt;\n&lt;/path&gt;</pre>\n      </li>\n      <li>\n        <p>\n          Define the Ant task for running JUnit:\n        </p>\n          <pre class=\"prettyprint linenums\">&lt;target name=\"test\"&gt;\n  &lt;junit fork=\"yes\" haltonfailure=\"yes\"&gt;\n    &lt;test name=\"${test.class.name}\" /&gt;\n    &lt;formatter type=\"plain\" usefile=\"false\" /&gt;\n    &lt;classpath refid=\"test.classpath\" /&gt;\n  &lt;/junit&gt;\n&lt;/target&gt;</pre>\n      </li>\n      <li>\n        <p>\n          Run the test:\n        </p>\n        <pre>ant test</pre>\n      </li>\n    </ol>\n    <p>\n      Refer to the <a\n      href=\"https://ant.apache.org/manual/Tasks/junit.html\">JUnit\n      Ant Task</a> for more information.\n    </p></answer>\n        </faq>\n        <faq id=\"running_6\">\n            <question>How do I use Ant to create HTML test\n      reports?</question>\n            <answer><p>\n      <i>(Submitted by: Eric Armstrong and Steffen Gemkow)</i>\n    </p>\n    <ol>\n      <li>\n        <p>\n          Ensure that Ant's <code>optional.jar</code> file is either\n          in your CLASSPATH or exists in\n          your <code>$ANT_HOME/lib</code> directory.\n        </p>\n      </li>\n      <li>\n        <p>\n          Add an ANT property for the directory containing the HTML reports:\n        </p>\n        <pre class=\"prettyprint linenums\">&lt;property name=\"test.reports\" value=\"./reports\" /&gt;</pre>\n      </li>\n      <li>\n        <p>\n          Define the Ant task for running JUnit and generating reports:\n        </p>\n          <pre class=\"prettyprint linenums\">&lt;target name=\"test-html\"&gt;\n  &lt;junit fork=\"yes\" printsummary=\"no\" haltonfailure=\"no\"&gt;\n    &lt;batchtest fork=\"yes\" todir=\"${test.reports}\" &gt;\n      &lt;fileset dir=\"${classes}\"&gt;\n        &lt;include name=\"**/*Test.class\" /&gt;\n      &lt;/fileset&gt;\n    &lt;/batchtest&gt;\n    &lt;formatter type=\"xml\" /&gt;\n    &lt;classpath refid=\"test.classpath\" /&gt;\n  &lt;/junit&gt;\n\n  &lt;junitreport todir=\"${test.reports}\"&gt;\n    &lt;fileset dir=\"${test.reports}\"&gt;\n      &lt;include name=\"TEST-*.xml\" /&gt;\n    &lt;/fileset&gt;\n    &lt;report todir=\"${test.reports}\" /&gt;\n  &lt;/junitreport&gt;\n&lt;/target&gt;</pre>\n      </li>\n      <li>\n        <p>\n          Run the test:\n        </p>\n        <div>\n          <code>\n            ant test-html\n          </code>\n        </div>\n      </li>\n    </ol>\n    <p>\n      Refer to the \n      <a href=\"https://ant.apache.org/manual/Tasks/junit.html\">JUnit Ant Task</a>\n      for more information.\n    </p></answer>\n        </faq>\n        <faq id=\"running_7\">\n            <question>How do I pass command-line arguments\n      to a test execution?</question>\n            <answer><p>\n      Use the <tt>-D</tt> JVM command-line options, as in:\n    </p>\n    <pre class=\"prettyprint\">-DparameterName=parameterValue</pre>\n    <p>\n      If the number of parameters on the command line gets unwieldy,\n      pass in the location of a property file that defines a set of\n      parameters. Alternatively, the <a\n      href=\"http://junit-addons.sf.net\">JUnit-addons package</a>\n      contains the <tt>XMLPropertyManager</tt>\n      and <tt>PropertyManager</tt> classes that allow you to define a\n      property file (or XML file) containing test parameters.\n    </p></answer>\n        </faq>\n        <faq id=\"running_9\">\n            <question>Why do I get\n      a <code>LinkageError</code> when using\n        XML interfaces in my test?</question>\n            <answer><p>\n      <i>(Submitted by: Scott Stirling)</i>\n    </p>\n    <p>\n      The workaround as of JUnit 3.7 is to\n      add <code>org.w3c.dom.*</code> and <code>org.xml.sax.*</code> to\n      your <code>excluded.properties</code>.\n    </p>\n    <p>\n      It's just a matter of time before this fix becomes incorporated\n      into the released version of\n      JUnit's <code>excluded.properties</code>, since JAXP is a\n      standard part of JDK 1.4. It will be just like\n      excluding <code>org.omg.*</code>. By the way, if you download\n      the JUnit source from its Sourceforge CVS, you will find that\n      these patterns have already been added to the default\n      excluded.properties and so has a pattern for JINI. In fact, here\n      is the current version in CVS, which demonstrates how to add\n      exclusions to the list too:\n    </p>\n    <pre class=\"prettyprint linenums\">#\n# The list of excluded package paths for the TestCaseClassLoader\n#\nexcluded.0=sun.*\nexcluded.1=com.sun.*\nexcluded.2=org.omg.*\nexcluded.3=javax.*\nexcluded.4=sunw.*\nexcluded.5=java.*\nexcluded.6=org.w3c.dom.*\nexcluded.7=org.xml.sax.*\nexcluded.8=net.jini.*</pre>\n    <p>\n      This is the most common case where the\n      default <code>excluded.properties</code> list needs\n      modification. The cause of the <code>LinkageError</code> is\n      related to using JAXP in your test cases. By JAXP I mean the\n      whole set of <code>javax.xml.*</code> classes and the\n      supporting <code>org.w3c.dom.*</code>\n      and <code>org.xml.sax.*</code> classes.\n    </p>\n    <p>\n      As stated above, the JUnit GUI TestRunners' classloader relies\n      on the <code>excluded.properties</code> for classes it should\n      delegate to the system classloader. JAXP is an unusual case\n      because it is a standard Java extension library dependent on\n      classes whose package names (<code>org.w3c.dom.*</code>\n      and <code>org.xml.sax.*</code>) do not begin with a standard\n      Java or Sun prefix. This is similar to the relationship\n      between <code>javax.rmi.*</code> and the <code>org.omg.*</code>\n      classes, which have been excluded by default in\n      JUnit'ss <code>excluded.properties</code> for a while.\n    </p>\n    <p>\n      What can happen, and frequently does when using the JUnit Swing\n      or AWT UI with test cases that reference, use or depend on JAXP\n      classes, such as Log4J, Apache SOAP, Axis, Cocoon, etc., is that\n      the JUnit class loader (properly)\n      delegates <code>javax.xml.*</code> classes it &quot;sees&quot;\n      to the system loader. But then the system loader, in the process\n      of initializing and loading that JAXP class, links and loads up\n      a bunch of <code>org.w3c.dom</code>/<code>org.xml.sax</code>\n      classes. When it does so, the JUnit custom classloader is not\n      involved at all because the system classloader never delegates\n      &quot;down&quot; or checks with custom classloaders to see if a\n      class is already loaded. At any point after this, if the JUnit\n      loader is asked to load\n      an <code>org.w3c.dom</code>/<code>org.xml.sax</code> class that\n      it's never seen before, it will try to load it because the\n      class' name doesn't match any of the patterns in the default\n      exclude list.  That's when a <code>LinkageError</code>\n      occurs. This is really a flaw in the JUnit classloader design,\n      but there is the workaround given above.\n    </p>\n    <p>\n      Java 2 JVMs keep classes (remember, classes and objects, though\n      related, are different entities to the JVM - I'm talking\n      about classes here, not object instances) in namespaces,\n      identifying them by their fully qualified classname plus the\n      instance of their defining (not initiating) loader. The JVM will\n      attempt to assign all unloaded classes referenced by an already\n      defined and loaded class to that class's defining loader. The\n      JVM's classresolver routine (implemented as a C function in the\n      JVM source code) keeps track of all these class loading events\n      and &quot;sees&quot; if another classloader (such as the JUnit\n      custom loader) attempts to define a class that has already been\n      defined by the system loader. According to the rules of Java 2\n      loader constraints, in case a class has already been defined by\n      the system loader, any attempts to load a class should first be\n      delegated to the system loader. A &quot;proper&quot; way for\n      JUnit to handle this feature would be to load classes from a\n      repository other than the CLASSPATH that the system classloader\n      knows nothing about. And then the JUnit custom classloader could\n      follow the standard Java 2 delegation model, which is to always\n      delegate class loading to the system loader, and only attempt to\n      load if that fails. Since they both load from the CLASSPATH in\n      the current model, if the JUnit loader delegated like it's\n      supposed to, it would never get to load any classes since the\n      system loader would always find them.\n    </p>\n    <p>\n      You could try to hack around this in the JUnit source by\n      catching the <code>LinkageError</code> in\n      TestCaseClassLoader's <code>loadClass()</code> method and then\n      making a recovery call to <code>findSystemClass()</code> --\n      thereby delegating to the system loader after the violation has\n      been caught. But this hack only works some of the time, because\n      now you can have the reverse problem where the JUnit loader will\n      load a host of <code>org.w3c.dom</code>/<code>org.xml.sax</code>\n      classes, and then the system loader violates the loader\n      constraints at some point when it tries to do exactly what I\n      described above with JAXP because it doesn't ever delegate to\n      its logical child (the JUnit loader). Inevitably, if your test\n      cases use many JAXP and related XML classes, one or the other\n      classloader will end up violating the constraints whatever you\n      do.\n    </p></answer>\n        </faq>\n        <faq id=\"running_11\">\n            <question>Why do I get the warning\n      \"AssertionFailedError: No\n        tests found in XXX\" when I run my test?</question>\n            <answer><p>\n      Make sure you have more or more method annotated with <code>@Test</code>.\n    </p>\n    <p>\n      For example:\n    </p>\n<pre class=\"prettyprint linenums\">@Test\npublic void testSomething() {\n}</pre></answer>\n        </faq>\n        <faq id=\"running_12\">\n            <question>Why do I see \"Unknown Source\" in the\n      stack trace of\na test failure, rather than the source file's line number?</question>\n            <answer><p>\n      The debug option for the Java compiler must be enabled in order\n      to see source file and line number information in a stack trace.\n    </p>\n    <p>\n      When invoking the Java compiler from the command line, use\n      the <code>-g</code> option to generate all debugging info.\n    </p>\n    <p>\n      When invoking the Java compiler from an \n      <a href=\"http://jakarta.apache.org/ant/index.html\">Ant</a> task, use the\n      <code>debug=\"on\"</code> attribute.  For example:\n    </p>\n      <pre>&lt;javac srcdir=\"${src}\" destdir=\"${build}\" debug=\"on\" /&gt;</pre>\n    <p>\n      When using older JVMs pre-Hotspot (JDK 1.1 and most/all 1.2),\n      run JUnit with the <code>-DJAVA_COMPILER=none</code> JMV command\n      line argument to prevent runtime JIT compilation from obscuring\n      line number info.\n    </p>\n    <p>\n      Compiling the test source with debug enabled will show the line\n      where the assertion failed.  Compiling the non-test source with\n      debug enabled will show the line where an exception was raised\n      in the class under test.\n    </p></answer>\n        </faq>\n        <faq id=\"running_15\">\n            <question>How do I organize all test classes\n        in a TestSuite automatically and not use or manage a TestSuite\n        explicitly?</question>\n            <answer><p>\n      <i>(Submitted by: Bill de hora)</i>\n    </p>\n    <p>\n      There are a number of ways to do this:\n    </p>\n    <ol>\n      <li>\n        <p>\n          In Ant, use the <code>junit</code> task and\n          the <code>batchtest</code> element:\n        </p>\n        <div>\n          <pre class=\"prettyprint linenums\">\n&lt;junit printsummary=\"yes\" haltonfailure=\"yes\"&gt;\n  ...\n  &lt;batchtest fork=\"yes\"&gt;\n    &lt;fileset dir=\"${src.dir}\"&gt;\n       &lt;include name=\"**/*Test.java\" /&gt;\n       &lt;include name=\"**/Test*.java\" /&gt;\n    &lt;/fileset&gt;\n  &lt;/batchtest&gt;\n&lt;/junit&gt; \n          </pre>\n        </div>\n        <p>\n          Idiomatic naming patterns for unit tests\n          are <code>Test*.java</code> and <code>*Test.java</code>.\n          Documentation and examples are at <a\n                                               href=\"https://ant.apache.org/manual/Tasks/junit.html\">https://ant.apache.org/manual/Tasks/junit.html</a>.\n        </p>\n      </li>\n      <li>\n        <p>\n          Use the <code>DirectorySuiteBuilder</code>\n          and <code>ArchiveSuiteBuilder</code> (for jar/zip files)\n          classes provided by JUnit-addons project:\n        </p>\n<pre class=\"prettyprint linenums\">DirectorySuiteBuilder builder = new DirectorySuiteBuilder();\nbuilder.setSuffix(\"Test\");\nTest suite = builder.suite(\"/home/project/myproject/tests\");</pre>\n        <p>\n          Documentation and examples are at <a\n                                               href=\"http://junit-addons.sourceforge.net/\">http://junit-addons.sourceforge.net</a>.\n        </p>\n      </li>\n      <li>\n        <p>\n          Write your own custom suite builder. \n        </p>\n        <p>\n          Have your test classes implement an interface and write a\n          treewalker to load each class in a directory, inspect the\n          class, and add any classes that implement the interface to a\n          TestSuite.\n        </p>\n        <p>\n          You might only want to do this if you are <b>very</b>\n          uncomfortable with using a naming convention for test\n          classes. Aside from being slow for larger suites, ultimately\n          it's arguable whether it's more effort to follow a naming\n          convention that have test classes implement an interface!\n        </p>\n        <p>\n          An example of this approach is at \n          <a href=\"http://www.javaworld.com/javaworld/jw-12-2000/jw-1221-junit_p.html\">http://www.javaworld.com/javaworld/jw-12-2000/jw-1221-junit_p.html</a>.  \n        </p>\n    </li>\n</ol>\n    </answer>\n        </faq>\n    </part>\n    <part id=\"best\">\n        <title>Best Practices</title>\n        <faq id=\"best_1\">\n            <question>When should tests be written?</question>\n            <answer><p>\n      Tests should be written before the code.  Test-first programming\n      is practiced by only writing new code when an automated test is\n      failing.\n    </p>\n    <p>\n      Good tests tell you how to best design the system for its\n      intended use.  They effectively communicate in an executable\n      format how to use the software.  They also prevent tendencies to\n      over-build the system based on speculation.  When all the tests\n      pass, you know you're done!\n    </p>\n    <p>\n      Whenever a customer test fails or a bug is reported, first write\n      the necessary unit test(s) to expose the bug(s), <em>then</em>\n      fix them. This makes it almost impossible for that particular\n      bug to resurface later.\n    </p>\n    <p>\n      Test-driven development is a lot more fun than writing tests\n      after the code seems to be working.  Give it a try!\n    </p></answer>\n        </faq>\n        <faq id=\"best_2\">\n            <question>Do I have to write a test for\n        everything?</question>\n            <answer><p>\n      No, just test everything that could reasonably break.  \n    </p>\n    <p>\n      Be practical and maximize your testing investment.  Remember\n      that investments in testing are equal investments in design.  If\n      defects aren't being reported and your design responds well to\n      change, then you're probably testing enough.  If you're spending\n      a lot of time fixing defects and your design is difficult to\n      grow, you should write more tests.\n    </p>\n    <p>\n      If something is difficult to test, it's usually an opportunity\n      for a design improvement.  Look to improve the design so that\n      it's easier to test, and by doing so a better design will\n      usually emerge.\n    </p></answer>\n        </faq>\n        <faq id=\"best_3\">\n            <question>How simple is 'too simple to break'?</question>\n            <answer><p>\n      <i>(Submitted by: J. B. Rainsberger)</i>\n    </p>\n    <p>\n      The general philosophy is this: if it can't break <em>on its\n      own</em>, it's too simple to break.\n    </p>\n    <p>\n      First example is the <code>getX()</code> method. Suppose\n      the <code>getX()</code> method only answers the value of an\n      instance variable. In that case, <code>getX()</code> cannot\n      break unless either the compiler or the interpreter is also\n      broken. For that reason, don't test <code>getX()</code>; there\n      is no benefit.  The same is true of the <code>setX()</code>\n      method, although if your <code>setX()</code> method does any\n      parameter validation or has any side effects, you likely need to\n      test it.\n    </p>\n    <p>\n      Next example: suppose you have written a method that does\n      nothing but forward parameters into a method called on another\n      object. That method is too simple to break.\n    </p>\n<pre class=\"prettyprint linenums\">public void myMethod(final int a, final String b) {\n    myCollaborator.anotherMethod(a, b);\n}</pre>\n    <p>\n      <code>myMethod</code> cannot possibly break because it does nothing: it \n      forwards its input to another object and that's all. \n    </p>\n    <p>\n      The only precondition for this method is \"myCollaborator !=\n      null\", but that is generally the responsibility of the\n      constructor, and not of myMethod. If you are concerned, add a\n      test to verify that myCollaborator is always set to something\n      non-null by every constructor.\n    </p>\n    <p>\n      The only way myMethod could break would be\n      if <code>myCollaborator.anotherMethod()</code> were broken. In\n      that case, test <code>myCollaborator</code>, and not the current\n      class.\n    </p>\n    <p>\n      It is true that adding tests for even these simple methods\n      guards against the possibility that someone refactors and makes\n      the methods \"not-so-simple\" anymore. In that case, though, the\n      refactorer needs to be aware that the method is now complex\n      enough to break, and should write tests for it -- and preferably\n      before the refactoring.\n    </p>\n    <p>\n      Another example: suppose you have a JSP and, like a good\n      programmer, you have removed all business logic from it. All it\n      does is provide a layout for a number of JavaBeans and never\n      does anything that could change the value of any object. That\n      JSP is too simple to break, and since JSPs are notoriously\n      annoying to test, you should strive to make all your JSPs too\n      simple to break.\n    </p>\n    <p>\n      Here's the way testing goes: \n    </p>\n    <pre class=\"prettyprint linenums\">becomeTimidAndTestEverything\nwhile writingTheSameThingOverAndOverAgain\n    becomeMoreAggressive\n    writeFewerTests\n    writeTestsForMoreInterestingCases\n    if getBurnedByStupidDefect\n        feelStupid\n        becomeTimidAndTestEverything\n    end\nend</pre>\n    <p>\n      The loop, as you can see, never terminates.\n    </p></answer>\n        </faq>\n        <faq id=\"best_4\">\n            <question>How often should I run my tests?</question>\n            <answer><p>\n      Run all your unit tests as often as possible, ideally every time\n      the code is changed.  Make sure all your unit tests always run\n      at 100%.  Frequent testing gives you confidence that your\n      changes didn't break anything and generally lowers the stress of\n      programming in the dark.\n    </p>\n    <p>\n      For larger systems, you may just run specific test suites that\n      are relevant to the code you're working on.\n    </p>\n    <p>\n      Run all your acceptance, integration, stress, and unit tests at\n      least once per day (or night).\n    </p>\n    <p>\n      If you're using Eclipse, be sure to check out David Saff's \n      <a href=\"http://pag.csail.mit.edu/continuoustesting/\">continuous\n      testing plug-in</a>.\n    </p></answer>\n        </faq>\n        <faq id=\"best_5\">\n            <question>What do I do when a defect is reported?</question>\n            <answer><p>\n      Test-driven development generally lowers the defect density of\n      software.  But we're all fallible, so sometimes a defect will\n      slip through.  When this happens, write a failing test that\n      exposes the defect.  When the test passes, you know the defect\n      is fixed!\n    </p>\n    <p>\n      Don't forget to use this as a learning opportunity.  Perhaps the\n      defect could have been prevented by being more aggressive about\n      testing everything that could reasonably break.\n    </p></answer>\n        </faq>\n        <faq id=\"best_6\">\n            <question>Why not just use <code>System.out.println()</code>?</question>\n            <answer><p>\n      Inserting debug statements into code is a low-tech method for\n      debugging it.  It usually requires that output be scanned\n      manually every time the program is run to ensure that the code\n      is doing what's expected.\n    </p>\n    <p>\n      It generally takes less time in the long run to codify\n      expectations in the form of an automated JUnit test that retains\n      its value over time.  If it's difficult to write a test to\n      assert expectations, the tests may be telling you that shorter\n      and more cohesive methods would improve your design.\n    </p></answer>\n        </faq>\n        <faq id=\"best_7\">\n            <question>Why not just use a debugger?</question>\n            <answer><p>\n      Debuggers are commonly used to step through code and inspect\n      that the variables along the way contain the expected values.\n      But stepping through a program in a debugger is a manual process\n      that requires tedious visual inspections.  In essence, the\n      debugging session is nothing more than a manual check of\n      expected vs. actual results.  Moreover, every time the program\n      changes we must manually step back through the program in the\n      debugger to ensure that nothing broke.\n    </p>\n    <p>\n      It generally takes less time to codify expectations in the form\n      of an automated JUnit test that retains its value over time.  If\n      it's difficult to write a test to assert expected values, the\n      tests may be telling you that shorter and more cohesive methods\n      would improve your design.\n    </p></answer>\n        </faq>\n   </part>\n    <part id=\"misc\">\n        <title>Miscellaneous</title>\n        <faq id=\"misc_2\">\n            <question>How do I launch a debugger when a test fails?</question>\n            <answer>    <p>\n      Start the <code>TestRunner</code> under the debugger and\n      configure the debugger so that it catches\n      the <code>junit.framework.AssertionFailedError</code>.\n    </p>\n    <p>\n      How you configure this depends on the debugger you prefer to\n      use. Most Java debuggers provide support to stop the program\n      when a specific exception is raised.\n    </p>\n    <p>\n      Notice that this will only launch the debugger when an expected\n      failure occurs.\n    </p></answer>\n        </faq>\n        <faq id=\"misc_3\">\n            <question>Where can I find unit testing frameworks\n      similar to JUnit for other languages?</question>\n            <answer><p>\n      Wikipedia maintains a list of available <a\n      href=\"https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks\">xUnit testing\n      frameworks</a>.\n    </p></answer>\n        </faq>\n    </part>\n</faqs>\n"
  },
  {
    "path": "src/site/markdown/cookbook.md",
    "content": "Title: JUnit Cookbook\nAuthor: Kent Beck, Erich Gamma\n\n\nHere is a short cookbook showing you the steps you can follow in writing\nand organizing your own tests using JUnit.\n\n## Simple Test Case\n\nHow do you write testing code?\n\nThe simplest way is as an expression in a debugger. You can change debug\nexpressions without recompiling, and you can wait to decide what to write\nuntil you have seen the running objects. You can also write test expressions\nas statements which print to the standard output stream. Both styles of\ntests are limited because they require human judgment to analyze their\nresults. Also, they don't compose nicely- you can only execute one debug\nexpression at a time and a program with too many print statements causes\nthe dreaded \"Scroll Blindness\".\n\nJUnit tests do not require human judgment to interpret, and it is easy\nto run many of them at the same time. When you need to test something,\nhere is what you do:\n\n1.  Annotate a method with `@org.junit.Test`\n\n1. When you want to check a value, import `org.junit.Assert.*` statically, call `assertTrue()` and pass a boolean\nthat is true if the test succeeds\n\nFor example, to test that the sum of two Moneys with the same currency\ncontains a value which is the sum of the values of the two Moneys, write:\n\n    @Test\n    public void simpleAdd() {\n        Money m12CHF= new Money(12, \"CHF\");\n        Money m14CHF= new Money(14, \"CHF\");\n        Money expected= new Money(26, \"CHF\");\n        Money result= m12CHF.add(m14CHF);\n        assertTrue(expected.equals(result));\n    }\n\nIf you want to write a test similar to one you have already written, write\na Fixture instead.\n\n## Fixture\n\nWhat if you have two or more tests that operate on the same or similar\nsets of objects?\n\nTests need to run against the background of a known set of objects.\nThis set of objects is called a test fixture. When you are writing tests\nyou will often find that you spend more time writing the code to set up\nthe fixture than you do in actually testing values.\n\nTo some extent, you can make writing the fixture code easier by paying\ncareful attention to the constructors you write. However, a much bigger\nsavings comes from sharing fixture code. Often, you will be able to use\nthe same fixture for several different tests. Each case will send slightly\ndifferent messages or parameters to the fixture and will check for different\nresults.\n\nWhen you have a common fixture, here is what you do:\n\n1.  Add a field for each part of the fixture\n2.  Annotate a method with `@org.junit.Before` and initialize the variables in that method\n3.  Annotate a method with `@org.junit.After` to release any permanent resources you allocated in `setUp`\n\nFor example, to write several test cases that want to work with different\ncombinations of 12 Swiss Francs, 14 Swiss Francs, and 28 US Dollars, first\ncreate a fixture:\n\n    public class MoneyTest {\n        private Money f12CHF;\n        private Money f14CHF;\n        private Money f28USD;\n\n        @Before public void setUp() {\n            f12CHF= new Money(12, \"CHF\");\n            f14CHF= new Money(14, \"CHF\");\n            f28USD= new Money(28, \"USD\");\n        }\n    }\n\nOnce you have the Fixture in place, you can write as many Test Cases as\nyou'd like. Add as many test methods (annotated with `@Test`) as you'd like.\n\n## Running Tests\n\nHow do you run your tests and collect their results?\n\nOnce you have tests, you'll want to run them. JUnit provides tools\nto define the suite to be run and to display its results. To run tests and see the\nresults on the console, run this from a Java program:\n\n    org.junit.runner.JUnitCore.runClasses(TestClass1.class, ...);\n\nor this from the command line, with both your test class and junit on the classpath:\n\n    java org.junit.runner.JUnitCore TestClass1.class [...other test classes...]\n\nYou make your JUnit 4 test classes accessible to a TestRunner designed to work with earlier versions of JUnit,\ndeclare a static method _suite_\nthat returns a test.\n\n    public static junit.framework.Test suite() {\n        return new JUnit4TestAdapter(Example.class);\n    }\n\n## Expected Exceptions\n\nHow do you verify that code throws exceptions as expected?\n\nVerifying that code completes normally is only part of programming. Making sure the code\nbehaves as expected in exceptional situations is part of the craft of programming too. For example:\n\n    new ArrayList<Object>().get(0);\n\nThis code should throw an `IndexOutOfBoundsException`. The `@Test` annotation has an optional parameter `expected`\nthat takes as values subclasses of `Throwable`. If we wanted to verify that `ArrayList` throws the correct exception,\nwe would write:\n\n    @Test(expected= IndexOutOfBoundsException.class)\n    public void empty() {\n        new ArrayList<Object>().get(0);\n    }\n\n* * *\n"
  },
  {
    "path": "src/site/resources/css/carousel.css",
    "content": ".carousel-content {\n\theight: 20em;\n}\n.carousel-caption a {\n\tcolor: #ffffff;\n}\n#junit-lambda-teaser {\n\tbackground: url(../images/junit-lambda/background.png);\n\ttext-align: center;\n}\n#junit-lambda-teaser p {\n\tpadding-top: 25px;\n}"
  },
  {
    "path": "src/site/resources/css/junit-lambda.css",
    "content": "ul.inline {\n    margin-left: 0;\n    list-style: none;\n}\n.inline li {\n  display: inline-block;\n\tmargin-right: 10px;\n\tmargin-bottom: 10px;\n}\n\n.sponsors li {\n\tborder: 1px solid #e3e3e3;\n\t-webkit-border-radius: 4px;\n\t   -moz-border-radius: 4px;\n\t        border-radius: 4px;\n}\n.sponsors li:hover {\n\tborder-color: #c5c5c5;\n}\n.sponsors li {\n\ttext-align: center;\n\tpadding: 0;\n\t-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);\n\t   -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);\n\t        box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);\n}\n.sponsors li a {\n\tdisplay: block;\n\tpadding: 0 10px !important;\n}\n\n.sponsors-small li a img {\n  max-height: 100px;\n  max-width: 200px;\n}\n\n.sponsors-small li a {\n\twidth: 200px;\n\theight: 120px;\n\tline-height: 120px;\n}\n.sponsors-medium li a {\n\twidth: 278px;\n\theight: 141px;\n\tline-height: 141px;\n}\n.sponsors-large li a {\n\twidth: 435px;\n\theight: 237px;\n\tline-height: 237px;\n}\n\nul.people {\n\tmargin-left: 7px;\n\tmargin-right: 7px;\n}\n.people li {\n\tdisplay: block;\n\twidth: 170px;\n\tmargin: 0;\n\tpadding: 0 15px 0 0;\n\tfloat: left;\n\ttext-align: center;\n}\n.people img.avatar {\n\tdisplay: block;\n\twidth: 100%;\n\tmargin: 0 0 10px 0;\n}\n"
  },
  {
    "path": "src/site/resources/css/plain-links.css",
    "content": "a.externalLink {\n\tbackground: none !important;\n\tpadding-right: 0 !important;\n}"
  },
  {
    "path": "src/site/resources/scripts/index.js",
    "content": "$(document).ready(function(){\n    $('#main-carousel').carousel({\n        interval:10000\n    });\n\n    $('#main-carousel-prev').on(\"click\", function () {\n        $('#main-carousel').carousel('prev');\n    });\n\n    $('#main-carousel-next').on(\"click\", function () {\n        $('#main-carousel').carousel('next');\n    });\n});"
  },
  {
    "path": "src/site/site.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<project xmlns=\"http://maven.apache.org/DECORATION/1.1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd\">\n  <bannerLeft>\n    <name>${project.name}</name>\n    <src>./images/junit-logo.png</src>\n    <href>http://junit.org/</href>\n  </bannerLeft>\n\n  <publishDate format=\"yyyy-MM-dd\" position=\"right\" />\n  <version position=\"right\" />\n\n  <poweredBy>\n    <logo name=\"Built by Maven\" href=\"http://maven.apache.org/\" img=\"images/logos/maven-feather.png\" />\n  </poweredBy>\n\n  <skin>\n    <groupId>org.apache.maven.skins</groupId>\n    <artifactId>maven-fluido-skin</artifactId>\n    <version>1.3.0</version>\n  </skin>\n\n  <body>\n    <head>\n      <link rel=\"stylesheet\" href=\"@relativePath@/css/plain-links.css\" />\n      <link rel=\"stylesheet\" href=\"@relativePath@/css/carousel.css\" />\n      <link rel=\"stylesheet\" href=\"@relativePath@/css/junit-lambda.css\" />\n    </head>\n    <breadcrumbs>\n      <item name=\"JUnit 4\" href=\"http://junit.org/\" />\n    </breadcrumbs>\n\n    <menu name=\"JUnit 4\">\n      <item name=\"Introduction\" href=\"index.html\"/>\n      <item name=\"Frequently asked questions\" href=\"faq.html\"/>\n      <item name=\"Cookbook\" href=\"cookbook.html\"/>\n    </menu>\n\n    <menu name=\"Project Documentation\" ref=\"reports\" inherit=\"bottom\" />\n\n  </body>\n\n  <custom>\n    <fluidoSkin>\n      <topBarEnabled>true</topBarEnabled>\n      <sideBarEnabled>false</sideBarEnabled>\n      <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>\n      <gitHub>\n        <projectId>junit-team/junit4</projectId>\n        <ribbonOrientation>right</ribbonOrientation>\n      </gitHub>\n    </fluidoSkin>\n  </custom>\n</project>\n"
  },
  {
    "path": "src/site/xdoc/index.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<document>\n  <properties>\n    <title>About</title>\n  </properties>\n  <head>\n    <link rel=\"stylesheet\" href=\"./css/hopscotch-0.1.2.min.css\" />\n    <script src=\"scripts/index.js\" type=\"text/javascript\" ></script>\n  </head>\n  <body>\n       <p>\n        JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.\n      </p>\n     <div id=\"carousel-main\">\n        <div id=\"main-carousel\" class=\"carousel slide\">\n          <div class=\"carousel-inner\">\n\t          <div class=\"item active\">\n\t            <div class=\"carousel-content\" id=\"junit-lambda-teaser\">\n\t\t\t\t\t\t\t\t<p><a href=\"http://junit.org/junit5/\"><img src=\"images/junit5-banner.png\" alt=\"JUnit 5\" style=\"height:120px; margin-top:20px\" /></a></p>\n\t            </div>\n\t            <div class=\"carousel-caption\">\n\t              <p><strong><a href=\"http://junit.org/junit5/\">JUnit 5 is released:</a></strong></p>\n\t              <p><a href=\"http://junit.org/junit5/\">Explore the new release!</a></p>\n\t            </div>\n\t          </div>\n            <div class=\"item\">\n              <div class=\"carousel-content\">\n              <pre class=\"prettyprint\">\n    @Test\n    public void newArrayListsHaveNoElements() {\n        assertThat(new ArrayList&lt;Integer&gt;().size(), is(0));\n    }\n\n    @Test\n    public void sizeReturnsNumberOfElements() {\n        List&lt;Object&gt; instance = new ArrayList&lt;Object&gt;();\n        instance.add(new Object());\n        instance.add(new Object());\n        assertThat(instance.size(), is(2));\n    }\n\n              </pre>\n              </div>\n              <div class=\"carousel-caption\">\n                <p><strong>Annotations</strong></p>\n                <p>Start by marking your tests with <code>@Test</code>.</p>\n              </div>\n            </div>\n            <div class=\"item\">\n              <div class=\"carousel-content\">\n              <pre class=\"prettyprint lang-java\">\n    @Test\n    public void lookupEmailAddresses() {\n        assertThat(new CartoonCharacterEmailLookupService().getResults(\"looney\"), allOf(\n            not(empty()),\n            containsInAnyOrder(\n                allOf(instanceOf(Map.class), hasEntry(\"id\", \"56\"), hasEntry(\"email\", \"roadrunner@fast.org\")),\n                allOf(instanceOf(Map.class), hasEntry(\"id\", \"76\"), hasEntry(\"email\", \"wiley@acme.com\"))\n            )\n        ));\n    }\n\n\n\n              </pre>\n              </div>\n              <div class=\"carousel-caption\">\n                <p><strong>Hamcrest matchers</strong></p>\n                <p>Make your assertions more expressive and get better failure reports in return. </p>\n              </div>\n            </div>\n          </div>\n          <a id=\"main-carousel-prev\" class=\"carousel-control left\" name=\"main-carousel-prev\" data-slide=\"prev\">&#8249;</a>\n          <a id=\"main-carousel-next\" class=\"carousel-control right\" name=\"main-carousel-next\" data-slide=\"next\">&#8250;</a>\n        </div>\n      </div>\n      <p  class=\"pagination-centered\">\n        <a class=\"btn btn-primary btn-large\" href=\"javascript:startSiteTour()\">Let's take a tour »</a>\n      </p>\n\n      <div class=\"container\">\n      <div class=\"row\">\n        <div class=\"span4\" id=\"welcome-section\">\n          <p><b>Welcome</b></p>\n          <ul>\n            <li><a href=\"https://github.com/junit-team/junit4/wiki/Download-and-Install\">Download and install</a></li>\n            <li><a href=\"https://github.com/junit-team/junit4/wiki/Getting-started\">Getting started</a></li>\n            <li>Release Notes\n              <ul>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.13.2.md\">4.13.2</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.13.1.md\">4.13.1</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.13.md\">4.13</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.12.md\">4.12</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.11.md\">4.11</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.10.md\">4.10</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.9.1.md\">4.9.1</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.9.md\">4.9</a></li>\n              </ul>\n            </li>\n            <li><a href=\"https://github.com/junit-team/junit4/wiki/Maintainer-documentation\">Maintainer Documentation</a></li>\n            <li><a href=\"https://github.com/junit-team/junit4/wiki/I-want-to-help%21\">I want to help!</a></li>\n            <li><a href=\"http://stackoverflow.com/questions/tagged/junit\">Latest JUnit Questions on StackOverflow</a></li>\n            <li><a href=\"javadoc/latest/index.html\">JavaDocs</a></li>\n            <li><a href=\"./faq.html\">Frequently asked questions</a></li>\n            <li><a href=\"https://github.com/junit-team/junit4/wiki\">Wiki</a></li>\n            <li><a href=\"./license.html\">License</a></li>\n          </ul>\n        </div>\n        <div class=\"span4\" id=\"concepts-section\">\n          <p><b>Usage and Idioms</b></p>\n          <ul>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Assertions\">Assertions</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Test-runners\">Test Runners</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Aggregating-tests-in-suites\">Aggregating tests in Suites</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Test-execution-order\">Test Execution Order</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Exception-testing\">Exception Testing</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Matchers-and-assertthat\">Matchers and assertThat</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Ignoring-tests\">Ignoring Tests</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Timeout-for-tests\">Timeout for Tests</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Parameterized-tests\">Parameterized Tests</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Assumptions-with-assume\">Assumptions with Assume</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Rules\">Rules</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Theories\">Theories</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Test-fixtures\">Test Fixtures</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Categories\">Categories</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Use-with-Maven\">Use with Maven</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Multithreaded-code-and-concurrency\">Multithreaded code and Concurrency</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Java-contract-test-helpers\">Java contract test helpers</a></li>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Continuous-testing\">Continuous Testing</a></li>          </ul>\n        </div>\n        <div class=\"span4\" id=\"thirdparty-section\">\n          <p><b>Third-party extensions</b></p>\n          <ul>\n<li><a href=\"https://github.com/junit-team/junit4/wiki/Custom-runners\">Custom Runners</a></li>\n<li>\n<a href=\"http://site.trajano.net/commons-testing/\">net.trajano.commons:commons-testing for UtilityClassTestUtil</a> per #646</li>\n<li>\n<a href=\"http://stefanbirkner.github.io/system-rules\">System Rules</a> – A collection of JUnit rules for testing code that uses java.lang.System.</li>\n<li>\n<a href=\"https://github.com/MichaelTamm/junit-toolbox\">JUnit Toolbox</a> - Provides runners for parallel testing, a <code>PoolingWait</code> class to ease asynchronous testing, and a <code>WildcardPatternSuite</code> which allow you to specify wildcard patterns instead of explicitly listing all classes when you create a suite class.</li>\n<li>\n<a href=\"https://github.com/pholser/junit-quickcheck\">junit-quickcheck</a> - QuickCheck-style parameter suppliers for JUnit theories. Uses <a href=\"https://github.com/junit-team/junit.contrib/tree/HEAD/theories\">junit.contrib's version of the theories machinery</a>, which respects generics on theory parameters.</li>          </ul>\n        </div>\n      </div>\n    </div>\n    <script src=\"scripts/hopscotch-0.1.2.min.js\" type=\"text/javascript\" ></script>\n    <script>//<![CDATA[\n        var tour = {\n          id: \"welcome_tour\",\n          steps:[\n            {\n              target: \"welcome-section\",\n              placement: \"right\",\n              title: \"First things first\",\n              content: \"Here are the links to the most important information\"\n            },\n            {\n              target: $('ul.nav')[0],\n              fixedElement: true,\n              placement: \"bottom\",\n              title: \"Maven site documentation\",\n              content: \"Don't forget that the documentation generated by Maven is hiding up here\"\n            },\n            {\n              target: $('body a[href=\"http://github.com/junit-team/junit4\"] img')[0],\n              placement: \"left\",\n              title: \"Source code\",\n              content: \"The source code for JUnit is hosted on GitHub\"\n            },\n            {\n              target: \"concepts-section\",\n              placement: \"right\",\n              title: \"Understanding JUnit\",\n              content: \"Find out more about how to do things with JUnit\"\n            },\n            {\n              target: \"thirdparty-section\",\n              placement: \"left\",\n              title: \"Extending JUnit\",\n              content: \"Find out about third party extensions to the JUnit framework\"\n            }\n          ]\n        }\n        window.startSiteTour = function(){\n            hopscotch.startTour(tour);\n            return undefined;\n        };\n    //]]></script>\n  </body>\n</document>\n"
  },
  {
    "path": "src/site/xhtml/junit-lambda-campaign.xhtml",
    "content": "<html>\n  <head>\n    <title>JUnit Lambda Crowdfunding Campaign</title>\n  </head>\n  <body>\n\t\t<h1>Crowdfunding JUnit Lambda <small>#fundJUnit</small></h1>\n\t\t<div>\n\t\t<iframe style=\"display:block; margin: 0 auto;\" width=\"940\" height=\"529\" src=\"https://www.youtube-nocookie.com/embed/Ai6M5G90Mlg?rel=0\" frameborder=\"0\" allowfullscreen=\"true\"></iframe>\n\t\t</div>\n    <hr />\n    <h2 align=\"center\" class=\"muted\">The crowdfunding campaign has successfully ended.<br/> Thank you all!</h2>\n    <p align=\"center\" style=\"font-size:150%\">\n\t\t\t<a class=\"btn btn-large btn-success\" href=\"https://www.indiegogo.com/projects/junit-lambda\" role=\"button\" style=\"font-size:100%\">Campaign page on Indiegogo</a>\n\t\t\t<a class=\"btn btn-large btn-default\" href=\"junit-lambda-contributors.html\" role=\"button\" style=\"font-size:100%\">Campaign Contributors</a>\n\t\t\t<a class=\"btn btn-large btn-default\" href=\"http://twitter.com/junitteam\" role=\"button\" style=\"font-size:100%\">Follow @junitteam on Twitter</a>\n\t\t</p>\n\t\t<hr />\n\t\t<h2>Main Sponsors</h2>\n\t\t<p>Each of these companies will fund a developer for 6 weeks. They will not receive any money collected through the campaign.</p>\n\t\t<ul class=\"inline sponsors sponsors-large\">\n\t\t\t<li><a href=\"http://www.andrena.de\" title=\"andrena objects ag, Germany\"><img src=\"images/junit-lambda/sponsors/andrena.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.heidelberg-mobil.com\" title=\"Heidelberg Mobil International GmbH, Germany\"><img src=\"images/junit-lambda/sponsors/heidelberg-mobil.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.namics.com\" title=\"Namics (Deutschland) GmbH, Germany\"><img src=\"images/junit-lambda/sponsors/namics.png\" /></a></li>\n\t\t\t<li><a href=\"http://pivotal.io/\" title=\"Pivotal Software, Inc., U.S.A.\"><img src=\"images/junit-lambda/sponsors/pivotal.png\" /></a></li>\n\t\t</ul>\n\t\t<h2>Main Campaign Sponsor</h2>\n\t\t<p>This company will fund JUnit Lambda through the Main Sponsor campaign perk.</p>\n\t\t<ul class=\"inline sponsors sponsors-large\">\n\t\t\t<li><a href=\"http://www.americanexpress.com/\" title=\"American Express Company\"><img src=\"images/junit-lambda/sponsors/amex.png\" /></a></li>\n\t\t</ul>\n\t\t<h2>Campaign Contributors</h2>\n\t\t<p>Thank you to all other people, companies, and organizations that have contributed already! Please check out our <a href=\"junit-lambda-contributors.html\">contributors page</a>.</p>\n    <hr />\n    <h2>Why JUnit needs your support</h2>\n\t\t<p>With 43 million downloads from Maven Central in 2014 <strong>JUnit</strong> still is the default testing library for Java. Millions of projects rely on it being both stable and allowing to test the latest features of the latest JDK. Moreover, many other testing libraries hook into JUnit as a way to enable IDE and build tool integration. Keeping JUnit in shape is a major task for those maintaining and evolving the library.</p>\n\t\t<p>As of today, none of the active JUnit maintainers are payed by their employer to do this work. Not surprisingly many unresolved issues have piled up and, what’s worse, there is no hope to get JUnit to support and make use of all the features in Java 8 any time soon. Since <i>Lambdas</i> are the most prominent of those features, we borrowed their name for the campaign.</p>\n\t\t<p>This campaign will allow a team of long-time JUnit committers, backed by a few experienced Java developers, to focus on getting JUnit ready for the years—and JDKs—to come.</p>\n\t\t<h2>Obstacles for evolving JUnit</h2>\n\t\t<p>A major design goal of JUnit has always been simplicity. JUnit 4 was released 10 years ago and has served its purpose very well. Since then many things have changed: Java got a couple of new versions and many new testing frameworks and ideas about testing have popped up.</p>\n\t\t<p>The basic design of JUnit, however, has remained the same since 2005. Some constructs like Rules were added, but at the same time backwards compatibility has always been and will continue to be the major goal of evolving JUnit. A number of issues have increasingly slowed down its evolution:</p>\n\t\t<ul>\n\t\t\t<li>\n\t\t\t\t<p><i>Runners</i> have found a widespread use and become a crucial concept to extend JUnit. Writing a custom runner is a very powerful way to customize how a test class is instantiated, how its children are collected, how they are run, reported, and so on. However, you can only have a single runner for each test class. For example, combining <i>SpringJUnit4ClassRunner</i> and <i>Parameterized</i> is not possible at the moment. We want to separate the different concerns, for which the runner is currently responsible, into separated interfaces.</p>\n\t\t\t</li>\n\t\t\t<li>\n\t\t\t\t<p>The current execution model requires all test cases to be known a-priori. This prevents the dynamic creation of test cases as response to observed behaviour during test execution. This also means that you cannot use Streams (Java 8), e.g. in combination with <i>@Parameters</i>, to create your test data.</p>\n\t\t\t</li>\n\t\t\t<li>\n\t\t\t\t<p>All IDEs and build tools include support for JUnit. While that makes it really easy to execute JUnit tests, on the flip side the IDEs and build tools are tightly coupled to JUnit internals. Some IDEs and build tools use internal JUnit classes or even reflection to circumvent the absence of a JUnit API that does what they want. For example, there is no extensible way to link to a test location in case it is not a Java method. Those “tricks” complicate the evolution of JUnit tremendously, and even render some changes virtually impossible. Therefore, we want to closely work with IDE and build tool developers to add features their users need in an extensible way.</p>\n\t\t\t</li>\n\t\t</ul>\n    <h2>The Vision</h2>\n\t\t<p>We’ve identified two main areas to focus on during the upcoming JUnit overhaul:</p>\n\t\t<ul>\n\t\t\t<li>\n\t\t\t\t<p><strong>Decouple test execution and reporting from test definition and provisioning</strong>: This will greatly simplify further evolution of JUnit and allow users to mix test specifications from different test libraries—like JUnit, Spock, ScalaTest and so on—more easily. Other testing libraries should only depend on the test execution/reporting API of JUnit, not on the test definition API (e.g. Runner).</p>\n\t\t\t</li>\n\t\t\t<li>\n\t\t\t\t<p><strong>Rethinking the JUnit’s extensibility story</strong>: Runners, Rules, subclassing and other techniques will be revamped into a cohesive set of constructs to enhance JUnit and to allow—if possible—the seamless combination of individual extensions.</p>\n\t\t\t</li>\n\t\t\t<li>\n\t\t\t\t<p><strong>Making use of Java 8 features (Lambdas, Streams, Interface default methods) for better assertions, generating test cases, formulating test hierarchies, testing asynchronous code and other stuff</strong>: We will provide those extensions in additional libraries to keep the JUnit core compatible with older JDKs.</p>\n\t\t\t</li>\n\t\t</ul>\n\t\t<p>All development will happen openly on <a href=\"https://github.com/junit-team/junit5\">GitHub</a> in order to foster early feedback and detect problems as soon as possible.</p>\n  </body>\n</html>\n"
  },
  {
    "path": "src/site/xhtml/junit-lambda-contributors.xhtml",
    "content": "<html>\n  <head>\n    <title>JUnit Lambda</title>\n  </head>\n  <body>\n\t\t<h1>Crowdfunding Campaign Contributors <small>#fundJUnit</small></h1>\n\t\t<p>The following individuals, companies, and organizations have made substantial contributions to the <a href=\"https://www.indiegogo.com/projects/junit-lambda\">JUnit Lambda crowdfunding campaign on Indiegogo</a>. Thank you from the JUnit team!</p>\n\t\t<p>Depending on the perk they have chosen, they are listed with a large logo, a small one, or by their name.</p>\n\t\t<ul class=\"inline sponsors sponsors-large\">\n\t\t\t<li><a href=\"http://www.ociweb.com\" title=\"Object Computing, Inc. (OCI), U.S.\"><img src=\"images/junit-lambda/contributors/ociweb.png\" /></a></li>\n\t\t\t<li><a href=\"http://devnexus.com\" title=\"DevNexus\"><img src=\"images/junit-lambda/contributors/devnexus.png\" /></a></li>\n\t\t\t<li><a href=\"http://about-us.autotrader.co.uk/\" title=\"Auto Trader Ltd, U.K.\"><img src=\"images/junit-lambda/contributors/autotrader.jpg\" /></a></li>\n\t\t\t<li><a href=\"https://www.ergon.ch/\" title=\"Ergon Informatik AG, Switzerland\"><img src=\"images/junit-lambda/contributors/ergon.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.sipgate.de/\" title=\"Sipgate, Germany\"><img src=\"images/junit-lambda/contributors/sipgate.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.adnovum.ch/\" title=\"AdNovum Informatik AG, Switzerland\"><img src=\"images/junit-lambda/contributors/adnovum.png\" /></a></li>\n\t\t\t<li><a href=\"https://www.jetbrains.com/idea/\" title=\"IntelliJ IDEA by JetBrains\"><img src=\"images/junit-lambda/contributors/intellijidea.png\" /></a></li>\n\t\t\t<li><a href=\"http://pivotal.io/\" title=\"Pivotal Software, Inc., U.S.A.\"><img src=\"images/junit-lambda/sponsors/pivotal.png\" /></a></li>\n\t\t\t<li><a href=\"http://samuraism.com/\" title=\"Samuraism Inc.\"><img src=\"images/junit-lambda/contributors/samuraism.png\" /></a></li>\n      <li><a href=\"http://www.msg-systems.com/\" title=\"msg systems AG, Germany\"><img src=\"images/junit-lambda/contributors/msgsystems.png\" /></a></li>\n      <li><a href=\"https://gradle.org/\" title=\"Gradle\"><img src=\"images/junit-lambda/contributors/gradle.png\" /></a></li>\n      <li><a href=\"http://www.klarna.com/\" title=\"Klarna AB, Sweden\"><img src=\"images/junit-lambda/contributors/klarna.png\" /></a></li>\n\t\t</ul>\n\t\t<ul class=\"inline sponsors sponsors-small\">\n\t\t\t<li><a href=\"http://www.tngtech.com\" title=\"TNG Technology Consulting, Germany\"><img src=\"images/junit-lambda/contributors/tng.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.bouvet.no/en/\" title=\"Bouvet, Norway\"><img src=\"images/junit-lambda/contributors/bouvet.png\" /></a></li>\n\t\t\t<li><a href=\"http://netcetera.com/\" title=\"Netcetera AG, Switzerland\"><img src=\"images/junit-lambda/contributors/netcetera.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.diffplug.com/\" title=\"DiffPlug LLC, U.S.\"><img src=\"images/junit-lambda/contributors/diffplug.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.disy.net/\" title=\"Disy, Germany\"><img src=\"images/junit-lambda/contributors/disy.jpg\" /></a></li>\n\t\t\t<li><a href=\"http://www.braintime.de/methoden/ueberblick-extreme-programming-beratung/xp-schulung-beratung/\" title=\"OiO, Germany\"><img src=\"images/junit-lambda/contributors/oio.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.squeed.com\" title=\"Squeed, Sweden\"><img src=\"images/junit-lambda/contributors/squeed.png\" /></a></li>\n\t\t\t<li><a href=\"http://bit.ly/1EXgtwv\" title=\"42talents GmbH, Switzerland\"><img src=\"images/junit-lambda/contributors/42talents.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.bol.com/\" title=\"bol.com, The Netherlands\"><img src=\"images/junit-lambda/contributors/bol.jpg\" /></a></li>\n\t\t\t<li><a href=\"http://www.murex.com/\" title=\"Murex, France\"><img src=\"images/junit-lambda/contributors/murex.jpg\" /></a></li>\n\t\t\t<li><a href=\"http://www.zenika.com/\" title=\"Zenika, France\"><img src=\"images/junit-lambda/contributors/zenika.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.six-group.com/en/home.html\" title=\"SIX, Switzerland\"><img src=\"images/junit-lambda/contributors/six.gif\" /></a></li>\n      <li><a href=\"http://vaddy.net/\" title=\"VAddy\"><img src=\"images/junit-lambda/contributors/vaddy.png\" /></a></li>\n      <li><a href=\"http://www.arcbees.com/\" title=\"Arcbees\"><img src=\"images/junit-lambda/contributors/arcbees.png\" /></a></li>\n      <li><a href=\"http://www.red6-es.de/\" title=\"Red Enterprise Software, Germany\"><img src=\"images/junit-lambda/contributors/red6-es.jpg\" /></a></li>\n      <li><a href=\"http://www.klosebrothers.de/\" title=\"klose brothers gmbh, Germany\"><img src=\"images/junit-lambda/contributors/klosebrothers.png\" /></a></li>\n      <li><a href=\"http://structure101.com/\" title=\"structure101\"><img src=\"images/junit-lambda/contributors/structure101.png\" /></a></li>\n      <li><a href=\"http://www.siili.com/campaign/junit-lambda\" title=\"Siili Solutions Oyj, Finland\"><img src=\"images/junit-lambda/contributors/siili.png\" /></a></li>\n      <li><a href=\"http://www.eclipse.org/\" title=\"Eclipse Foundation, U.S.A.\"><img src=\"images/junit-lambda/contributors/eclipse.png\" /></a></li>\n      <li><a href=\"http://www.novatec-gmbh.de/en/\" title=\"NovaTec Consulting GmbH, Germany\"><img src=\"images/junit-lambda/contributors/novatec.png\" /></a></li>\n      <li><a href=\"http://www.synyx.de/\" title=\"synyx GmbH &amp; Co. KG, Germany\"><img src=\"images/junit-lambda/contributors/synyx.jpg\" /></a></li>\n      <li><a href=\"http://careers.stackoverflow.com/company/TOPdesk\" title=\"TOPdesk\"><img src=\"images/junit-lambda/contributors/topdesk.png\" /></a></li>\n      <li><a href=\"http://www.sonrisa.hu/\" title=\"s:)nrisa, Hungary\"><img src=\"images/junit-lambda/contributors/sonrisa.png\" /></a></li>\n\t\t</ul>\n\t\t<ul class=\"inline\">\n\t\t\t<li>Hans Sowa</li>\n\t\t\t<li>Jens Schauder</li>\n\t\t\t<li>Tobias Ahlers</li>\n\t\t\t<li>Daniel Zappold</li>\n\t\t\t<li>Kai-Marian Pukall</li>\n\t\t\t<li>Julien Jakubowski</li>\n\t\t\t<li>Dmitry Karlinsky</li>\n\t\t\t<li>Mark Munson</li>\n\t\t\t<li>Andrew Janke</li>\n\t\t\t<li>Eric Lefevre-Ardant</li>\n\t\t\t<li>Brett Tucker</li>\n\t\t\t<li>Andi Scharfstein</li>\n\t\t\t<li>Oyvind Horneland</li>\n\t\t\t<li><a href=\"http://code-mentor.com/\">Görge Albrecht</a></li>\n\t\t\t<li>Justin Ryan</li>\n\t\t\t<li>Maria Savela</li>\n\t\t\t<li>Eugen Parasachiv</li>\n\t\t\t<li>Stefan Domnanovits</li>\n\t\t\t<li>Nils Wloka</li>\n\t\t\t<li>Eduardo Ucha Tortuero</li>\n\t\t\t<li>Mark Crossfield</li>\n\t\t\t<li>Benjamin Murray</li>\n\t\t\t<li>MinGyoo Jung</li>\n\t\t\t<li>Hadrien Zalek</li>\n\t\t\t<li>Khaled Sinno</li>\n\t\t\t<li>Chadi El Masri</li>\n\t\t\t<li>Davide Fucci</li>\n\t\t\t<li>Frederik Hahne</li>\n\t\t\t<li>Benjamin Murray</li>\n\t\t\t<li>Erik Severinsen</li>\n\t\t\t<li>Anna-Pitschna Kunz</li>\n\t\t\t<li>Daniel Baldes</li>\n\t\t\t<li>Stefan Ferstl</li>\n\t\t\t<li>Jonathan Gray</li>\n\t\t\t<li>Seb Heglmeier</li>\n\t\t\t<li>Bruno Girin</li>\n\t\t\t<li>Steve Ash</li>\n\t\t\t<li>Yves Geissbuehler</li>\n\t\t\t<li>Jacques Stadler</li>\n\t\t\t<li>Bernard D'Havé</li>\n\t\t\t<li>Monica Granbois</li>\n\t\t\t<li>Florian Hopf</li>\n\t\t\t<li>Erich Oswald</li>\n\t\t\t<li>Joe Schmetzer</li>\n\t\t\t<li>Sebastian Hempel</li>\n\t\t\t<li>Christoph Pater</li>\n\t\t\t<li>Klaus Unger</li>\n\t\t\t<li>Martijn Dashorst</li>\n\t\t\t<li>Alexey Kornev</li>\n\t\t\t<li>Timo Kockert</li>\n\t\t\t<li>Michael Prieß</li>\n\t\t\t<li>Joseph Moore</li>\n\t\t\t<li>Richard Capraro</li>\n\t\t\t<li><a href=\"http://www.jbrains.ca/\">J. B. Rainsberger</a></li>\n\t\t\t<li>Marcel Körtgen</li>\n\t\t\t<li>Tim Yates</li>\n\t\t\t<li>Evan Porter</li>\n\t\t\t<li>Jeroen Ingelbrecht</li>\n\t\t\t<li>Mustafa Ulu</li>\n\t\t\t<li>Daniel Wellman</li>\n\t\t\t<li>Juan Llado</li>\n\t\t\t<li>Michał Bendowski</li>\n\t\t\t<li>Samir Talwar</li>\n\t\t\t<li><a href=\"http://davidtanzer.net\">David Tanzer</a></li>\n\t\t\t<li>Siv Midtun Hollup</li>\n\t\t\t<li>Alexander Schwartz</li>\n\t\t\t<li><a href=\"http://www.code-project.org/\">Oliver Paulus</a></li>\n\t\t\t<li>Micael Gallego</li>\n\t\t\t<li>Johannes Seitz</li>\n\t\t\t<li>Tristan Mills</li>\n\t\t\t<li>Henk van Voorthuijsen</li>\n\t\t\t<li>Dennis Hunziker</li>\n\t\t\t<li>Stefan Odendahl</li>\n\t\t\t<li>Gregor Trefs</li>\n\t\t\t<li>Steve Moyer</li>\n\t\t\t<li>Björn Kimminich</li>\n\t\t\t<li>Fabrice Sznajderman</li>\n\t\t\t<li>Nikita Makarov</li>\n\t\t\t<li>Carsten Otto</li>\n\t\t\t<li>Markus Decke</li>\n\t\t\t<li>Henrik Steudel</li>\n\t\t\t<li>Matt Newell</li>\n\t\t\t<li>Thomas Michael</li>\n\t\t\t<li>Robert Klaus</li>\n\t\t\t<li>Martin Dürrmeier</li>\n\t\t\t<li><a href=\"http://www.petrikainulainen.net/blog/\">Petri Kainulainen</a></li>\n\t\t\t<li>Jean-Christophe Sirot</li>\n      <li>Max Schwaab</li>\n      <li>Brian Clozel</li>\n      <li>Per-Ingemar Andersson</li>\n      <li>Henry Voyer</li>\n      <li><a href=\"http://www.groodt.info/\">Greg Roodt</a></li>\n      <li>Java User Group Frankfurt</li>\n      <li>Adrian McMichael</li>\n      <li>Björn Darri Sigurðsson</li>\n      <li>Chris Williams</li>\n      <li><a href=\"http://agilepainrelief.com/\">Agile Pain Relief Consulting</a></li>\n      <li>Andrew Beussink</li>\n      <li>Per Arnold Blaasmo</li>\n      <li>Ian Mayo</li>\n      <li>Doyle Young</li>\n      <li>Wolfgang Werner</li>\n      <li>Daniel Kunz</li>\n      <li><a href=\"http://www.herbert.cc/\">Benjamin Herbert</a></li>\n      <li>Axel Schüssler</li>\n      <li>Matthias Lünemann</li>\n      <li>Christophe Taret</li>\n      <li><a href=\"http://coreagile.co/\">Stephen Starkey</a></li>\n      <li>Michael Dörsam</li>\n      <li>Matt Bertolini</li>\n      <li>Jun Yong Chong</li>\n      <li>Svante Kumlien</li>\n      <li><a href=\"http://www.boothen.co.uk/\">Matt Garner</a></li>\n      <li>Patrick Podbregar</li>\n      <li>Alessandro Proscia</li>\n      <li>David Burkhart</li>\n      <li>Matthias Grund</li>\n      <li>Tomas Michalec</li>\n      <li>Tadaya Tsuyukubo</li>\n      <li><a href=\"http://www.codeaffine.com/author/fappel/\">Frank Appel</a></li>\n      <li>Paul Holser</li>\n      <li>Patrick Baumgartner</li>\n      <li>Emmanuel Chavane</li>\n      <li>Kini</li>\n      <li>Robert-Jan Regout</li>\n      <li>Bastian Spanneberg</li>\n      <li>Jérémie Bresson</li>\n      <li><a href=\"http://brabenetz.net/\">Harald Brabenetz</a></li>\n      <li>Nacho Cougil</li>\n      <li>Martin Schröder</li>\n      <li>Thorsten Brunzendorf</li>\n      <li><a href=\"https://hubesco.com/\">Paolo Escobar</a></li>\n      <li>Brad Milne</li>\n      <li>Bill Chen</li>\n      <li>Craig Doremus</li>\n      <li>Jean-Michel Bea</li>\n      <li><a href=\"http://www.goeckeler.com/\">Thorsten Göckeler</a></li>\n      <li>Ben Romberg</li>\n      <li>Sixto Cantolla Sánchez</li>\n      <li><a href=\"http://www.altiria.com/\">Altiria</a></li>\n      <li>Andres Rodriguez</li>\n      <li>Romain Rocès</li>\n      <li>Ivan Caspeta</li>\n      <li><a href=\"http://olivergierke.de\">Oliver Gierke</a></li>\n      <li>Pierre Marguerite</li>\n      <li>Dmitry Spikhalskiy</li>\n      <li>Francisco Javier Jiménez Sáez</li>\n      <li>Ivo Smid</li>\n      <li>Sargon</li>\n      <li>Balázs Sándor Mracskó</li>\n      <li>Marco Fritschi</li>\n      <li>Matthias 'Yolgie' Holzinger</li>\n      <li>Christian Schubert</li>\n      <li>Rémy Francillette</li>\n      <li>Martin Klose</li>\n      <li><a href=\"https://www.tennisoff.net/\">tennisoff.net</a></li>\n      <li>Yoshio Terada</li>\n      <li>Oleg Lavorskyi</li>\n      <li>Marvin Lillehaug</li>\n      <li>y.ono</li>\n      <li>Kouji Nomura</li>\n      <li><a href=\"https://github.com/twada\">Takuto Wada</a></li>\n      <li>Teruaki Kanamori</li>\n      <li>Keita Kita</li>\n      <li>Manabu Matsuzaki</li>\n      <li><a href=\"http://blog.satotaichi.info/\">Sato Taichi</a></li>\n      <li>Koji Hasegawa</li>\n      <li>Lukas Hinsch</li>\n      <li>Hirofumi Nakagawa</li>\n      <li>Chanwook</li>\n      <li>Masashi Yoshida</li>\n      <li>Yusuke Ikeda</li>\n      <li>Takafumi Yoshida</li>\n      <li>Iwao Harada</li>\n      <li>Daisuke Nakagome</li>\n      <li>Yasushi Hagai</li>\n      <li>Takuya Kawabe</li>\n      <li>Oohara Kazutaka</li>\n      <li>Itsuo Okamoto</li>\n      <li>Shigeyuki Azuchi</li>\n      <li>Shinya Kamijo</li>\n      <li>Noritaka Ishizumi</li>\n      <li>Cagatay Kavukcuoglu</li>\n      <li>Lars Vogel</li>\n      <li>Koji LIn</li>\n      <li>Elmar Fasel</li>\n      <li>Behrang Saeedzadeh</li>\n      <li>Paul Naranja</li>\n      <li><a href=\"https://twitter.com/windish4649\">Naoko Yamazaki</a></li>\n      <li>Kouta Imanaka</li>\n      <li>Takahiro Yano</li>\n      <li>Minoru Yokomichi</li>\n      <li>Yuki Matsumura</li>\n      <li>Kazutoshi Tanaka</li>\n      <li>Itsuki Kuroda</li>\n      <li><a href=\"https://github.com/golonzovsky\">Alexander Golonzovsky</a></li>\n      <li>Ryo Uchino</li>\n      <li>Shingo Ishimura</li>\n      <li>Yamamoto Masaki</li>\n      <li>幸田英隆</li>\n      <li>Hiroyuki Ohnaka</li>\n      <li>Ito Sho</li>\n      <li>Yu Asano</li>\n      <li>Takeshi Hagikura</li>\n      <li>Shigeki Yamato</li>\n      <li>Shinya Yoshida</li>\n      <li><a href=\"https://dimitrisli.wordpress.com/\">Dimitrios Liapis</a></li>\n      <li>Kohei Yamamoto</li>\n      <li>Hiroto Kusuda</li>\n      <li>Jonas Lindholm</li>\n      <li>Takumi Endo</li>\n      <li>Gabi Merten</li>\n      <li>Ben Hale</li>\n      <li>Eiji Hachiya</li>\n      <li>Hideyuki Kikuma</li>\n      <li>Park Sungchul</li>\n      <li>Eiji Yamane</li>\n      <li>Akinori Ikeda</li>\n      <li>Jun Nakamura</li>\n      <li>Takuya Shimabukuro</li>\n      <li>Setsu Fujita</li>\n      <li>Jochen Winzen</li>\n      <li>Yousuke Tezuka</li>\n      <li>Shimizu  Yasuhiro</li>\n      <li><a href=\"https://twitter.com/kabao\">Satoshi Okano</a></li>\n      <li>Yasuyuki Fukai</li>\n      <li>Charles Goddard</li>\n      <li>Tiarê Balbi Bonamini</li>\n      <li>Kazumune Katagiri</li>\n      <li>Masahiro Wakame</li>\n      <li>Kazutaka Ogaki</li>\n      <li>Taizo Nakatani</li>\n      <li>Yoshitaka Kawaji</li>\n      <li>Akihiro Kitada</li>\n      <li>Kozaki Tsuneaki</li>\n      <li>Takehiro Inoue</li>\n      <li>Shigeki Shoji</li>\n      <li>Junya Suzuki</li>\n      <li>Tomoharu Nagasawa</li>\n      <li>Toby Lee</li>\n      <li>Yuichiro Mukai</li>\n      <li>Hiroyuki Yamaoka</li>\n      <li>Jun Sagawa</li>\n      <li>Soma Kuwabara</li>\n      <li>Yui Iwamatsu</li>\n      <li>Michael Schlechter</li>\n      <li><a href=\"https://twitter.com/itohiro73\">Hiroshi Ito</a></li>\n      <li>Tae-jun Jin</li>\n      <li>Dennis Rippinger</li>\n      <li>Dejan Janosevic</li>\n      <li>Dbj Shrestha</li>\n      <li>Hideaki Takahashi</li>\n      <li><a href=\"http://www.knightso.co.jp/\">Daigo Ikeda</a></li>\n      <li>Teppei Yamaguchi</li>\n      <li>Pierre Templier</li>\n      <li>TDD Base Camp</li>\n      <li>Hirofumi Nozaki</li>\n      <li>Takayuki Hayashi</li>\n      <li>Steven Christou</li>\n      <li>Kostadin Golev</li>\n      <li>Ricardo Gladwell</li>\n      <li>Thorsten Hoeger</li>\n      <li><a href=\"http://www.shino.de/blog\">Markus Gärtner</a></li>\n      <li>Hiroyuki Aoki</li>\n      <li>Gary Fleming</li>\n      <li>Samuel Eickelberg</li>\n      <li>Marcel Berschneider</li>\n      <li>Frank Jakop</li>\n      <li>Dominik Lange</li>\n      <li>Stefan Matzdorf</li>\n      <li>Suzanne Hamilton</li>\n      <li>Satoru Kimura</li>\n      <li>今井一幾</li>\n      <li>Yasuharu Nakano</li>\n      <li>Takatoshi Kawamura</li>\n\t\t</ul>\n  </body>\n</html>\n"
  },
  {
    "path": "src/site/xhtml/junit-lambda-spending.xhtml",
    "content": "<html>\n  <head>\n    <title>JUnit Lambda - Campaign Spending</title>\n  </head>\n  <body>\n\t\t<h1>JUnit Lambda - Spending</h1>\n    <p>\n      Since all the money is going through the books of a company (andrena objects ag),\n      the exact amount for taxes cannot be calculated. We will fill in details and\n      exact amounts for other positions as soon as we have them.\n    </p>\n    <table>\n      <tr><th>What</th><th style=\"text-align: right\">Credit/EUR</th><th style=\"text-align: right\">Debit/EUR</th><th style=\"text-align: right\">Balance/EUR</th></tr>\n      <tr><td>Indiegogo Sum</td><td style=\"text-align: right\">€53,937.00</td><td></td><td style=\"text-align: right\">€53,937.00</td></tr>\n      <tr><td>Indiegogo Fees (5%)</td><td></td><td style=\"text-align: right\">€2,696.85</td><td style=\"text-align: right\">€51,240.15</td></tr>\n      <tr><td>Paypal Fees</td><td></td><td style=\"text-align: right\">€2,270.06</td><td style=\"text-align: right\">€48,970.09</td></tr>\n      <tr><td>German VAT (estimated)</td><td></td><td style=\"text-align: right\">€7,666.49</td><td style=\"text-align: right\">€41,303.60</td></tr>\n      <tr><td>Kick-off Expenses, Travel and Food</td><td></td><td style=\"text-align: right\">€3,011.32</td><td style=\"text-align: right\">€38,292.28</td></tr>\n      <tr><td>Development October 2015</td><td></td><td style=\"text-align: right\">€14,000.00</td><td style=\"text-align: right\">€24,292.28</td></tr>\n      <tr><td>Development November 2015</td><td></td><td style=\"text-align: right\">€7,600.00</td><td style=\"text-align: right\">€16,692.28</td></tr>\n      <tr><td>Development December 2015</td><td></td><td style=\"text-align: right\">€5,400.00</td><td style=\"text-align: right\">€11,292.28</td></tr>\n      <tr><td>Travel Expenses December 2015</td><td></td><td style=\"text-align: right\">€749.69</td><td style=\"text-align: right\">€10,542.59</td></tr>\n      <tr><td>Development January 2016</td><td></td><td style=\"text-align: right\">€6,000.00</td><td style=\"text-align: right\">€4,542.59</td></tr>\n      <tr><td>Travel Expenses January 2016</td><td></td><td style=\"text-align: right\">€1,001.13</td><td style=\"text-align: right\">€3,541.46</td></tr>\n      <tr><td>Development April 2016</td><td></td><td style=\"text-align: right\">€1,200.00</td><td style=\"text-align: right\">€2,341.46</td></tr>\n      <tr><td>Development August 2016</td><td></td><td style=\"text-align: right\">€2,341.46</td><td style=\"text-align: right\">€0.00</td></tr>\n    </table>\n  </body>\n</html>\n"
  },
  {
    "path": "src/site/xhtml/junit-lambda.xhtml",
    "content": "<html>\n  <head>\n    <title>JUnit Lambda</title>\n  </head>\n  <body>\n\t\t<h1>JUnit Lambda</h1>\n    <p>\n      <em>JUnit Lambda</em> was the working title for\n      what has now become <a href=\"http://junit.org/junit5/\">JUnit 5</a>.\n    </p>\n    <p>\n      The initial phases of this work <a href=\"junit-lambda-campaign.html\">were enabled by a crowdfunding campaign on Indiegogo</a>.\n    </p>\n    <hr />\n    <h2>Campaign Spending</h2>\n    <p>\n      As part of our accountability we agreed to make <a href=\"junit-lambda-spending.html\">all campaign spending transparent</a>.\n    </p>\n\t\t<hr />\n\t\t<h2>Main Sponsors and Campaign Sponsor</h2>\n\t\t<p>Without sponsoring JUnit Lambda would not exist. We're especially grateful to the companies below:</p>\n\t\t<ul class=\"inline sponsors sponsors-large\">\n\t\t\t<li><a href=\"http://www.andrena.de\" title=\"andrena objects ag, Germany\"><img src=\"images/junit-lambda/sponsors/andrena.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.heidelberg-mobil.com\" title=\"Heidelberg Mobil International GmbH, Germany\"><img src=\"images/junit-lambda/sponsors/heidelberg-mobil.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.namics.com\" title=\"Namics (Deutschland) GmbH, Germany\"><img src=\"images/junit-lambda/sponsors/namics.png\" /></a></li>\n\t\t\t<li><a href=\"http://pivotal.io/\" title=\"Pivotal Software, Inc., U.S.A.\"><img src=\"images/junit-lambda/sponsors/pivotal.png\" /></a></li>\n\t\t\t<li><a href=\"http://www.americanexpress.com/\" title=\"American Express Company\"><img src=\"images/junit-lambda/sponsors/amex.png\" /></a></li>\n\t\t</ul>\n  </body>\n</html>\n"
  },
  {
    "path": "src/site/xhtml/junit5.xhtml",
    "content": "<html>\n  <head>\n    <title>JUnit 5</title>\n  </head>\n  <body>\n\t\t<h1>JUnit 5</h1>\n    <p>\n      This page has moved to <a href=\"https://junit.org/\">https://junit.org/</a>.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "src/test/java/junit/samples/AllTests.java",
    "content": "package junit.samples;\n\nimport junit.framework.Test;\nimport junit.framework.TestSuite;\n\n/**\n * TestSuite that runs all the sample tests\n */\npublic class AllTests {\n\n    public static void main(String[] args) {\n        junit.textui.TestRunner.run(suite());\n    }\n\n    public static Test suite() {\n        TestSuite suite = new TestSuite(\"All JUnit Tests\");\n        suite.addTest(ListTest.suite());\n        suite.addTest(new TestSuite(junit.samples.money.MoneyTest.class));\n        suite.addTest(junit.tests.AllTests.suite());\n        return suite;\n    }\n}"
  },
  {
    "path": "src/test/java/junit/samples/ListTest.java",
    "content": "package junit.samples;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\n\n/**\n * A sample test case, testing {@link java.util.ArrayList}.\n */\npublic class ListTest extends TestCase {\n    private List<Integer> emptyList;\n    private List<Integer> fullList;\n\n\n    @Override\n    protected void setUp() {\n        emptyList = new ArrayList<Integer>();\n        fullList = new ArrayList<Integer>();\n        fullList.add(1);\n        fullList.add(2);\n        fullList.add(3);\n    }\n\n    public static Test suite() {\n        return new TestSuite(ListTest.class);\n    }\n\n    public void testCapacity() {\n        int size = fullList.size();\n        for (int i = 0; i < 100; i++) {\n            fullList.add(i);\n        }\n        assertTrue(fullList.size() == 100 + size);\n    }\n\n    public void testContains() {\n        assertTrue(fullList.contains(1));\n        assertFalse(emptyList.contains(1));\n    }\n\n    public void testElementAt() {\n        int i = fullList.get(0);\n        assertEquals(1,i);\n\n        try {\n            fullList.get(fullList.size());\n        } catch (IndexOutOfBoundsException e) {\n            return;\n        }\n        fail(\"Should raise an ArrayIndexOutOfBoundsException\");\n    }\n\n    public void testRemoveAll() {\n        fullList.removeAll(fullList);\n        emptyList.removeAll(emptyList);\n        assertTrue(fullList.isEmpty());\n        assertTrue(emptyList.isEmpty());\n    }\n\n    public void testRemoveElement() {\n        fullList.remove(Integer.valueOf(3));\n        assertFalse(fullList.contains(3));\n    }\n}"
  },
  {
    "path": "src/test/java/junit/samples/SimpleTest.java",
    "content": "package junit.samples;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\n\n/**\n * Some simple tests.\n */\npublic class SimpleTest extends TestCase {\n    protected int fValue1;\n    protected int fValue2;\n\n    @Override\n    protected void setUp() {\n        fValue1 = 2;\n        fValue2 = 3;\n    }\n\n    public static Test suite() {\n\n        /*\n           * the type safe way\n           *\n          TestSuite suite= new TestSuite();\n          suite.addTest(\n              new SimpleTest(\"add\") {\n                   protected void runTest() { testAdd(); }\n              }\n          );\n\n          suite.addTest(\n              new SimpleTest(\"testDivideByZero\") {\n                   protected void runTest() { testDivideByZero(); }\n              }\n          );\n          return suite;\n          */\n\n        /*\n           * the dynamic way\n           */\n        return new TestSuite(SimpleTest.class);\n    }\n\n    public void testAdd() {\n        double result = fValue1 + fValue2;\n        // forced failure result == 5\n        assertTrue(result == 6);\n    }\n\n    public int unused;\n\n    public void testDivideByZero() {\n        int zero = 0;\n        int result = 8 / zero;\n        unused = result; // avoid warning for not using result\n    }\n\n    public void testEquals() {\n        assertEquals(12, 12);\n        assertEquals(12L, 12L);\n        assertEquals(Long.valueOf(12), Long.valueOf(12));\n\n        assertEquals(\"Size\", 12, 13);\n        assertEquals(\"Capacity\", 12.0, 11.99, 0.0);\n    }\n\n    public static void main(String[] args) {\n        junit.textui.TestRunner.run(suite());\n    }\n}"
  },
  {
    "path": "src/test/java/junit/samples/money/IMoney.java",
    "content": "package junit.samples.money;\n\n/**\n * The common interface for simple Monies and MoneyBags\n */\npublic interface IMoney {\n    /**\n     * Adds a money to this money.\n     */\n    IMoney add(IMoney m);\n\n    /**\n     * Adds a simple Money to this money. This is a helper method for\n     * implementing double dispatch\n     */\n    IMoney addMoney(Money m);\n\n    /**\n     * Adds a MoneyBag to this money. This is a helper method for\n     * implementing double dispatch\n     */\n    IMoney addMoneyBag(MoneyBag s);\n\n    /**\n     * Tests whether this money is zero\n     */\n    boolean isZero();\n\n    /**\n     * Multiplies a money by the given factor.\n     */\n    IMoney multiply(int factor);\n\n    /**\n     * Negates this money.\n     */\n    IMoney negate();\n\n    /**\n     * Subtracts a money from this money.\n     */\n    IMoney subtract(IMoney m);\n\n    /**\n     * Append this to a MoneyBag m.\n     * appendTo() needs to be public because it is used\n     * polymorphically, but it should not be used by clients\n     * because it modifies the argument m.\n     */\n    void appendTo(MoneyBag m);\n}\n"
  },
  {
    "path": "src/test/java/junit/samples/money/Money.java",
    "content": "package junit.samples.money;\n\n/**\n * A simple Money.\n */\npublic class Money implements IMoney {\n\n    private int fAmount;\n    private String fCurrency;\n\n    /**\n     * Constructs a money from the given amount and currency.\n     */\n    public Money(int amount, String currency) {\n        fAmount = amount;\n        fCurrency = currency;\n    }\n\n    /**\n     * Adds a money to this money. Forwards the request to the addMoney helper.\n     */\n    public IMoney add(IMoney m) {\n        return m.addMoney(this);\n    }\n\n    public IMoney addMoney(Money m) {\n        if (m.currency().equals(currency())) {\n            return new Money(amount() + m.amount(), currency());\n        }\n        return MoneyBag.create(this, m);\n    }\n\n    public IMoney addMoneyBag(MoneyBag s) {\n        return s.addMoney(this);\n    }\n\n    public int amount() {\n        return fAmount;\n    }\n\n    public String currency() {\n        return fCurrency;\n    }\n\n    @Override\n    public boolean equals(Object anObject) {\n        if (isZero()) {\n            if (anObject instanceof IMoney) {\n                return ((IMoney) anObject).isZero();\n            }\n        }\n        if (anObject instanceof Money) {\n            Money aMoney = (Money) anObject;\n            return aMoney.currency().equals(currency())\n                    && amount() == aMoney.amount();\n        }\n        return false;\n    }\n\n    @Override\n    public int hashCode() {\n        if (fAmount == 0) {\n            return 0;\n        }\n        return fCurrency.hashCode() + fAmount;\n    }\n\n    public boolean isZero() {\n        return amount() == 0;\n    }\n\n    public IMoney multiply(int factor) {\n        return new Money(amount() * factor, currency());\n    }\n\n    public IMoney negate() {\n        return new Money(-amount(), currency());\n    }\n\n    public IMoney subtract(IMoney m) {\n        return add(m.negate());\n    }\n\n    @Override\n    public String toString() {\n        return \"[\" + amount() + \" \" + currency() + \"]\";\n    }\n\n    public /*this makes no sense*/ void appendTo(MoneyBag m) {\n        m.appendMoney(this);\n    }\n}"
  },
  {
    "path": "src/test/java/junit/samples/money/MoneyBag.java",
    "content": "package junit.samples.money;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * A MoneyBag defers exchange rate conversions. For example adding\n * 12 Swiss Francs to 14 US Dollars is represented as a bag\n * containing the two Monies 12 CHF and 14 USD. Adding another\n * 10 Swiss francs gives a bag with 22 CHF and 14 USD. Due to\n * the deferred exchange rate conversion we can later value a\n * MoneyBag with different exchange rates.\n *\n * A MoneyBag is represented as a list of Monies and provides\n * different constructors to create a MoneyBag.\n */\npublic class MoneyBag implements IMoney {\n    private List<Money> fMonies = new ArrayList<Money>(5);\n\n    public static IMoney create(IMoney m1, IMoney m2) {\n        MoneyBag result = new MoneyBag();\n        m1.appendTo(result);\n        m2.appendTo(result);\n        return result.simplify();\n    }\n\n    public IMoney add(IMoney m) {\n        return m.addMoneyBag(this);\n    }\n\n    public IMoney addMoney(Money m) {\n        return MoneyBag.create(m, this);\n    }\n\n    public IMoney addMoneyBag(MoneyBag s) {\n        return MoneyBag.create(s, this);\n    }\n\n    void appendBag(MoneyBag aBag) {\n        for (Money each : aBag.fMonies) {\n            appendMoney(each);\n        }\n    }\n\n    void appendMoney(Money aMoney) {\n        if (aMoney.isZero()) return;\n        IMoney old = findMoney(aMoney.currency());\n        if (old == null) {\n            fMonies.add(aMoney);\n            return;\n        }\n        fMonies.remove(old);\n        Money sum = (Money) old.add(aMoney);\n        if (sum.isZero()) {\n            return;\n        }\n        fMonies.add(sum);\n    }\n\n    @Override\n    public boolean equals(Object anObject) {\n        if (isZero()) {\n            if (anObject instanceof IMoney) {\n                return ((IMoney) anObject).isZero();\n            }\n        }\n\n        if (anObject instanceof MoneyBag) {\n            MoneyBag aMoneyBag = (MoneyBag) anObject;\n            if (aMoneyBag.fMonies.size() != fMonies.size()) {\n                return false;\n            }\n\n            for (Money each : fMonies) {\n                if (!aMoneyBag.contains(each)) {\n                    return false;\n                }\n            }\n            return true;\n        }\n        return false;\n    }\n\n    private Money findMoney(String currency) {\n        for (Money each : fMonies) {\n            if (each.currency().equals(currency)) {\n                return each;\n            }\n        }\n        return null;\n    }\n\n    private boolean contains(Money m) {\n        Money found = findMoney(m.currency());\n        if (found == null) return false;\n        return found.amount() == m.amount();\n    }\n\n    @Override\n    public int hashCode() {\n        int hash = 0;\n        for (Money each : fMonies) {\n            hash ^= each.hashCode();\n        }\n        return hash;\n    }\n\n    public boolean isZero() {\n        return fMonies.size() == 0;\n    }\n\n    public IMoney multiply(int factor) {\n        MoneyBag result = new MoneyBag();\n        if (factor != 0) {\n            for (Money each : fMonies) {\n                result.appendMoney((Money) each.multiply(factor));\n            }\n        }\n        return result;\n    }\n\n    public IMoney negate() {\n        MoneyBag result = new MoneyBag();\n        for (Money each : fMonies) {\n            result.appendMoney((Money) each.negate());\n        }\n        return result;\n    }\n\n    private IMoney simplify() {\n        if (fMonies.size() == 1) {\n            return fMonies.iterator().next();\n        }\n        return this;\n    }\n\n    public IMoney subtract(IMoney m) {\n        return add(m.negate());\n    }\n\n    @Override\n    public String toString() {\n        StringBuilder sb = new StringBuilder();\n        sb.append(\"{\");\n        for (Money each : fMonies) {\n            sb.append(each);\n        }\n        sb.append(\"}\");\n        return sb.toString();\n    }\n\n    public void appendTo(MoneyBag m) {\n        m.appendBag(this);\n    }\n}"
  },
  {
    "path": "src/test/java/junit/samples/money/MoneyTest.java",
    "content": "package junit.samples.money;\n\nimport junit.framework.TestCase;\n\npublic class MoneyTest extends TestCase {\n    private Money f12CHF;\n    private Money f14CHF;\n    private Money f7USD;\n    private Money f21USD;\n\n    private IMoney fMB1;\n    private IMoney fMB2;\n\n    public static void main(String args[]) {\n        junit.textui.TestRunner.run(MoneyTest.class);\n    }\n\n    @Override\n    protected void setUp() {\n        f12CHF = new Money(12, \"CHF\");\n        f14CHF = new Money(14, \"CHF\");\n        f7USD = new Money(7, \"USD\");\n        f21USD = new Money(21, \"USD\");\n\n        fMB1 = MoneyBag.create(f12CHF, f7USD);\n        fMB2 = MoneyBag.create(f14CHF, f21USD);\n    }\n\n    public void testBagMultiply() {\n        // {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]}\n        IMoney expected = MoneyBag.create(new Money(24, \"CHF\"), new Money(14, \"USD\"));\n        assertEquals(expected, fMB1.multiply(2));\n        assertEquals(fMB1, fMB1.multiply(1));\n        assertTrue(fMB1.multiply(0).isZero());\n    }\n\n    public void testBagNegate() {\n        // {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]}\n        IMoney expected = MoneyBag.create(new Money(-12, \"CHF\"), new Money(-7, \"USD\"));\n        assertEquals(expected, fMB1.negate());\n    }\n\n    public void testBagSimpleAdd() {\n        // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]}\n        IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), new Money(7, \"USD\"));\n        assertEquals(expected, fMB1.add(f14CHF));\n    }\n\n    public void testBagSubtract() {\n        // {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]}\n        IMoney expected = MoneyBag.create(new Money(-2, \"CHF\"), new Money(-14, \"USD\"));\n        assertEquals(expected, fMB1.subtract(fMB2));\n    }\n\n    public void testBagSumAdd() {\n        // {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]}\n        IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), new Money(28, \"USD\"));\n        assertEquals(expected, fMB1.add(fMB2));\n    }\n\n    public void testIsZero() {\n        assertTrue(fMB1.subtract(fMB1).isZero());\n        assertTrue(MoneyBag.create(new Money(0, \"CHF\"), new Money(0, \"USD\")).isZero());\n    }\n\n    public void testMixedSimpleAdd() {\n        // [12 CHF] + [7 USD] == {[12 CHF][7 USD]}\n        IMoney expected = MoneyBag.create(f12CHF, f7USD);\n        assertEquals(expected, f12CHF.add(f7USD));\n    }\n\n    public void testBagNotEquals() {\n        IMoney bag = MoneyBag.create(f12CHF, f7USD);\n        assertFalse(bag.equals(new Money(12, \"DEM\").add(f7USD)));\n    }\n\n    public void testMoneyBagEquals() {\n        assertTrue(!fMB1.equals(null));\n\n        assertEquals(fMB1, fMB1);\n        IMoney equal = MoneyBag.create(new Money(12, \"CHF\"), new Money(7, \"USD\"));\n        assertTrue(fMB1.equals(equal));\n        assertTrue(!fMB1.equals(f12CHF));\n        assertTrue(!f12CHF.equals(fMB1));\n        assertTrue(!fMB1.equals(fMB2));\n    }\n\n    public void testMoneyBagHash() {\n        IMoney equal = MoneyBag.create(new Money(12, \"CHF\"), new Money(7, \"USD\"));\n        assertEquals(fMB1.hashCode(), equal.hashCode());\n    }\n\n    public void testMoneyEquals() {\n        assertTrue(!f12CHF.equals(null));\n        Money equalMoney = new Money(12, \"CHF\");\n        assertEquals(f12CHF, f12CHF);\n        assertEquals(f12CHF, equalMoney);\n        assertEquals(f12CHF.hashCode(), equalMoney.hashCode());\n        assertTrue(!f12CHF.equals(f14CHF));\n    }\n\n    public void testMoneyHash() {\n        assertTrue(!f12CHF.equals(null));\n        Money equal = new Money(12, \"CHF\");\n        assertEquals(f12CHF.hashCode(), equal.hashCode());\n    }\n\n    public void testSimplify() {\n        IMoney money = MoneyBag.create(new Money(26, \"CHF\"), new Money(28, \"CHF\"));\n        assertEquals(new Money(54, \"CHF\"), money);\n    }\n\n    public void testNormalize2() {\n        // {[12 CHF][7 USD]} - [12 CHF] == [7 USD]\n        Money expected = new Money(7, \"USD\");\n        assertEquals(expected, fMB1.subtract(f12CHF));\n    }\n\n    public void testNormalize3() {\n        // {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD]\n        IMoney ms1 = MoneyBag.create(new Money(12, \"CHF\"), new Money(3, \"USD\"));\n        Money expected = new Money(4, \"USD\");\n        assertEquals(expected, fMB1.subtract(ms1));\n    }\n\n    public void testNormalize4() {\n        // [12 CHF] - {[12 CHF][3 USD]} == [-3 USD]\n        IMoney ms1 = MoneyBag.create(new Money(12, \"CHF\"), new Money(3, \"USD\"));\n        Money expected = new Money(-3, \"USD\");\n        assertEquals(expected, f12CHF.subtract(ms1));\n    }\n\n    public void testPrint() {\n        assertEquals(\"[12 CHF]\", f12CHF.toString());\n    }\n\n    public void testSimpleAdd() {\n        // [12 CHF] + [14 CHF] == [26 CHF]\n        Money expected = new Money(26, \"CHF\");\n        assertEquals(expected, f12CHF.add(f14CHF));\n    }\n\n    public void testSimpleBagAdd() {\n        // [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]}\n        IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), new Money(7, \"USD\"));\n        assertEquals(expected, f14CHF.add(fMB1));\n    }\n\n    public void testSimpleMultiply() {\n        // [14 CHF] *2 == [28 CHF]\n        Money expected = new Money(28, \"CHF\");\n        assertEquals(expected, f14CHF.multiply(2));\n    }\n\n    public void testSimpleNegate() {\n        // [14 CHF] negate == [-14 CHF]\n        Money expected = new Money(-14, \"CHF\");\n        assertEquals(expected, f14CHF.negate());\n    }\n\n    public void testSimpleSubtract() {\n        // [14 CHF] - [12 CHF] == [2 CHF]\n        Money expected = new Money(2, \"CHF\");\n        assertEquals(expected, f14CHF.subtract(f12CHF));\n    }\n}"
  },
  {
    "path": "src/test/java/junit/samples/money/package-info.java",
    "content": "/**\n * Example \"Money\" for JUnit v3.x.\n */\npackage junit.samples.money;"
  },
  {
    "path": "src/test/java/junit/samples/package-info.java",
    "content": "/**\n * JUnit v3.x examples.\n */\npackage junit.samples;"
  },
  {
    "path": "src/test/java/junit/tests/AllTests.java",
    "content": "package junit.tests;\n\nimport junit.framework.Test;\nimport junit.framework.TestSuite;\n\n/**\n * TestSuite that runs all the JUnit tests\n */\npublic class AllTests {\n\n    public static void main(String[] args) {\n        junit.textui.TestRunner.run(suite());\n    }\n\n    public static Test suite() {\n        TestSuite suite = new TestSuite(\"Framework Tests\");\n        suite.addTest(junit.tests.framework.AllTests.suite());\n        suite.addTest(junit.tests.runner.AllTests.suite());\n        suite.addTest(junit.tests.extensions.AllTests.suite());\n        return suite;\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/SampleJUnit3Tests.java",
    "content": "package junit.tests;\n\nimport junit.framework.TestCase;\n\n/**\n * Container for sample JUnit3-style tests used in integration tests.\n */\npublic class SampleJUnit3Tests {\n\n    public static class TestWithOneThrowingTestMethod extends TestCase {\n\n        public void testAlwaysThrows() {\n            new FakeClassUnderTest().throwsExceptionWithoutCause();\n        }\n    }\n\n    public static class TestWithThrowingSetUpMethod extends TestCase {\n\n        @Override\n        protected void setUp() throws Exception {\n            super.setUp();\n            new FakeClassUnderTest().throwsExceptionWithoutCause();\n        }\n\n        public void testAlwaysPasses() {\n        }\n    }\n\n    private static class FakeClassUnderTest {\n\n        public void throwsExceptionWithCause() {\n            doThrowExceptionWithCause();\n        }\n\n        public void throwsExceptionWithoutCause() {\n            doThrowExceptionWithoutCause();\n        }\n\n        private void doThrowExceptionWithCause() {\n            try {\n                throwsExceptionWithoutCause();\n            } catch (Exception e) {\n                throw new RuntimeException(\"outer\", e);\n            }\n        }\n\n        private void doThrowExceptionWithoutCause() {\n            throw new RuntimeException(\"cause\");\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/WasRun.java",
    "content": "package junit.tests;\n\nimport junit.framework.TestCase;\n\n/**\n * A helper test case for testing whether the testing method\n * is run.\n */\npublic class WasRun extends TestCase {\n    public boolean fWasRun = false;\n\n    @Override\n    protected void runTest() {\n        fWasRun = true;\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/extensions/ActiveTestTest.java",
    "content": "package junit.tests.extensions;\n\nimport junit.extensions.ActiveTestSuite;\nimport junit.extensions.RepeatedTest;\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\n\n/**\n * Testing the ActiveTest support\n */\npublic class ActiveTestTest extends TestCase {\n\n    public static class SuccessTest extends TestCase {\n        @Override\n        public void runTest() {\n        }\n    }\n\n    public void testActiveTest() {\n        Test test = createActiveTestSuite();\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(100, result.runCount());\n        assertEquals(0, result.failureCount());\n        assertEquals(0, result.errorCount());\n    }\n\n    public void testActiveRepeatedTest() {\n        Test test = new RepeatedTest(createActiveTestSuite(), 5);\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(500, result.runCount());\n        assertEquals(0, result.failureCount());\n        assertEquals(0, result.errorCount());\n    }\n\n    public void testActiveRepeatedTest0() {\n        Test test = new RepeatedTest(createActiveTestSuite(), 0);\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(0, result.runCount());\n        assertEquals(0, result.failureCount());\n        assertEquals(0, result.errorCount());\n    }\n\n    public void testActiveRepeatedTest1() {\n        Test test = new RepeatedTest(createActiveTestSuite(), 1);\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(100, result.runCount());\n        assertEquals(0, result.failureCount());\n        assertEquals(0, result.errorCount());\n    }\n\n    ActiveTestSuite createActiveTestSuite() {\n        ActiveTestSuite suite = new ActiveTestSuite();\n        for (int i = 0; i < 100; i++) {\n            suite.addTest(new SuccessTest());\n        }\n        return suite;\n    }\n\n}"
  },
  {
    "path": "src/test/java/junit/tests/extensions/AllTests.java",
    "content": "package junit.tests.extensions;\n\nimport junit.framework.Test;\nimport junit.framework.TestSuite;\n\n/**\n * TestSuite that runs all the extension tests\n */\npublic class AllTests {\n\n    public static void main(String[] args) {\n        junit.textui.TestRunner.run(suite());\n    }\n\n    public static Test suite() { // Collect tests manually because we have to test class collection code\n        TestSuite suite = new TestSuite(\"Framework Tests\");\n        suite.addTestSuite(ExtensionTest.class);\n        suite.addTestSuite(ActiveTestTest.class);\n        suite.addTestSuite(RepeatedTestTest.class);\n        return suite;\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/extensions/ExtensionTest.java",
    "content": "package junit.tests.extensions;\n\nimport junit.extensions.TestSetup;\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\nimport junit.tests.WasRun;\n\n/**\n * A test case testing the extensions to the testing framework.\n */\npublic class ExtensionTest extends TestCase {\n    static class TornDown extends TestSetup {\n        boolean fTornDown = false;\n\n        TornDown(Test test) {\n            super(test);\n        }\n\n        @Override\n        protected void tearDown() {\n            fTornDown = true;\n        }\n    }\n\n    public void testRunningErrorInTestSetup() {\n        TestCase test = new TestCase(\"failure\") {\n            @Override\n            public void runTest() {\n                fail();\n            }\n        };\n\n        TestSetup wrapper = new TestSetup(test);\n\n        TestResult result = new TestResult();\n        wrapper.run(result);\n        assertTrue(!result.wasSuccessful());\n    }\n\n    public void testRunningErrorsInTestSetup() {\n        TestCase failure = new TestCase(\"failure\") {\n            @Override\n            public void runTest() {\n                fail();\n            }\n        };\n\n        TestCase error = new TestCase(\"error\") {\n            @Override\n            public void runTest() {\n                throw new Error();\n            }\n        };\n\n        TestSuite suite = new TestSuite();\n        suite.addTest(failure);\n        suite.addTest(error);\n\n        TestSetup wrapper = new TestSetup(suite);\n\n        TestResult result = new TestResult();\n        wrapper.run(result);\n\n        assertEquals(1, result.failureCount());\n        assertEquals(1, result.errorCount());\n    }\n\n    public void testSetupErrorDontTearDown() {\n        WasRun test = new WasRun();\n\n        TornDown wrapper = new TornDown(test) {\n            @SuppressWarnings(\"deprecation\")\n            @Override\n            public void setUp() {\n                fail();\n            }\n        };\n\n        TestResult result = new TestResult();\n        wrapper.run(result);\n\n        assertTrue(!wrapper.fTornDown);\n    }\n\n    public void testSetupErrorInTestSetup() {\n        WasRun test = new WasRun();\n\n        TestSetup wrapper = new TestSetup(test) {\n            @SuppressWarnings(\"deprecation\")\n            @Override\n            public void setUp() {\n                fail();\n            }\n        };\n\n        TestResult result = new TestResult();\n        wrapper.run(result);\n\n        assertTrue(!test.fWasRun);\n        assertTrue(!result.wasSuccessful());\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/extensions/RepeatedTestTest.java",
    "content": "package junit.tests.extensions;\n\nimport junit.extensions.RepeatedTest;\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\n\n/**\n * Testing the RepeatedTest support.\n */\npublic class RepeatedTestTest extends TestCase {\n    private TestSuite fSuite;\n\n    public static class SuccessTest extends TestCase {\n\n        @Override\n        public void runTest() {\n        }\n    }\n\n    public RepeatedTestTest(String name) {\n        super(name);\n        fSuite = new TestSuite();\n        fSuite.addTest(new SuccessTest());\n        fSuite.addTest(new SuccessTest());\n    }\n\n    public void testRepeatedOnce() {\n        Test test = new RepeatedTest(fSuite, 1);\n        assertEquals(2, test.countTestCases());\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(2, result.runCount());\n    }\n\n    public void testRepeatedMoreThanOnce() {\n        Test test = new RepeatedTest(fSuite, 3);\n        assertEquals(6, test.countTestCases());\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(6, result.runCount());\n    }\n\n    public void testRepeatedZero() {\n        Test test = new RepeatedTest(fSuite, 0);\n        assertEquals(0, test.countTestCases());\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(0, result.runCount());\n    }\n\n    public void testRepeatedNegative() {\n        try {\n            new RepeatedTest(fSuite, -1);\n        } catch (IllegalArgumentException e) {\n            assertTrue(e.getMessage().contains(\">=\"));\n            return;\n        }\n        fail(\"Should throw an IllegalArgumentException\");\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/extensions/package-info.java",
    "content": "/**\n * Tests for the JUnit v3.x extension functionality.\n */\npackage junit.tests.extensions;"
  },
  {
    "path": "src/test/java/junit/tests/framework/AllTests.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.Test;\nimport junit.framework.TestSuite;\n\n/**\n * TestSuite that runs all the sample tests\n */\npublic class AllTests {\n\n    public static void main(String[] args) {\n        junit.textui.TestRunner.run(suite());\n    }\n\n    public static Test suite() {\n        TestSuite suite = new TestSuite(\"Framework Tests\");\n        suite.addTestSuite(TestCaseTest.class);\n        suite.addTest(SuiteTest.suite()); // Tests suite building, so can't use automatic test extraction\n        suite.addTestSuite(TestListenerTest.class);\n        suite.addTestSuite(AssertionFailedErrorTest.class);\n        suite.addTestSuite(AssertTest.class);\n        suite.addTestSuite(TestImplementorTest.class);\n        suite.addTestSuite(NoArgTestCaseTest.class);\n        suite.addTestSuite(ComparisonCompactorTest.class);\n        suite.addTestSuite(ComparisonFailureTest.class);\n        suite.addTestSuite(DoublePrecisionAssertTest.class);\n        suite.addTestSuite(FloatAssertTest.class);\n        return suite;\n    }\n\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/AssertTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.ComparisonFailure;\nimport junit.framework.TestCase;\n\npublic class AssertTest extends TestCase {\n\n    /* In the tests that follow, we can't use standard formatting\n      * for exception tests:\n      *     try {\n      *         somethingThatShouldThrow();\n      *         fail();\n      *     catch (AssertionFailedError e) {\n      *     }\n      * because fail() would never be reported.\n      */\n    public void testFail() {\n        // Also, we are testing fail, so we can't rely on fail() working.\n        // We have to throw the exception manually.\n        try {\n            fail();\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        throw new AssertionFailedError();\n    }\n\n    public void testAssertionFailedErrorToStringWithNoMessage() {\n        // Also, we are testing fail, so we can't rely on fail() working.\n        // We have to throw the exception manually.\n        try {\n            fail();\n        } catch (AssertionFailedError e) {\n            assertEquals(\"junit.framework.AssertionFailedError\", e.toString());\n            return;\n        }\n        throw new AssertionFailedError();\n    }\n\n    public void testAssertionFailedErrorToStringWithMessage() {\n        // Also, we are testing fail, so we can't rely on fail() working.\n        // We have to throw the exception manually.\n        try {\n            fail(\"woops!\");\n        } catch (AssertionFailedError e) {\n            assertEquals(\"junit.framework.AssertionFailedError: woops!\", e.toString());\n            return;\n        }\n        throw new AssertionFailedError();\n    }\n\n    public void testAssertEquals() {\n        Object o = new Object();\n        assertEquals(o, o);\n        try {\n            assertEquals(new Object(), new Object());\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertEqualsNull() {\n        assertEquals((Object) null, (Object) null);\n    }\n\n    public void testAssertStringEquals() {\n        assertEquals(\"a\", \"a\");\n    }\n\n    public void testAssertNullNotEqualsString() {\n        try {\n            assertEquals(null, \"foo\");\n            fail();\n        } catch (ComparisonFailure e) {\n        }\n    }\n\n    public void testAssertStringNotEqualsNull() {\n        try {\n            assertEquals(\"foo\", null);\n            fail();\n        } catch (ComparisonFailure e) {\n            assertNotNull(e.getMessage());\n        }\n    }\n\n    public void testAssertNullNotEqualsNull() {\n        try {\n            assertEquals(null, new Object());\n        } catch (AssertionFailedError e) {\n            assertNotNull(e.getMessage());\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNull() {\n        assertNull(null);\n        try {\n            assertNull(new Object());\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNotNull() {\n        assertNotNull(new Object());\n        try {\n            assertNotNull(null);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertTrue() {\n        assertTrue(true);\n        try {\n            assertTrue(false);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertFalse() {\n        assertFalse(false);\n        try {\n            assertFalse(true);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertSame() {\n        Object o = new Object();\n        assertSame(o, o);\n        try {\n            assertSame(new MyInt(1), new MyInt(1));\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNotSame() {\n        assertNotSame(new MyInt(1), null);\n        assertNotSame(null, new MyInt(1));\n        assertNotSame(new MyInt(1), new MyInt(1));\n        try {\n            MyInt obj = new MyInt(1);\n            assertNotSame(obj, obj);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNotSameFailsNull() {\n        try {\n            assertNotSame(null, null);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    private static final class MyInt {\n        private final int value;\n\n        MyInt(int value) {\n            this.value = value;\n        }\n\n        @Override\n        public boolean equals(Object obj) {\n            return obj instanceof MyInt && value == ((MyInt) obj).value;\n        }\n\n        @Override\n        public int hashCode() {\n            return value;\n        }\n\n        @Override\n        public String toString() {\n            return Integer.toString(value);\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/AssertionFailedErrorTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.TestCase;\n\npublic class AssertionFailedErrorTest extends TestCase {\n    private static final String ARBITRARY_MESSAGE = \"arbitrary message\";\n\n    public void testCreateErrorWithoutMessage() throws Exception {\n        AssertionFailedError error = new AssertionFailedError();\n        assertNull(error.getMessage());\n    }\n\n    public void testCreateErrorWithMessage() throws Exception {\n        AssertionFailedError error = new AssertionFailedError(ARBITRARY_MESSAGE);\n        assertEquals(ARBITRARY_MESSAGE, error.getMessage());\n    }\n\n    public void testCreateErrorWithoutMessageInsteadOfNull() throws Exception {\n        AssertionFailedError error = new AssertionFailedError(null);\n        assertEquals(\"\", error.getMessage());\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/ComparisonCompactorTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.ComparisonCompactor;\nimport junit.framework.TestCase;\n\npublic class ComparisonCompactorTest extends TestCase {\n\n    public void testMessage() {\n        String failure = new ComparisonCompactor(0, \"b\", \"c\").compact(\"a\");\n        assertTrue(\"a expected:<[b]> but was:<[c]>\".equals(failure));\n    }\n\n    public void testStartSame() {\n        String failure = new ComparisonCompactor(1, \"ba\", \"bc\").compact(null);\n        assertEquals(\"expected:<b[a]> but was:<b[c]>\", failure);\n    }\n\n    public void testEndSame() {\n        String failure = new ComparisonCompactor(1, \"ab\", \"cb\").compact(null);\n        assertEquals(\"expected:<[a]b> but was:<[c]b>\", failure);\n    }\n\n    public void testSame() {\n        String failure = new ComparisonCompactor(1, \"ab\", \"ab\").compact(null);\n        assertEquals(\"expected:<ab> but was:<ab>\", failure);\n    }\n\n    public void testNoContextStartAndEndSame() {\n        String failure = new ComparisonCompactor(0, \"abc\", \"adc\").compact(null);\n        assertEquals(\"expected:<...[b]...> but was:<...[d]...>\", failure);\n    }\n\n    public void testStartAndEndContext() {\n        String failure = new ComparisonCompactor(1, \"abc\", \"adc\").compact(null);\n        assertEquals(\"expected:<a[b]c> but was:<a[d]c>\", failure);\n    }\n\n    public void testStartAndEndContextWithEllipses() {\n        String failure = new ComparisonCompactor(1, \"abcde\", \"abfde\").compact(null);\n        assertEquals(\"expected:<...b[c]d...> but was:<...b[f]d...>\", failure);\n    }\n\n    public void testComparisonErrorStartSameComplete() {\n        String failure = new ComparisonCompactor(2, \"ab\", \"abc\").compact(null);\n        assertEquals(\"expected:<ab[]> but was:<ab[c]>\", failure);\n    }\n\n    public void testComparisonErrorEndSameComplete() {\n        String failure = new ComparisonCompactor(0, \"bc\", \"abc\").compact(null);\n        assertEquals(\"expected:<[]...> but was:<[a]...>\", failure);\n    }\n\n    public void testComparisonErrorEndSameCompleteContext() {\n        String failure = new ComparisonCompactor(2, \"bc\", \"abc\").compact(null);\n        assertEquals(\"expected:<[]bc> but was:<[a]bc>\", failure);\n    }\n\n    public void testComparisonErrorOverlappingMatches() {\n        String failure = new ComparisonCompactor(0, \"abc\", \"abbc\").compact(null);\n        assertEquals(\"expected:<...[]...> but was:<...[b]...>\", failure);\n    }\n\n    public void testComparisonErrorOverlappingMatchesContext() {\n        String failure = new ComparisonCompactor(2, \"abc\", \"abbc\").compact(null);\n        assertEquals(\"expected:<ab[]c> but was:<ab[b]c>\", failure);\n    }\n\n    public void testComparisonErrorOverlappingMatches2() {\n        String failure = new ComparisonCompactor(0, \"abcdde\", \"abcde\").compact(null);\n        assertEquals(\"expected:<...[d]...> but was:<...[]...>\", failure);\n    }\n\n    public void testComparisonErrorOverlappingMatches2Context() {\n        String failure = new ComparisonCompactor(2, \"abcdde\", \"abcde\").compact(null);\n        assertEquals(\"expected:<...cd[d]e> but was:<...cd[]e>\", failure);\n    }\n\n    public void testComparisonErrorWithActualNull() {\n        String failure = new ComparisonCompactor(0, \"a\", null).compact(null);\n        assertEquals(\"expected:<a> but was:<null>\", failure);\n    }\n\n    public void testComparisonErrorWithActualNullContext() {\n        String failure = new ComparisonCompactor(2, \"a\", null).compact(null);\n        assertEquals(\"expected:<a> but was:<null>\", failure);\n    }\n\n    public void testComparisonErrorWithExpectedNull() {\n        String failure = new ComparisonCompactor(0, null, \"a\").compact(null);\n        assertEquals(\"expected:<null> but was:<a>\", failure);\n    }\n\n    public void testComparisonErrorWithExpectedNullContext() {\n        String failure = new ComparisonCompactor(2, null, \"a\").compact(null);\n        assertEquals(\"expected:<null> but was:<a>\", failure);\n    }\n\n    public void testBug609972() {\n        String failure = new ComparisonCompactor(10, \"S&P500\", \"0\").compact(null);\n        assertEquals(\"expected:<[S&P50]0> but was:<[]0>\", failure);\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/ComparisonFailureTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.ComparisonFailure;\nimport junit.framework.TestCase;\n\npublic class ComparisonFailureTest extends TestCase {\n\n    // Most of the tests are in ComparisonCompactorTest\n    public void testConnection() {\n        ComparisonFailure failure = new ComparisonFailure(\"warning\", \"Mary had a little lamb\", \"Mary had the little lamb\");\n        assertEquals(\"warning expected:<Mary had [a] little lamb> but was:<Mary had [the] little lamb>\", failure.getMessage());\n    }\n\n    // This is like an instanceof test.\n    public void testThrowing() {\n        try {\n            assertEquals(\"a\", \"b\");\n        } catch (ComparisonFailure e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testExceptionToStringWithMessage() {\n        try {\n            assertEquals(\"woops!\", \"a\", \"b\");\n        } catch (ComparisonFailure e) {\n            if (!e.toString().startsWith(\"junit.framework.ComparisonFailure: woops! expected:<\")) {\n                fail(\"Unexpected message: \" + e);\n            }\n            return;\n        }\n        fail();\n    }\n\n    public void testExceptionToStringWithoutMessage() {\n        try {\n            assertEquals(\"a\", \"b\");\n        } catch (ComparisonFailure e) {\n            if (!e.toString().startsWith(\"junit.framework.ComparisonFailure: expected:<\")) {\n                fail(\"Unexpected message: \" + e);\n            }\n            return;\n        }\n        fail();\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/DoublePrecisionAssertTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.TestCase;\n\npublic class DoublePrecisionAssertTest extends TestCase {\n\n    /**\n     * Test for the special Double.NaN value.\n     */\n    public void testAssertEqualsNaNFails() {\n        try {\n            assertEquals(1.234, Double.NaN, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNaNEqualsFails() {\n        try {\n            assertEquals(Double.NaN, 1.234, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNaNEqualsNaN() {\n        assertEquals(Double.NaN, Double.NaN, 0.0);\n    }\n\n    public void testAssertPosInfinityNotEqualsNegInfinity() {\n        try {\n            assertEquals(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertPosInfinityNotEquals() {\n        try {\n            assertEquals(Double.POSITIVE_INFINITY, 1.23, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertPosInfinityEqualsInfinity() {\n        assertEquals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 0.0);\n    }\n\n    public void testAssertNegInfinityEqualsInfinity() {\n        assertEquals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0);\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/Failure.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\n/**\n * A test case testing the testing framework.\n */\npublic class Failure extends TestCase {\n    @Override\n    public void runTest() {\n        fail();\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/FloatAssertTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.TestCase;\n\npublic class FloatAssertTest extends TestCase {\n\n    /**\n     * Test for the special Double.NaN value.\n     */\n    public void testAssertEqualsNaNFails() {\n        try {\n            assertEquals(1.234f, Float.NaN, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNaNEqualsFails() {\n        try {\n            assertEquals(Float.NaN, 1.234f, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertNaNEqualsNaN() {\n        assertEquals(Float.NaN, Float.NaN, 0.0);\n    }\n\n    public void testAssertPosInfinityNotEqualsNegInfinity() {\n        try {\n            assertEquals(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertPosInfinityNotEquals() {\n        try {\n            assertEquals(Float.POSITIVE_INFINITY, 1.23f, 0.0);\n        } catch (AssertionFailedError e) {\n            return;\n        }\n        fail();\n    }\n\n    public void testAssertPosInfinityEqualsInfinity() {\n        assertEquals(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 0.0);\n    }\n\n    public void testAssertNegInfinityEqualsInfinity() {\n        assertEquals(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, 0.0);\n    }\n\n    public void testAllInfinities() {\n        assertEquals(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY);\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/InheritedTestCase.java",
    "content": "package junit.tests.framework;\n\n/**\n * Test class used in SuiteTest\n */\npublic class InheritedTestCase extends OneTestCase {\n    public void test2() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/NoArgTestCaseTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\npublic class NoArgTestCaseTest extends TestCase {\n    public void testNothing() { // If this compiles, the no arg ctor is there\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/NoTestCaseClass.java",
    "content": "package junit.tests.framework;\n\n/**\n * Test class used in SuiteTest\n */\npublic class NoTestCaseClass extends Object {\n    public void testSuccess() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/NoTestCases.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\n/**\n * Test class used in SuiteTest\n */\npublic class NoTestCases extends TestCase {\n    public void noTestCase() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/NotPublicTestCase.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\n/**\n * Test class used in SuiteTest\n */\npublic class NotPublicTestCase extends TestCase {\n    protected void testNotPublic() {\n    }\n\n    public void testPublic() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/NotVoidTestCase.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\n/**\n * Test class used in SuiteTest\n */\npublic class NotVoidTestCase extends TestCase {\n    public int testNotVoid() {\n        return 1;\n    }\n\n    public void testVoid() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/OneTestCase.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\n/**\n * Test class used in SuiteTest\n */\npublic class OneTestCase extends TestCase {\n    public void noTestCase() {\n    }\n\n    public void testCase() {\n    }\n\n    public void testCase(int arg) {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/OverrideTestCase.java",
    "content": "package junit.tests.framework;\n\n/**\n * Test class used in SuiteTest\n */\npublic class OverrideTestCase extends OneTestCase {\n    @Override\n    public void testCase() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/Success.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\n/**\n * A test case testing the testing framework.\n */\npublic class Success extends TestCase {\n\n    @Override\n    public void runTest() {\n    }\n\n    public void testSuccess() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/SuiteTest.java",
    "content": "package junit.tests.framework;\n\nimport java.util.Collections;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\n\n/**\n * A fixture for testing the \"auto\" test suite feature.\n */\npublic class SuiteTest extends TestCase {\n    protected TestResult fResult;\n\n    public SuiteTest(String name) {\n        super(name);\n    }\n\n    @Override\n    protected void setUp() {\n        fResult = new TestResult();\n    }\n\n    public static Test suite() {\n        TestSuite suite = new TestSuite(\"Suite Tests\");\n        // build the suite manually, because some of the suites are testing\n        // the functionality that automatically builds suites\n        suite.addTest(new SuiteTest(\"testNoTestCases\"));\n        suite.addTest(new SuiteTest(\"testOneTestCase\"));\n        suite.addTest(new SuiteTest(\"testNotPublicTestCase\"));\n        suite.addTest(new SuiteTest(\"testNotVoidTestCase\"));\n        suite.addTest(new SuiteTest(\"testNotExistingTestCase\"));\n        suite.addTest(new SuiteTest(\"testInheritedTests\"));\n        suite.addTest(new SuiteTest(\"testOneTestCaseEclipseSeesSameStructureAs381\"));\n        suite.addTest(new SuiteTest(\"testNoTestCaseClass\"));\n        suite.addTest(new SuiteTest(\"testShadowedTests\"));\n        suite.addTest(new SuiteTest(\"testAddTestSuite\"));\n        suite.addTest(new SuiteTest(\"testCreateSuiteFromArray\"));\n\n        return suite;\n    }\n\n    public void testInheritedTests() {\n        TestSuite suite = new TestSuite(InheritedTestCase.class);\n        suite.run(fResult);\n        assertTrue(fResult.wasSuccessful());\n        assertEquals(2, fResult.runCount());\n    }\n\n    public void testNoTestCaseClass() {\n        Test t = new TestSuite(NoTestCaseClass.class);\n        t.run(fResult);\n        assertEquals(1, fResult.runCount());  // warning test\n        assertTrue(!fResult.wasSuccessful());\n    }\n\n    public void testNoTestCases() {\n        Test t = new TestSuite(NoTestCases.class);\n        t.run(fResult);\n        assertTrue(fResult.runCount() == 1);  // warning test\n        assertTrue(fResult.failureCount() == 1);\n        assertTrue(!fResult.wasSuccessful());\n    }\n\n    public void testNotExistingTestCase() {\n        Test t = new SuiteTest(\"notExistingMethod\");\n        t.run(fResult);\n        assertTrue(fResult.runCount() == 1);\n        assertTrue(fResult.failureCount() == 1);\n        assertTrue(fResult.errorCount() == 0);\n    }\n\n    public void testNotPublicTestCase() {\n        TestSuite suite = new TestSuite(NotPublicTestCase.class);\n        // 1 public test case + 1 warning for the non-public test case\n        assertEquals(2, suite.countTestCases());\n    }\n\n    public void testNotVoidTestCase() {\n        TestSuite suite = new TestSuite(NotVoidTestCase.class);\n        assertTrue(suite.countTestCases() == 1);\n    }\n\n    public void testOneTestCase() {\n        TestSuite t = new TestSuite(OneTestCase.class);\n        t.run(fResult);\n        assertTrue(fResult.runCount() == 1);\n        assertTrue(fResult.failureCount() == 0);\n        assertTrue(fResult.errorCount() == 0);\n        assertTrue(fResult.wasSuccessful());\n    }\n\n    public void testOneTestCaseEclipseSeesSameStructureAs381() {\n        TestSuite t = new TestSuite(ThreeTestCases.class);\n        assertEquals(3, Collections.list(t.tests()).size());\n    }\n\n    public void testShadowedTests() {\n        TestSuite suite = new TestSuite(OverrideTestCase.class);\n        suite.run(fResult);\n        assertEquals(1, fResult.runCount());\n    }\n\n    public void testAddTestSuite() {\n        TestSuite suite = new TestSuite();\n        suite.addTestSuite(OneTestCase.class);\n        suite.run(fResult);\n        assertEquals(1, fResult.runCount());\n    }\n\n    public void testCreateSuiteFromArray() {\n        TestSuite suite = new TestSuite(OneTestCase.class, DoublePrecisionAssertTest.class);\n        assertEquals(2, suite.testCount());\n        assertEquals(\"junit.tests.framework.DoublePrecisionAssertTest\", ((TestSuite) suite.testAt(1)).getName());\n        assertEquals(\"junit.tests.framework.OneTestCase\", ((TestSuite) suite.testAt(0)).getName());\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/TestCaseTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestFailure;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\nimport junit.tests.WasRun;\n\n/**\n * A test case testing the testing framework.\n */\npublic class TestCaseTest extends TestCase {\n\n    static class TornDown extends TestCase {\n        boolean fTornDown = false;\n\n        @Override\n        protected void tearDown() {\n            fTornDown = true;\n        }\n\n        @Override\n        protected void runTest() {\n            throw new Error(\"running\");\n        }\n    }\n\n    public void testCaseToString() {\n        // This test wins the award for twisted snake tail eating while\n        // writing self tests. And you thought those weird anonymous\n        // inner classes were bad...\n        assertEquals(\"testCaseToString(junit.tests.framework.TestCaseTest)\", toString());\n    }\n\n    public void testError() {\n        TestCase error = new TestCase(\"error\") {\n            @Override\n            protected void runTest() {\n                throw new Error();\n            }\n        };\n        verifyError(error);\n    }\n\n    public void testRunAndTearDownFails() {\n        TornDown fails = new TornDown() {\n            @Override\n            protected void tearDown() {\n                super.tearDown();\n                throw new Error();\n            }\n\n            @Override\n            protected void runTest() {\n                throw new Error();\n            }\n        };\n        verifyError(fails);\n        assertTrue(fails.fTornDown);\n    }\n\n    public void testSetupFails() {\n        TestCase fails = new TestCase(\"success\") {\n            @Override\n            protected void setUp() {\n                throw new Error();\n            }\n\n            @Override\n            protected void runTest() {\n            }\n        };\n        verifyError(fails);\n    }\n\n    public void testSuccess() {\n        TestCase success = new TestCase(\"success\") {\n            @Override\n            protected void runTest() {\n            }\n        };\n        verifySuccess(success);\n    }\n\n    public void testFailure() {\n        TestCase failure = new TestCase(\"failure\") {\n            @Override\n            protected void runTest() {\n                fail();\n            }\n        };\n        verifyFailure(failure);\n    }\n\n    public void testTearDownAfterError() {\n        TornDown fails = new TornDown();\n        verifyError(fails);\n        assertTrue(fails.fTornDown);\n    }\n\n    public void testTearDownFails() {\n        TestCase fails = new TestCase(\"success\") {\n            @Override\n            protected void tearDown() {\n                throw new Error();\n            }\n\n            @Override\n            protected void runTest() {\n            }\n        };\n        verifyError(fails);\n    }\n\n    public void testTearDownSetupFails() {\n        TornDown fails = new TornDown() {\n            @Override\n            protected void setUp() {\n                throw new Error();\n            }\n        };\n        verifyError(fails);\n        assertTrue(!fails.fTornDown);\n    }\n\n    public void testWasRun() {\n        WasRun test = new WasRun();\n        test.run();\n        assertTrue(test.fWasRun);\n    }\n\n    public void testExceptionRunningAndTearDown() {\n        // With 1.4, we should\n        // wrap the exception thrown while running with the exception thrown\n        // while tearing down\n        Test t = new TornDown() {\n            @Override\n            public void tearDown() {\n                throw new Error(\"tearingDown\");\n            }\n        };\n        TestResult result = new TestResult();\n        t.run(result);\n        TestFailure failure = result.errors().nextElement();\n        assertEquals(\"running\", failure.thrownException().getMessage());\n    }\n\n    public void testErrorTearingDownDoesntMaskErrorRunning() {\n        final Exception running = new Exception(\"Running\");\n        TestCase t = new TestCase() {\n            @Override\n            protected void runTest() throws Throwable {\n                throw running;\n            }\n\n            @Override\n            protected void tearDown() throws Exception {\n                throw new Error(\"Tearing down\");\n            }\n        };\n        try {\n            t.runBare();\n        } catch (Throwable thrown) {\n            assertSame(running, thrown);\n        }\n    }\n\n    public void testNoArgTestCasePasses() {\n        Test t = new TestSuite(NoArgTestCaseTest.class);\n        TestResult result = new TestResult();\n        t.run(result);\n        assertTrue(result.runCount() == 1);\n        assertTrue(result.failureCount() == 0);\n        assertTrue(result.errorCount() == 0);\n    }\n\n    public void testNamelessTestCase() {\n        TestCase t = new TestCase() {\n        };\n        TestResult result = t.run();\n        assertEquals(1, result.failureCount());\n    }\n\n    void verifyError(TestCase test) {\n        TestResult result = test.run();\n        assertTrue(result.runCount() == 1);\n        assertTrue(result.failureCount() == 0);\n        assertTrue(result.errorCount() == 1);\n    }\n\n    void verifyFailure(TestCase test) {\n        TestResult result = test.run();\n        assertTrue(result.runCount() == 1);\n        assertTrue(result.failureCount() == 1);\n        assertTrue(result.errorCount() == 0);\n    }\n\n    void verifySuccess(TestCase test) {\n        TestResult result = test.run();\n        assertTrue(result.runCount() == 1);\n        assertTrue(result.failureCount() == 0);\n        assertTrue(result.errorCount() == 0);\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/TestImplementorTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.Protectable;\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\n\n/**\n * Test an implementor of junit.framework.Test other than TestCase or TestSuite\n */\npublic class TestImplementorTest extends TestCase {\n    public static class DoubleTestCase implements Test {\n        private TestCase fTestCase;\n\n        public DoubleTestCase(TestCase testCase) {\n            fTestCase = testCase;\n        }\n\n        public int countTestCases() {\n            return 2;\n        }\n\n        public void run(TestResult result) {\n            result.startTest(this);\n            Protectable p = new Protectable() {\n                public void protect() throws Throwable {\n                    fTestCase.runBare();\n                    fTestCase.runBare();\n                }\n            };\n            result.runProtected(this, p);\n            result.endTest(this);\n        }\n    }\n\n    private DoubleTestCase fTest;\n\n    public TestImplementorTest() {\n        TestCase testCase = new TestCase() {\n            @Override\n            public void runTest() {\n            }\n        };\n        fTest = new DoubleTestCase(testCase);\n    }\n\n    public void testSuccessfulRun() {\n        TestResult result = new TestResult();\n        fTest.run(result);\n        assertEquals(fTest.countTestCases(), result.runCount());\n        assertEquals(0, result.errorCount());\n        assertEquals(0, result.failureCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/framework/TestListenerTest.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestListener;\nimport junit.framework.TestResult;\n\n/**\n * Test class used in SuiteTest\n */\npublic class TestListenerTest extends TestCase implements TestListener {\n    private TestResult fResult;\n    private int fStartCount;\n    private int fEndCount;\n    private int fFailureCount;\n    private int fErrorCount;\n\n    public void addError(Test test, Throwable e) {\n        fErrorCount++;\n    }\n\n    public void addFailure(Test test, AssertionFailedError t) {\n        fFailureCount++;\n    }\n\n    public void endTest(Test test) {\n        fEndCount++;\n    }\n\n    @Override\n    protected void setUp() {\n        fResult = new TestResult();\n        fResult.addListener(this);\n\n        fStartCount = 0;\n        fEndCount = 0;\n        fFailureCount = 0;\n        fErrorCount = 0;\n    }\n\n    public void startTest(Test test) {\n        fStartCount++;\n    }\n\n    public void testError() {\n        TestCase test = new TestCase(\"noop\") {\n            @Override\n            public void runTest() {\n                throw new Error();\n            }\n        };\n        test.run(fResult);\n        assertEquals(1, fErrorCount);\n        assertEquals(1, fEndCount);\n    }\n\n    public void testFailure() {\n        TestCase test = new TestCase(\"noop\") {\n            @Override\n            public void runTest() {\n                fail();\n            }\n        };\n        test.run(fResult);\n        assertEquals(1, fFailureCount);\n        assertEquals(1, fEndCount);\n    }\n\n    public void testStartStop() {\n        TestCase test = new TestCase(\"noop\") {\n            @Override\n            public void runTest() {\n            }\n        };\n        test.run(fResult);\n        assertEquals(1, fStartCount);\n        assertEquals(1, fEndCount);\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/ThreeTestCases.java",
    "content": "package junit.tests.framework;\n\nimport junit.framework.TestCase;\n\n/**\n * Test class used in SuiteTest\n */\npublic class ThreeTestCases extends TestCase {\n    public void testCase() {\n    }\n\n    public void testCase2() {\n    }\n\n    public void testCase3thisTimeItsPersonal() {\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/framework/package-info.java",
    "content": "/**\n * Tests the JUnit v3.x core classes.\n */\npackage junit.tests.framework;"
  },
  {
    "path": "src/test/java/junit/tests/package-info.java",
    "content": "/**\n * Tests the JUnit v3.x framework.\n */\npackage junit.tests;"
  },
  {
    "path": "src/test/java/junit/tests/runner/AllTests.java",
    "content": "package junit.tests.runner;\n\nimport junit.framework.Test;\nimport junit.framework.TestSuite;\n\n/**\n * TestSuite that runs all the sample tests\n */\npublic class AllTests {\n\n    public static void main(String[] args) {\n        junit.textui.TestRunner.run(suite());\n    }\n\n    public static Test suite() { // Collect tests manually because we have to test class collection code\n        TestSuite suite = new TestSuite(\"Framework Tests\");\n        suite.addTestSuite(StackFilterTest.class);\n        suite.addTestSuite(ResultTest.class);\n        suite.addTestSuite(BaseTestRunnerTest.class);\n        suite.addTestSuite(TextFeedbackTest.class);\n        suite.addTestSuite(TextRunnerSingleMethodTest.class);\n        suite.addTestSuite(TextRunnerTest.class);\n        return suite;\n    }\n\n    static boolean isJDK11() {\n        String version = System.getProperty(\"java.version\");\n        return version.startsWith(\"1.1\");\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/runner/BaseTestRunnerTest.java",
    "content": "package junit.tests.runner;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\nimport junit.runner.BaseTestRunner;\n\npublic class BaseTestRunnerTest extends TestCase {\n    public static class MockRunner extends BaseTestRunner {\n        private boolean fRunFailed = false;\n\n        @Override\n        protected void runFailed(String message) {\n            fRunFailed = true;\n        }\n\n        @Override\n        public void testEnded(String testName) {\n        }\n\n        @Override\n        public void testFailed(int status, Test test, Throwable e) {\n        }\n\n        @Override\n        public void testStarted(String testName) {\n        }\n    }\n\n    public static class NonStatic {\n        public Test suite() {\n            return null;\n        }\n    }\n\n    public void testInvokeNonStaticSuite() {\n        BaseTestRunner runner = new MockRunner();\n        runner.getTest(\"junit.tests.runner.BaseTestRunnerTest$NonStatic\"); // Used to throw NullPointerException\n    }\n\n    public static class DoesntExtendTestCase {\n        public static Test suite() {\n            return new TestSuite();\n        }\n    }\n\n    public void testInvokeSuiteOnNonSubclassOfTestCase() {\n        MockRunner runner = new MockRunner();\n        runner.getTest(DoesntExtendTestCase.class.getName());\n        assertFalse(runner.fRunFailed);\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/runner/ResultTest.java",
    "content": "package junit.tests.runner;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\nimport java.util.List;\n\nimport junit.framework.TestCase;\nimport junit.tests.framework.Success;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.tests.running.methods.AnnotationTest;\n\npublic class ResultTest extends TestCase {\n\n    private Result fromStream;\n\n    public void testRunFailureResultCanBeSerialised() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(AnnotationTest.FailureTest.class);\n        assertResultSerializable(result);\n    }\n\n    public void testRunFailureResultCanBeReserialised_v4_12() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(AnnotationTest.FailureTest.class);\n        assertResultReserializable(result, SerializationFormat.V4_12);\n    }\n\n    public void testRunAssumptionFailedResultCanBeSerialised() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(AssumptionFailedTest.class);\n        assertResultSerializable(result);\n    }\n\n    public void testRunAssumptionFailedResultCanBeReserialised_v4_12() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(AssumptionFailedTest.class);\n        assertResultReserializable(result, SerializationFormat.V4_12);\n    }\n\n    public void testRunAssumptionFailedResultCanBeReserialised_v4_13() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(AssumptionFailedTest.class);\n        assertResultReserializable(result, SerializationFormat.V4_13);\n    }\n\n    public void testRunSuccessResultCanBeSerialised() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(Success.class);\n        assertResultSerializable(result);\n    }\n\n    public void testRunSuccessResultCanBeReserialised_v4_12() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(Success.class);\n        assertResultReserializable(result, SerializationFormat.V4_12);\n    }\n\n    public void testRunSuccessResultCanBeReserialised_v4_13() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(Success.class);\n        assertResultReserializable(result, SerializationFormat.V4_13);\n    }\n\n    private enum SerializationFormat {\n        V4_12,\n        V4_13\n    }\n\n    private void assertResultSerializable(Result result) throws IOException, ClassNotFoundException {\n        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);\n        objectOutputStream.writeObject(result);\n        objectOutputStream.flush();\n        byte[] bytes = byteArrayOutputStream.toByteArray();\n        ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));\n        Result fromStream = (Result) objectInputStream.readObject();\n        assertSerializedCorrectly(result, fromStream, SerializationFormat.V4_13);\n    }\n \n    private void assertResultReserializable(Result result, SerializationFormat resourceSerializationFormat)\n            throws IOException, ClassNotFoundException {\n        String resourceName = getName();\n        InputStream resource = getClass().getResourceAsStream(resourceName);\n        assertNotNull(\"Could not read resource \" + resourceName, resource);\n        ObjectInputStream objectInputStream = new ObjectInputStream(resource);\n        fromStream = (Result) objectInputStream.readObject();\n\n        assertSerializedCorrectly(new ResultWithFixedRunTime(result),\n                fromStream, resourceSerializationFormat);\n    }\n\n    public static class AssumptionFailedTest {\n        @Test\n        public void assumptionFailed() throws Exception {\n            org.junit.Assume.assumeTrue(false);\n        }\n    }\n\n    /**\n     * A version of {@code Result} that returns a hard-coded runtime.\n     * This makes values returned by the methods deterministic.\n     */\n    private static class ResultWithFixedRunTime extends Result {\n\n        private static final long serialVersionUID = 1L;\n\n        private final Result delegate;\n\n        public ResultWithFixedRunTime(Result delegate) {\n            this.delegate = delegate;\n        }\n\n        @Override\n        public int getRunCount() {\n            return delegate.getRunCount();\n        }\n\n        @Override\n        public int getFailureCount() {\n            return delegate.getFailureCount();\n        }\n\n        @Override\n        public long getRunTime() {\n            return 2;\n        }\n\n        @Override\n        public List<Failure> getFailures() {\n            return delegate.getFailures();\n        }\n\n        @Override\n        public int getIgnoreCount() {\n            return delegate.getIgnoreCount();\n        }\n\n        @Override\n        public int getAssumptionFailureCount() {\n            return delegate.getAssumptionFailureCount();\n        }\n    }\n\n    private void assertSerializedCorrectly(\n            Result result, Result fromStream, SerializationFormat serializationFormat) {\n        assertNotNull(fromStream);\n\n        // Exceptions don't implement equals() so we need to compare field by field\n        assertEquals(\"failureCount\", result.getFailureCount(), fromStream.getFailureCount());\n        assertEquals(\"ignoreCount\", result.getIgnoreCount(), fromStream.getIgnoreCount());\n\n        if (serializationFormat == SerializationFormat.V4_13) {\n            // assumption failures are serialized\n            assertEquals(\"assumptionFailureCount\",\n                    result.getAssumptionFailureCount(),\n                    fromStream.getAssumptionFailureCount());\n        } else {\n            // assumption failures were not serialized\n            try {\n                fromStream.getAssumptionFailureCount();\n                fail(\"UnsupportedOperationException expected\");\n            } catch (UnsupportedOperationException expected) {\n            }\n        }\n\n        assertEquals(\"runTime\", result.getRunTime(), fromStream.getRunTime());\n        assertEquals(\"failures\", result.getFailures().size(), fromStream.getFailures().size());\n        int index = 0;\n        for (Failure failure : result.getFailures()) {\n            Failure failureFromStream = fromStream.getFailures().get(index);\n            String messagePrefix = String.format(\"failures[%d]\", index++);\n            assertEquals(messagePrefix + \".description\",\n                    failure.getDescription(), failureFromStream.getDescription());\n            Throwable exception = failure.getException();\n            Throwable exceptionFromStream = failureFromStream.getException();\n            assertEquals(messagePrefix + \".exception\",\n                    exception.getClass(), exceptionFromStream.getClass());\n            assertEquals(messagePrefix + \".exception\",\n                    exception.getMessage(), exceptionFromStream.getMessage());\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/runner/StackFilterTest.java",
    "content": "package junit.tests.runner;\n\nimport java.io.PrintWriter;\nimport java.io.StringWriter;\n\nimport junit.framework.TestCase;\nimport junit.runner.BaseTestRunner;\n\npublic class StackFilterTest extends TestCase {\n    String fFiltered;\n    String fUnfiltered;\n\n    @Override\n    protected void setUp() {\n        StringWriter swin = new StringWriter();\n        PrintWriter pwin = new PrintWriter(swin);\n        pwin.println(\"junit.framework.AssertionFailedError\");\n        pwin.println(\"\\tat junit.framework.Assert.fail(Assert.java:144)\");\n        pwin.println(\"\\tat junit.framework.Assert.assert(Assert.java:19)\");\n        pwin.println(\"\\tat junit.framework.Assert.assert(Assert.java:26)\");\n        pwin.println(\"\\tat MyTest.f(MyTest.java:13)\");\n        pwin.println(\"\\tat MyTest.testStackTrace(MyTest.java:8)\");\n        pwin.println(\"\\tat java.lang.reflect.Method.invoke(Native Method)\");\n        pwin.println(\"\\tat junit.framework.TestCase.runTest(TestCase.java:156)\");\n        pwin.println(\"\\tat junit.framework.TestCase.runBare(TestCase.java:130)\");\n        pwin.println(\"\\tat junit.framework.TestResult$1.protect(TestResult.java:100)\");\n        pwin.println(\"\\tat junit.framework.TestResult.runProtected(TestResult.java:118)\");\n        pwin.println(\"\\tat junit.framework.TestResult.run(TestResult.java:103)\");\n        pwin.println(\"\\tat junit.framework.TestCase.run(TestCase.java:121)\");\n        pwin.println(\"\\tat junit.framework.TestSuite.runTest(TestSuite.java:157)\");\n        pwin.println(\"\\tat junit.framework.TestSuite.run(TestSuite.java, Compiled Code)\");\n        pwin.println(\"\\tat junit.swingui.TestRunner$17.run(TestRunner.java:669)\");\n        fUnfiltered = swin.toString();\n\n        StringWriter swout = new StringWriter();\n        PrintWriter pwout = new PrintWriter(swout);\n        pwout.println(\"junit.framework.AssertionFailedError\");\n        pwout.println(\"\\tat MyTest.f(MyTest.java:13)\");\n        pwout.println(\"\\tat MyTest.testStackTrace(MyTest.java:8)\");\n        fFiltered = swout.toString();\n    }\n\n    public void testFilter() {\n        assertEquals(fFiltered, BaseTestRunner.getFilteredTrace(fUnfiltered));\n    }\n}"
  },
  {
    "path": "src/test/java/junit/tests/runner/TextFeedbackTest.java",
    "content": "package junit.tests.runner;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.OutputStream;\nimport java.io.PrintStream;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\nimport junit.textui.ResultPrinter;\nimport junit.textui.TestRunner;\n\npublic class TextFeedbackTest extends TestCase {\n    OutputStream output;\n    TestRunner runner;\n\n    static class TestResultPrinter extends ResultPrinter {\n        TestResultPrinter(PrintStream writer) {\n            super(writer);\n        }\n\n        /* Spoof printing time so the tests are deterministic\n           */\n        @Override\n        protected String elapsedTimeAsString(long runTime) {\n            return \"0\";\n        }\n    }\n\n    public static void main(String[] args) {\n        TestRunner.run(TextFeedbackTest.class);\n    }\n\n    @Override\n    public void setUp() {\n        output = new ByteArrayOutputStream();\n        runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));\n    }\n\n    public void testEmptySuite() {\n        String expected = expected(new String[]{\"\", \"Time: 0\", \"\", \"OK (0 tests)\", \"\"});\n        runner.doRun(new TestSuite());\n        assertEquals(expected, output.toString());\n    }\n\n\n    public void testOneTest() {\n        String expected = expected(new String[]{\".\", \"Time: 0\", \"\", \"OK (1 test)\", \"\"});\n        TestSuite suite = new TestSuite();\n        suite.addTest(new TestCase() {\n            @Override\n            public void runTest() {\n            }\n        });\n        runner.doRun(suite);\n        assertEquals(expected, output.toString());\n    }\n\n    public void testTwoTests() {\n        String expected = expected(new String[]{\"..\", \"Time: 0\", \"\", \"OK (2 tests)\", \"\"});\n        TestSuite suite = new TestSuite();\n        suite.addTest(new TestCase() {\n            @Override\n            public void runTest() {\n            }\n        });\n        suite.addTest(new TestCase() {\n            @Override\n            public void runTest() {\n            }\n        });\n        runner.doRun(suite);\n        assertEquals(expected, output.toString());\n    }\n\n    public void testFailure() {\n        String expected = expected(new String[]{\".F\", \"Time: 0\", \"Failures here\", \"\", \"FAILURES!!!\", \"Tests run: 1,  Failures: 1,  Errors: 0\", \"\"});\n        ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {\n            @Override\n            public void printFailures(TestResult result) {\n                getWriter().println(\"Failures here\");\n            }\n        };\n        runner.setPrinter(printer);\n        TestSuite suite = new TestSuite();\n        suite.addTest(new TestCase() {\n            @Override\n            public void runTest() {\n                throw new AssertionFailedError();\n            }\n        });\n        runner.doRun(suite);\n        assertEquals(expected, output.toString());\n    }\n\n    public void testError() {\n        String expected = expected(new String[]{\".E\", \"Time: 0\", \"Errors here\", \"\", \"FAILURES!!!\", \"Tests run: 1,  Failures: 0,  Errors: 1\", \"\"});\n        ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {\n            @Override\n            public void printErrors(TestResult result) {\n                getWriter().println(\"Errors here\");\n            }\n        };\n        runner.setPrinter(printer);\n        TestSuite suite = new TestSuite();\n        suite.addTest(new TestCase() {\n            @Override\n            public void runTest() throws Exception {\n                throw new Exception();\n            }\n        });\n        runner.doRun(suite);\n        assertEquals(expected, output.toString());\n    }\n\n    private String expected(String[] lines) {\n        OutputStream expected = new ByteArrayOutputStream();\n        PrintStream expectedWriter = new PrintStream(expected);\n        for (int i = 0; i < lines.length; i++) {\n            expectedWriter.println(lines[i]);\n        }\n        return expected.toString();\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/junit/tests/runner/TextRunnerSingleMethodTest.java",
    "content": "package junit.tests.runner;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.PrintStream;\n\nimport junit.framework.TestCase;\nimport junit.textui.ResultPrinter;\nimport junit.textui.TestRunner;\n\n/**\n * Test invoking a single test method of a TestCase.\n */\npublic class TextRunnerSingleMethodTest extends TestCase {\n\n    static boolean fgWasInvoked;\n\n    public static class InvocationTest extends TestCase {\n\n        public void testWasInvoked() {\n            TextRunnerSingleMethodTest.fgWasInvoked = true;\n        }\n\n        public void testNotInvoked() {\n            fail(\"Shouldn't get here.\");\n        }\n    }\n\n    public void testSingle() throws Exception {\n        TestRunner t = new TestRunner();\n        t.setPrinter(new ResultPrinter(new PrintStream(new ByteArrayOutputStream())));\n        String[] args = {\n                \"-m\", \"junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest.testWasInvoked\"\n        };\n        fgWasInvoked = false;\n        t.start(args);\n        assertTrue(fgWasInvoked);\n    }\n\n}"
  },
  {
    "path": "src/test/java/junit/tests/runner/TextRunnerTest.java",
    "content": "package junit.tests.runner;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintStream;\n\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\n\npublic class TextRunnerTest extends TestCase {\n\n    public void testFailure() throws Exception {\n        execTest(\"junit.tests.framework.Failure\", false);\n    }\n\n    public void testSuccess() throws Exception {\n        execTest(\"junit.tests.framework.Success\", true);\n    }\n\n    public void testError() throws Exception {\n        execTest(\"junit.tests.BogusDude\", false);\n    }\n\n    void execTest(String testClass, boolean success) throws Exception {\n        String java = System.getProperty(\"java.home\") + File.separator + \"bin\" + File.separator + \"java\";\n        String cp = System.getProperty(\"java.class.path\");\n        //use -classpath for JDK 1.1.7 compatibility\n        String[] cmd = {java, \"-classpath\", cp, \"junit.textui.TestRunner\", testClass};\n        Process p = Runtime.getRuntime().exec(cmd);\n        InputStream i = p.getInputStream();\n        while ((i.read()) != -1)\n            ;\n        assertTrue((p.waitFor() == 0) == success);\n        if (success) {\n            assertTrue(p.exitValue() == 0);\n        } else {\n            assertFalse(p.exitValue() == 0);\n        }\n    }\n\n    public void testRunReturnsResult() {\n        PrintStream oldOut = System.out;\n        System.setOut(new PrintStream(\n                new OutputStream() {\n                    @Override\n                    public void write(int arg0) throws IOException {\n                    }\n                }\n        ));\n        try {\n            TestResult result = junit.textui.TestRunner.run(new TestSuite());\n            assertTrue(result.wasSuccessful());\n        } finally {\n            System.setOut(oldOut);\n        }\n    }\n\n\n}"
  },
  {
    "path": "src/test/java/junit/tests/runner/package-info.java",
    "content": "/**\n * Tests for the JUnit v3.x runner functionality.\n */\npackage junit.tests.runner;"
  },
  {
    "path": "src/test/java/org/junit/AssumptionViolatedExceptionTest.java",
    "content": "package org.junit;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.notNullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.hamcrest.core.IsNot.not;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assume.assumeThat;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\nimport java.io.Serializable;\n\nimport org.hamcrest.BaseMatcher;\nimport org.hamcrest.Description;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.StringDescription;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.rules.TestName;\nimport org.junit.runner.RunWith;\n\n@RunWith(Theories.class)\npublic class AssumptionViolatedExceptionTest {\n    @DataPoint\n    public static Integer TWO = 2;\n\n    @DataPoint\n    public static Matcher<Integer> IS_THREE = is(3);\n\n    @DataPoint\n    public static Matcher<Integer> NULL = null;\n\n    @Rule\n    public TestName name = new TestName();\n\n    private static final String MESSAGE = \"Assumption message\";\n    private static Matcher<Integer> SERIALIZABLE_IS_THREE = new SerializableIsThreeMatcher<Integer>();\n    private static final UnserializableClass UNSERIALIZABLE_VALUE = new UnserializableClass();\n    private static final Matcher<UnserializableClass> UNSERIALIZABLE_MATCHER = not(is(UNSERIALIZABLE_VALUE));\n\n    @Theory\n    public void toStringReportsMatcher(Integer actual, Matcher<Integer> matcher) {\n        assumeThat(matcher, notNullValue());\n        assertThat(new AssumptionViolatedException(actual, matcher).toString(),\n                containsString(matcher.toString()));\n    }\n\n    @Theory\n    public void toStringReportsValue(Integer actual, Matcher<Integer> matcher) {\n        assertThat(new AssumptionViolatedException(actual, matcher).toString(),\n                containsString(String.valueOf(actual)));\n    }\n\n    @Test\n    public void assumptionViolatedExceptionWithMatcherDescribesItself() {\n        AssumptionViolatedException e = new AssumptionViolatedException(3, is(2));\n        assertThat(StringDescription.asString(e), is(\"got: <3>, expected: is <2>\"));\n    }\n\n    @Test\n    public void simpleAssumptionViolatedExceptionDescribesItself() {\n        AssumptionViolatedException e = new AssumptionViolatedException(\"not enough money\");\n        assertThat(StringDescription.asString(e), is(\"not enough money\"));\n    }\n\n    @Test\n    public void canInitCauseWithInstanceCreatedWithString() {\n      AssumptionViolatedException e = new AssumptionViolatedException(\"invalid number\");\n      Throwable cause = new RuntimeException(\"cause\");\n      e.initCause(cause);\n      assertThat(e.getCause(), is(cause));\n    }\n\n    @Test\n    @SuppressWarnings(\"deprecation\")\n    public void canSetCauseWithInstanceCreatedWithObjectAndMatcher() {\n      Throwable testObject = new Exception();\n      org.junit.internal.AssumptionViolatedException e\n              = new org.junit.internal.AssumptionViolatedException(\n                      testObject, containsString(\"test matcher\"));\n      assertThat(e.getCause(), is(testObject));\n    }\n\n    @Test\n    @SuppressWarnings(\"deprecation\")\n    public void canSetCauseWithInstanceCreatedWithAssumptionObjectAndMatcher() {\n      Throwable testObject = new Exception();\n      org.junit.internal.AssumptionViolatedException e\n              = new org.junit.internal.AssumptionViolatedException(\n                      \"sample assumption\", testObject, containsString(\"test matcher\"));\n      assertThat(e.getCause(), is(testObject));\n    }\n\n    @Test\n    @SuppressWarnings(\"deprecation\")\n    public void canSetCauseWithInstanceCreatedWithMainConstructor() {\n      Throwable testObject = new Exception();\n      org.junit.internal.AssumptionViolatedException e\n              = new org.junit.internal.AssumptionViolatedException(\n                      \"sample assumption\", false, testObject, containsString(\"test matcher\"));\n      assertThat(e.getCause(), is(testObject));\n    }\n\n    @Test\n    public void canSetCauseWithInstanceCreatedWithExplicitThrowableConstructor() {\n      Throwable cause = new Exception();\n      AssumptionViolatedException e = new AssumptionViolatedException(\"invalid number\", cause);\n      assertThat(e.getCause(), is(cause));\n    }\n\n    @Test\n    public void assumptionViolatedExceptionWithoutValueAndMatcherCanBeReserialized_v4_13()\n            throws IOException, ClassNotFoundException {\n        assertReserializable(new AssumptionViolatedException(MESSAGE));\n    }\n\n    @Test\n    public void assumptionViolatedExceptionWithValueAndMatcherCanBeReserialized_v4_13()\n            throws IOException, ClassNotFoundException {\n        assertReserializable(new AssumptionViolatedException(MESSAGE, TWO, SERIALIZABLE_IS_THREE));\n    }\n\n    @Test\n    public void unserializableValueAndMatcherCanBeSerialized() throws IOException, ClassNotFoundException {\n        AssumptionViolatedException exception = new AssumptionViolatedException(MESSAGE,\n                UNSERIALIZABLE_VALUE, UNSERIALIZABLE_MATCHER);\n\n        assertCanBeSerialized(exception);\n    }\n\n    @Test\n    public void nullValueAndMatcherCanBeSerialized() throws IOException, ClassNotFoundException {\n        AssumptionViolatedException exception = new AssumptionViolatedException(MESSAGE);\n\n        assertCanBeSerialized(exception);\n    }\n\n    @Test\n    public void serializableValueAndMatcherCanBeSerialized() throws IOException, ClassNotFoundException {\n        AssumptionViolatedException exception = new AssumptionViolatedException(MESSAGE,\n                TWO, SERIALIZABLE_IS_THREE);\n\n        assertCanBeSerialized(exception);\n    }\n\n    private void assertCanBeSerialized(AssumptionViolatedException exception)\n            throws IOException, ClassNotFoundException {\n        ByteArrayOutputStream baos = new ByteArrayOutputStream();\n        ObjectOutputStream oos = new ObjectOutputStream(baos);\n        oos.writeObject(exception);\n\n        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());\n        ObjectInputStream ois = new ObjectInputStream(bais);\n        AssumptionViolatedException fromStream = (AssumptionViolatedException) ois.readObject();\n\n        assertSerializedCorrectly(exception, fromStream);\n    }\n\n    private void assertReserializable(AssumptionViolatedException expected)\n            throws IOException, ClassNotFoundException {\n        String resourceName = name.getMethodName();\n        InputStream resource = getClass().getResourceAsStream(resourceName);\n        assertNotNull(\"Could not read resource \" + resourceName, resource);\n        ObjectInputStream objectInputStream = new ObjectInputStream(resource);\n        AssumptionViolatedException fromStream = (AssumptionViolatedException) objectInputStream.readObject();\n\n        assertSerializedCorrectly(expected, fromStream);\n    }\n\n    private void assertSerializedCorrectly(\n            AssumptionViolatedException expected, AssumptionViolatedException fromStream) {\n        assertNotNull(fromStream);\n\n        // Exceptions don't implement equals() so we need to compare field by field\n        assertEquals(\"message\", expected.getMessage(), fromStream.getMessage());\n        assertEquals(\"description\", StringDescription.asString(expected), StringDescription.asString(fromStream));\n        // We don't check the stackTrace as that will be influenced by how the test was started\n        // (e.g. by maven or directly from IDE)\n        // We also don't check the cause as that should already be serialized correctly by the superclass\n    }\n\n    private static class SerializableIsThreeMatcher<T> extends BaseMatcher<T> implements Serializable {\n\n        public boolean matches(Object item) {\n            return IS_THREE.matches(item);\n        }\n\n        public void describeTo(Description description) {\n            IS_THREE.describeTo(description);\n        }\n    }\n\n    private static class UnserializableClass {\n        @Override\n        public String toString() {\n            return \"I'm not serializable\";\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/experimental/categories/AllCategoriesTests.java",
    "content": "package org.junit.experimental.categories;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        CategoriesAndParameterizedTest.class,\n        CategoryFilterFactoryTest.class,\n        CategoryTest.class,\n        CategoryValidatorTest.class,\n        JavadocTest.class,\n        MultiCategoryTest.class\n})\npublic class AllCategoriesTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/experimental/categories/CategoriesAndParameterizedTest.java",
    "content": "package org.junit.experimental.categories;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.Arrays;\n\nimport org.junit.Assert;\nimport org.junit.Test;\nimport org.junit.experimental.categories.Categories.IncludeCategory;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameters;\nimport org.junit.runners.Suite.SuiteClasses;\n\npublic class CategoriesAndParameterizedTest {\n    public static class Token {\n\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ParameterizedTestWithoutCategory {\n        @Parameters\n        public static Iterable<String> getParameters() {\n            return Arrays.asList(\"first\", \"second\");\n        }\n\n        @Parameterized.Parameter\n        public String value;\n\n        @Test\n        public void testSomething() {\n            Assert.assertTrue(true);\n        }\n    }\n\n    @Category(Token.class)\n    public static class TestThatAvoidsNoTestRemainsException {\n        @Test\n        public void testSomething() {\n            Assert.assertTrue(true);\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(Token.class)\n    @SuiteClasses({ TestThatAvoidsNoTestRemainsException.class,\n            ParameterizedTestWithoutCategory.class })\n    public static class SuiteWithParameterizedTestWithoutCategory {\n    }\n\n    @Test\n    public void doesNotRunTestsWithoutCategory() {\n        Result result = new JUnitCore()\n                .run(SuiteWithParameterizedTestWithoutCategory.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n\n    @RunWith(Parameterized.class)\n    @Category(Token.class)\n    public static class ParameterizedTestWithCategory {\n        @Parameters\n        public static Iterable<String> getParameters() {\n            return Arrays.asList(\"first\", \"second\");\n        }\n\n        @Parameterized.Parameter\n        public String value;\n\n        @Test\n        public void testSomething() {\n            Assert.assertTrue(true);\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(Token.class)\n    @SuiteClasses({ ParameterizedTestWithCategory.class })\n    public static class SuiteWithParameterizedTestWithCategory {\n    }\n\n    @Test\n    public void runsTestsWithoutCategory() {\n        Result result = new JUnitCore()\n                .run(SuiteWithParameterizedTestWithCategory.class);\n        assertEquals(2, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ParameterizedTestWithMethodWithCategory {\n        @Parameters\n        public static Iterable<String> getParameters() {\n            return Arrays.asList(\"first\", \"second\");\n        }\n\n        @Parameterized.Parameter\n        public String value;\n\n        @Test\n        @Category(Token.class)\n        public void testSomething() {\n            Assert.assertTrue(true);\n        }\n\n        @Test\n        public void testThatIsNotExecuted() {\n            Assert.assertTrue(true);\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(Token.class)\n    @SuiteClasses({ ParameterizedTestWithMethodWithCategory.class })\n    public static class SuiteWithParameterizedTestWithMethodWithCategory {\n    }\n\n    @Test\n    public void runsTestMethodWithCategory() {\n        Result result = new JUnitCore()\n                .run(SuiteWithParameterizedTestWithMethodWithCategory.class);\n        assertEquals(2, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java",
    "content": "package org.junit.experimental.categories;\r\n\r\nimport static org.hamcrest.CoreMatchers.instanceOf;\r\nimport static org.hamcrest.MatcherAssert.assertThat;\r\nimport static org.junit.runner.Description.createSuiteDescription;\r\n\r\nimport java.util.List;\r\n\r\nimport org.junit.Rule;\r\nimport org.junit.Test;\r\nimport org.junit.rules.ExpectedException;\r\nimport org.junit.rules.TestName;\r\nimport org.junit.runner.Description;\r\nimport org.junit.runner.FilterFactory;\r\nimport org.junit.runner.FilterFactoryParams;\r\nimport org.junit.runner.manipulation.Filter;\r\n\r\npublic class CategoryFilterFactoryTest {\r\n    @Rule\r\n    public ExpectedException expectedException = ExpectedException.none();\r\n\r\n    @Rule\r\n    public TestName testName = new TestName();\r\n\r\n    private final CategoryFilterFactory categoryFilterFactory = new CategoryFilterFactoryStub();\r\n\r\n    @Test\r\n    public void shouldCreateFilter() throws Exception {\r\n        FilterFactoryParams params = new FilterFactoryParams(\r\n                createSuiteDescription(testName.getMethodName()),\r\n                CategoryFilterFactoryStub.class.getName());\r\n        Filter filter = categoryFilterFactory.createFilter(params);\r\n\r\n        assertThat(filter, instanceOf(DummyFilter.class));\r\n    }\r\n\r\n    @Test\r\n    public void shouldThrowException() throws Exception {\r\n        FilterFactoryParams params = new FilterFactoryParams(\r\n                createSuiteDescription(testName.getMethodName()),\r\n                \"NonExistentFilter\");\r\n\r\n        expectedException.expect(FilterFactory.FilterNotCreatedException.class);\r\n\r\n        categoryFilterFactory.createFilter(params);\r\n    }\r\n\r\n    private static class CategoryFilterFactoryStub extends CategoryFilterFactory {\r\n        @Override\r\n        protected Filter createFilter(List<Class<?>> categories) {\r\n            return new DummyFilter();\r\n        }\r\n    }\r\n\r\n    private static class DummyFilter extends Filter {\r\n        @Override\r\n        public boolean shouldRun(Description description) {\r\n            return false;\r\n        }\r\n\r\n        @Override\r\n        public String describe() {\r\n            return null;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/test/java/org/junit/experimental/categories/CategoryTest.java",
    "content": "package org.junit.experimental.categories;\n\nimport static java.lang.String.format;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.hamcrest.core.AnyOf.anyOf;\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.core.IsEqual.equalTo;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.failureCountIs;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.Set;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.experimental.categories.Categories.CategoryFilter;\nimport org.junit.experimental.categories.Categories.ExcludeCategory;\nimport org.junit.experimental.categories.Categories.IncludeCategory;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.runners.model.InitializationError;\n\npublic class CategoryTest {\n    public interface FastTests {\n        // category marker\n    }\n\n    public interface SlowTests {\n        // category marker\n    }\n\n    public interface ReallySlowTests {\n        // category marker\n    }\n\n    public static class OneOfEach {\n\n        @Category(FastTests.class)\n        @Test\n        public void a() {\n        }\n\n        @Category(SlowTests.class)\n        @Test\n        public void b() {\n        }\n\n        @Category(ReallySlowTests.class)\n        @Test\n        public void c() {\n        }\n    }\n\n    public static class A {\n        @Test\n        public void a() {\n            fail();\n        }\n\n        @Category(SlowTests.class)\n        @Test\n        public void b() {\n        }\n    }\n\n    @Category(SlowTests.class)\n    public static class B {\n        @Test\n        public void c() {\n\n        }\n    }\n\n    public static class C {\n        @Test\n        public void d() {\n            fail();\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(SlowTests.class)\n    @SuiteClasses({A.class, B.class, C.class})\n    public static class SlowTestSuite {\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(SlowTests.class)\n    @SuiteClasses({A.class})\n    public static class JustA {\n    }\n\n    @Test\n    public void testCountOnJustA() {\n        assertThat(testResult(JustA.class), isSuccessful());\n    }\n\n    @Test\n    public void testCount() {\n        assertThat(testResult(SlowTestSuite.class), isSuccessful());\n    }\n\n    public static class Category1 {\n    }\n\n    public static class Category2 {\n    }\n\n    public static class SomeAreSlow {\n        @Test\n        public void noCategory() {\n        }\n\n        @Category(Category1.class)\n        @Test\n        public void justCategory1() {\n        }\n\n        @Category(Category2.class)\n        @Test\n        public void justCategory2() {\n        }\n\n        @Category({Category1.class, Category2.class})\n        @Test\n        public void both() {\n        }\n\n        @Category({Category2.class, Category1.class})\n        @Test\n        public void bothReversed() {\n        }\n    }\n\n    @RunWith(Categories.class)\n    @ExcludeCategory(Category1.class)\n    @SuiteClasses({SomeAreSlow.class})\n    public static class SomeAreSlowSuite {\n    }\n\n    @Test\n    public void testCountOnAWithoutSlowTests() {\n        Result result = JUnitCore.runClasses(SomeAreSlowSuite.class);\n        assertThat(testResult(SomeAreSlowSuite.class), isSuccessful());\n        assertEquals(2, result.getRunCount());\n        assertTrue(result.wasSuccessful());\n    }\n\n    @RunWith(Categories.class)\n    @ExcludeCategory(Category1.class)\n    @IncludeCategory(Category2.class)\n    @SuiteClasses({SomeAreSlow.class})\n    public static class IncludeAndExcludeSuite {\n    }\n\n    @Test\n    public void testsThatAreBothIncludedAndExcludedAreExcluded() {\n        Result result = JUnitCore.runClasses(IncludeAndExcludeSuite.class);\n        assertEquals(1, result.getRunCount());\n        assertTrue(result.wasSuccessful());\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses({A.class, B.class, C.class})\n    public static class TestSuiteWithNoCategories {\n    }\n\n    @Test\n    public void testCountWithExplicitIncludeFilter() throws Throwable {\n        CategoryFilter include = CategoryFilter.include(SlowTests.class);\n        Request baseRequest = Request.aClass(TestSuiteWithNoCategories.class);\n        Result result = new JUnitCore().run(baseRequest.filterWith(include));\n        assertTrue(result.wasSuccessful());\n        assertEquals(2, result.getRunCount());\n    }\n\n    @Test\n    public void testCountWithExplicitExcludeFilter() throws Throwable {\n        CategoryFilter include = CategoryFilter.exclude(SlowTests.class);\n        Request baseRequest = Request.aClass(TestSuiteWithNoCategories.class);\n        Result result = new JUnitCore().run(baseRequest.filterWith(include));\n        assertEquals(2, result.getFailureCount());\n        assertEquals(2, result.getRunCount());\n    }\n\n    @Test\n    public void testCountWithExplicitExcludeFilter_usingConstructor() throws Throwable {\n        CategoryFilter include = new CategoryFilter(null, SlowTests.class);\n        Request baseRequest = Request.aClass(TestSuiteWithNoCategories.class);\n        Result result = new JUnitCore().run(baseRequest.filterWith(include));\n        assertEquals(2, result.getFailureCount());\n        assertEquals(2, result.getRunCount());\n    }\n\n    @Test\n    public void categoryFilterLeavesOnlyMatchingMethods()\n            throws InitializationError, NoTestsRemainException {\n        CategoryFilter filter = CategoryFilter.include(SlowTests.class);\n        BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(A.class);\n        filter.apply(runner);\n        assertEquals(1, runner.testCount());\n    }\n\n    @Test\n    public void categoryFilterLeavesOnlyMatchingMethods_usingConstructor()\n            throws InitializationError, NoTestsRemainException {\n        CategoryFilter filter = new CategoryFilter(SlowTests.class, null);\n        BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(A.class);\n        filter.apply(runner);\n        assertEquals(1, runner.testCount());\n    }\n\n    public static class OneFastOneSlow {\n        @Category(FastTests.class)\n        @Test\n        public void a() {\n\n        }\n\n        @Category(SlowTests.class)\n        @Test\n        public void b() {\n\n        }\n    }\n\n    @Test\n    public void categoryFilterRejectsIncompatibleCategory()\n            throws InitializationError, NoTestsRemainException {\n        CategoryFilter filter = CategoryFilter.include(SlowTests.class);\n        BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(\n                OneFastOneSlow.class);\n        filter.apply(runner);\n        assertEquals(1, runner.testCount());\n    }\n\n    public static class OneFast {\n        @Category(FastTests.class)\n        @Test\n        public void a() {\n\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(SlowTests.class)\n    @SuiteClasses({OneFast.class})\n    public static class OneFastSuite {\n    }\n\n    @Test\n    public void ifNoTestsToRunUseErrorRunner() {\n        Result result = JUnitCore.runClasses(OneFastSuite.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        assertFalse(result.wasSuccessful());\n    }\n\n    @Test\n    public void describeACategoryFilter() {\n        CategoryFilter filter = CategoryFilter.include(SlowTests.class);\n        assertEquals(\"categories [\" + SlowTests.class + \"]\", filter.describe());\n    }\n\n    @Test\n    public void describeMultipleCategoryFilter() {\n        CategoryFilter filter= CategoryFilter.include(FastTests.class, SlowTests.class);\n        String d1= format(\"categories [%s, %s]\", FastTests.class, SlowTests.class);\n        String d2= format(\"categories [%s, %s]\", SlowTests.class, FastTests.class);\n        assertThat(filter.describe(), is(anyOf(equalTo(d1), equalTo(d2))));\n    }\n\n\n    public static class OneThatIsBothFastAndSlow {\n        @Category({FastTests.class, SlowTests.class})\n        @Test\n        public void a() {\n\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(SlowTests.class)\n    @SuiteClasses({OneThatIsBothFastAndSlow.class})\n    public static class ChooseSlowFromBoth {\n    }\n\n    @Test\n    public void runMethodWithTwoCategories() {\n        assertThat(testResult(ChooseSlowFromBoth.class), isSuccessful());\n    }\n\n    public interface VerySlowTests extends SlowTests {\n\n    }\n\n    public static class OneVerySlowTest {\n        @Category(VerySlowTests.class)\n        @Test\n        public void a() {\n\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(SlowTests.class)\n    @SuiteClasses({OneVerySlowTest.class})\n    public static class RunSlowFromVerySlow {\n    }\n\n    @Test\n    public void subclassesOfIncludedCategoriesAreRun() {\n        assertThat(testResult(RunSlowFromVerySlow.class), isSuccessful());\n    }\n\n    public interface MultiA {\n    }\n\n    public interface MultiB {\n    }\n\n    public interface MultiC {\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(value= {MultiA.class, MultiB.class}, matchAny= false)\n    @SuiteClasses(AllIncludedMustMatched.class)\n    public static class AllIncludedMustBeMatchedSuite {\n    }\n\n    public static class AllIncludedMustMatched {\n        @Test\n        @Category({MultiA.class, MultiB.class})\n        public void a() {\n        }\n\n        @Test\n        @Category(MultiB.class)\n        public void b() {\n            fail(\"When multiple categories are included in a Suite, \" +\n                    \"@Test method must match all include categories\");\n        }\n    }\n\n    @Test\n    public void allIncludedSuiteCategoriesMustBeMatched() {\n        Result result= JUnitCore.runClasses(AllIncludedMustBeMatchedSuite.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory({MultiA.class, MultiB.class})\n    @ExcludeCategory(MultiC.class)\n    @SuiteClasses(MultipleIncludesAndExcludeOnMethod.class)\n    public static class MultiIncludeWithExcludeCategorySuite {\n    }\n\n    public static class MultipleIncludesAndExcludeOnMethod {\n        @Test\n        @Category({MultiA.class, MultiB.class})\n        public void a() {\n        }\n\n        @Test\n        @Category({ MultiA.class, MultiB.class, MultiC.class })\n        public void b() {\n            fail(\"When multiple categories are included and excluded in a Suite, \" +\n                    \"@Test method must match all include categories and contain non of the excluded\");\n        }\n    }\n\n    @Test\n    public void anyMethodWithExcludedCategoryWillBeExcluded() {\n        Result result= JUnitCore.runClasses(MultiIncludeWithExcludeCategorySuite.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n\n    public static class ClassAsCategory {\n    }\n\n    public static class OneMoreTest {\n        @Category(ClassAsCategory.class)\n        @Test\n        public void a() {\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(ClassAsCategory.class)\n    @SuiteClasses({OneMoreTest.class})\n    public static class RunClassAsCategory {\n    }\n\n    @Test\n    public void classesCanBeCategories() {\n        assertThat(testResult(RunClassAsCategory.class), isSuccessful());\n    }\n\n    @Category(SlowTests.class)\n    public abstract static class Ancestor{}\n\n    public static class Inherited extends Ancestor {\n        @Test\n        public void a(){\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(SlowTests.class)\n    @SuiteClasses(Inherited.class)\n    public interface InheritanceSuite {}\n\n    @Test\n    public void testInheritance() {\n        Result result = JUnitCore.runClasses(InheritanceSuite.class);\n        assertEquals(1, result.getRunCount());\n        assertTrue(result.wasSuccessful());\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(Runnable.class)\n    @ExcludeCategory(Runnable.class)\n    @SuiteClasses({})\n    public static class EmptyCategoriesSuite {\n    }\n\n    @Test public void emptyCategoriesSuite() {\n        assertThat(testResult(EmptyCategoriesSuite.class), failureCountIs(1));\n    }\n\n    @Category(Runnable.class)\n    public static class NoTest {\n    }\n\n    @Category(Runnable.class)\n    public static class IgnoredTest {\n\n        @Ignore\n        @Test\n        public void test() {\n            fail();\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory(Runnable.class)\n    @SuiteClasses({NoTest.class, IgnoredTest.class})\n    public static class IgnoredTestCategoriesSuite {\n    }\n\n    @Test\n    public void ignoredTest() {// behaves same as Suite\n        Result result= JUnitCore.runClasses(IgnoredTestCategoriesSuite.class);\n        assertFalse(result.wasSuccessful());\n        assertThat(result.getRunCount(), is(1));\n        assertThat(result.getFailureCount(), is(1));\n        assertThat(result.getIgnoreCount(), is(1));\n    }\n\n    @Category(Runnable.class)\n    public static class ExcludedTest1 {\n\n        @Test\n        public void test() {\n            fail();\n        }\n    }\n\n    @Category(Runnable.class)\n    public static class ExcludedTest2 {\n\n        @Test\n        @Category(Runnable.class)\n        public void test() {\n            fail();\n        }\n    }\n\n    public static class IncludedTest {\n\n        @Test\n        @Category(Object.class)\n        public void test() {\n        }\n    }\n\n    @RunWith(Categories.class)\n    @IncludeCategory({Runnable.class, Object.class})\n    @ExcludeCategory(Runnable.class)\n    @SuiteClasses({ExcludedTest1.class, ExcludedTest2.class, IncludedTest.class})\n    public static class IncludedExcludedSameSuite {\n    }\n\n    @Test\n    public void oneRunnableOthersAvoided() {\n        Result result= JUnitCore.runClasses(IncludedExcludedSameSuite.class);\n        assertEquals(1, result.getRunCount());\n        assertTrue(result.wasSuccessful());\n    }\n\n    @Test\n    @SuppressWarnings(\"unchecked\")\n    public void testCountWithMultipleExcludeFilter() throws Throwable {\n        Set<Class<?>> exclusions= new HashSet<Class<?>>(2);\n        Collections.addAll(exclusions, SlowTests.class, FastTests.class);\n        CategoryFilter exclude = CategoryFilter.categoryFilter(true, null, true, exclusions);\n        Request baseRequest= Request.aClass(OneOfEach.class);\n        Result result= new JUnitCore().run(baseRequest.filterWith(exclude));\n        assertTrue(result.wasSuccessful());\n        assertEquals(1, result.getRunCount());\n    }\n\n    @Test\n    public void testCountWithMultipleIncludeFilter() throws Throwable {\n        CategoryFilter exclude = CategoryFilter.include(true, SlowTests.class, FastTests.class);\n        Request baseRequest= Request.aClass(OneOfEach.class);\n        Result result= new JUnitCore().run(baseRequest.filterWith(exclude));\n        assertTrue(result.wasSuccessful());\n        assertEquals(2, result.getRunCount());\n    }\n\n    @RunWith(Categories.class)\n    @Categories.ExcludeCategory(String.class)\n    @Suite.SuiteClasses(NoIncludeCategoryAnnotationTest.class)\n    public static class NoIncludeCategoryAnnotationSuite {\n    }\n\n    @Category(CharSequence.class)\n    public static class NoIncludeCategoryAnnotationTest {\n\n        @Test\n        public void test2() {\n        }\n\n        @Test\n        @Category(String.class) public void test1() {\n        }\n    }\n\n    @Test\n    public void noIncludeCategoryAnnotation() {\n        Result testResult= JUnitCore.runClasses(NoIncludeCategoryAnnotationSuite.class);\n        assertTrue(testResult.wasSuccessful());\n        assertEquals(1, testResult.getRunCount());\n    }\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory(CharSequence.class)\n    @Categories.ExcludeCategory(String.class)\n    @Suite.SuiteClasses(NoIncludeCategoryAnnotationTest.class)\n    public static class SameAsNoIncludeCategoryAnnotationSuite {\n    }\n\n    @Test\n    public void sameAsNoIncludeCategoryAnnotation() {\n        Result testResult= JUnitCore.runClasses(SameAsNoIncludeCategoryAnnotationSuite.class);\n        assertTrue(testResult.wasSuccessful());\n        assertEquals(1, testResult.getRunCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/experimental/categories/CategoryValidatorTest.java",
    "content": "package org.junit.experimental.categories;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\nimport java.util.List;\n\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.TestClass;\n\npublic class CategoryValidatorTest {\n\n    public static class SampleCategory {\n    }\n\n    public static class CategoryTest {\n        @BeforeClass\n        @Category(value = SampleCategory.class)\n        public static void methodWithCategoryAndBeforeClass() {\n        }\n\n        @AfterClass\n        @Category(value = SampleCategory.class)\n        public static void methodWithCategoryAndAfterClass() {\n        }\n\n        @Before\n        @Category(value = SampleCategory.class)\n        public static void methodWithCategoryAndBefore() {\n        }\n\n        @After\n        @Category(value = SampleCategory.class)\n        public static void methodWithCategoryAndAfter() {\n        }\n\n        @Category(value = SampleCategory.class)\n        public static void methodWithCategory() {\n        }\n    }\n\n    @Test\n    public void errorIsAddedWhenCategoryIsUsedWithBeforeClass() {\n        FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(BeforeClass.class).get(0);\n        testAndAssertErrorMessage(method, \"@BeforeClass can not be combined with @Category\");\n    }\n\n    @Test\n    public void errorIsAddedWhenCategoryIsUsedWithAfterClass() {\n        FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(AfterClass.class).get(0);\n        testAndAssertErrorMessage(method, \"@AfterClass can not be combined with @Category\");\n    }\n\n    @Test\n    public void errorIsAddedWhenCategoryIsUsedWithBefore() {\n        FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(Before.class).get(0);\n        testAndAssertErrorMessage(method, \"@Before can not be combined with @Category\");\n    }\n\n    @Test\n    public void errorIsAddedWhenCategoryIsUsedWithAfter() {\n        FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(After.class).get(0);\n        testAndAssertErrorMessage(method, \"@After can not be combined with @Category\");\n    }\n\n    private void testAndAssertErrorMessage(FrameworkMethod method, String expectedErrorMessage) {\n        List<Exception> errors = new CategoryValidator().validateAnnotatedMethod(method);\n\n        assertThat(errors.size(), is(1));\n        Exception exception = errors.get(0);\n        assertThat(exception.getMessage(), is(expectedErrorMessage));\n    }\n\n    @Test\n    public void errorIsNotAddedWhenCategoryIsNotCombinedWithIllegalCombination() throws NoSuchMethodException {\n        FrameworkMethod method = new FrameworkMethod(CategoryTest.class.getMethod(\"methodWithCategory\"));\n        List<Exception> errors = new CategoryValidator().validateAnnotatedMethod(method);\n\n        assertThat(errors.size(), is(0));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/experimental/categories/JavadocTest.java",
    "content": "package org.junit.experimental.categories;\n\nimport static org.hamcrest.core.Is.is;\nimport static org.junit.Assert.assertThat;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\n\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n/**\n * @author tibor17\n * @version 4.12\n * @since 4.12\n */\npublic class JavadocTest {\n    public static interface FastTests {}\n    public static interface SlowTests {}\n    public static interface SmokeTests {}\n\n    public static class A {\n        public void a() {\n            fail();\n        }\n\n        @Category(SlowTests.class)\n        @Test\n        public void b() {\n        }\n\n        @Category({FastTests.class, SmokeTests.class})\n        @Test\n        public void c() {\n        }\n    }\n\n    @Category({SlowTests.class, FastTests.class})\n    public static class B {\n        @Test\n        public void d() {\n        }\n    }\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory(SlowTests.class)\n    @Suite.SuiteClasses({A.class, B.class})\n    public static class SlowTestSuite {\n        // Will run A.b and B.d, but not A.a and A.c\n    }\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory({FastTests.class, SmokeTests.class})\n    @Suite.SuiteClasses({A.class, B.class})\n    public static class FastOrSmokeTestSuite {\n        // Will run A.c and B.d, but not A.b because it is not any of FastTests or SmokeTests\n    }\n\n    @Test\n    public void slowTests() {\n        Result testResult= JUnitCore.runClasses(SlowTestSuite.class);\n        assertTrue(testResult.wasSuccessful());\n        assertThat(\"unexpected run count\", testResult.getRunCount(), is(2));\n        assertThat(\"unexpected failure count\", testResult.getFailureCount(), is(0));\n    }\n\n    @Test\n    public void fastSmokeTests() {\n        Result testResult= JUnitCore.runClasses(FastOrSmokeTestSuite.class);\n        assertTrue(testResult.wasSuccessful());\n        assertThat(\"unexpected run count\", testResult.getRunCount(), is(2));\n        assertThat(\"unexpected failure count\", testResult.getFailureCount(), is(0));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/experimental/categories/MultiCategoryTest.java",
    "content": "package org.junit.experimental.categories;\n\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.core.IsEqual.equalTo;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertThat;\nimport static org.junit.Assert.fail;\n\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n/**\n * @author tibor17\n * @version 4.12\n * @since 4.12\n */\npublic final class MultiCategoryTest {\n    public interface A {}\n    public interface B {}\n    public interface C {}\n\n    /**\n     * This test is mentioned in {@code Categories} and any changes\n     * must be reflected.\n     */\n    @Test\n    public void runSuite() {\n        // Targeting Test:\n        Result testResult= JUnitCore.runClasses(MultiCategorySuite.class);\n\n        assertThat(\"unexpected run count\", testResult.getRunCount(), is(equalTo(2)));\n        assertThat(\"unexpected failure count\", testResult.getFailureCount(), is(equalTo(0)));\n        assertThat(\"unexpected failure count\", testResult.getIgnoreCount(), is(equalTo(0)));\n    }\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory({A.class, B.class})\n    @Categories.ExcludeCategory(C.class)\n    @Suite.SuiteClasses({CategoriesTest.class})\n    public static final class MultiCategorySuite {}\n\n    public static final class CategoriesTest {\n\n        @Test\n        @Category(A.class)\n        public void a() {}\n\n        @Test\n        @Category(B.class)\n        public void b() {}\n\n        @Test\n        @Category(C.class)\n        public void c() {\n            fail();\n        }\n\n        @Test\n        public void anything() {\n            fail();\n        }\n    }\n\n    @Test\n    public void inheritanceAnyIncluded() {\n        Result testResult= JUnitCore.runClasses(InheritanceAny.class);\n        assertThat(\"unexpected run count\", testResult.getRunCount(), is(equalTo(3)));\n        assertThat(\"unexpected failure count\", testResult.getFailureCount(), is(equalTo(0)));\n        assertThat(\"unexpected failure count\", testResult.getIgnoreCount(), is(equalTo(0)));\n    }\n\n    @Test\n    public void inheritanceAllIncluded() {\n        Result testResult= JUnitCore.runClasses(InheritanceAll.class);\n        assertThat(\"unexpected run count\", testResult.getRunCount(), is(equalTo(1)));\n        assertThat(\"unexpected failure count\", testResult.getFailureCount(), is(equalTo(0)));\n        assertThat(\"unexpected failure count\", testResult.getIgnoreCount(), is(equalTo(0)));\n    }\n\n    @Test\n    public void inheritanceAnyAll() {//any included, all excluded\n        Result testResult= JUnitCore.runClasses(InheritanceAnyAll.class);\n        assertThat(\"unexpected run count\", testResult.getRunCount(), is(equalTo(3)));\n        assertThat(\"unexpected failure count\", testResult.getFailureCount(), is(equalTo(0)));\n        assertThat(\"unexpected failure count\", testResult.getIgnoreCount(), is(equalTo(0)));\n    }\n\n    @Test\n    public void inheritanceAllAny() {//all included, any excluded\n        Result testResult= JUnitCore.runClasses(InheritanceAllAny.class);\n        assertThat(\"unexpected run count\", testResult.getRunCount(), is(equalTo(1)));\n        assertThat(\"unexpected failure count\", testResult.getFailureCount(), is(equalTo(1)));\n        assertThat(\"unexpected failure count\", testResult.getIgnoreCount(), is(equalTo(0)));\n        assertFalse(testResult.wasSuccessful());\n    }\n\n    public static class X implements A {}\n    public static class Y implements B {}\n    public static class Z implements A, B {}\n    public static class W implements A, B, C {}\n    public static class Q implements A, C {}\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory({A.class, B.class})\n    @Categories.ExcludeCategory(C.class)\n    @Suite.SuiteClasses({InheritanceAnyTest.class})\n    public static final class InheritanceAny {}\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory(value= {A.class, B.class}, matchAny= false)\n    @Categories.ExcludeCategory(C.class)\n    @Suite.SuiteClasses({InheritanceAllTest.class})\n    public static final class InheritanceAll {}\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory({A.class, B.class})\n    @Categories.ExcludeCategory(value= {A.class, C.class}, matchAny= false)\n    @Suite.SuiteClasses({InheritanceAnyAllTest.class})\n    public static final class InheritanceAnyAll {}\n\n    @RunWith(Categories.class)\n    @Categories.IncludeCategory(value= {A.class, B.class}, matchAny= false)\n    @Categories.ExcludeCategory({A.class, C.class})\n    @Suite.SuiteClasses({InheritanceAllAnyTest.class})\n    public static final class InheritanceAllAny {}\n\n    public static final class InheritanceAnyTest {\n        @Test @Category(X.class) public void x() {}\n        @Test @Category(Y.class) public void y() {}\n        @Test @Category(Z.class) public void z() {}\n        @Test @Category(W.class) public void w() { fail(); }\n        @Test @Category(Q.class) public void q() { fail(); }\n        @Test @Category(Runnable.class) public void runnable() { fail(); }\n        @Test public void t() { fail(); }\n    }\n\n    public static final class InheritanceAllTest {\n        @Test @Category(X.class) public void x() { fail(); }\n        @Test @Category(Y.class) public void y() { fail(); }\n        @Test @Category(Z.class) public void z() {}\n        @Test @Category(W.class) public void w() { fail(); }\n        @Test @Category(Q.class) public void q() { fail(); }\n        @Test @Category(Runnable.class) public void runnable() { fail(); }\n        @Test public void t() { fail(); }\n    }\n\n    public static final class InheritanceAnyAllTest {\n        @Test @Category(X.class) public void x() {}\n        @Test @Category(Y.class) public void y() {}\n        @Test @Category(Z.class) public void z() {}\n        @Test @Category(W.class) public void w() { fail(); }\n        @Test @Category(Q.class) public void q() { fail(); }\n        @Test @Category(Runnable.class) public void runnable() { fail(); }\n        @Test public void t() { fail(); }\n    }\n\n    public static final class InheritanceAllAnyTest {\n        @Test @Category(X.class) public void x() { fail(); }\n        @Test @Category(Y.class) public void y() { fail(); }\n        @Test @Category(Z.class) public void z() { fail(); }\n        @Test @Category(W.class) public void w() { fail(); }\n        @Test @Category(Q.class) public void q() { fail(); }\n        @Test @Category(Runnable.class) public void runnable() { fail(); }\n        @Test public void t() { fail(); }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/internal/AllInternalTests.java",
    "content": "package org.junit.internal;\n\nimport org.junit.internal.builders.AnnotatedBuilderTest;\nimport org.junit.internal.matchers.StacktracePrintingMatcherTest;\nimport org.junit.internal.matchers.ThrowableCauseMatcherTest;\nimport org.junit.internal.runners.ErrorReportingRunnerTest;\nimport org.junit.internal.runners.statements.ExpectExceptionTest;\nimport org.junit.internal.runners.statements.FailOnTimeoutTest;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AnnotatedBuilderTest.class,\n        ChecksTest.class,\n        ErrorReportingRunnerTest.class,\n        ExpectExceptionTest.class,\n        FailOnTimeoutTest.class,\n        MethodSorterTest.class,\n        StacktracePrintingMatcherTest.class,\n        StackTracesTest.class,\n        ThrowableCauseMatcherTest.class,\n        ArrayComparisonFailureTest.class\n})\npublic class AllInternalTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/internal/ArrayComparisonFailureTest.java",
    "content": "package org.junit.internal;\n\nimport org.junit.Test;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.ObjectInputStream;\n\nimport static org.junit.Assert.assertArrayEquals;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.fail;\n\npublic class ArrayComparisonFailureTest {\n\n    private static final String ARRAY_COMPARISON_FAILURE_411 = \"arrayComparisonFailure_411\";\n    private static final String ARRAY_COMPARISON_FAILURE_412 = \"arrayComparisonFailure_412\";\n\n    /*\n        Test compatibility of older versions of ArrayComparisonFailure\n        Setup:\n        - checkout prior versions of the codebase (r4.11, r4.12 in this case)\n        - catch the exception resulting from:\n            assertArrayEquals(new int[]{0, 1}, new int[]{0, 5});\n        - serialize the resulting exception to a file, moving into the test/resources path\n            Ex., for v4.11's resulting exception {@link org/junit/internal/arrayComparisonFailure_411}\n        Current unit test:\n        - deserialize the above files casting it to the current version of the class\n            (catches any forward incompatibility with missing fields)\n        - assert the results from existing methods: getCause(), toString() -> getMessage()\n            (catches incompatible usages of fields)\n\n        This does not test if an instance of the current version of the class is able to deserialize to a previous ver.\n     */\n\n    @Test\n    public void classShouldAccept411Version() throws Exception {\n        assertFailureSerializableFromOthers(ARRAY_COMPARISON_FAILURE_411);\n    }\n\n    @Test\n    public void classShouldAccept412Version() throws Exception {\n        assertFailureSerializableFromOthers(ARRAY_COMPARISON_FAILURE_412);\n    }\n\n    private void assertFailureSerializableFromOthers(String failureFileName) throws IOException,\n            ClassNotFoundException {\n        try {\n            assertArrayEquals(new int[]{0, 1}, new int[]{0, 5});\n            fail();\n        } catch (ArrayComparisonFailure e) {\n            ArrayComparisonFailure arrayComparisonFailureFromFile = deserializeFailureFromFile(failureFileName);\n            assertNotNull(\"ArrayComparisonFailure.getCause() should fallback to the deprecated fCause field\"\n                            + \" for compatibility with older versions of junit4 that didn't use Throwable.initCause().\",\n                    arrayComparisonFailureFromFile.getCause());\n            assertEquals(e.getCause().toString(), arrayComparisonFailureFromFile.getCause().toString());\n            assertEquals(e.toString(), arrayComparisonFailureFromFile.toString());\n        }\n    }\n\n    private ArrayComparisonFailure deserializeFailureFromFile(String fileName) throws IOException,\n            ClassNotFoundException {\n        InputStream resource = getClass().getResourceAsStream(fileName);\n        ObjectInputStream objectInputStream = new ObjectInputStream(resource);\n        return (ArrayComparisonFailure) objectInputStream.readObject();\n    }\n\n}"
  },
  {
    "path": "src/test/java/org/junit/internal/ChecksTest.java",
    "content": "package org.junit.internal;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNull;\nimport static org.junit.Assert.assertSame;\nimport static org.junit.Assert.fail;\nimport static org.junit.internal.Checks.notNull;\nimport org.junit.Test;\n\n/** Tests for {@link Checks}. */\npublic class ChecksTest {\n\n    @Test\n    public void notNullShouldReturnNonNullValues() {\n        Double value = Double.valueOf(3.14);\n\n        Double result = notNull(value);\n\n        assertSame(value, result);\n    }\n\n    @Test\n    public void notNullShouldThrowOnNullValues() {\n        try {\n            notNull(null);\n            fail(\"NullPointerException expected\");\n        } catch (NullPointerException e) {\n            assertNull(\"message should be null\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void notNullWithMessageShouldReturnNonNullValues() {\n        Float value = Float.valueOf(3.14f);\n\n        Float result = notNull(value, \"woops\");\n\n        assertSame(value, result);\n    }\n\n    @Test\n    public void notNullWithMessageShouldThrowOnNullValues() {\n        try {\n            notNull(null, \"woops\");\n            fail(\"NullPointerException expected\");\n        } catch (NullPointerException e) {\n            assertEquals(\"message does not match\", \"woops\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void notNullWithNullMessageShouldThrowOnNullValues() {\n        try {\n            notNull(null, null);\n            fail(\"NullPointerException expected\");\n        } catch (NullPointerException e) {\n            assertNull(\"message should be null\", e.getMessage());\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/internal/MethodSorterTest.java",
    "content": "package org.junit.internal;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertArrayEquals;\n\nimport java.lang.reflect.Method;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.FixMethodOrder;\nimport org.junit.Test;\nimport org.junit.runners.MethodSorters;\n\npublic class MethodSorterTest {\n    private static final String ALPHA = \"java.lang.Object alpha(int,double,java.lang.Thread)\";\n    private static final String BETA = \"void beta(int[][])\";\n    private static final String GAMMA_VOID = \"int gamma()\";\n    private static final String GAMMA_BOOLEAN = \"void gamma(boolean)\";\n    private static final String DELTA = \"void delta()\";\n    private static final String EPSILON = \"void epsilon()\";\n    private static final String SUPER_METHOD = \"void superMario()\";\n    private static final String SUB_METHOD = \"void subBowser()\";\n\n    static class DummySortWithoutAnnotation {\n        Object alpha(int i, double d, Thread t) {\n            return null;\n        }\n\n        void beta(int[][] x) {\n        }\n\n        int gamma() {\n            return 0;\n        }\n\n        void gamma(boolean b) {\n        }\n\n        void delta() {\n        }\n\n        void epsilon() {\n        }\n    }\n\n    static class Super {\n        void superMario() {\n        }\n    }\n\n    static class Sub extends Super {\n        void subBowser() {\n        }\n    }\n\n    private List<String> getDeclaredMethodNames(Class<?> clazz) {\n        Method[] actualMethods = MethodSorter.getDeclaredMethods(clazz);\n\n        // Obtain just the names instead of the full methods.\n        List<String> names = new ArrayList<String>();\n        for (Method m : actualMethods) {\n            // Filter out synthetic methods from, e.g., coverage tools.\n            if (!m.isSynthetic()) {\n                names.add(m.toString().replace(clazz.getName() + '.', \"\"));\n        \t}\n        }\n        \n        return names;\n    }\n\n    @Test\n    public void testMethodsNullSorterSelf() {\n        List<String> expected = Arrays.asList(EPSILON, BETA, ALPHA, DELTA, GAMMA_VOID, GAMMA_BOOLEAN);\n        List<String> actual = getDeclaredMethodNames(DummySortWithoutAnnotation.class);\n        assertEquals(expected, actual);\n    }\n    \n    @Test\n    public void testMethodsNullSorterSuper() {\n        List<String> expected = Arrays.asList(SUPER_METHOD);\n        List<String> actual = getDeclaredMethodNames(Super.class);\n        assertEquals(expected, actual);\n    }\n    \n    @Test\n    public void testMethodsNullSorterSub() {\n        List<String> expected = Arrays.asList(SUB_METHOD);\n        List<String> actual = getDeclaredMethodNames(Sub.class);\n        assertEquals(expected, actual);\n    }\n\n    @FixMethodOrder(MethodSorters.DEFAULT)\n    static class DummySortWithDefault {\n        Object alpha(int i, double d, Thread t) {\n            return null;\n        }\n\n        void beta(int[][] x) {\n        }\n\n        int gamma() {\n            return 0;\n        }\n\n        void gamma(boolean b) {\n        }\n\n        void delta() {\n        }\n\n        void epsilon() {\n        }\n    }\n\n    @Test\n    public void testDefaultMethodSorter() {\n        List<String> expected = Arrays.asList(EPSILON, BETA, ALPHA, DELTA, GAMMA_VOID, GAMMA_BOOLEAN);\n        List<String> actual = getDeclaredMethodNames(DummySortWithDefault.class);\n        assertEquals(expected, actual);\n    }\n\n    @FixMethodOrder(MethodSorters.JVM)\n    static class DummySortJvm {\n        Object alpha(int i, double d, Thread t) {\n            return null;\n        }\n\n        void beta(int[][] x) {\n        }\n\n        int gamma() {\n            return 0;\n        }\n\n        void gamma(boolean b) {\n        }\n\n        void delta() {\n        }\n\n        void epsilon() {\n        }\n    }\n\n    @Test\n    public void testJvmMethodSorter() {\n        Method[] fromJvmWithSynthetics = DummySortJvm.class.getDeclaredMethods();\n        Method[] sorted = MethodSorter.getDeclaredMethods(DummySortJvm.class);\n        assertArrayEquals(fromJvmWithSynthetics, sorted);\n    }\n\n    @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n    static class DummySortWithNameAsc {\n        Object alpha(int i, double d, Thread t) {\n            return null;\n        }\n\n        void beta(int[][] x) {\n        }\n\n        int gamma() {\n            return 0;\n        }\n\n        void gamma(boolean b) {\n        }\n\n        void delta() {\n        }\n\n        void epsilon() {\n        }\n    }\n\n    @Test\n    public void testAscendingMethodSorter() {\n        List<String> expected = Arrays.asList(ALPHA, BETA, DELTA, EPSILON, GAMMA_VOID, GAMMA_BOOLEAN);\n        List<String> actual = getDeclaredMethodNames(DummySortWithNameAsc.class);\n        assertEquals(expected, actual);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/internal/StackTracesTest.java",
    "content": "package org.junit.internal;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotEquals;\nimport static org.junit.Assert.fail;\nimport static org.junit.Assume.assumeTrue;\n\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.ExecutionException;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.Future;\nimport java.util.regex.Pattern;\n\nimport junit.tests.SampleJUnit3Tests;\nimport org.hamcrest.CoreMatchers;\nimport org.hamcrest.Description;\nimport org.hamcrest.Matcher;\nimport org.hamcrest.StringDescription;\nimport org.hamcrest.TypeSafeMatcher;\nimport org.junit.AfterClass;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.tests.SampleJUnit4Tests.*;\n\npublic class StackTracesTest {\n    private static final String EOL = System.getProperty(\"line.separator\", \"\\n\");\n    private static ExecutorService executorService;\n\n    @BeforeClass\n    public static void startExecutorService() {\n        executorService = Executors.newFixedThreadPool(1);\n    }\n\n    @AfterClass\n    public static void shutDownExecutorService() {\n        executorService.shutdown();\n        executorService = null;\n    } \n\n    @Test\n    public void getTrimmedStackForJUnit4TestFailingInTestMethod() {\n        Result result = runTest(TestWithOneThrowingTestMethod.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: cause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$TestWithOneThrowingTestMethod.alwaysThrows\"));\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    @Test\n    public void getTrimmedStackForJUnit4TestFailingInTestMethodWithCause() {\n        Result result = runTest(TestWithOneThrowingTestMethodWithCause.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: outer\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.throwsExceptionWithCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$TestWithOneThrowingTestMethodWithCause.alwaysThrows\"),\n                framesTrimmed(),\n                message(\"Caused by: java.lang.RuntimeException: cause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithCause\"),\n                framesInCommon());\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    @Test\n    public void getTrimmedStackForJUnit4TestFailingInBeforeMethod() {\n        Result result = runTest(TestWithThrowingBeforeMethod.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: cause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$TestWithThrowingBeforeMethod.alwaysThrows\"));\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    @Test\n    public void getTrimmedStackForJUnit3TestFailingInTestMethod() {\n        Result result = runTest(SampleJUnit3Tests.TestWithOneThrowingTestMethod.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: cause\"),\n                at(\"junit.tests.SampleJUnit3Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"junit.tests.SampleJUnit3Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"junit.tests.SampleJUnit3Tests$TestWithOneThrowingTestMethod.testAlwaysThrows\"));\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n    \n    @Test\n    public void getTrimmedStackForJUnit3TestFailingInSetupMethod() {\n        Result result = runTest(SampleJUnit3Tests.TestWithThrowingSetUpMethod.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: cause\"),\n                at(\"junit.tests.SampleJUnit3Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"junit.tests.SampleJUnit3Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"junit.tests.SampleJUnit3Tests$TestWithThrowingSetUpMethod.setUp\"));\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    @Test\n    public void getTrimmedStackForJUnit4TestFailingInTestRule() {\n        Result result = runTest(TestWithThrowingTestRule.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: cause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$ThrowingTestRule.apply\"));\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    @Test\n    public void getTrimmedStackForJUnit4TestFailingInClassRule() {\n        Result result = runTest(TestWithThrowingClassRule.class);\n        assertEquals(\"No tests were executed\", 0, result.getRunCount());\n        assertEquals(\"One failure\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: cause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$ThrowingTestRule.apply\"));\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    @Test\n    public void getTrimmedStackForJUnit4TestFailingInMethodRule() {\n        Result result = runTest(TestWithThrowingMethodRule.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: cause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.doThrowExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$FakeClassUnderTest.throwsExceptionWithoutCause\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$ThrowingMethodRule.apply\"));\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    @Test\n    public void getTrimmedStackWithSuppressedExceptions() {\n        assumeTrue(\"Running on 1.7+\", TestWithSuppressedException.addSuppressed != null);\n        Result result = runTest(TestWithSuppressedException.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"One test should fail\", 1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n\n        assertHasTrimmedTrace(failure,\n                message(\"java.lang.RuntimeException: error\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$TestWithSuppressedException.alwaysThrows\"),\n                message(\"\\tSuppressed: java.lang.RuntimeException: suppressed\"),\n                at(\"org.junit.tests.SampleJUnit4Tests$TestWithSuppressedException.alwaysThrows\"),\n                framesInCommon());\n        assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());\n    }\n\n    private abstract static class StringMatcher extends TypeSafeMatcher<String> {\n    }\n\n    /**\n     * A matcher that matches the exception message in a stack trace.\n     */\n    private static class ExceptionMessageMatcher extends StringMatcher {\n        private final Matcher<String> matcher;\n\n        public ExceptionMessageMatcher(String message) {\n            matcher = CoreMatchers.equalTo(message);\n        }\n\n        public void describeTo(Description description) {\n            matcher.describeTo(description);\n        }\n\n        @Override\n        protected boolean matchesSafely(String line) {\n            return matcher.matches(line);\n        }\n    }\n\n    /** Returns a matcher that matches the message line in a stack trace. */\n    private static StringMatcher message(String message) {\n        return new ExceptionMessageMatcher(message);\n    }\n\n    /**\n     * A matcher that matches the \"at ...\" line in a stack trace.\n     */\n    private static class StackTraceLineMatcher extends StringMatcher {\n        private static final Pattern PATTERN\n                = Pattern.compile(\"\\t*at ([a-zA-Z0-9.$]+)\\\\([a-zA-Z0-9]+\\\\.java:[0-9]+\\\\)\");\n\n        private final String method;\n\n        public StackTraceLineMatcher(String method) {\n            this.method = method;\n        }\n\n        public void describeTo(Description description) {\n            description.appendText(\"A stack trace line for method \" + method);\n        }\n\n        @Override\n        protected boolean matchesSafely(String line) {\n            if (!line.startsWith(\"\\t\")) {\n                return false;\n            }\n\n            line = line.substring(1);\n            java.util.regex.Matcher matcher = PATTERN.matcher(line);\n            if (!matcher.matches()) {\n                fail(\"Line does not look like a stack trace line: \" + line);\n            }\n            String matchedMethod = matcher.group(1);\n            return method.equals(matchedMethod);\n        }\n    }\n\n    /** Returns a matcher that matches the \"at ...\" line in a stack trace. */\n    private static StringMatcher at(String method) {\n        return new StackTraceLineMatcher(method);\n    }\n\n    /**\n     * A matcher that matches the line printed when frames were removed from a stack trace.\n     */\n    private static class FramesRemovedMatcher extends StringMatcher {\n        private static final Pattern PATTERN\n                = Pattern.compile(\"\\t*\\\\.\\\\.\\\\. [0-9]+ ([a-z]+)\");\n\n        private final String suffix;\n\n        public FramesRemovedMatcher(String suffix) {\n            this.suffix = suffix;\n        }\n\n        public void describeTo(Description description) {\n            description.appendText(\"A line matching \\\"..x \" + suffix + \"\\\"\");\n        }\n\n        @Override\n        protected boolean matchesSafely(String line) {\n            if (!line.startsWith(\"\\t\")) {\n                return false;\n            }\n            line = line.substring(1);\n\n            java.util.regex.Matcher matcher = PATTERN.matcher(line);\n            if (!matcher.matches()) {\n                fail(\"Line does not look like a stack trace line: \" + line);\n            }\n            return suffix.equals(matcher.group(1));\n        }\n    }\n\n    /** Returns a matcher that matches the \"\\t...x more\" line in a stack trace. */\n    private static StringMatcher framesInCommon() {\n        return new FramesRemovedMatcher(\"more\");\n    }\n\n    /** Returns a matcher that matches the \"\\t...x trimmed\" line in a stack trace. */\n    private static StringMatcher framesTrimmed() {\n        return new FramesRemovedMatcher(\"trimmed\");\n    }\n\n    private static Result runTest(final Class<?> testClass) {\n        Future<Result> future = executorService.submit(new Callable<Result>() {\n            public Result call() throws Exception {\n                JUnitCore core = new JUnitCore();\n                return core.run(testClass);\n            }\n        });\n\n        try {\n            return future.get();\n        } catch (InterruptedException e) {\n            throw new RuntimeException(\"Could not run test \" + testClass, e);\n        } catch (ExecutionException e) {\n            throw new RuntimeException(\"Could not run test \" + testClass, e);\n        }\n    }\n    \n    private static void assertHasTrimmedTrace(Failure failure, StringMatcher... matchers) {\n        String trimmedTrace = failure.getTrimmedTrace();\n        String[] lines = trimmedTrace.split(EOL);\n\n        int index = 0;\n        for (; index < lines.length && index < matchers.length; index++) {\n            String line = lines[index];\n            StringMatcher matcher = matchers[index];\n            assertThat(line, matcher);\n        }\n        if (index < lines.length) {\n            String extraLine = lines[index];\n            fail(\"Extra line in trimmed trace: \" + extraLine);\n        } else if (index < matchers.length) {\n            StringDescription description = new StringDescription();\n            matchers[index].describeTo(description);\n            fail(\"Missing line in trimmed trace: \" + description.toString());\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/internal/builders/AnnotatedBuilderTest.java",
    "content": "package org.junit.internal.builders;\n\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.core.IsInstanceOf.instanceOf;\nimport static org.hamcrest.core.IsNull.nullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.RunnerSpy;\nimport org.junit.runners.model.RunnerBuilder;\nimport org.junit.runners.model.RunnerBuilderStub;\n\npublic class AnnotatedBuilderTest {\n    private AnnotatedBuilder builder = new AnnotatedBuilder(new RunnerBuilderStub());\n\n    @Test\n    public void topLevelTestClassWithoutAnnotation_isRunWithDefaultRunner() throws Exception {\n        Runner runner = builder.runnerForClass(Object.class);\n        assertThat(runner, is(nullValue()));\n    }\n\n    @Test\n    public void topLevelTestClassWithAnnotation_isRunWithAnnotatedRunner() throws Exception {\n        Runner runner = builder.runnerForClass(OuterClass.class);\n        assertThat(runner, is(instanceOf(RunnerSpy.class)));\n\n        RunnerSpy runnerSpy = (RunnerSpy) runner;\n        assertThat(runnerSpy.getInvokedTestClass(), is((Object) OuterClass.class));\n    }\n\n    @Test\n    public void memberClassInsideAnnotatedTopLevelClass_isRunWithTopLevelRunner() throws Exception {\n        Runner runner = builder.runnerForClass(OuterClass.InnerClassWithoutOwnRunWith.class);\n        assertThat(runner, is(instanceOf(RunnerSpy.class)));\n\n        RunnerSpy runnerSpy = (RunnerSpy) runner;\n        assertThat(runnerSpy.getInvokedTestClass(), is((Object) OuterClass.InnerClassWithoutOwnRunWith.class));\n    }\n\n    @Test\n    public void memberClassDeepInsideAnnotatedTopLevelClass_isRunWithTopLevelRunner() throws Exception {\n        Runner runner = builder.runnerForClass(OuterClass.InnerClassWithoutOwnRunWith.MostInnerClass.class);\n        assertThat(runner, is(instanceOf(RunnerSpy.class)));\n\n        RunnerSpy runnerSpy = (RunnerSpy) runner;\n        assertThat(runnerSpy.getInvokedTestClass(), is((Object) OuterClass.InnerClassWithoutOwnRunWith.MostInnerClass.class));\n    }\n\n    @Test\n    public void annotatedMemberClassInsideAnnotatedTopLevelClass_isRunWithOwnRunner() throws Exception {\n        Runner runner = builder.runnerForClass(OuterClass.InnerClassWithOwnRunWith.class);\n        assertThat(runner, is(instanceOf(InnerRunner.class)));\n\n        RunnerSpy runnerSpy = (RunnerSpy) runner;\n        assertThat(runnerSpy.getInvokedTestClass(), is((Object) OuterClass.InnerClassWithOwnRunWith.class));\n    }\n\n    @Test\n    public void memberClassDeepInsideAnnotatedMemberClass_isRunWithParentMemberClassRunner() throws Exception {\n        Runner runner = builder.runnerForClass(OuterClass.InnerClassWithOwnRunWith.MostInnerClass.class);\n        assertThat(runner, is(instanceOf(InnerRunner.class)));\n\n        RunnerSpy runnerSpy = (RunnerSpy) runner;\n        assertThat(runnerSpy.getInvokedTestClass(), is((Object) OuterClass.InnerClassWithOwnRunWith.MostInnerClass.class));\n    }\n\n    @RunWith(RunnerSpy.class)\n    public static class OuterClass {\n        public class InnerClassWithoutOwnRunWith {\n            @Test\n            public void test() {\n            }\n\n            public class MostInnerClass {\n                @Test\n                public void test() {\n                }\n            }\n        }\n\n        @RunWith(InnerRunner.class)\n        public class InnerClassWithOwnRunWith {\n            @Test\n            public void test() {\n            }\n\n            public class MostInnerClass {\n                @Test\n                public void test() {\n                }\n            }\n        }\n    }\n\n    public static class InnerRunner extends RunnerSpy {\n        public InnerRunner(Class<?> testClass) {\n            super(testClass);\n        }\n\n        public InnerRunner(Class<?> testClass, RunnerBuilder runnerBuilder) {\n            super(testClass, runnerBuilder);\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/internal/matchers/StacktracePrintingMatcherTest.java",
    "content": "package org.junit.internal.matchers;\n\nimport static org.hamcrest.CoreMatchers.any;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.CoreMatchers.notNullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.internal.matchers.StacktracePrintingMatcher.isException;\nimport static org.junit.internal.matchers.StacktracePrintingMatcher.isThrowable;\n\nimport org.junit.Test;\n\npublic class StacktracePrintingMatcherTest {\n\n    @Test\n    public void succeedsWhenInnerMatcherSucceeds() throws Exception {\n        assertTrue(isThrowable(any(Throwable.class)).matches(new Exception()));\n    }\n\n    @Test\n    public void failsWhenInnerMatcherFails() throws Exception {\n        assertFalse(isException(notNullValue(Exception.class)).matches(null));\n    }\n\n    @Test\n    public void assertThatIncludesStacktrace() {\n        Exception actual = new IllegalArgumentException(\"my message\");\n        Exception expected = new NullPointerException();\n\n        try {\n            assertThat(actual, isThrowable(equalTo(expected)));\n        } catch (AssertionError e) {\n            assertThat(e.getMessage(), containsString(\"Stacktrace was: java.lang.IllegalArgumentException: my message\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/internal/matchers/ThrowableCauseMatcherTest.java",
    "content": "package org.junit.internal.matchers;\n\nimport org.junit.Test;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause;\n\npublic class ThrowableCauseMatcherTest {\n\n    @Test\n    public void shouldAllowCauseOfDifferentClassFromRoot() throws Exception {\n        NullPointerException expectedCause = new NullPointerException(\"expected\");\n        Exception actual = new Exception(expectedCause);\n\n        assertThat(actual, hasCause(is(expectedCause)));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/internal/runners/ErrorReportingRunnerTest.java",
    "content": "package org.junit.internal.runners;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.InvalidTestClassError;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.startsWith;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\npublic class ErrorReportingRunnerTest {\n    \n    @Test(expected = NullPointerException.class)\n    public void cannotCreateWithNullClass() {\n        new ErrorReportingRunner(null, new RuntimeException());\n    }\n    \n    @Test(expected = NullPointerException.class)\n    public void cannotCreateWithNullClass2() {\n        new ErrorReportingRunner(new RuntimeException(), (Class<?>) null);\n    }\n    \n    @Test(expected = NullPointerException.class)\n    public void cannotCreateWithNullClasses() {\n        new ErrorReportingRunner(new RuntimeException(), (Class<?>[]) null);\n    }\n    \n    @Test(expected = NullPointerException.class)\n    public void cannotCreateWithoutClass() {\n        new ErrorReportingRunner(new RuntimeException());\n    }\n\n    @Test\n    public void givenInvalidTestClassErrorAsCause() {\n        final List<Failure> firedFailures = new ArrayList<Failure>();\n        InvalidTestClassError testClassError = new InvalidTestClassError(TestClassWithErrors.class,\n                Arrays.asList(new Throwable(\"validation error 1\"), new Throwable(\"validation error 2\")));\n        ErrorReportingRunner sut = new ErrorReportingRunner(TestClassWithErrors.class, testClassError);\n\n        sut.run(new RunNotifier() {\n            @Override\n            public void fireTestFailure(Failure failure) {\n                super.fireTestFailure(failure);\n                firedFailures.add(failure);\n            }\n        });\n\n        assertThat(firedFailures.size(), is(1));\n        Throwable exception = firedFailures.get(0).getException();\n        assertThat(exception, instanceOf(InvalidTestClassError.class));\n        assertThat(((InvalidTestClassError) exception), is(testClassError));\n    }\n\n    @Test\n    public void givenInvalidTestClass_integrationTest() {\n        Result result = JUnitCore.runClasses(TestClassWithErrors.class);\n\n        assertThat(result.getFailureCount(), is(1));\n        Throwable failure = result.getFailures().get(0).getException();\n        assertThat(failure, instanceOf(InvalidTestClassError.class));\n        assertThat(failure.getMessage(), allOf(\n                startsWith(\"Invalid test class '\" + TestClassWithErrors.class.getName() + \"'\"),\n                containsString(\"\\n  1. \"),\n                containsString(\"\\n  2. \")\n        ));\n    }\n\n    private static class TestClassWithErrors {\n        @Before public static void staticBeforeMethod() {}\n        @After public static void staticAfterMethod() {}\n\n        @Test public String testMethodReturningString() {\n            return \"this should not be allowed\";\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/internal/runners/statements/ExpectExceptionTest.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport org.junit.Test;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runners.model.Statement;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.fail;\n\n/**\n * Integration tests can be found in {@link org.junit.tests.running.methods.ExpectedTest}.\n * See e.g. {@link org.junit.tests.running.methods.ExpectedTest#expectsAssumptionViolatedException()}\n */\npublic class ExpectExceptionTest {\n\n    @Test\n    public void whenExpectingAssumptionViolatedExceptionStatementsThrowingItShouldPass() {\n        Statement delegate = new Fail(new AssumptionViolatedException(\"expected\"));\n        ExpectException expectException = new ExpectException(delegate, AssumptionViolatedException.class);\n\n        try {\n            expectException.evaluate();\n            // then AssumptionViolatedException should not be thrown\n        } catch (Throwable e) { // need to explicitly catch and re-throw as an AssertionError or it might be skipped\n            fail(\"should not throw anything, but was thrown: \" + e);\n        }\n    }\n\n    @Test\n    public void whenExpectingAssumptionViolatedExceptionStatementsThrowingSubclassShouldPass() {\n        Statement delegate = new Fail(new AssumptionViolatedExceptionSubclass(\"expected\"));\n        ExpectException expectException = new ExpectException(delegate, AssumptionViolatedException.class);\n\n        try {\n            expectException.evaluate();\n            // then no exception should be thrown\n        } catch (Throwable e) {\n            fail(\"should not throw anything, but was thrown: \" + e);\n        }\n    }\n\n    @Test\n    public void whenExpectingAssumptionViolatedExceptionStatementsThrowingDifferentExceptionShouldFail() {\n        Statement delegate = new Fail(new SomeException(\"not expected\"));\n        ExpectException expectException = new ExpectException(delegate, AssumptionViolatedException.class);\n\n        try {\n            expectException.evaluate();\n            fail(\"should throw 'Unexpected exception' when statement throws an exception which is not the one expected\");\n        } catch (Exception e) {\n            assertThat(e.getMessage(), equalTo(\"Unexpected exception, expected<org.junit.internal.AssumptionViolatedException> \" +\n                    \"but was<org.junit.internal.runners.statements.ExpectExceptionTest$SomeException>\"));\n        }\n    }\n\n    @Test\n    public void whenExpectingAssumptionViolatedExceptionStatementsPassingShouldFail() throws Exception {\n        ExpectException expectException = new ExpectException(new PassingStatement(), AssumptionViolatedException.class);\n\n        try {\n            expectException.evaluate();\n        } catch (AssertionError e) {\n            assertThat(e.getMessage(), containsString(\"Expected exception: \" + AssumptionViolatedException.class.getName()));\n            return;\n        }\n        fail(\"ExpectException should throw when the given statement passes\");\n    }\n\n    private static class PassingStatement extends Statement {\n        public void evaluate() throws Throwable {\n            // nop\n        }\n    }\n\n    private static class SomeException extends RuntimeException {\n        public SomeException(String message) {\n            super(message);\n        }\n    }\n\n    private static class AssumptionViolatedExceptionSubclass extends AssumptionViolatedException {\n        public AssumptionViolatedExceptionSubclass(String assumption) {\n            super(assumption);\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/internal/runners/statements/FailOnTimeoutTest.java",
    "content": "package org.junit.internal.runners.statements;\n\nimport static java.lang.Long.MAX_VALUE;\nimport static java.lang.Math.atan;\nimport static java.lang.System.currentTimeMillis;\nimport static java.lang.Thread.currentThread;\nimport static java.lang.Thread.interrupted;\nimport static java.lang.Thread.sleep;\nimport static java.util.concurrent.TimeUnit.MILLISECONDS;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.assertNotSame;\nimport static org.junit.Assert.assertSame;\nimport static org.junit.Assert.assertThrows;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assume.assumeFalse;\nimport static org.junit.Assume.assumeTrue;\n\nimport java.util.Arrays;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicBoolean;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport org.junit.Test;\nimport org.junit.function.ThrowingRunnable;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameter;\nimport org.junit.runners.Parameterized.Parameters;\nimport org.junit.runners.model.Statement;\nimport org.junit.runners.model.TestTimedOutException;\n\n\n/**\n * @author Asaf Ary, Stefan Birkner\n */\n@RunWith(Parameterized.class)\npublic class FailOnTimeoutTest {\n\n    @Parameters(name = \"lookingForStuckThread = {0}\")\n    public static Iterable<Boolean> getParameters() {\n        return Arrays.asList(Boolean.TRUE, Boolean.FALSE);\n    }\n\n    @Parameter\n    public boolean lookingForStuckThread;\n\n    @Test\n    public void noExceptionIsThrownWhenWrappedStatementFinishesBeforeTimeoutWithoutThrowingException()\n            throws Throwable {\n        FailOnTimeout failOnTimeout = failAfter50Ms(new FastStatement());\n\n        failOnTimeout.evaluate();\n\n        // test is successful when no exception is thrown\n    }\n\n    @Test\n    public void throwsTestTimedOutExceptionWithMeaningfulMessage() {\n        Exception e = assertThrows(\n                TestTimedOutException.class,\n                run(failAfter50Ms(new RunForASecond())));\n        assertEquals(\"test timed out after 50 milliseconds\", e.getMessage());\n    }\n\n    @Test\n    public void sendUpExceptionThrownByStatement() {\n        Exception exception = new RuntimeException();\n        Exception e = assertThrows(\n                Exception.class,\n                run(failAfter50Ms(new Fail(exception))));\n        assertSame(exception, e);\n    }\n\n    @Test\n    public void throwExceptionIfTheSecondCallToEvaluateNeedsTooMuchTime()\n            throws Throwable {\n        DelegatingStatement statement = new DelegatingStatement();\n        FailOnTimeout failOnTimeout = failAfter50Ms(statement);\n\n        statement.delegate = new FastStatement();\n        failOnTimeout.evaluate();\n\n        statement.delegate = new RunForASecond();\n        assertThrows(\n                TestTimedOutException.class,\n                run(failOnTimeout));\n    }\n\n    @Test\n    public void throwTimeoutExceptionOnSecondCallAlthoughFirstCallThrowsException() {\n        DelegatingStatement statement = new DelegatingStatement();\n        FailOnTimeout failOnTimeout = failAfter50Ms(statement);\n\n        statement.delegate = new Fail(new AssertionError(\"first execution failed\"));\n        assertThrows(\n                AssertionError.class,\n                run(failOnTimeout)\n        );\n\n        statement.delegate = new RunForASecond();\n        assertThrows(\n                TestTimedOutException.class,\n                run(failOnTimeout));\n    }\n\n    @Test\n    public void throwsExceptionWithTimeoutValueAndTimeUnitSet() {\n        TestTimedOutException e = assertThrows(\n                TestTimedOutException.class,\n                run(failAfter50Ms(new RunForASecond())));\n        assertEquals(50, e.getTimeout());\n        assertEquals(MILLISECONDS, e.getTimeUnit());\n    }\n\n    @Test\n    public void statementThatCanBeInterruptedIsStoppedAfterTimeout() throws Throwable {\n        // RunForASecond can be interrupted because it checks the Thread's\n        // interrupted flag.\n        RunForASecond runForASecond = new RunForASecond();\n        assertThrows(\n                TestTimedOutException.class,\n                run(failAfter50Ms(runForASecond)));\n\n        // Thread is explicitly stopped if it finishes faster than its\n        // pre-defined execution time of one second.\n        boolean stopped = runForASecond.finished.await(50, MILLISECONDS);\n        assertTrue(\"Thread has not been stopped.\", stopped);\n    }\n\n    @Test\n    public void stackTraceContainsRealCauseOfTimeout() {\n        TestTimedOutException timedOutException = assertThrows(\n                TestTimedOutException.class,\n                run(failAfter50Ms(new StuckStatement())));\n\n        StackTraceElement[] stackTrace = timedOutException.getStackTrace();\n        boolean stackTraceContainsTheRealCauseOfTheTimeout = false;\n        boolean stackTraceContainsOtherThanTheRealCauseOfTheTimeout = false;\n        for (StackTraceElement element : stackTrace) {\n            String methodName = element.getMethodName();\n            if (\"theRealCauseOfTheTimeout\".equals(methodName)) {\n                stackTraceContainsTheRealCauseOfTheTimeout = true;\n            }\n            if (\"notTheRealCauseOfTheTimeout\".equals(methodName)) {\n                stackTraceContainsOtherThanTheRealCauseOfTheTimeout = true;\n            }\n        }\n        assertTrue(\n                \"Stack trace does not contain the real cause of the timeout\",\n                stackTraceContainsTheRealCauseOfTheTimeout);\n        assertFalse(\n                \"Stack trace contains other than the real cause of the timeout, which can be very misleading\",\n                stackTraceContainsOtherThanTheRealCauseOfTheTimeout);\n    }\n\n    private static final class StuckStatement extends Statement {\n\n        @Override\n        public void evaluate() throws Throwable {\n            try {\n                // Must show up in stack trace\n                theRealCauseOfTheTimeout();\n            } catch (InterruptedException e) {\n            } finally {\n                // Must _not_ show up in stack trace\n                notTheRealCauseOfTheTimeout();\n            }\n        }\n\n        private void theRealCauseOfTheTimeout() throws InterruptedException {\n            sleep(MAX_VALUE);\n        }\n\n        private void notTheRealCauseOfTheTimeout() {\n            for (long now = currentTimeMillis(), eta = now + 1000L; now < eta; now = currentTimeMillis()) {\n                // Doesn't matter, just pretend to be busy\n                atan(now);\n            }\n        }\n    }\n\n    @Test\n    public void lookingForStuckThread_threadGroupNotLeaked() throws Throwable {\n        assumeTrue(lookingForStuckThread);\n        assumeTrue(\"Thread groups can no longer be destroyed on JDK 16 and later\", System.getProperty(\"java.vm.specification.version\").compareTo(\"16\") < 0);\n\n        final AtomicReference<ThreadGroup> innerThreadGroup = new AtomicReference<ThreadGroup>();\n        final AtomicReference<Thread> innerThread = new AtomicReference<Thread>();\n        final ThreadGroup outerThreadGroup = currentThread().getThreadGroup();\n        FailOnTimeout failOnTimeout = failAfter50Ms(new Statement() {\n            @Override\n            public void evaluate() {\n                innerThread.set(currentThread());\n                ThreadGroup group = currentThread().getThreadGroup();\n                assertNotSame(\"inner thread should use a different thread group\",\n                        outerThreadGroup, group);\n                innerThreadGroup.set(group);\n                assertTrue(\"the 'FailOnTimeoutGroup' thread group should be a daemon thread group\",\n                        group.isDaemon());\n            }\n        });\n\n        failOnTimeout.evaluate();\n\n        assertNotNull(\"the Statement was never run\", innerThread.get());\n        innerThread.get().join();\n        assertTrue(\"the 'FailOnTimeoutGroup' thread group should be destroyed after running the test\",\n                innerThreadGroup.get().isDestroyed());\n    }\n\n    @Test\n    public void notLookingForStuckThread_usesSameThreadGroup() throws Throwable {\n        assumeFalse(lookingForStuckThread);\n        final AtomicBoolean statementWasExecuted = new AtomicBoolean();\n        final ThreadGroup outerThreadGroup = currentThread().getThreadGroup();\n        FailOnTimeout failOnTimeout = failAfter50Ms(new Statement() {\n            @Override\n            public void evaluate() {\n                statementWasExecuted.set(true);\n                ThreadGroup group = currentThread().getThreadGroup();\n                assertSame(\"inner thread should use the same thread group\", outerThreadGroup, group);\n            }\n        });\n\n        failOnTimeout.evaluate();\n\n        assertTrue(\"the Statement was never run\", statementWasExecuted.get());\n    }\n\n    private FailOnTimeout failAfter50Ms(Statement statement) {\n        return FailOnTimeout.builder()\n                .withTimeout(50, MILLISECONDS)\n                .withLookingForStuckThread(lookingForStuckThread)\n                .build(statement);\n    }\n\n    private ThrowingRunnable run(final FailOnTimeout failOnTimeout) {\n        return new ThrowingRunnable() {\n            public void run() throws Throwable {\n                failOnTimeout.evaluate();\n            }\n        };\n    }\n\n    private static class DelegatingStatement extends Statement {\n        volatile Statement delegate;\n\n        @Override\n        public void evaluate() throws Throwable {\n            delegate.evaluate();\n        }\n    }\n\n    private static class FastStatement extends Statement {\n        @Override\n        public void evaluate() throws Throwable {\n        }\n    }\n\n    private static final class RunForASecond extends Statement {\n        final CountDownLatch finished = new CountDownLatch(1);\n\n        @Override\n        public void evaluate() throws Throwable {\n            long timeout = currentTimeMillis() + 1000L;\n            while (!interrupted() && currentTimeMillis() < timeout) {\n            }\n            finished.countDown();\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/AllRulesTests.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        BlockJUnit4ClassRunnerOverrideTest.class,\n        ClassRulesTest.class,\n        DisableOnDebugTest.class,\n        ErrorCollectorTest.class,\n        ExpectedExceptionTest.class,\n        ExternalResourceRuleTest.class,\n        MethodRulesTest.class,\n        NameRulesTest.class,\n        RuleChainTest.class,\n        RuleMemberValidatorTest.class,\n        StopwatchTest.class,\n        TempFolderRuleTest.class,\n        TemporaryFolderRuleAssuredDeletionTest.class,\n        TemporaryFolderUsageTest.class,\n        TestRuleTest.class,\n        TestWatcherTest.class,\n        TestWatchmanTest.class,\n        TestWatchmanTest.class,\n        TimeoutRuleTest.class,\n        VerifierRuleTest.class\n})\npublic class AllRulesTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/BlockJUnit4ClassRunnerOverrideTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.Statement;\n\npublic class BlockJUnit4ClassRunnerOverrideTest {\n    public static class FlipBitRule implements MethodRule {\n        public Statement apply(final Statement base, FrameworkMethod method,\n                final Object target) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    target.getClass().getField(\"flipBit\").set(target, true);\n                    base.evaluate();\n                }\n            };\n        }\n\n    }\n\n    public static class OverrideRulesRunner extends BlockJUnit4ClassRunner {\n        public OverrideRulesRunner(Class<?> klass) throws InitializationError {\n            super(klass);\n        }\n\n        @Override\n        protected List<MethodRule> rules(Object test) {\n            final LinkedList<MethodRule> methodRules = new LinkedList<MethodRule>(\n                    super.rules(test));\n            methodRules.add(new FlipBitRule());\n            return methodRules;\n        }\n    }\n\n    @RunWith(OverrideRulesRunner.class)\n    public static class OverrideRulesTest {\n        public boolean flipBit = false;\n\n        @Test\n        public void testFlipBit() {\n            assertTrue(flipBit);\n        }\n    }\n\n    @Test\n    public void overrideRulesMethod() {\n        assertThat(testResult(OverrideTestRulesTest.class), isSuccessful());\n    }\n\n    public static class OverrideTestRulesRunner extends BlockJUnit4ClassRunner {\n        public OverrideTestRulesRunner(Class<?> klass)\n                throws InitializationError {\n            super(klass);\n        }\n\n        @Override\n        protected List<TestRule> getTestRules(final Object test) {\n            final LinkedList<TestRule> methodRules = new LinkedList<TestRule>(\n                    super.getTestRules(test));\n            methodRules.add(new TestRule() {\n                public Statement apply(Statement base, Description description) {\n                    return new FlipBitRule().apply(base, null, test);\n                }\n            });\n            return methodRules;\n        }\n    }\n\n    @RunWith(OverrideTestRulesRunner.class)\n    public static class OverrideTestRulesTest extends OverrideRulesTest {\n    }\n\n    @Test\n    public void overrideTestRulesMethod() {\n        assertThat(testResult(OverrideRulesTest.class), isSuccessful());\n    }\n\n\n    /**\n     * Runner for testing override of {@link org.junit.runners.BlockJUnit4ClassRunner#createTest(org.junit.runners.model.FrameworkMethod)}\n     * by setting the {@link org.junit.runners.model.FrameworkMethod} in a field\n     * of the test class so it can be compared with the test method that is being\n     * executed.\n     */\n    public static class OverrideCreateTestRunner extends BlockJUnit4ClassRunner {\n        public OverrideCreateTestRunner(final Class<?> klass) throws InitializationError {\n            super(klass);\n\n            assert(klass.equals(OverrideCreateTest.class));\n        }\n\n        @Override\n        protected Object createTest(FrameworkMethod method) {\n            final OverrideCreateTest obj = new OverrideCreateTest();\n\n            obj.method = method;\n\n            return obj;\n        }\n    }\n\n    @RunWith(OverrideCreateTestRunner.class)\n    public static class OverrideCreateTest {\n        public FrameworkMethod method;\n\n        @Test\n        public void testMethodA() {\n            assertEquals(\"testMethodA\", method.getMethod().getName());\n        }\n\n        @Test\n        public void testMethodB() {\n            assertEquals(\"testMethodB\", method.getMethod().getName());\n        }\n    }\n\n    @Test\n    public void overrideCreateTestMethod() {\n        assertThat(testResult(OverrideCreateTest.class), isSuccessful());\n    }\n\n\n    /**\n     * Runner for testing override of {@link org.junit.runners.BlockJUnit4ClassRunner#createTest()}\n     * is still called by default if no other {@code createTest} method override\n     * is in place. This is tested by setting a boolean flag in a field of the\n     * test class so it can be checked to confirm that the createTest method was\n     * called.\n     */\n    public static class CreateTestDefersToNoArgCreateTestRunner extends BlockJUnit4ClassRunner {\n        public CreateTestDefersToNoArgCreateTestRunner(final Class<?> klass) throws InitializationError {\n            super(klass);\n\n            assert(klass.equals(CreateTestDefersToNoArgCreateTestTest.class));\n        }\n\n        @Override\n        protected Object createTest() {\n            final CreateTestDefersToNoArgCreateTestTest obj = new CreateTestDefersToNoArgCreateTestTest();\n\n            obj.createTestCalled = true;\n\n            return obj;\n        }\n    }\n\n    @RunWith(CreateTestDefersToNoArgCreateTestRunner.class)\n    public static class CreateTestDefersToNoArgCreateTestTest {\n        public boolean createTestCalled = false;\n\n        @Test\n        public void testCreateTestCalled() {\n            assertEquals(true, createTestCalled);\n        }\n    }\n\n    @Test\n    public void createTestDefersToNoArgCreateTest() {\n        assertThat(testResult(CreateTestDefersToNoArgCreateTestTest.class), isSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/ClassRulesTest.java",
    "content": "/*\n * Created Oct 19, 2009\n */\npackage org.junit.rules;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport org.junit.ClassRule;\nimport org.junit.FixMethodOrder;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.MethodSorters;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.Statement;\n\n/**\n * Tests to exercise class-level rules.\n */\npublic class ClassRulesTest {\n    public static class Counter extends ExternalResource {\n        public int count = 0;\n\n        @Override\n        protected void before() throws Throwable {\n            count++;\n        }\n    }\n\n    public static class ExampleTestWithClassRule {\n        @ClassRule\n        public static Counter counter = new Counter();\n\n        @Test\n        public void firstTest() {\n            assertEquals(1, counter.count);\n        }\n\n        @Test\n        public void secondTest() {\n            assertEquals(1, counter.count);\n        }\n    }\n\n    @Test\n    public void ruleIsAppliedOnce() {\n        ExampleTestWithClassRule.counter.count = 0;\n        JUnitCore.runClasses(ExampleTestWithClassRule.class);\n        assertEquals(1, ExampleTestWithClassRule.counter.count);\n    }\n\n    public static class SubclassOfTestWithClassRule extends\n            ExampleTestWithClassRule {\n\n    }\n\n    @Test\n    public void ruleIsIntroducedAndEvaluatedOnSubclass() {\n        ExampleTestWithClassRule.counter.count = 0;\n        JUnitCore.runClasses(SubclassOfTestWithClassRule.class);\n        assertEquals(1, ExampleTestWithClassRule.counter.count);\n    }\n\n    public static class CustomCounter implements TestRule {\n        public int count = 0;\n\n        public Statement apply(final Statement base, Description description) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    count++;\n                    base.evaluate();\n                }\n            };\n        }\n    }\n\n    public static class ExampleTestWithCustomClassRule {\n        @ClassRule\n        public static CustomCounter counter = new CustomCounter();\n\n        @Test\n        public void firstTest() {\n            assertEquals(1, counter.count);\n        }\n\n        @Test\n        public void secondTest() {\n            assertEquals(1, counter.count);\n        }\n    }\n\n\n    @Test\n    public void customRuleIsAppliedOnce() {\n        ExampleTestWithCustomClassRule.counter.count = 0;\n        Result result = JUnitCore.runClasses(ExampleTestWithCustomClassRule.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(1, ExampleTestWithCustomClassRule.counter.count);\n    }\n\n    private static final List<String> orderList = new LinkedList<String>();\n\n    private static class OrderTestRule implements TestRule {\n        private String name;\n\n        public OrderTestRule(String name) {\n            this.name = name;\n        }\n\n        public Statement apply(final Statement base, final Description description) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    orderList.add(name);\n                    base.evaluate();\n                }\n            };\n        }\n    }\n\n    public static class UsesFieldAndMethodRule {\n        @ClassRule\n        public static OrderTestRule orderMethod() {\n            return new OrderTestRule(\"orderMethod\");\n        }\n\n        @ClassRule\n        public static OrderTestRule orderField = new OrderTestRule(\"orderField\");\n\n        @Test\n        public void foo() {\n            assertEquals(\"orderField\", orderList.get(0));\n            assertEquals(\"orderMethod\", orderList.get(1));\n        }\n    }\n\n    @Test\n    public void usesFieldAndMethodRule() {\n        orderList.clear();\n        assertThat(testResult(UsesFieldAndMethodRule.class), isSuccessful());\n    }\n\n\n    public static class MethodExampleTestWithClassRule {\n        private static Counter counter = new Counter();\n\n        @ClassRule\n        public static Counter getCounter() {\n            return counter;\n        }\n\n        @Test\n        public void firstTest() {\n            assertEquals(1, counter.count);\n        }\n\n        @Test\n        public void secondTest() {\n            assertEquals(1, counter.count);\n        }\n    }\n\n    @Test\n    public void methodRuleIsAppliedOnce() {\n        MethodExampleTestWithClassRule.counter.count = 0;\n        JUnitCore.runClasses(MethodExampleTestWithClassRule.class);\n        assertEquals(1, MethodExampleTestWithClassRule.counter.count);\n    }\n\n    public static class MethodSubclassOfTestWithClassRule extends\n            MethodExampleTestWithClassRule {\n\n    }\n\n    @Test\n    public void methodRuleIsIntroducedAndEvaluatedOnSubclass() {\n        MethodExampleTestWithClassRule.counter.count = 0;\n        JUnitCore.runClasses(MethodSubclassOfTestWithClassRule.class);\n        assertEquals(1, MethodExampleTestWithClassRule.counter.count);\n    }\n\n    public static class MethodExampleTestWithCustomClassRule {\n        private static CustomCounter counter = new CustomCounter();\n\n        @ClassRule\n        public static CustomCounter getCounter() {\n            return counter;\n        }\n\n        @Test\n        public void firstTest() {\n            assertEquals(1, counter.count);\n        }\n\n        @Test\n        public void secondTest() {\n            assertEquals(1, counter.count);\n        }\n    }\n\n\n    @Test\n    public void methodCustomRuleIsAppliedOnce() {\n        MethodExampleTestWithCustomClassRule.counter.count = 0;\n        Result result = JUnitCore.runClasses(MethodExampleTestWithCustomClassRule.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(1, MethodExampleTestWithCustomClassRule.counter.count);\n    }\n\n    public static class CallMethodOnlyOnceRule {\n        static int countOfMethodCalls = 0;\n\n        private static class Dummy implements TestRule {\n            public Statement apply(final Statement base, Description description) {\n                return new Statement() {\n                    @Override\n                    public void evaluate() throws Throwable {\n                        base.evaluate();\n                    }\n                };\n            }\n        }\n\n        @ClassRule\n        public static Dummy both() {\n            countOfMethodCalls++;\n            return new Dummy();\n        }\n\n        @Test\n        public void onlyOnce() {\n            assertEquals(1, countOfMethodCalls);\n        }\n    }\n\n    @Test\n    public void testCallMethodOnlyOnceRule() {\n        CallMethodOnlyOnceRule.countOfMethodCalls = 0;\n        assertTrue(JUnitCore.runClasses(CallMethodOnlyOnceRule.class).wasSuccessful());\n    }\n\n    private static final StringBuilder log = new StringBuilder();\n\n    @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n    public static class ClassRuleOrdering {\n        @ClassRule(order = 1)\n        public static TestRule a() {\n            return new LoggingTestRule(log, \"outer\");\n        }\n\n        @ClassRule(order = 2)\n        public static TestRule z() {\n            return new LoggingTestRule(log, \"inner\");\n        }\n\n        @Test\n        public void foo() {\n            log.append(\" foo\");\n        }\n\n        @Test\n        public void bar() {\n            log.append(\" bar\");\n        }\n    }\n\n    @Test\n    public void classRuleOrdering() {\n        log.setLength(0);\n        Result result = JUnitCore.runClasses(ClassRuleOrdering.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(\" outer.begin inner.begin bar foo inner.end outer.end\", log.toString());\n    }\n\n    @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n    public static class ClassRuleOrderingDefault {\n        @ClassRule\n        public static TestRule a() {\n            return new LoggingTestRule(log, \"outer\");\n        }\n\n        @ClassRule\n        public static TestRule b() {\n            return new LoggingTestRule(log, \"inner\");\n        }\n\n        @Test\n        public void foo() {\n            log.append(\" foo\");\n        }\n\n        @Test\n        public void bar() {\n            log.append(\" bar\");\n        }\n    }\n\n    @Test\n    public void classRuleOrderingDefault() {\n        log.setLength(0);\n        Result result = JUnitCore.runClasses(ClassRuleOrderingDefault.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(\" inner.begin outer.begin bar foo outer.end inner.end\", log.toString());\n    }\n\n    public static class RunnerWithClassRuleAddedProgrammatically extends BlockJUnit4ClassRunner {\n        public RunnerWithClassRuleAddedProgrammatically(Class testClass) throws InitializationError {\n            super(testClass);\n        }\n\n        @Override\n        protected List<TestRule> classRules() {\n            final List<TestRule> rules = super.classRules();\n            rules.add(new LoggingTestRule(log, \"fromCode\"));\n            return rules;\n        }\n    }\n\n    @RunWith(RunnerWithClassRuleAddedProgrammatically.class)\n    public static class ClassRulesModifiableListEmpty {\n        @Test\n        public void test() {\n            log.append(\" test\");\n        }\n    }\n\n    @Test\n    public void classRulesModifiableListEmpty() {\n        log.setLength(0);\n        Result result = JUnitCore.runClasses(ClassRulesModifiableListEmpty.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(\" fromCode.begin test fromCode.end\", log.toString());\n    }\n\n    @RunWith(RunnerWithClassRuleAddedProgrammatically.class)\n    public static class ClassRulesModifiableList {\n        @ClassRule\n        public static TestRule classRule() {\n            return new LoggingTestRule(log, \"classRule\");\n        }\n\n        @Test\n        public void test() {\n            log.append(\" test\");\n        }\n    }\n\n    @Test\n    public void classRulesModifiableList() {\n        log.setLength(0);\n        Result result = JUnitCore.runClasses(ClassRulesModifiableList.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(\" fromCode.begin classRule.begin test classRule.end fromCode.end\", log.toString());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/DisableOnDebugTest.java",
    "content": "package org.junit.rules;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.Assert;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runners.model.Statement;\n\npublic class DisableOnDebugTest {\n    private static final List<String> WITHOUT_DEBUG_ARGUMENTS = Collections\n            .emptyList();\n\n    private static final List<String> PRE_JAVA5_DEBUG_ARGUMENTS = Arrays\n            .asList(\"-Xdebug\",\n                    \"-Xrunjdwp:transport=dt_socket,server=y,address=8000\");\n\n    private static final List<String> PRE_JAVA5_DEBUG_ARGUMENTS_IN_REVERSE_ORDER = Arrays\n            .asList(\"-Xrunjdwp:transport=dt_socket,server=y,address=8000\",\n                    \"-Xdebug\");\n\n    private static final List<String> POST_JAVA5_DEBUG_ARGUMENTS = Arrays\n            .asList(\"-agentlib:jdwp=transport=dt_socket,server=y,address=8000\");\n\n    /**\n     * Nasty rule that always fails\n     */\n    private static class FailOnExecution implements TestRule {\n\n        public Statement apply(Statement base,\n                Description description) {\n            return new Statement() {\n\n                @Override\n                public void evaluate() throws Throwable {\n                    throw new AssertionError();\n                }\n            };\n        }\n\n    }\n\n    public abstract static class AbstractDisableOnDebugTest {\n\n        @Rule\n        public TestRule failOnExecution;\n\n        public AbstractDisableOnDebugTest(List<String> arguments) {\n            this.failOnExecution = new DisableOnDebug(new FailOnExecution(),\n                    arguments);\n        }\n\n        @Test\n        public void test() {\n        }\n    }\n\n    public static class PreJava5DebugArgumentsTest extends\n            AbstractDisableOnDebugTest {\n\n        public PreJava5DebugArgumentsTest() {\n            super(PRE_JAVA5_DEBUG_ARGUMENTS);\n        }\n\n    }\n\n    public static class PreJava5DebugArgumentsReversedTest extends\n            AbstractDisableOnDebugTest {\n\n        public PreJava5DebugArgumentsReversedTest() {\n            super(PRE_JAVA5_DEBUG_ARGUMENTS_IN_REVERSE_ORDER);\n        }\n\n    }\n\n    public static class PostJava5DebugArgumentsTest extends\n            AbstractDisableOnDebugTest {\n\n        public PostJava5DebugArgumentsTest() {\n            super(POST_JAVA5_DEBUG_ARGUMENTS);\n        }\n\n    }\n\n    public static class WithoutDebugArgumentsTest extends\n            AbstractDisableOnDebugTest {\n\n        public WithoutDebugArgumentsTest() {\n            super(WITHOUT_DEBUG_ARGUMENTS);\n        }\n\n    }\n\n    @Test\n    public void givenPreJava5DebugArgumentsIsDebuggingShouldReturnTrue() {\n        DisableOnDebug subject = new DisableOnDebug(\n                new FailOnExecution(), PRE_JAVA5_DEBUG_ARGUMENTS);\n        assertTrue(\"Should be debugging\", subject.isDebugging());\n    }\n\n    @Test\n    public void givenPreJava5DebugArgumentsInReverseIsDebuggingShouldReturnTrue() {\n        DisableOnDebug subject = new DisableOnDebug(\n                new FailOnExecution(),\n                PRE_JAVA5_DEBUG_ARGUMENTS_IN_REVERSE_ORDER);\n        assertTrue(\"Should be debugging\", subject.isDebugging());\n    }\n\n    @Test\n    public void givenPostJava5DebugArgumentsIsDebuggingShouldReturnTrue() {\n        DisableOnDebug subject = new DisableOnDebug(\n                new FailOnExecution(), POST_JAVA5_DEBUG_ARGUMENTS);\n        assertTrue(\"Should be debugging\", subject.isDebugging());\n    }\n\n    @Test\n    public void givenArgumentsWithoutDebugFlagsIsDebuggingShouldReturnFalse() {\n        DisableOnDebug subject = new DisableOnDebug(\n                new FailOnExecution(), WITHOUT_DEBUG_ARGUMENTS);\n        Assert.assertFalse(\"Should not be debugging\", subject.isDebugging());\n    }\n\n    @Test\n    public void whenRunWithPreJava5DebugArgumentsTestShouldFail() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(PreJava5DebugArgumentsTest.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"Test should not have failed\", 0, result.getFailureCount());\n    }\n\n    @Test\n    public void whenRunWithPreJava5DebugArgumentsInReverseOrderTestShouldFail() {\n        JUnitCore core = new JUnitCore();\n        Result result = core\n                .run(PreJava5DebugArgumentsReversedTest.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"Test should not have failed\", 0, result.getFailureCount());\n    }\n\n    @Test\n    public void whenRunWithPostJava5DebugArgumentsTestShouldFail() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(PostJava5DebugArgumentsTest.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"Test should not have failed\", 0, result.getFailureCount());\n    }\n\n    @Test\n    public void whenRunWithoutDebugFlagsTestShouldPass() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(WithoutDebugArgumentsTest.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"Test should have failed\", 1, result.getFailureCount());\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/ErrorCollectorTest.java",
    "content": "package org.junit.rules;\n\nimport org.hamcrest.Matcher;\nimport org.hamcrest.Matchers;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.function.ThrowingRunnable;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameter;\nimport org.junit.runners.Parameterized.Parameters;\n\nimport java.util.concurrent.Callable;\n\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.fail;\nimport static org.junit.Assume.assumeTrue;\nimport static org.junit.rules.EventCollector.*;\n\n@RunWith(Parameterized.class)\npublic class ErrorCollectorTest {\n\n    @Parameters(name= \"{0}\")\n    public static Object[][] testsWithEventMatcher() {\n        return new Object[][]{\n                {\n                    AddSingleError.class,\n                        hasSingleFailureWithMessage(\"message\")},\n                {\n                    AddTwoErrors.class,\n                        hasNumberOfFailures(2)},\n                {\n                    AddInternalAssumptionViolatedException.class,\n                        allOf(hasSingleFailure(), hasNoAssumptionFailure())},\n                {\n                    CheckMatcherThatDoesNotFailWithoutProvidedReason.class,\n                        everyTestRunSuccessful()},\n                {\n                    CheckMatcherThatDoesNotFailWithProvidedReason.class,\n                        everyTestRunSuccessful()},\n                {\n                    CheckMatcherThatFailsWithoutProvidedReason.class,\n                        hasSingleFailureWithMessage(Matchers.<String>allOf(\n                            containsString(\"Expected: is <4>\"),\n                            containsString(\"but: was <3>\")))},\n                {\n                    CheckMatcherThatFailsWithProvidedReason.class,\n                        hasSingleFailureWithMessage(Matchers.<String>allOf(\n                            containsString(\"reason\"),\n                            containsString(\"Expected: is <4>\"),\n                            containsString(\"but: was <3>\")))},\n                {\n                    CheckTwoMatchersThatFail.class,\n                        hasNumberOfFailures(2)},\n                {\n                    CheckCallableThatThrowsAnException.class,\n                        hasSingleFailureWithMessage(\"first!\")},\n                {\n                    CheckTwoCallablesThatThrowExceptions.class,\n                        hasNumberOfFailures(2)},\n                {\n                    CheckCallableThatThrowsInternalAssumptionViolatedException.class,\n                        allOf(hasSingleFailure(), hasNoAssumptionFailure())},\n                {\n                    CheckCallableWithFailingAssumption.class,\n                        allOf(hasSingleFailure(), hasNoAssumptionFailure())},\n                {\n                    CheckCallableThatDoesNotThrowAnException.class,\n                        everyTestRunSuccessful()},\n                {\n                    CheckRunnableThatThrowsExpectedTypeOfException.class,\n                        everyTestRunSuccessful()},\n                {\n                    CheckRunnableThatThrowsUnexpectedTypeOfException.class,\n                        hasSingleFailureWithMessage(\"unexpected exception type thrown; expected:<java.lang.IllegalArgumentException> but was:<java.lang.NullPointerException>\")},\n                {\n                    CheckRunnableThatThrowsNoExceptionAlthoughOneIsExpected.class,\n                        hasSingleFailureWithMessage(\"expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown\")},\n                {\n                    ErrorCollectorNotCalledBySuccessfulTest.class,\n                        everyTestRunSuccessful()},\n                {\n                    ErrorCollectorNotCalledByFailingTest.class,\n                        hasSingleFailure()},\n        };\n    }\n\n    @Parameter(0)\n    public Class<?> classUnderTest;\n\n    @Parameter(1)\n    public Matcher<EventCollector> matcher;\n\n    @Test\n    public void runTestClassAndVerifyEvents() {\n        EventCollector collector = new EventCollector();\n        JUnitCore core = new JUnitCore();\n        core.addListener(collector);\n        core.run(classUnderTest);\n        assertThat(collector, matcher);\n    }\n\n    public static class AddSingleError {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.addError(new Throwable(\"message\"));\n        }\n    }\n\n    public static class AddTwoErrors {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.addError(new Throwable(\"first thing went wrong\"));\n            collector.addError(new Throwable(\"second thing went wrong\"));\n        }\n    }\n\n    public static class AddInternalAssumptionViolatedException {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.addError(new AssumptionViolatedException(\"message\"));\n        }\n    }\n\n    public static class CheckMatcherThatDoesNotFailWithProvidedReason {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThat(\"dummy reason\", 3, is(3));\n        }\n    }\n\n    public static class CheckMatcherThatDoesNotFailWithoutProvidedReason {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThat(3, is(3));\n        }\n    }\n\n    public static class CheckMatcherThatFailsWithoutProvidedReason {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThat(3, is(4));\n        }\n    }\n\n    public static class CheckMatcherThatFailsWithProvidedReason {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThat(\"reason\", 3, is(4));\n        }\n    }\n\n    public static class CheckTwoMatchersThatFail {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThat(3, is(4));\n            collector.checkThat(\"reason\", 7, is(8));\n        }\n    }\n\n    public static class CheckCallableThatThrowsAnException {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkSucceeds(new Callable<Object>() {\n                public Object call() throws Exception {\n                    throw new RuntimeException(\"first!\");\n                }\n            });\n        }\n    }\n\n    public static class CheckTwoCallablesThatThrowExceptions {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkSucceeds(new Callable<Object>() {\n                public Object call() throws Exception {\n                    throw new RuntimeException(\"first!\");\n                }\n            });\n            collector.checkSucceeds(new Callable<Integer>() {\n                public Integer call() throws Exception {\n                    throw new RuntimeException(\"second!\");\n                }\n            });\n        }\n    }\n\n    public static class CheckCallableThatThrowsInternalAssumptionViolatedException {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkSucceeds(new Callable<Object>() {\n                public Object call() throws Exception {\n                    throw new AssumptionViolatedException(\"message\");\n                }\n            });\n        }\n    }\n\n    public static class CheckCallableWithFailingAssumption {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkSucceeds(new Callable<Object>() {\n                public Object call() throws Exception {\n                    assumeTrue(false);\n                    return null;\n                }\n            });\n        }\n    }\n\n    public static class CheckCallableThatDoesNotThrowAnException {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            Object result = collector.checkSucceeds(new Callable<Object>() {\n                public Object call() throws Exception {\n                    return 3;\n                }\n            });\n            assertEquals(3, result);\n        }\n    }\n\n    public static class CheckRunnableThatThrowsExpectedTypeOfException {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThrows(IllegalArgumentException.class, new ThrowingRunnable() {\n                public void run() throws Throwable {\n                    throw new IllegalArgumentException();\n                }\n            });\n        }\n    }\n\n    public static class CheckRunnableThatThrowsUnexpectedTypeOfException {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThrows(IllegalArgumentException.class, new ThrowingRunnable() {\n                public void run() throws Throwable {\n                    throw new NullPointerException();\n                }\n            });\n        }\n    }\n\n    public static class CheckRunnableThatThrowsNoExceptionAlthoughOneIsExpected {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            collector.checkThrows(IllegalArgumentException.class, new ThrowingRunnable() {\n                public void run() throws Throwable {\n                }\n            });\n        }\n    }\n\n    public static class ErrorCollectorNotCalledBySuccessfulTest {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n        }\n    }\n\n    public static class ErrorCollectorNotCalledByFailingTest {\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Test\n        public void example() {\n            fail();\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/EventCollector.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.core.IsEqual.equalTo;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.hamcrest.Matcher;\nimport org.hamcrest.TypeSafeMatcher;\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\n\npublic class EventCollector extends RunListener {\n    static Matcher<EventCollector> everyTestRunSuccessful() {\n        return allOf(hasNoFailure(), hasNoAssumptionFailure());\n    }\n\n    static Matcher<EventCollector> hasNumberOfFailures(\n            final int numberOfFailures) {\n        return new TypeSafeMatcher<EventCollector>() {\n            @Override\n            public boolean matchesSafely(EventCollector item) {\n                return item.fFailures.size() == numberOfFailures;\n            }\n\n            public void describeTo(org.hamcrest.Description description) {\n                description.appendText(\"has \");\n                description.appendValue(numberOfFailures);\n                description.appendText(\" failures\");\n            }\n\n            @Override\n            protected void describeMismatchSafely(EventCollector item,\n                    org.hamcrest.Description description) {\n                description.appendValue(item.fFailures.size());\n                description.appendText(\" failures\");\n            }\n        };\n    }\n\n    static Matcher<EventCollector> hasSingleFailure() {\n        return hasNumberOfFailures(1);\n    }\n\n    static Matcher<EventCollector> hasNoFailure() {\n        return hasNumberOfFailures(0);\n    }\n\n    private static Matcher<EventCollector> hasNumberOfAssumptionFailures(\n            final int numberOfFailures) {\n        return new TypeSafeMatcher<EventCollector>() {\n            @Override\n            public boolean matchesSafely(EventCollector item) {\n                return item.fAssumptionFailures.size() == numberOfFailures;\n            }\n\n            public void describeTo(org.hamcrest.Description description) {\n                description.appendText(\"has \");\n                description.appendValue(numberOfFailures);\n                description.appendText(\" assumption failures\");\n            }\n        };\n    }\n\n    static Matcher<EventCollector> hasSingleAssumptionFailure() {\n        return hasNumberOfAssumptionFailures(1);\n    }\n\n    static Matcher<EventCollector> hasNoAssumptionFailure() {\n        return hasNumberOfAssumptionFailures(0);\n    }\n\n    public static Matcher<EventCollector> hasSingleFailureWithMessage(String message) {\n        return hasSingleFailureWithMessage(equalTo(message));\n    }\n\n    static Matcher<EventCollector> hasSingleFailureWithMessage(\n            final Matcher<String> messageMatcher) {\n        return new TypeSafeMatcher<EventCollector>() {\n            @Override\n            public boolean matchesSafely(EventCollector item) {\n                return hasSingleFailure().matches(item)\n                        && messageMatcher.matches(item.fFailures.get(0)\n                        .getMessage());\n            }\n\n            public void describeTo(org.hamcrest.Description description) {\n                description.appendText(\"has single failure with message \");\n                messageMatcher.describeTo(description);\n            }\n\n            @Override\n            protected void describeMismatchSafely(EventCollector item,\n                    org.hamcrest.Description description) {\n                description.appendText(\"was \");\n                hasSingleFailure().describeMismatch(item, description);\n                description.appendText(\": \");\n                boolean first= true;\n                for (Failure f : item.fFailures) {\n                    if (!first) {\n                        description.appendText(\" ,\");\n                    }\n                    description.appendText(\"'\");\n                    description.appendText(f.getMessage());\n                    description.appendText(\"'\");\n                    first= false;\n                }\n            }\n        };\n    }\n\n    static Matcher<EventCollector> failureIs(final Matcher<? super Throwable> exceptionMatcher) {\n        return new TypeSafeMatcher<EventCollector>() {\n            @Override\n            public boolean matchesSafely(EventCollector item) {\n                for (Failure f : item.fFailures) {\n                    return exceptionMatcher.matches(f.getException());\n                }\n                return false;\n            }\n\n            public void describeTo(org.hamcrest.Description description) {\n                description.appendText(\"failure is \");\n                exceptionMatcher.describeTo(description);\n            }\n        };\n    }\n\n    private final List<Description> fTestRunsStarted = new ArrayList<Description>();\n\n    private final List<Result> fTestRunsFinished = new ArrayList<Result>();\n\n    private final List<Description> fTestsStarted = new ArrayList<Description>();\n\n    private final List<Description> fTestsFinished = new ArrayList<Description>();\n\n    private final List<Failure> fFailures = new ArrayList<Failure>();\n\n    private final List<Failure> fAssumptionFailures = new ArrayList<Failure>();\n\n    private final List<Description> fTestsIgnored = new ArrayList<Description>();\n\n    @Override\n    public void testRunStarted(Description description) throws Exception {\n        fTestRunsStarted.add(description);\n    }\n\n    @Override\n    public void testRunFinished(Result result) throws Exception {\n        fTestRunsFinished.add(result);\n    }\n\n    @Override\n    public void testStarted(Description description) throws Exception {\n        fTestsStarted.add(description);\n    }\n\n    @Override\n    public void testFinished(Description description) throws Exception {\n        fTestsFinished.add(description);\n    }\n\n    @Override\n    public void testFailure(Failure failure) throws Exception {\n        fFailures.add(failure);\n    }\n\n    @Override\n    public void testAssumptionFailure(Failure failure) {\n        fAssumptionFailures.add(failure);\n    }\n\n    @Override\n    public void testIgnored(Description description) throws Exception {\n        fTestsIgnored.add(description);\n    }\n\n    @Override\n    public String toString() {\n        return fTestRunsStarted.size() + \" test runs started, \"\n            + fTestRunsFinished.size() + \" test runs finished, \"\n            + fTestsStarted.size() + \" tests started, \"\n            + fTestsFinished.size() + \" tests finished, \"\n            + fFailures.size() + \" failures, \"\n            + fAssumptionFailures.size() + \" assumption failures, \"\n            + fTestsIgnored.size() + \" tests ignored\";\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/ExpectedExceptionTest.java",
    "content": "package org.junit.rules;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.CoreMatchers.any;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.nullValue;\nimport static org.hamcrest.CoreMatchers.startsWith;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.hamcrest.core.IsEqual.equalTo;\nimport static org.junit.Assert.fail;\nimport static org.junit.Assume.assumeTrue;\nimport static org.junit.rules.ExpectedException.none;\nimport static org.junit.rules.EventCollector.everyTestRunSuccessful;\nimport static org.junit.rules.EventCollector.hasSingleAssumptionFailure;\nimport static org.junit.rules.EventCollector.hasSingleFailure;\nimport static org.junit.rules.EventCollector.hasSingleFailureWithMessage;\n\nimport java.util.Collection;\n\nimport org.hamcrest.CoreMatchers;\nimport org.hamcrest.Matcher;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameters;\n\n@RunWith(Parameterized.class)\npublic class ExpectedExceptionTest {\n    private static final String ARBITRARY_MESSAGE = \"arbitrary message\";\n\n    @Parameters(name= \"{0}\")\n    public static Collection<Object[]> testsWithEventMatcher() {\n        return asList(new Object[][]{\n                {EmptyTestExpectingNoException.class, everyTestRunSuccessful()},\n                {ThrowExceptionWithExpectedType.class,\n                        everyTestRunSuccessful()},\n                {ThrowExceptionWithExpectedPartOfMessage.class,\n                        everyTestRunSuccessful()},\n                {\n                        ThrowExceptionWithWrongType.class,\n                        hasSingleFailureWithMessage(startsWith(\"\\nExpected: an instance of java.lang.NullPointerException\"))},\n                {\n                        HasWrongMessage.class,\n                        hasSingleFailureWithMessage(startsWith(\"\\nExpected: exception with message a string containing \\\"expectedMessage\\\"\\n\"\n                                + \"     but: message was \\\"actualMessage\\\"\"))},\n                {\n                        ThrowNoExceptionButExpectExceptionWithType.class,\n                        hasSingleFailureWithMessage(\"Expected test to throw an instance of java.lang.NullPointerException\")},\n                {WronglyExpectsExceptionMessage.class, hasSingleFailure()},\n                {ExpectsSubstring.class, everyTestRunSuccessful()},\n                {\n                        ExpectsSubstringNullMessage.class,\n                        hasSingleFailureWithMessage(startsWith(\"\\nExpected: exception with message a string containing \\\"anything!\\\"\"))},\n                {ExpectsMessageMatcher.class, everyTestRunSuccessful()},\n                {\n                        ExpectedMessageMatcherFails.class,\n                        hasSingleFailureWithMessage(startsWith(\"\\nExpected: exception with message \\\"Wrong start\\\"\"))},\n                {ExpectsMatcher.class, everyTestRunSuccessful()},\n                {ExpectAssertionErrorWhichIsNotThrown.class, hasSingleFailure()},\n                {FailedAssumptionAndExpectException.class,\n                        hasSingleAssumptionFailure()},\n                {FailBeforeExpectingException.class,\n                        hasSingleFailureWithMessage(ARBITRARY_MESSAGE)},\n                {\n                        ExpectsMultipleMatchers.class,\n                        hasSingleFailureWithMessage(startsWith(\"\\nExpected: (an instance of java.lang.IllegalArgumentException and exception with message a string containing \\\"Ack!\\\")\"))},\n                {ThrowExceptionWithMatchingCause.class, everyTestRunSuccessful()},\n                {ThrowExpectedNullCause.class, everyTestRunSuccessful()},\n                {\n                        ThrowUnexpectedCause.class,\n                        hasSingleFailureWithMessage(CoreMatchers.<String>allOf(\n                                startsWith(\"\\nExpected: (\"),\n                                containsString(\"exception with cause is <java.lang.NullPointerException: expected cause>\"),\n                                containsString(\"cause was <java.lang.NullPointerException: an unexpected cause>\"),\n                                containsString(\"Stacktrace was: java.lang.IllegalArgumentException: Ack!\"),\n                                containsString(\"Caused by: java.lang.NullPointerException: an unexpected cause\")))},\n                {\n                        UseNoCustomMessage.class,\n                        hasSingleFailureWithMessage(\"Expected test to throw an instance of java.lang.IllegalArgumentException\") },\n                {\n                        UseCustomMessageWithoutPlaceHolder.class,\n                        hasSingleFailureWithMessage(ARBITRARY_MESSAGE) },\n                {\n                        UseCustomMessageWithPlaceHolder.class,\n                        hasSingleFailureWithMessage(ARBITRARY_MESSAGE\n                                + \" - an instance of java.lang.IllegalArgumentException\") },\n                {\n                        ErrorCollectorShouldFailAlthoughExpectedExceptionDoesNot.class,\n                        hasSingleFailureWithMessage(ARBITRARY_MESSAGE) }\n        });\n    }\n\n    private final Class<?> classUnderTest;\n\n    private final Matcher<EventCollector> matcher;\n\n    public ExpectedExceptionTest(Class<?> classUnderTest,\n            Matcher<EventCollector> matcher) {\n        this.classUnderTest = classUnderTest;\n        this.matcher = matcher;\n    }\n\n    @Test\n    public void runTestAndVerifyResult() {\n        EventCollector collector = new EventCollector();\n        JUnitCore core = new JUnitCore();\n        core.addListener(collector);\n        core.run(classUnderTest);\n        assertThat(collector, matcher);\n    }\n\n    public static class EmptyTestExpectingNoException {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsNothing() {\n        }\n    }\n\n    public static class ThrowExceptionWithExpectedType {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsNullPointerException() {\n            thrown.expect(NullPointerException.class);\n            throw new NullPointerException();\n        }\n    }\n\n    public static class ThrowExceptionWithExpectedPartOfMessage {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsNullPointerExceptionWithMessage() {\n            thrown.expect(NullPointerException.class);\n            thrown.expectMessage(ARBITRARY_MESSAGE);\n            throw new NullPointerException(ARBITRARY_MESSAGE + \"something else\");\n        }\n    }\n\n    public static class ThrowExceptionWithWrongType {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsNullPointerException() {\n            thrown.expect(NullPointerException.class);\n            throw new IllegalArgumentException();\n        }\n    }\n\n    public static class HasWrongMessage {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsNullPointerException() {\n            thrown.expectMessage(\"expectedMessage\");\n            throw new IllegalArgumentException(\"actualMessage\");\n        }\n    }\n\n    public static class ThrowNoExceptionButExpectExceptionWithType {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void doesntThrowNullPointerException() {\n            thrown.expect(NullPointerException.class);\n        }\n    }\n\n    public static class WronglyExpectsExceptionMessage {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void doesntThrowAnything() {\n            thrown.expectMessage(\"anything!\");\n        }\n    }\n\n    public static class ExpectsSubstring {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsMore() {\n            thrown.expectMessage(\"anything!\");\n            throw new NullPointerException(\n                    \"This could throw anything! (as long as it has the right substring)\");\n        }\n    }\n\n    public static class ExpectsSubstringNullMessage {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsMore() {\n            thrown.expectMessage(\"anything!\");\n            throw new NullPointerException();\n        }\n    }\n\n    public static class ExpectsMessageMatcher {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsMore() {\n            thrown.expectMessage(startsWith(ARBITRARY_MESSAGE));\n            throw new NullPointerException(ARBITRARY_MESSAGE + \"!\");\n        }\n    }\n\n    public static class ExpectedMessageMatcherFails {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsMore() {\n            thrown.expectMessage(equalTo(\"Wrong start\"));\n            throw new NullPointerException(\"Back!\");\n        }\n    }\n\n    public static class ExpectsMatcher {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsMore() {\n            thrown.expect(any(Exception.class));\n            throw new NullPointerException(\"Ack!\");\n        }\n    }\n\n    public static class ExpectsMultipleMatchers {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwsMore() {\n            thrown.expect(IllegalArgumentException.class);\n            thrown.expectMessage(\"Ack!\");\n            throw new NullPointerException(\"Ack!\");\n        }\n    }\n\n    //https://github.com/junit-team/junit4/pull/583\n    public static class ExpectAssertionErrorWhichIsNotThrown {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void fails() {\n            thrown.expect(AssertionError.class);\n        }\n    }\n\n    public static class FailBeforeExpectingException {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void fails() {\n            fail(ARBITRARY_MESSAGE);\n            thrown.expect(IllegalArgumentException.class);\n        }\n    }\n\n    public static class FailedAssumptionAndExpectException {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void failedAssumption() {\n            assumeTrue(false);\n            thrown.expect(NullPointerException.class);\n        }\n    }\n\n    public static class ThrowExceptionWithMatchingCause {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwExceptionWithMatchingCause() {\n            NullPointerException expectedCause = new NullPointerException(\"expected cause\");\n\n            thrown.expect(IllegalArgumentException.class);\n            thrown.expectMessage(\"Ack!\");\n            thrown.expectCause(is(expectedCause));\n\n            throw new IllegalArgumentException(\"Ack!\", expectedCause);\n        }\n    }\n\n    public static class ThrowExpectedNullCause {\n        @Rule\n        public ExpectedException thrown = none();\n\n        @Test\n        public void throwExpectedNullCause() {\n            thrown.expect(IllegalArgumentException.class);\n            thrown.expectMessage(\"Ack!\");\n            thrown.expectCause(nullValue(Throwable.class));\n\n            throw new IllegalArgumentException(\"Ack!\");\n        }\n    }\n\n    public static class ThrowUnexpectedCause {\n\n        @Rule\n        public ExpectedException thrown = ExpectedException.none();\n\n        @Test\n        public void throwWithCause() {\n            thrown.expect(IllegalArgumentException.class);\n            thrown.expectMessage(\"Ack!\");\n            thrown.expectCause(is(new NullPointerException(\"expected cause\")));\n\n            throw new IllegalArgumentException(\"Ack!\", new NullPointerException(\"an unexpected cause\"));\n        }\n    }\n    \n    public static class UseNoCustomMessage {\n\n        @Rule\n        public ExpectedException thrown= ExpectedException.none();\n\n        @Test\n        public void noThrow() {\n            thrown.expect(IllegalArgumentException.class);\n        }\n    }\n\n    public static class UseCustomMessageWithPlaceHolder {\n\n        @Rule\n        public ExpectedException thrown = ExpectedException.none();\n\n        @Test\n        public void noThrow() {\n            thrown.expect(IllegalArgumentException.class);\n            thrown.reportMissingExceptionWithMessage(ARBITRARY_MESSAGE\n                    + \" - %s\");\n        }\n    }\n\n    public static class UseCustomMessageWithoutPlaceHolder {\n\n        @Rule\n        public ExpectedException thrown= ExpectedException.none();\n\n        @Test\n        public void noThrow() {\n            thrown.expect(IllegalArgumentException.class);\n            thrown.reportMissingExceptionWithMessage(ARBITRARY_MESSAGE);\n        }\n    }\n\n    public static class ErrorCollectorShouldFailAlthoughExpectedExceptionDoesNot {\n\n        @Rule\n        public ErrorCollector collector = new ErrorCollector();\n\n        @Rule(order = Integer.MAX_VALUE)\n        public ExpectedException thrown = ExpectedException.none();\n\n        @Test\n        public void test() {\n            collector.addError(new AssertionError(ARBITRARY_MESSAGE));\n            thrown.expect(Exception.class);\n            throw new RuntimeException();\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/rules/ExternalResourceRuleTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.hamcrest.CoreMatchers.sameInstance;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.fail;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\nimport static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport org.hamcrest.CoreMatchers;\nimport org.hamcrest.Matcher;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.TestCouldNotBeSkippedException;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.internal.runners.statements.Fail;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runners.model.MultipleFailureException;\nimport org.junit.runners.model.Statement;\n\npublic class ExternalResourceRuleTest {\n    private static String callSequence;\n\n    public static class UsesExternalResource {\n        @Rule\n        public ExternalResource resource = new ExternalResource() {\n            @Override\n            protected void before() throws Throwable {\n                callSequence += \"before \";\n            }\n\n            @Override\n            protected void after() {\n                callSequence += \"after \";\n            }\n        };\n\n        @Test\n        public void testFoo() {\n            callSequence += \"test \";\n        }\n    }\n\n    @Test\n    public void externalResourceGeneratesCorrectSequence() {\n        callSequence = \"\";\n        assertThat(testResult(UsesExternalResource.class), isSuccessful());\n        assertEquals(\"before test after \", callSequence);\n    }\n\n    @Test\n    public void shouldThrowMultipleFailureExceptionWhenTestFailsAndClosingResourceFails() throws Throwable {\n        // given\n        ExternalResource resourceRule = new ExternalResource() {\n            @Override\n            protected void after() {\n                throw new RuntimeException(\"simulating resource tear down failure\");\n            }\n        };\n        Statement failingTest = new Fail(new RuntimeException(\"simulated test failure\"));\n        Description dummyDescription = Description.createTestDescription(\n                \"dummy test class name\", \"dummy test name\");\n\n        try {\n            resourceRule.apply(failingTest, dummyDescription).evaluate();\n            fail(\"ExternalResource should throw\");\n        } catch (MultipleFailureException e) {\n            assertThat(e.getMessage(), allOf(\n                    containsString(\"simulated test failure\"),\n                    containsString(\"simulating resource tear down failure\")\n            ));\n        }\n    }\n\n    public static class TestFailsAndTwoClosingResourcesFail {\n        @Rule\n        public ExternalResource resourceRule1 = new ExternalResource() {\n            @Override\n            protected void after() {\n                throw new RuntimeException(\"simulating resource1 tear down failure\");\n            }\n        };\n\n        @Rule\n        public ExternalResource resourceRule2 = new ExternalResource() {\n            @Override\n            protected void after() {\n                throw new RuntimeException(\"simulating resource2 tear down failure\");\n            }\n        };\n\n        @Test\n        public void failingTest() {\n            throw new RuntimeException(\"simulated test failure\");\n        }\n    }\n\n    @Test\n    public void shouldThrowMultipleFailureExceptionWhenTestFailsAndTwoClosingResourcesFail() {\n        Result result = JUnitCore.runClasses(TestFailsAndTwoClosingResourcesFail.class);\n        assertEquals(3, result.getFailures().size());\n        List<String> messages = new ArrayList<String>();\n        for (Failure failure : result.getFailures()) {\n            messages.add(failure.getMessage());\n        }\n        assertThat(messages, CoreMatchers.hasItems(\n                \"simulated test failure\",\n                \"simulating resource1 tear down failure\",\n                \"simulating resource2 tear down failure\"\n        ));\n    }\n\n    @Test\n    public void shouldWrapAssumptionFailuresWhenClosingResourceFails() throws Throwable {\n        // given\n        final AtomicReference<Throwable> externalResourceException = new AtomicReference<Throwable>();\n        ExternalResource resourceRule = new ExternalResource() {\n            @Override\n            protected void after() {\n                RuntimeException runtimeException = new RuntimeException(\"simulating resource tear down failure\");\n                externalResourceException.set(runtimeException);\n                throw runtimeException;\n            }\n        };\n        final AtomicReference<Throwable> assumptionViolatedException = new AtomicReference<Throwable>();\n        Statement skippedTest = new Statement() {\n            @Override\n            public void evaluate() throws Throwable {\n                AssumptionViolatedException assumptionFailure = new AssumptionViolatedException(\"skip it\");\n                assumptionViolatedException.set(assumptionFailure);\n                throw assumptionFailure;\n            }\n        };\n        Description dummyDescription = Description.createTestDescription(\n                \"dummy test class name\", \"dummy test name\");\n\n        try {\n            resourceRule.apply(skippedTest, dummyDescription).evaluate();\n            fail(\"ExternalResource should throw\");\n        } catch (MultipleFailureException e) {\n            assertThat(e.getFailures(), hasItems(\n                    instanceOf(TestCouldNotBeSkippedException.class),\n                    sameInstance(externalResourceException.get())\n            ));\n            assertThat(e.getFailures(), hasItems(\n                    hasCause(sameInstance(assumptionViolatedException.get())),\n                    sameInstance(externalResourceException.get())\n            ));\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private Matcher<? super List<Throwable>> hasItems(\n            Matcher<? super Throwable> one, Matcher<? super Throwable> two) {\n        return CoreMatchers.hasItems(one, two);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/LoggingMethodRule.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\nclass LoggingMethodRule implements MethodRule {\n    private final StringBuilder log;\n    private final String name;\n\n    LoggingMethodRule(StringBuilder log, String name) {\n        this.name = name;\n        this.log = log;\n    }\n\n    public Statement apply(Statement base, FrameworkMethod method, Object target) {\n        return new LoggingStatement(base, log, name);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/LoggingStatement.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runners.model.Statement;\n\nclass LoggingStatement extends Statement {\n    private final Statement base;\n    private final StringBuilder log;\n    private final String name;\n\n    LoggingStatement(Statement base, StringBuilder log, String name) {\n        this.base = base;\n        this.log = log;\n        this.name = name;\n    }\n\n    public void evaluate() throws Throwable {\n        log.append(\" \").append(name).append(\".begin\");\n        try {\n            base.evaluate();\n        } finally {\n            log.append(\" \").append(name).append(\".end\");\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/LoggingTestRule.java",
    "content": "package org.junit.rules;\n\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\nclass LoggingTestRule implements TestRule {\n    private final StringBuilder log;\n    private final String name;\n\n    LoggingTestRule(StringBuilder log, String name) {\n        this.name = name;\n        this.log = log;\n    }\n\n    public Statement apply(Statement base, Description description) {\n        return new LoggingStatement(base, log, name);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/LoggingTestWatcher.java",
    "content": "package org.junit.rules;\n\nimport org.junit.AssumptionViolatedException;\nimport org.junit.runner.Description;\n\nclass LoggingTestWatcher extends TestWatcher {\n    private final StringBuilder log;\n\n    LoggingTestWatcher(StringBuilder log) {\n        this.log = log;\n    }\n\n    @Override\n    protected void succeeded(Description description) {\n        log.append(\"succeeded \");\n    }\n\n    @Override\n    protected void failed(Throwable e, Description description) {\n        log.append(\"failed \");\n    }\n\n    @Override\n    protected void skipped(AssumptionViolatedException e, Description description) {\n        log.append(\"skipped \");\n    }\n\n    @Override\n    protected void skipped(org.junit.internal.AssumptionViolatedException e, Description description) {\n        log.append(\"deprecated skipped \");\n    }\n\n    @Override\n    protected void starting(Description description) {\n        log.append(\"starting \");\n    }\n\n    @Override\n    protected void finished(Description description) {\n        log.append(\"finished \");\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/rules/MethodRulesTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.failureCountIs;\nimport static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\n@SuppressWarnings(\"deprecation\")\npublic class MethodRulesTest {\n    private static boolean ruleWasEvaluated;\n\n    private static class TestMethodRule implements MethodRule {\n\n        public Statement apply(final Statement base, FrameworkMethod method, Object target) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    ruleWasEvaluated = true;\n                    base.evaluate();\n                }\n            };\n        }\n    }\n\n    public static class ExampleTest {\n        @Rule\n        public MethodRule example = new TestMethodRule();\n\n        @Test\n        public void nothing() {\n        }\n    }\n\n    abstract static class NonPublicExampleTest {\n        @Rule\n        public MethodRule example = new TestMethodRule();\n\n        @Test\n        public void nothing() {\n        }\n    }\n\n    @Test\n    public void ruleIsIntroducedAndEvaluated() {\n        ruleWasEvaluated = false;\n        assertThat(testResult(ExampleTest.class), isSuccessful());\n        assertTrue(ruleWasEvaluated);\n    }\n\n    public static class SonOfExampleTest extends ExampleTest {\n\n    }\n\n    @Test\n    public void ruleIsIntroducedAndEvaluatedOnSubclass() {\n        ruleWasEvaluated = false;\n        assertThat(testResult(SonOfExampleTest.class), isSuccessful());\n        assertTrue(ruleWasEvaluated);\n    }\n\n    public static class SonOfNonPublicExampleTest extends NonPublicExampleTest {\n\n    }\n\n    @Test\n    public void ruleIsIntroducedAndEvaluatedOnSubclassOfNonPublicClass() {\n        ruleWasEvaluated = false;\n        assertThat(testResult(SonOfNonPublicExampleTest.class), isSuccessful());\n        assertTrue(ruleWasEvaluated);\n    }\n\n    private static int runCount;\n\n    private static class Increment implements MethodRule {\n        public Statement apply(final Statement base,\n                FrameworkMethod method, Object target) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    runCount++;\n                    base.evaluate();\n                }\n            };\n        }\n    }\n    \n    public static class MultipleRuleTest {\n\n        @Rule\n        public MethodRule incrementor1 = new Increment();\n\n        @Rule\n        public MethodRule incrementor2 = new Increment();\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void multipleRulesAreRun() {\n        runCount = 0;\n        assertThat(testResult(MultipleRuleTest.class), isSuccessful());\n        assertEquals(2, runCount);\n    }\n\n    public static class NoRulesTest {\n        public int x;\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void ignoreNonRules() {\n        assertThat(testResult(NoRulesTest.class), isSuccessful());\n    }\n\n    private static String log;\n\n    public static class OnFailureTest {\n        @Rule\n        public MethodRule watchman = new TestWatchman() {\n            @Override\n            public void failed(Throwable e, FrameworkMethod method) {\n                log += method.getName() + \" \" + e.getClass().getSimpleName();\n            }\n        };\n\n        @Test\n        public void nothing() {\n            fail();\n        }\n    }\n\n    @Test\n    public void onFailure() {\n        log = \"\";\n        assertThat(testResult(OnFailureTest.class), failureCountIs(1));\n        assertEquals(\"nothing AssertionError\", log);\n    }\n\n    public static class WatchmanTest {\n        private static String watchedLog;\n\n        @Rule\n        public MethodRule watchman = new TestWatchman() {\n            @Override\n            public void failed(Throwable e, FrameworkMethod method) {\n                watchedLog += method.getName() + \" \"\n                        + e.getClass().getSimpleName() + \"\\n\";\n            }\n\n            @Override\n            public void succeeded(FrameworkMethod method) {\n                watchedLog += method.getName() + \" \" + \"success!\\n\";\n            }\n        };\n\n        @Test\n        public void fails() {\n            fail();\n        }\n\n        @Test\n        public void succeeds() {\n        }\n    }\n\n    @Test\n    public void succeeded() {\n        WatchmanTest.watchedLog = \"\";\n        assertThat(testResult(WatchmanTest.class), failureCountIs(1));\n        assertThat(WatchmanTest.watchedLog, containsString(\"fails AssertionError\"));\n        assertThat(WatchmanTest.watchedLog, containsString(\"succeeds success!\"));\n    }\n\n    public static class BeforesAndAfters {\n        private static String watchedLog;\n\n        @Before\n        public void before() {\n            watchedLog += \"before \";\n        }\n\n        @Rule\n        public MethodRule watchman = new TestWatchman() {\n            @Override\n            public void starting(FrameworkMethod method) {\n                watchedLog += \"starting \";\n            }\n\n            @Override\n            public void finished(FrameworkMethod method) {\n                watchedLog += \"finished \";\n            }\n\n            @Override\n            public void succeeded(FrameworkMethod method) {\n                watchedLog += \"succeeded \";\n            }\n        };\n\n        @After\n        public void after() {\n            watchedLog += \"after \";\n        }\n\n        @Test\n        public void succeeds() {\n            watchedLog += \"test \";\n        }\n    }\n\n    @Test\n    public void beforesAndAfters() {\n        BeforesAndAfters.watchedLog = \"\";\n        assertThat(testResult(BeforesAndAfters.class), isSuccessful());\n        assertThat(BeforesAndAfters.watchedLog, is(\"starting before test after succeeded finished \"));\n    }\n\n    public static class WrongTypedField {\n        @Rule\n        public int x = 5;\n\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test\n    public void validateWrongTypedField() {\n        assertThat(testResult(WrongTypedField.class),\n                hasSingleFailureContaining(\"must implement MethodRule\"));\n    }\n\n    public static class SonOfWrongTypedField extends WrongTypedField {\n\n    }\n\n    @Test\n    public void validateWrongTypedFieldInSuperclass() {\n        assertThat(testResult(SonOfWrongTypedField.class),\n                hasSingleFailureContaining(\"must implement MethodRule\"));\n    }\n\n    public static class PrivateRule {\n        @Rule\n        private TestRule rule = new TestName();\n\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test\n    public void validatePrivateRule() {\n        assertThat(testResult(PrivateRule.class),\n                hasSingleFailureContaining(\"must be public\"));\n    }\n\n    public static class CustomTestName implements TestRule {\n        public String name = null;\n\n        public Statement apply(final Statement base, final Description description) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    name = description.getMethodName();\n                    base.evaluate();\n                }\n            };\n        }\n    }\n\n    public static class UsesCustomMethodRule {\n        @Rule\n        public CustomTestName counter = new CustomTestName();\n\n        @Test\n        public void foo() {\n            assertEquals(\"foo\", counter.name);\n        }\n    }\n\n    @Test\n    public void useCustomMethodRule() {\n        assertThat(testResult(UsesCustomMethodRule.class), isSuccessful());\n    }\n    \n    public static class HasMethodReturningMethodRule {\n        private MethodRule methodRule = new MethodRule() {\n            public Statement apply(final Statement base, FrameworkMethod method, Object target) {\n                return new Statement() {\n                    \n                    @Override\n                    public void evaluate() throws Throwable {\n                        ruleWasEvaluated = true;\n                        base.evaluate();\n                    }\n                };\n            }\n        };\n        \n        @Rule\n        public MethodRule methodRule() {\n            return methodRule;\n        }\n        \n        @Test\n        public void doNothing() {\n            \n        }\n    }\n\n    /**\n     * If there are any public methods annotated with @Rule returning a {@link MethodRule}\n     * then it should also be run.\n     * \n     * <p>This case has been added with \n     * <a href=\"https://github.com/junit-team/junit4/issues/589\">Issue #589</a> - \n     * Support @Rule for methods works only for TestRule but not for MethodRule\n     */\n    @Test\n    public void runsMethodRuleThatIsReturnedByMethod() {\n        ruleWasEvaluated = false;\n        assertThat(testResult(HasMethodReturningMethodRule.class), isSuccessful());\n        assertTrue(ruleWasEvaluated);\n    }\n    \n    public static class HasMultipleMethodsReturningMethodRule {\n        @Rule\n        public Increment methodRule1() {\n            return new Increment();\n        }\n        \n        @Rule\n        public Increment methodRule2() {\n            return new Increment();\n        }\n        \n        @Test\n        public void doNothing() {\n            \n        }\n    }\n\n    /**\n     * If there are multiple public methods annotated with @Rule returning a {@link MethodRule}\n     * then all the rules returned should be run.\n     * \n     * <p>This case has been added with \n     * <a href=\"https://github.com/junit-team/junit4/issues/589\">Issue #589</a> - \n     * Support @Rule for methods works only for TestRule but not for MethodRule\n     */\n    @Test\n    public void runsAllMethodRulesThatAreReturnedByMethods() {\n        runCount = 0;\n        assertThat(testResult(HasMultipleMethodsReturningMethodRule.class), isSuccessful());\n        assertEquals(2, runCount);\n    }\n    \n    \n    public static class CallsMethodReturningRuleOnlyOnce {\n        int callCount = 0;\n        \n        private static class Dummy implements MethodRule {\n            public Statement apply(final Statement base, FrameworkMethod method, Object target) {\n                return new Statement() {\n                    \n                    @Override\n                    public void evaluate() throws Throwable {\n                        base.evaluate();\n                    }\n                };\n            }\n        }\n       \n        \n        @Rule\n        public MethodRule methodRule() {\n            callCount++;\n            return new Dummy();\n        }\n        \n        @Test\n        public void doNothing() {\n            assertEquals(1, callCount);\n        }\n    }\n\n    /**\n     * If there are any public methods annotated with @Rule returning a {@link MethodRule}\n     * then method should be called only once.\n     * \n     * <p>This case has been added with \n     * <a href=\"https://github.com/junit-team/junit4/issues/589\">Issue #589</a> - \n     * Support @Rule for methods works only for TestRule but not for MethodRule\n     */\n    @Test\n    public void callsMethodReturningRuleOnlyOnce() {\n        assertThat(testResult(CallsMethodReturningRuleOnlyOnce.class), isSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/NameRulesTest.java",
    "content": "package org.junit.rules;\n\nimport static org.junit.Assert.assertEquals;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.experimental.runners.Enclosed;\nimport org.junit.runner.RunWith;\n\n@RunWith(Enclosed.class)\npublic class NameRulesTest {\n    public static class TestNames {\n        @Rule\n        public TestName name = new TestName();\n\n        @Test\n        public void testA() {\n            assertEquals(\"testA\", name.getMethodName());\n        }\n\n        @Test\n        public void testB() {\n            assertEquals(\"testB\", name.getMethodName());\n        }\n    }\n\n    public static class BeforeAndAfterTest {\n        @Rule\n        public TestName name = new TestName();\n\n        private final String expectedName = \"x\";\n\n        @Before\n        public void setUp() {\n            assertEquals(expectedName, name.getMethodName());\n        }\n\n        @Test\n        public void x() {\n            assertEquals(expectedName, name.getMethodName());\n        }\n\n        @After\n        public void tearDown() {\n            assertEquals(expectedName, name.getMethodName());\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/RuleChainTest.java",
    "content": "package org.junit.rules;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.rules.RuleChain.outerRule;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.internal.Throwables;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\n\npublic class RuleChainTest {\n    private static final List<String> LOG = new ArrayList<String>();\n\n    private static class LoggingRule extends TestWatcher {\n        private final String label;\n\n        public LoggingRule(String label) {\n            this.label = label;\n        }\n\n        @Override\n        protected void starting(Description description) {\n            LOG.add(\"starting \" + label);\n        }\n\n        @Override\n        protected void finished(Description description) {\n            LOG.add(\"finished \" + label);\n        }\n    }\n\n    public static class UseRuleChain {\n        @Rule\n        public final RuleChain chain = outerRule(new LoggingRule(\"outer rule\"))\n                .around(new LoggingRule(\"middle rule\")).around(\n                        new LoggingRule(\"inner rule\"));\n\n        @Test\n        public void example() {\n            assertTrue(true);\n        }\n    }\n\n    @Test\n    public void executeRulesInCorrectOrder() throws Exception {\n        testResult(UseRuleChain.class);\n        List<String> expectedLog = asList(\"starting outer rule\",\n                \"starting middle rule\", \"starting inner rule\",\n                \"finished inner rule\", \"finished middle rule\",\n                \"finished outer rule\");\n        assertEquals(expectedLog, LOG);\n    }\n\n    @Test\n    public void aroundShouldNotAllowNullRules() {\n        RuleChain chain = RuleChain.emptyRuleChain();\n        try {\n            chain.around(null);\n            fail(\"around() should not allow null rules\");\n        } catch (NullPointerException e) {\n            assertThat(e.getMessage(), equalTo(\"The enclosed rule must not be null\"));\n        }\n    }\n\n    public static class RuleChainWithNullRules {\n        @Rule\n        public final RuleChain chain = outerRule(new LoggingRule(\"outer rule\"))\n                .around(null);\n\n        @Test\n        public void example() {}\n    }\n\n    @Test\n    public void whenRuleChainHasNullRuleTheStacktraceShouldPointToIt() {\n        Result result = JUnitCore.runClasses(RuleChainWithNullRules.class);\n\n        assertThat(result.getFailures().size(), equalTo(1));\n        String stacktrace = Throwables.getStacktrace(result.getFailures().get(0).getException());\n        assertThat(stacktrace, containsString(\"\\tat org.junit.rules.RuleChainTest$RuleChainWithNullRules.<init>(RuleChainTest.java:\"));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/rules/RuleMemberValidatorTest.java",
    "content": "package org.junit.rules;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.internal.runners.rules.RuleMemberValidator.CLASS_RULE_METHOD_VALIDATOR;\nimport static org.junit.internal.runners.rules.RuleMemberValidator.CLASS_RULE_VALIDATOR;\nimport static org.junit.internal.runners.rules.RuleMemberValidator.RULE_METHOD_VALIDATOR;\nimport static org.junit.internal.runners.rules.RuleMemberValidator.RULE_VALIDATOR;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.ClassRule;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\nimport org.junit.runners.model.TestClass;\n\npublic class RuleMemberValidatorTest {\n    private final List<Throwable> errors = new ArrayList<Throwable>();\n\n    @Test\n    public void rejectProtectedClassRule() {\n        TestClass target = new TestClass(TestWithProtectedClassRule.class);\n        CLASS_RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'temporaryFolder' must be public.\");\n    }\n\n    public static class TestWithProtectedClassRule {\n        @ClassRule\n        protected static TestRule temporaryFolder = new TemporaryFolder();\n    }\n\n    @Test\n    public void rejectNonStaticClassRule() {\n        TestClass target = new TestClass(TestWithNonStaticClassRule.class);\n        CLASS_RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'temporaryFolder' must be static.\");\n    }\n\n    public static class TestWithNonStaticClassRule {\n        @ClassRule\n        public TestRule temporaryFolder = new TemporaryFolder();\n    }\n\n    @Test\n    public void acceptStaticTestRuleThatIsAlsoClassRule() {\n        TestClass target = new TestClass(TestWithStaticClassAndTestRule.class);\n        CLASS_RULE_VALIDATOR.validate(target, errors);\n        assertNumberOfErrors(0);\n    }\n\n    public static class TestWithStaticClassAndTestRule {\n        @ClassRule\n        @Rule\n        public static TestRule temporaryFolder = new TemporaryFolder();\n    }\n\n    @Test\n    public void rejectClassRuleInNonPublicClass() {\n        TestClass target = new TestClass(NonPublicTestWithClassRule.class);\n        CLASS_RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'temporaryFolder' must be declared in a public class.\");\n    }\n\n    static class NonPublicTestWithClassRule {\n        @ClassRule\n        public static TestRule temporaryFolder = new TemporaryFolder();\n    }\n    \n    /**\n     * If there is any property annotated with @ClassRule then it must implement\n     * {@link TestRule}\n     * \n     * <p>This case has been added with \n     * <a href=\"https://github.com/junit-team/junit4/issues/1019\">Issue #1019</a>\n     */\n    @Test\n    public void rejectClassRuleThatIsImplementationOfMethodRule() {\n        TestClass target = new TestClass(TestWithClassRuleIsImplementationOfMethodRule.class);\n        CLASS_RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'classRule' must implement TestRule.\");\n    }\n    \n    public static class TestWithClassRuleIsImplementationOfMethodRule {\n        @ClassRule\n        public static MethodRule classRule = new MethodRule() {\n            \n            public Statement apply(Statement base, FrameworkMethod method, Object target) {\n                return base;\n            }\n        };\n    }\n\n    /**\n     * If there is any method annotated with @ClassRule then it must return an \n     * implementation of {@link TestRule}\n     * \n     * <p>This case has been added with \n     * <a href=\"https://github.com/junit-team/junit4/issues/1019\">Issue #1019</a>\n     */\n    @Test\n    public void rejectClassRuleThatReturnsImplementationOfMethodRule() {\n        TestClass target = new TestClass(TestWithClassRuleMethodThatReturnsMethodRule.class);\n        CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'methodRule' must return an implementation of TestRule.\");\n    }\n\n    public static class TestWithClassRuleMethodThatReturnsMethodRule {\n        @ClassRule\n        public static MethodRule methodRule() {\n            return new MethodRule() {\n                \n                public Statement apply(Statement base, FrameworkMethod method, Object target) {\n                    return base;\n                }\n            };\n        }\n    }\n    \n    /**\n     * If there is any property annotated with @ClassRule then it must implement\n     * {@link TestRule}\n     * \n     * <p>This case has been added with \n     * <a href=\"https://github.com/junit-team/junit4/issues/1019\">Issue #1019</a>\n     */\n    @Test\n    public void rejectClassRuleIsAnArbitraryObject() throws Exception {\n        TestClass target = new TestClass(TestWithClassRuleIsAnArbitraryObject.class);\n        CLASS_RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'arbitraryObject' must implement TestRule.\");\n    }\n\n    public static class TestWithClassRuleIsAnArbitraryObject {\n        @ClassRule\n        public static Object arbitraryObject = 1;\n    }\n    \n    /**\n     * If there is any method annotated with @ClassRule then it must return an \n     * implementation of {@link TestRule}\n     * \n     * <p>This case has been added with \n     * <a href=\"https://github.com/junit-team/junit4/issues/1019\">Issue #1019</a> \n     */\n    @Test\n    public void rejectClassRuleMethodReturnsAnArbitraryObject() throws Exception {\n        TestClass target = new TestClass(TestWithClassRuleMethodReturnsAnArbitraryObject.class);\n        CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'arbitraryObject' must return an implementation of TestRule.\");\n    }\n\n    public static class TestWithClassRuleMethodReturnsAnArbitraryObject {\n        @ClassRule\n        public static Object arbitraryObject() {\n            return 1;\n        }\n    }\n    \n    @Test\n    public void acceptNonStaticTestRule() {\n        TestClass target = new TestClass(TestWithNonStaticTestRule.class);\n        RULE_VALIDATOR.validate(target, errors);\n        assertNumberOfErrors(0);\n    }\n\n    public static class TestWithNonStaticTestRule {\n        @Rule\n        public TestRule temporaryFolder = new TemporaryFolder();\n    }\n\n    @Test\n    public void rejectStaticTestRule() {\n        TestClass target = new TestClass(TestWithStaticTestRule.class);\n        RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @Rule 'temporaryFolder' must not be static or it must be annotated with @ClassRule.\");\n    }\n\n    public static class TestWithStaticTestRule {\n        @Rule\n        public static TestRule temporaryFolder = new TemporaryFolder();\n    }\n\n    @Test\n    public void rejectStaticMethodRule() {\n        TestClass target = new TestClass(TestWithStaticMethodRule.class);\n        RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @Rule 'someMethodRule' must not be static.\");\n    }\n\n    public static class TestWithStaticMethodRule {\n        @Rule\n        public static MethodRule someMethodRule = new SomeMethodRule();\n    }\n    \n    @Test\n    public void acceptMethodRule() throws Exception {\n        TestClass target = new TestClass(TestWithMethodRule.class);\n        RULE_VALIDATOR.validate(target, errors);\n        assertNumberOfErrors(0);\n    }\n\n    public static class TestWithMethodRule {\n        @Rule\n        public MethodRule temporaryFolder = new MethodRule() {\n            public Statement apply(Statement base, FrameworkMethod method,\n                    Object target) {\n                return null;\n            }\n        };\n    }\n\n    @Test\n    public void rejectArbitraryObjectWithRuleAnnotation() throws Exception {\n        TestClass target = new TestClass(TestWithArbitraryObjectWithRuleAnnotation.class);\n        RULE_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @Rule 'arbitraryObject' must implement MethodRule or TestRule.\");\n    }\n\n    public static class TestWithArbitraryObjectWithRuleAnnotation {\n        @Rule\n        public Object arbitraryObject = 1;\n    }\n\n    @Test\n    public void methodRejectProtectedClassRule() {\n        TestClass target = new TestClass(MethodTestWithProtectedClassRule.class);\n        CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'getTemporaryFolder' must be public.\");\n    }\n\n    public static class MethodTestWithProtectedClassRule {\n        @ClassRule\n        protected static TestRule getTemporaryFolder() {\n            return new TemporaryFolder();\n        }\n    }\n\n    @Test\n    public void methodRejectNonStaticClassRule() {\n        TestClass target = new TestClass(MethodTestWithNonStaticClassRule.class);\n        CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @ClassRule 'getTemporaryFolder' must be static.\");\n    }\n\n    public static class MethodTestWithNonStaticClassRule {\n        @ClassRule\n        public TestRule getTemporaryFolder() {\n            return new TemporaryFolder();\n        }\n    }\n\n    @Test\n    public void acceptMethodStaticTestRuleThatIsAlsoClassRule() {\n        TestClass target = new TestClass(MethodTestWithStaticClassAndTestRule.class);\n        CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertNumberOfErrors(0);\n    }\n\n    public static class MethodTestWithStaticClassAndTestRule {\n        @ClassRule\n        @Rule\n        public static TestRule getTemporaryFolder() {\n            return new TemporaryFolder();\n        }\n    }\n\n    @Test\n    public void acceptMethodNonStaticTestRule() {\n        TestClass target = new TestClass(TestMethodWithNonStaticTestRule.class);\n        RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertNumberOfErrors(0);\n    }\n\n    public static class TestMethodWithNonStaticTestRule {\n        @Rule\n        public TestRule getTemporaryFolder() {\n            return new TemporaryFolder();\n        }\n    }\n\n    @Test\n    public void rejectMethodStaticTestRule() {\n        TestClass target = new TestClass(TestMethodWithStaticTestRule.class);\n        RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @Rule 'getTemporaryFolder' must not be static or it must be annotated with @ClassRule.\");\n    }\n\n    public static class TestMethodWithStaticTestRule {\n        @Rule\n        public static TestRule getTemporaryFolder() {\n            return new TemporaryFolder();\n        }\n    }\n\n    @Test\n    public void rejectMethodStaticMethodRule() {\n        TestClass target = new TestClass(TestMethodWithStaticMethodRule.class);\n        RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @Rule 'getSomeMethodRule' must not be static.\");\n    }\n\n    public static class TestMethodWithStaticMethodRule {\n        @Rule\n        public static MethodRule getSomeMethodRule() { return new SomeMethodRule(); }\n    }\n\n    @Test\n    public void methodAcceptMethodRuleMethod() throws Exception {\n        TestClass target = new TestClass(MethodTestWithMethodRule.class);\n        RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertNumberOfErrors(0);\n    }\n\n    public static class MethodTestWithMethodRule {\n        @Rule\n        public MethodRule getTemporaryFolder() {\n            return new MethodRule() {\n                public Statement apply(Statement base, FrameworkMethod method,\n                        Object target) {\n                    return null;\n                }\n            };\n        }\n    }\n\n    @Test\n    public void methodRejectArbitraryObjectWithRuleAnnotation() throws Exception {\n        TestClass target = new TestClass(MethodTestWithArbitraryObjectWithRuleAnnotation.class);\n        RULE_METHOD_VALIDATOR.validate(target, errors);\n        assertOneErrorWithMessage(\"The @Rule 'getArbitraryObject' must return an implementation of MethodRule or TestRule.\");\n    }\n\n    public static class MethodTestWithArbitraryObjectWithRuleAnnotation {\n        @Rule\n        public Object getArbitraryObject() {\n            return 1;\n        }\n    }\n\n    private void assertOneErrorWithMessage(String message) {\n        assertNumberOfErrors(1);\n        assertEquals(\"Wrong error message:\", message, errors.get(0).getMessage());\n    }\n\n    private void assertNumberOfErrors(int numberOfErrors) {\n        assertEquals(\"Wrong number of errors:\", numberOfErrors, errors.size());\n    }\n    \n    private static final class SomeMethodRule implements MethodRule {\n        public Statement apply(Statement base, FrameworkMethod method, Object target) {\n            return base;\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/StopwatchTest.java",
    "content": "package org.junit.rules;\n\nimport static java.util.concurrent.TimeUnit.MILLISECONDS;\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.junit.Assume.assumeTrue;\n\nimport java.util.concurrent.TimeUnit;\n\nimport org.junit.AssumptionViolatedException;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\n\n/**\n * @author tibor17\n * @since 4.12\n */\npublic class StopwatchTest {\n    private static enum TestStatus { SUCCEEDED, FAILED, SKIPPED }\n    private static Record record;\n    private static Record finishedRecord;\n    private static long fakeTimeNanos = 1234;\n\n    private static class Record {\n        final long duration;\n        final String name;\n        final TestStatus status;\n\n        Record() {\n            this(0, null, null);\n        }\n\n        Record(long duration, Description description) {\n            this(duration, null, description);\n        }\n\n        Record(long duration, TestStatus status, Description description) {\n            this.duration = duration;\n            this.status = status;\n            this.name = description == null ? null : description.getMethodName();\n        }\n    }\n\n    public abstract static class AbstractStopwatchTest {\n\n        /**\n         * Fake implementation of {@link Stopwatch.Clock} that increments the time\n         * every time it is asked.\n         */\n        private final Stopwatch.Clock fakeClock = new Stopwatch.Clock() {\n            @Override\n            public long nanoTime() {\n                return fakeTimeNanos++;\n            }\n        };\n\n        protected final Stopwatch stopwatch = new Stopwatch(fakeClock) {\n            @Override\n            protected void succeeded(long nanos, Description description) {\n                StopwatchTest.record = new Record(nanos, TestStatus.SUCCEEDED, description);\n                simulateTimePassing(1);\n            }\n\n            @Override\n            protected void failed(long nanos, Throwable e, Description description) {\n                StopwatchTest.record = new Record(nanos, TestStatus.FAILED, description);\n                simulateTimePassing(1);\n            }\n\n            @Override\n            protected void skipped(long nanos, AssumptionViolatedException e, Description description) {\n                StopwatchTest.record = new Record(nanos, TestStatus.SKIPPED, description);\n                simulateTimePassing(1);\n            }\n\n            @Override\n            protected void finished(long nanos, Description description) {\n                StopwatchTest.finishedRecord = new Record(nanos, description);\n            }\n        };\n\n        private final TestWatcher watcher = new TestWatcher() {\n            @Override\n            protected void finished(Description description) {\n                afterStopwatchRule();\n            }\n        };\n\n        @Rule\n        public final RuleChain chain = RuleChain\n            .outerRule(watcher)\n            .around(stopwatch);\n\n        protected void afterStopwatchRule() {\n        }\n    }\n\n    public static class SuccessfulTest extends AbstractStopwatchTest {\n        @Test\n        public void successfulTest() {\n        }\n    }\n\n    public static class FailedTest extends AbstractStopwatchTest {\n        @Test\n        public void failedTest() {\n            fail();\n        }\n    }\n\n    public static class SkippedTest extends AbstractStopwatchTest {\n        @Test\n        public void skippedTest() {\n            assumeTrue(false);\n        }\n    }\n\n    public static class DurationDuringTestTest extends AbstractStopwatchTest {\n        @Test\n        public void duration() {\n            simulateTimePassing(300L);\n            assertEquals(300L, stopwatch.runtime(MILLISECONDS));\n            simulateTimePassing(500L);\n            assertEquals(800L, stopwatch.runtime(MILLISECONDS));\n        }\n    }\n\n    public static class DurationAfterTestTest extends AbstractStopwatchTest {\n        @Test\n        public void duration() {\n            simulateTimePassing(300L);\n            assertEquals(300L, stopwatch.runtime(MILLISECONDS));\n        }\n\n        @Override\n        protected void afterStopwatchRule() {\n            assertEquals(300L, stopwatch.runtime(MILLISECONDS));\n            simulateTimePassing(500L);\n            assertEquals(300L, stopwatch.runtime(MILLISECONDS));\n        }\n    }\n\n    @Before\n    public void init() {\n        record = new Record();\n        finishedRecord = new Record();\n        simulateTimePassing(1L);\n    }\n\n    private static Result runTest(Class<?> test) {\n        simulateTimePassing(1L);\n        JUnitCore junitCore = new JUnitCore();\n        return junitCore.run(Request.aClass(test).getRunner());\n    }\n\n    private static void simulateTimePassing(long millis) {\n        fakeTimeNanos += TimeUnit.MILLISECONDS.toNanos(millis);\n    }\n\n    @Test\n    public void succeeded() {\n        Result result = runTest(SuccessfulTest.class);\n        assertEquals(0, result.getFailureCount());\n        assertThat(record.name, is(\"successfulTest\"));\n        assertThat(record.name, is(finishedRecord.name));\n        assertThat(record.status, is(TestStatus.SUCCEEDED));\n        assertTrue(\"timeSpent > 0\", record.duration > 0);\n        assertThat(record.duration, is(finishedRecord.duration));\n    }\n\n    @Test\n    public void failed() {\n        Result result = runTest(FailedTest.class);\n        assertEquals(1, result.getFailureCount());\n        assertThat(record.name, is(\"failedTest\"));\n        assertThat(record.name, is(finishedRecord.name));\n        assertThat(record.status, is(TestStatus.FAILED));\n        assertTrue(\"timeSpent > 0\", record.duration > 0);\n        assertThat(record.duration, is(finishedRecord.duration));\n    }\n\n    @Test\n    public void skipped() {\n        Result result = runTest(SkippedTest.class);\n        assertEquals(0, result.getFailureCount());\n        assertThat(record.name, is(\"skippedTest\"));\n        assertThat(record.name, is(finishedRecord.name));\n        assertThat(record.status, is(TestStatus.SKIPPED));\n        assertTrue(\"timeSpent > 0\", record.duration > 0);\n        assertThat(record.duration, is(finishedRecord.duration));\n    }\n\n    @Test\n    public void runtimeDuringTestShouldReturnTimeSinceStart() {\n        Result result = runTest(DurationDuringTestTest.class);\n        assertTrue(result.wasSuccessful());\n    }\n\n  @Test\n    public void runtimeAfterTestShouldReturnRunDuration() {\n        Result result = runTest(DurationAfterTestTest.class);\n        assertTrue(result.wasSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/TempFolderRuleTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.hasItem;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.hamcrest.core.IsNot.not;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assume.assumeTrue;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.failureCountIs;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.lang.reflect.Array;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.util.Arrays;\nimport java.util.Set;\nimport java.util.SortedSet;\nimport java.util.TreeSet;\n\nimport org.junit.After;\nimport org.junit.AssumptionViolatedException;\nimport org.junit.Rule;\nimport org.junit.Test;\n\npublic class TempFolderRuleTest {\n    private static File[] createdFiles = new File[20];\n\n    public static class HasTempFolder {\n        @Rule\n        public TemporaryFolder folder = new TemporaryFolder();\n\n        @Test\n        public void testUsingTempFolder() throws IOException {\n            createdFiles[0] = folder.newFile(\"myfile.txt\");\n            assertTrue(createdFiles[0].exists());\n        }\n\n        @Test\n        public void testTempFolderLocation() throws IOException {\n            File folderRoot = folder.getRoot();\n            String tmpRoot = System.getProperty(\"java.io.tmpdir\");\n            assertTrue(folderRoot.toString().startsWith(tmpRoot));\n        }\n    }\n\n    @Test\n    public void tempFolderIsDeleted() {\n        assertThat(testResult(HasTempFolder.class), isSuccessful());\n        assertFalse(createdFiles[0].exists());\n    }\n\n    public static class CreatesSubFolder {\n        @Rule\n        public TemporaryFolder folder = new TemporaryFolder();\n\n        @Test\n        public void testUsingTempFolderStringReflection() throws Exception {\n            String subfolder = \"subfolder\";\n            String filename = \"a.txt\";\n            // force usage of folder.newFolder(String),\n            // check is available and works, to avoid a potential NoSuchMethodError with non-recompiled code.\n            Method method = folder.getClass().getMethod(\"newFolder\", new Class<?>[]{String.class});\n            createdFiles[0] = (File) method.invoke(folder, subfolder);\n            new File(createdFiles[0], filename).createNewFile();\n\n            File expectedFile = new File(folder.getRoot(), join(subfolder, filename));\n\n            assertTrue(expectedFile.exists());\n        }\n\n        @Test\n        public void testUsingTempFolderString() throws IOException {\n            String subfolder = \"subfolder\";\n            String filename = \"a.txt\";\n            // this uses newFolder(String), ensure that a single String works\n            createdFiles[0] = folder.newFolder(subfolder);\n            new File(createdFiles[0], filename).createNewFile();\n\n            File expectedFile = new File(folder.getRoot(), join(subfolder, filename));\n\n            assertTrue(expectedFile.exists());\n        }\n\n        @Test\n        public void testUsingTempTreeFolders() throws IOException {\n            String subfolder = \"subfolder\";\n            String anotherfolder = \"anotherfolder\";\n            String filename = \"a.txt\";\n\n            createdFiles[0] = folder.newFolder(subfolder, anotherfolder);\n            new File(createdFiles[0], filename).createNewFile();\n\n            File expectedFile = new File(folder.getRoot(), join(subfolder, anotherfolder, filename));\n\n            assertTrue(expectedFile.exists());\n        }\n\n        private String join(String... folderNames) {\n            StringBuilder path = new StringBuilder();\n            for (String folderName : folderNames) {\n                path.append(File.separator).append(folderName);\n            }\n            return path.toString();\n        }\n    }\n\n    @Test\n    public void subFolderIsDeleted() {\n        assertThat(testResult(CreatesSubFolder.class), isSuccessful());\n        assertFalse(createdFiles[0].exists());\n    }\n\n    public static class CreatesRandomSubFolders {\n        @Rule\n        public TemporaryFolder folder = new TemporaryFolder();\n\n        @Test\n        public void testUsingRandomTempFolders() throws IOException {\n            for (int i = 0; i < 20; i++) {\n                File newFolder = folder.newFolder();\n                assertThat(Arrays.asList(createdFiles), not(hasItem(newFolder)));\n                createdFiles[i] = newFolder;\n                new File(newFolder, \"a.txt\").createNewFile();\n                assertTrue(newFolder.exists());\n            }\n        }\n    }\n\n    @Test\n    public void randomSubFoldersAreDeleted() {\n        assertThat(testResult(CreatesRandomSubFolders.class), isSuccessful());\n        for (File f : createdFiles) {\n            assertFalse(f.exists());\n        }\n    }\n\n    public static class CreatesRandomFiles {\n        @Rule\n        public TemporaryFolder folder = new TemporaryFolder();\n\n        @Test\n        public void testUsingRandomTempFiles() throws IOException {\n            for (int i = 0; i < 20; i++) {\n                File newFile = folder.newFile();\n                assertThat(Arrays.asList(createdFiles), not(hasItem(newFile)));\n                createdFiles[i] = newFile;\n                assertTrue(newFile.exists());\n            }\n        }\n    }\n\n    @Test\n    public void randomFilesAreDeleted() {\n        assertThat(testResult(CreatesRandomFiles.class), isSuccessful());\n        for (File f : createdFiles) {\n            assertFalse(f.exists());\n        }\n    }\n\n    @Test\n    public void recursiveDeleteFolderWithOneElement() throws IOException {\n        TemporaryFolder folder = new TemporaryFolder();\n        folder.create();\n        File file = folder.newFile(\"a\");\n        folder.delete();\n        assertFalse(file.exists());\n        assertFalse(folder.getRoot().exists());\n    }\n\n    @Test\n    public void recursiveDeleteFolderWithOneRandomElement() throws IOException {\n        TemporaryFolder folder = new TemporaryFolder();\n        folder.create();\n        File file = folder.newFile();\n        folder.delete();\n        assertFalse(file.exists());\n        assertFalse(folder.getRoot().exists());\n    }\n\n    @Test\n    public void recursiveDeleteFolderWithZeroElements() throws IOException {\n        TemporaryFolder folder = new TemporaryFolder();\n        folder.create();\n        folder.delete();\n        assertFalse(folder.getRoot().exists());\n    }\n\n    @Test\n    public void tempFolderIsOnlyAccessibleByOwner() throws IOException {\n        TemporaryFolder folder = new TemporaryFolder();\n        folder.create();\n\n        Set<String> expectedPermissions = new TreeSet<String>(Arrays.asList(\"OWNER_READ\", \"OWNER_WRITE\", \"OWNER_EXECUTE\"));\n        Set<String> actualPermissions = getPosixFilePermissions(folder.getRoot());\n        assertEquals(expectedPermissions, actualPermissions);\n    }\n\n    private Set<String> getPosixFilePermissions(File root) {\n        try {\n            Class<?> pathClass = Class.forName(\"java.nio.file.Path\");\n            Object linkOptionArray = Array.newInstance(Class.forName(\"java.nio.file.LinkOption\"), 0);\n            Class<?> filesClass = Class.forName(\"java.nio.file.Files\");\n            Object path = File.class.getDeclaredMethod(\"toPath\").invoke(root);\n            Method posixFilePermissionsMethod = filesClass.getDeclaredMethod(\"getPosixFilePermissions\", pathClass, linkOptionArray.getClass());\n            Set<?> permissions = (Set<?>) posixFilePermissionsMethod.invoke(null, path, linkOptionArray);\n            SortedSet<String> convertedPermissions = new TreeSet<String>();\n            for (Object item : permissions) {\n                convertedPermissions.add(item.toString());\n            }\n            return convertedPermissions;\n        } catch (Exception e) {\n            throw new AssumptionViolatedException(\"Test requires at least Java 1.7\", e);\n        }\n    }\n\n    public static class NameClashes {\n        @Rule\n        public TemporaryFolder folder = new TemporaryFolder();\n\n        @Test\n        public void fileWithFileClash() throws IOException {\n            folder.newFile(\"something.txt\");\n            folder.newFile(\"something.txt\");\n        }\n\n        @Test\n        public void fileWithFolderTest() throws IOException {\n            folder.newFolder(\"dummy\");\n            folder.newFile(\"dummy\");\n        }\n    }\n\n    @Test\n    public void nameClashesResultInTestFailures() {\n        assertThat(testResult(NameClashes.class), failureCountIs(2));\n    }\n\n    private static final String GET_ROOT_DUMMY = \"dummy-getRoot\";\n\n    private static final String NEW_FILE_DUMMY = \"dummy-newFile\";\n\n    private static final String NEW_FOLDER_DUMMY = \"dummy-newFolder\";\n\n    public static class IncorrectUsage {\n        public TemporaryFolder folder = new TemporaryFolder();\n\n        @Test\n        public void testGetRoot() throws IOException {\n            new File(folder.getRoot(), GET_ROOT_DUMMY).createNewFile();\n        }\n\n        @Test\n        public void testNewFile() throws IOException {\n            folder.newFile(NEW_FILE_DUMMY);\n        }\n\n        @Test\n        public void testNewFolder() throws IOException {\n            folder.newFolder(NEW_FOLDER_DUMMY);\n        }\n    }\n\n    @Test\n    public void incorrectUsageWithoutApplyingTheRuleShouldNotPolluteTheCurrentWorkingDirectory() {\n        assertThat(testResult(IncorrectUsage.class), failureCountIs(3));\n        assertFalse(\"getRoot should have failed early\", new File(GET_ROOT_DUMMY).exists());\n        assertFalse(\"newFile should have failed early\", new File(NEW_FILE_DUMMY).exists());\n        assertFalse(\"newFolder should have failed early\", new File(NEW_FOLDER_DUMMY).exists());\n    }\n\n    @After\n    public void cleanCurrentWorkingDirectory() {\n        new File(GET_ROOT_DUMMY).delete();\n        new File(NEW_FILE_DUMMY).delete();\n        new File(NEW_FOLDER_DUMMY).delete();\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/TemporaryFolderRuleAssuredDeletionTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.failureCountIs;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.experimental.results.PrintableResult;\n\npublic class TemporaryFolderRuleAssuredDeletionTest {\n\n    public static class TestClass {\n        static TemporaryFolder injectedRule;\n\n        @Rule\n        public TemporaryFolder folder = injectedRule;\n\n        @Test\n        public void alwaysPassesButDeletesRootFolder() {\n            //we delete the folder in the test so that it cannot be deleted by\n            //the rule\n            folder.getRoot().delete();\n        }\n    }\n\n    @Test\n    public void testFailsWhenCreatedFolderCannotBeDeletedButDeletionIsAssured() {\n        TestClass.injectedRule = TemporaryFolder.builder()\n                .assureDeletion()\n                .build();\n        PrintableResult result = testResult(TestClass.class);\n        assertThat(result, failureCountIs(1));\n        assertThat(result.toString(), containsString(\"Unable to clean up temporary folder\"));\n    }\n\n    @Test\n    public void byDefaultTestDoesNotFailWhenCreatedFolderCannotBeDeleted() {\n        TestClass.injectedRule = new TemporaryFolder();\n        PrintableResult result = testResult(TestClass.class);\n        assertThat(result, isSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/TemporaryFolderUsageTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.notNullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assume.assumeTrue;\n\nimport java.io.File;\nimport java.io.IOException;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.Test;\n\n/**\n * <tt>TemporaryFolderUsageTest</tt> provides tests for API usage correctness\n * and ensure implementation symmetry of public methods against a root folder.\n */\npublic class TemporaryFolderUsageTest {\n\n    private TemporaryFolder tempFolder;\n\n    @Rule\n    public final ExpectedException thrown = ExpectedException.none();\n\n    @Before\n    public void setUp() {\n        tempFolder = new TemporaryFolder();\n    }\n\n    @After\n    public void tearDown() {\n        tempFolder.delete();\n    }\n\n    @Test(expected = IllegalStateException.class)\n    public void getRootShouldThrowIllegalStateExceptionIfCreateWasNotInvoked() {\n        new TemporaryFolder().getRoot();\n    }\n\n    @Test(expected = IllegalStateException.class)\n    public void newFileThrowsIllegalStateExceptionIfCreateWasNotInvoked()\n            throws IOException {\n        new TemporaryFolder().newFile();\n    }\n\n    @Test(expected = IllegalStateException.class)\n    public void newFileWithGivenNameThrowsIllegalStateExceptionIfCreateWasNotInvoked()\n            throws IOException {\n        new TemporaryFolder().newFile(\"MyFile.txt\");\n    }\n\n    @Test\n    public void newFileWithGivenFilenameThrowsIOExceptionIfFileExists() throws IOException {\n        tempFolder.create();\n        tempFolder.newFile(\"MyFile.txt\");\n\n        thrown.expect(IOException.class);\n        thrown.expectMessage(\"a file with the name 'MyFile.txt' already exists in the test folder\");\n        tempFolder.newFile(\"MyFile.txt\");\n    }\n\n    @Test(expected = IllegalStateException.class)\n    public void newFolderThrowsIllegalStateExceptionIfCreateWasNotInvoked()\n            throws IOException {\n        new TemporaryFolder().newFolder();\n    }\n\n    @Test(expected = IllegalStateException.class)\n    public void newFolderWithGivenPathThrowsIllegalStateExceptionIfCreateWasNotInvoked() throws IOException {\n        new TemporaryFolder().newFolder(\"level1\", \"level2\", \"level3\");\n    }\n\n    @Test\n    public void newFolderWithGivenFolderThrowsIOExceptionIfFolderExists() throws IOException {\n        tempFolder.create();\n        tempFolder.newFolder(\"level1\");\n\n        thrown.expect(IOException.class);\n        thrown.expectMessage(\"a folder with the path 'level1' already exists\");\n        tempFolder.newFolder(\"level1\");\n    }\n\n    @Test\n    public void newFolderWithGivenFolderThrowsIOExceptionIfFileExists() throws IOException {\n        tempFolder.create();\n        File file = new File(tempFolder.getRoot(), \"level1\");\n        assertTrue(\"Could not create\" + file, file.createNewFile());\n\n        thrown.expect(IOException.class);\n        thrown.expectMessage(\"a file with the path 'level1' exists\");\n        tempFolder.newFolder(\"level1\");\n    }\n\n    @Test\n    public void newFolderWithGivenFolderThrowsIOExceptionWhenFolderCannotBeCreated() throws IOException {\n        tempFolder.create();\n        assumeTrue(\"Could not make folder \" + tempFolder.getRoot() + \" read only.\",\n                tempFolder.getRoot().setReadOnly());\n\n        thrown.expect(IOException.class);\n        thrown.expectMessage(\"could not create a folder with the path 'level1'\");\n        tempFolder.newFolder(\"level1\");\n    }\n    \n    @Test\n    public void newFolderWithPathStartingWithFileSeparatorThrowsIOException()\n            throws IOException {\n        String fileAtRoot;\n        File[] roots = File.listRoots();\n        if (roots != null && roots.length > 0) {\n            fileAtRoot = roots[0].getAbsolutePath() + \"temp1\";\n        } else {\n            fileAtRoot = File.separator + \"temp1\";\n        }\n        tempFolder.create();\n        thrown.expect(IOException.class);\n        thrown.expectMessage(\"folder path '\" + fileAtRoot + \"' is not a relative path\");\n        tempFolder.newFolder(fileAtRoot);\n    }\n    \n    @Test\n    public void newFolderWithPathContainingFileSeparatorCreatesDirectories()\n            throws IOException {\n        tempFolder.create();\n        tempFolder.newFolder(\"temp1\" + File.separator + \"temp2\");\n        File temp1 = new File(tempFolder.getRoot(), \"temp1\");\n        assertFileIsDirectory(temp1);\n        assertFileIsDirectory(new File(temp1, \"temp2\"));\n    }\n \n    @Test\n    public void newFolderWithPathContainingForwardSlashCreatesDirectories()\n            throws IOException {\n        tempFolder.create();\n        tempFolder.newFolder(\"temp1/temp2\");\n        File temp1 = new File(tempFolder.getRoot(), \"temp1\");\n        assertFileIsDirectory(temp1);\n        assertFileIsDirectory(new File(temp1, \"temp2\"));\n    }\n    \n    @Test\n    public void newFolderWithGivenPathThrowsIOExceptionIfFolderExists() throws IOException {\n        tempFolder.create();\n        tempFolder.newFolder(\"level1\", \"level2\", \"level3\");\n\n        thrown.expect(IOException.class);\n        String path = \"level1\" + File.separator + \"level2\" + File.separator + \"level3\";\n        thrown.expectMessage(\"a folder with the path '\" + path + \"' already exists\");\n        tempFolder.newFolder(\"level1\", \"level2\", \"level3\");\n    }\n\n    @Test\n    public void newFolderWithGivenEmptyArrayThrowsIllegalArgumentException() throws IOException {\n        tempFolder.create();\n\n        thrown.expect(IllegalArgumentException.class);\n        thrown.expectMessage(\"must pass at least one path\");\n        tempFolder.newFolder(new String[0]);\n    }\n\n    @Test\n    public void newFolderWithPathsContainingForwardSlashCreatesFullPath()\n            throws IOException {\n        tempFolder.create();\n        tempFolder.newFolder(\"temp1\", \"temp2\", \"temp3/temp4\");\n\n        File directory = new File(tempFolder.getRoot(), \"temp1\");\n        assertFileIsDirectory(directory);\n        directory = new File(directory, \"temp2/temp3/temp4\");\n        assertFileIsDirectory(directory);\n    }\n\n    @Test\n    public void newFolderWithPathsContainingFileSeparatorCreatesFullPath()\n            throws IOException {\n        tempFolder.create();\n        tempFolder.newFolder(\"temp1\", \"temp2\", \"temp3\" + File.separator + \"temp4\");\n\n        File directory = new File(tempFolder.getRoot(), \"temp1\");\n        assertFileIsDirectory(directory);\n        directory = new File(directory, \"temp2/temp3/temp4\");\n        assertFileIsDirectory(directory);\n    }\n    \n    @Test\n    public void createInitializesRootFolder() throws IOException {\n        tempFolder.create();\n        assertFileIsDirectory(tempFolder.getRoot());\n    }\n\n    @Test\n    public void deleteShouldDoNothingIfRootFolderWasNotInitialized() {\n        tempFolder.delete();\n    }\n\n    @Test\n    public void deleteRemovesRootFolder() throws IOException {\n        tempFolder.create();\n        tempFolder.delete();\n        assertFileDoesNotExist(tempFolder.getRoot());\n    }\n\n    @Test\n    public void newRandomFileIsCreatedUnderRootFolder() throws IOException {\n        tempFolder.create();\n\n        File f = tempFolder.newFile();\n        assertFileExists(f);\n        assertFileCreatedUnderRootFolder(\"Random file\", f);\n    }\n\n    @Test\n    public void newNamedFileIsCreatedUnderRootFolder() throws IOException {\n        final String fileName = \"SampleFile.txt\";\n        tempFolder.create();\n\n        File f = tempFolder.newFile(fileName);\n\n        assertFileExists(f);\n        assertFileCreatedUnderRootFolder(\"Named file\", f);\n        assertThat(\"file name\", f.getName(), equalTo(fileName));\n    }\n\n    @Test\n    public void newRandomFolderIsCreatedUnderRootFolder() throws IOException {\n        tempFolder.create();\n\n        File f = tempFolder.newFolder();\n        assertFileIsDirectory(f);\n        assertFileCreatedUnderRootFolder(\"Random folder\", f);\n    }\n\n    @Test\n    public void newNestedFoldersCreatedUnderRootFolder() throws IOException {\n        tempFolder.create();\n\n        File f = tempFolder.newFolder(\"top\", \"middle\", \"bottom\");\n        assertFileIsDirectory(f);\n        assertParentFolderForFileIs(f, new File(tempFolder.getRoot(),\n                \"top/middle\"));\n        assertParentFolderForFileIs(f.getParentFile(),\n                new File(tempFolder.getRoot(), \"top\"));\n        assertFileCreatedUnderRootFolder(\"top\", f.getParentFile()\n                .getParentFile());\n    }\n\n    @Test\n    public void canSetTheBaseFileForATemporaryFolder() throws IOException {\n        File tempDir = createTemporaryFolder();\n\n        TemporaryFolder folder = new TemporaryFolder(tempDir);\n        folder.create();\n\n        assertThat(tempDir, is(folder.getRoot().getParentFile()));\n    }\n\n    private File createTemporaryFolder() throws IOException {\n        File tempDir = File.createTempFile(\"junit\", \"tempFolder\");\n        assertTrue(\"Unable to delete temporary file\", tempDir.delete());\n        assertTrue(\"Unable to create temp directory\", tempDir.mkdir());\n        return tempDir;\n    }\n\n    private void assertFileDoesNotExist(File file) {\n        checkFileExists(\"exists\", file, false);\n    }\n\n    private void checkFileExists(String msg, File file, boolean exists) {\n        assertThat(\"File is null\", file, is(notNullValue()));\n        assertThat(\"File '\" + file.getAbsolutePath() + \"' \" + msg,\n                file.exists(), is(exists));\n    }\n\n    private void checkFileIsDirectory(String msg, File file, boolean isDirectory) {\n        assertThat(\"File is null\", file, is(notNullValue()));\n        assertThat(\"File '\" + file.getAbsolutePath() + \"' \" + msg,\n                file.isDirectory(), is(isDirectory));\n    }\n\n    private void assertFileExists(File file) {\n        checkFileExists(\"does not exist\", file, true);\n        checkFileIsDirectory(\"is a directory\", file, false);\n    }\n\n    private void assertFileIsDirectory(File file) {\n        checkFileExists(\"does not exist\", file, true);\n        checkFileIsDirectory(\"is not a directory\", file, true);\n    }\n\n    private void assertFileCreatedUnderRootFolder(String msg, File f) {\n        assertParentFolderForFileIs(f, tempFolder.getRoot());\n    }\n\n    private void assertParentFolderForFileIs(File f, File parentFolder) {\n        assertThat(\"'\" + f.getAbsolutePath() + \"': not under root\",\n                f.getParentFile(), is(parentFolder));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/TestRuleTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\npublic class TestRuleTest {\n    private static boolean wasRun;\n\n    public static class ExampleTest {\n        @Rule\n        public TestRule example = new TestRule() {\n            public Statement apply(final Statement base, Description description) {\n                return new Statement() {\n                    @Override\n                    public void evaluate() throws Throwable {\n                        wasRun = true;\n                        base.evaluate();\n                    }\n                };\n            }\n        };\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void ruleIsIntroducedAndEvaluated() {\n        wasRun = false;\n        JUnitCore.runClasses(ExampleTest.class);\n        assertTrue(wasRun);\n    }\n\n    public static class BothKindsOfRule implements TestRule, org.junit.rules.MethodRule {\n        public int applications = 0;\n\n        public Statement apply(Statement base, FrameworkMethod method,\n                Object target) {\n            applications++;\n            return base;\n        }\n\n        public Statement apply(Statement base, Description description) {\n            applications++;\n            return base;\n        }\n    }\n\n    public static class OneFieldTwoKindsOfRule {\n        @Rule\n        public BothKindsOfRule both = new BothKindsOfRule();\n\n        @Test\n        public void onlyOnce() {\n            assertEquals(1, both.applications);\n        }\n    }\n\n\n    @Test\n    public void onlyApplyOnceEvenIfImplementsBothInterfaces() {\n        assertTrue(JUnitCore.runClasses(OneFieldTwoKindsOfRule.class).wasSuccessful());\n    }\n\n    public static class SonOfExampleTest extends ExampleTest {\n\n    }\n\n    @Test\n    public void ruleIsIntroducedAndEvaluatedOnSubclass() {\n        wasRun = false;\n        JUnitCore.runClasses(SonOfExampleTest.class);\n        assertTrue(wasRun);\n    }\n\n    private static int runCount;\n\n    public static class MultipleRuleTest {\n        private static class Increment implements TestRule {\n            public Statement apply(final Statement base, Description description) {\n                return new Statement() {\n                    @Override\n                    public void evaluate() throws Throwable {\n                        runCount++;\n                        base.evaluate();\n                    }\n                };\n            }\n        }\n\n        @Rule\n        public TestRule incrementor1 = new Increment();\n\n        @Rule\n        public TestRule incrementor2 = new Increment();\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void multipleRulesAreRun() {\n        runCount = 0;\n        JUnitCore.runClasses(MultipleRuleTest.class);\n        assertEquals(2, runCount);\n    }\n\n    public static class NoRulesTest {\n        public int x;\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void ignoreNonRules() {\n        Result result = JUnitCore.runClasses(NoRulesTest.class);\n        assertEquals(0, result.getFailureCount());\n    }\n\n    private static String log;\n\n    public static class BeforesAndAfters {\n        private static StringBuilder watchedLog = new StringBuilder();\n\n        @Before\n        public void before() {\n            watchedLog.append(\"before \");\n        }\n\n        @Rule\n        public TestRule watcher = new LoggingTestWatcher(watchedLog);\n\n        @After\n        public void after() {\n            watchedLog.append(\"after \");\n        }\n\n        @Test\n        public void succeeds() {\n            watchedLog.append(\"test \");\n        }\n    }\n\n    @Test\n    public void beforesAndAfters() {\n        BeforesAndAfters.watchedLog = new StringBuilder();\n        JUnitCore.runClasses(BeforesAndAfters.class);\n        assertThat(BeforesAndAfters.watchedLog.toString(),\n                is(\"starting before test after succeeded finished \"));\n    }\n\n    public static class WrongTypedField {\n        @Rule\n        public int x = 5;\n\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test\n    public void validateWrongTypedField() {\n        assertThat(testResult(WrongTypedField.class),\n                hasSingleFailureContaining(\"must implement MethodRule\"));\n    }\n\n    public static class SonOfWrongTypedField extends WrongTypedField {\n\n    }\n\n    @Test\n    public void validateWrongTypedFieldInSuperclass() {\n        assertThat(testResult(SonOfWrongTypedField.class),\n                hasSingleFailureContaining(\"must implement MethodRule\"));\n    }\n\n    public static class PrivateRule {\n        @Rule\n        private TestRule rule = new TestName();\n\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test\n    public void validatePrivateRule() {\n        assertThat(testResult(PrivateRule.class),\n                hasSingleFailureContaining(\"must be public\"));\n    }\n\n    public static class CustomTestName implements TestRule {\n        public String name = null;\n\n        public Statement apply(final Statement base, final Description description) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    name = description.getMethodName();\n                    base.evaluate();\n                }\n            };\n        }\n    }\n\n    public static class UsesCustomMethodRule {\n        @Rule\n        public CustomTestName counter = new CustomTestName();\n\n        @Test\n        public void foo() {\n            assertEquals(\"foo\", counter.name);\n        }\n    }\n\n    @Test\n    public void useCustomMethodRule() {\n        assertThat(testResult(UsesCustomMethodRule.class), isSuccessful());\n    }\n\n    public static class MethodExampleTest {\n        private TestRule example = new TestRule() {\n            public Statement apply(final Statement base, Description description) {\n                return new Statement() {\n                    @Override\n                    public void evaluate() throws Throwable {\n                        wasRun = true;\n                        base.evaluate();\n                    }\n                };\n            }\n        };\n\n        @Rule\n        public TestRule getExample() {\n            return example;\n        }\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void methodRuleIsIntroducedAndEvaluated() {\n        wasRun = false;\n        JUnitCore.runClasses(MethodExampleTest.class);\n        assertTrue(wasRun);\n    }\n\n    public static class MethodBothKindsOfRule implements TestRule, org.junit.rules.MethodRule {\n        public int applications = 0;\n\n        public Statement apply(Statement base, FrameworkMethod method,\n                Object target) {\n            applications++;\n            return base;\n        }\n\n        public Statement apply(Statement base, Description description) {\n            applications++;\n            return base;\n        }\n    }\n\n    public static class MethodOneFieldTwoKindsOfRule {\n        private MethodBothKindsOfRule both = new MethodBothKindsOfRule();\n\n        @Rule\n        public MethodBothKindsOfRule getBoth() {\n            return both;\n        }\n\n        @Test\n        public void onlyOnce() {\n            assertEquals(1, both.applications);\n        }\n    }\n\n\n    @Test\n    public void methodOnlyApplyOnceEvenIfImplementsBothInterfaces() {\n        assertTrue(JUnitCore.runClasses(MethodOneFieldTwoKindsOfRule.class).wasSuccessful());\n    }\n\n    public static class MethodSonOfExampleTest extends MethodExampleTest {\n\n    }\n\n    @Test\n    public void methodRuleIsIntroducedAndEvaluatedOnSubclass() {\n        wasRun = false;\n        JUnitCore.runClasses(MethodSonOfExampleTest.class);\n        assertTrue(wasRun);\n    }\n\n    public static class MethodMultipleRuleTest {\n        private static class Increment implements TestRule {\n            public Statement apply(final Statement base, Description description) {\n                return new Statement() {\n                    @Override\n                    public void evaluate() throws Throwable {\n                        runCount++;\n                        base.evaluate();\n                    }\n                };\n            }\n        }\n\n        private TestRule incrementor1 = new Increment();\n\n        @Rule\n        public TestRule getIncrementor1() {\n            return incrementor1;\n        }\n\n        private TestRule incrementor2 = new Increment();\n\n        @Rule\n        public TestRule getIncrementor2() {\n            return incrementor2;\n        }\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void methodMultipleRulesAreRun() {\n        runCount = 0;\n        JUnitCore.runClasses(MethodMultipleRuleTest.class);\n        assertEquals(2, runCount);\n    }\n\n    public static class MethodNoRulesTest {\n        public int x;\n\n        @Test\n        public void nothing() {\n\n        }\n    }\n\n    @Test\n    public void methodIgnoreNonRules() {\n        Result result = JUnitCore.runClasses(MethodNoRulesTest.class);\n        assertEquals(0, result.getFailureCount());\n    }\n\n    public static class BeforesAndAftersAreEnclosedByRule {\n        private static StringBuilder log;\n\n        @Rule\n        public TestRule watcher = new LoggingTestWatcher(log);\n\n        @Before\n        public void before() {\n            log.append(\"before \");\n        }\n\n        @After\n        public void after() {\n            log.append(\"after \");\n        }\n\n        @Test\n        public void succeeds() {\n            log.append(\"test \");\n        }\n    }\n\n    @Test\n    public void beforesAndAftersAreEnclosedByRule() {\n        BeforesAndAftersAreEnclosedByRule.log = new StringBuilder();\n        JUnitCore.runClasses(BeforesAndAftersAreEnclosedByRule.class);\n        assertEquals(\"starting before test after succeeded finished \",\n                BeforesAndAftersAreEnclosedByRule.log.toString());\n    }\n\n    public static class MethodWrongTypedField {\n        @Rule\n        public int getX() {\n            return 5;\n        }\n\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test\n    public void methodValidateWrongTypedField() {\n        assertThat(testResult(MethodWrongTypedField.class),\n                hasSingleFailureContaining(\"must return an implementation of MethodRule\"));\n    }\n\n    public static class MethodSonOfWrongTypedField extends MethodWrongTypedField {\n\n    }\n\n    @Test\n    public void methodValidateWrongTypedFieldInSuperclass() {\n        assertThat(testResult(MethodSonOfWrongTypedField.class),\n                hasSingleFailureContaining(\"must return an implementation of MethodRule\"));\n    }\n\n    public static class MethodPrivateRule {\n        @Rule\n        private TestRule getRule() {\n            return new TestName();\n        }\n\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test\n    public void methodValidatePrivateRule() {\n        assertThat(testResult(MethodPrivateRule.class),\n                hasSingleFailureContaining(\"must be public\"));\n    }\n\n    public static class MethodUsesCustomMethodRule {\n        private CustomTestName counter = new CustomTestName();\n\n        @Rule\n        public CustomTestName getCounter() {\n            return counter;\n        }\n\n        @Test\n        public void foo() {\n            assertEquals(\"foo\", counter.name);\n        }\n    }\n\n    @Test\n    public void methodUseCustomMethodRule() {\n        assertThat(testResult(MethodUsesCustomMethodRule.class), isSuccessful());\n    }\n\n    private static final List<String> orderList = new LinkedList<String>();\n\n    private static class OrderTestRule implements TestRule {\n        private String name;\n\n        public OrderTestRule(String name) {\n            this.name = name;\n        }\n\n        public Statement apply(final Statement base, final Description description) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    orderList.add(name);\n                    base.evaluate();\n                }\n            };\n        }\n    }\n\n    public static class UsesFieldAndMethodRule {\n        @Rule\n        public OrderTestRule orderMethod() {\n            return new OrderTestRule(\"orderMethod\");\n        }\n\n        @Rule\n        public OrderTestRule orderField = new OrderTestRule(\"orderField\");\n\n        @Test\n        public void foo() {\n            assertEquals(\"orderField\", orderList.get(0));\n            assertEquals(\"orderMethod\", orderList.get(1));\n        }\n    }\n\n    @Test\n    public void usesFieldAndMethodRule() {\n        orderList.clear();\n        assertThat(testResult(UsesFieldAndMethodRule.class), isSuccessful());\n    }\n\n    public static class CallMethodOnlyOnceRule {\n        int countOfMethodCalls = 0;\n\n        private static class Dummy implements TestRule {\n            public Statement apply(final Statement base, Description description) {\n                return new Statement() {\n                    @Override\n                    public void evaluate() throws Throwable {\n                        base.evaluate();\n                    }\n                };\n            }\n        }\n\n        @Rule\n        public Dummy both() {\n            countOfMethodCalls++;\n            return new Dummy();\n        }\n\n        @Test\n        public void onlyOnce() {\n            assertEquals(1, countOfMethodCalls);\n        }\n    }\n\n    @Test\n    public void testCallMethodOnlyOnceRule() {\n        assertTrue(JUnitCore.runClasses(CallMethodOnlyOnceRule.class).wasSuccessful());\n    }\n\n    private static final StringBuilder ruleLog = new StringBuilder();\n\n    public static class TestRuleIsAroundMethodRule {\n        @Rule\n        public final MethodRule z = new LoggingMethodRule(ruleLog, \"methodRule\");\n\n        @Rule\n        public final TestRule a = new LoggingTestRule(ruleLog, \"testRule\");\n\n        @Test\n        public void foo() {\n            ruleLog.append(\" foo\");\n        }\n    }\n\n    @Test\n    public void testRuleIsAroundMethodRule() {\n        ruleLog.setLength(0);\n        Result result = JUnitCore.runClasses(TestRuleIsAroundMethodRule.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(\" testRule.begin methodRule.begin foo methodRule.end testRule.end\",\n                ruleLog.toString());\n    }\n\n    public static class TestRuleOrdering {\n        @Rule(order = 1)\n        public final TestRule a = new LoggingTestRule(ruleLog, \"outer\");\n\n        @Rule(order = 2)\n        public final TestRule z = new LoggingTestRule(ruleLog, \"inner\");\n\n        @Test\n        public void foo() {\n            ruleLog.append(\" foo\");\n        }\n    }\n\n    @Test\n    public void testRuleOrdering() {\n        ruleLog.setLength(0);\n        Result result = JUnitCore.runClasses(TestRuleOrdering.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(\" outer.begin inner.begin foo inner.end outer.end\", ruleLog.toString());\n    }\n\n    public static class TestRuleOrderingWithMethodRule {\n        @Rule(order = 1)\n        public final MethodRule z = new LoggingMethodRule(ruleLog, \"methodRule\");\n\n        @Rule(order = 2)\n        public final TestRule a = new LoggingTestRule(ruleLog, \"testRule\");\n\n        @Test\n        public void foo() {\n            ruleLog.append(\" foo\");\n        }\n    }\n\n    @Test\n    public void testRuleOrderingWithMethodRule() {\n        ruleLog.setLength(0);\n        Result result = JUnitCore.runClasses(TestRuleOrderingWithMethodRule.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(\" methodRule.begin testRule.begin foo testRule.end methodRule.end\",\n                ruleLog.toString());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/TestWatcherTest.java",
    "content": "package org.junit.rules;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.*;\nimport static org.junit.Assume.assumeTrue;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.failureCountIs;\nimport static org.junit.experimental.results.ResultMatchers.hasFailureContaining;\nimport static org.junit.rules.ExpectedException.none;\n\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.experimental.results.PrintableResult;\nimport org.junit.experimental.runners.Enclosed;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameter;\nimport org.junit.runners.Parameterized.Parameters;\nimport org.junit.runners.model.Statement;\n\nimport java.util.List;\n\n@RunWith(Enclosed.class)\npublic class TestWatcherTest {\n\n    @RunWith(Parameterized.class)\n    public static class Callbacks {\n\n        @Parameters(name = \"{0}\")\n        public static Object[][] parameters() {\n            return new Object[][] {\n                    {\n                        FailingTest.class,\n                        \"starting failed finished \",\n                        asList(\"starting failed\", \"test failed\", \"failed failed\", \"finished failed\") },\n                    {\n                        InternalViolatedAssumptionTest.class,\n                        \"starting deprecated skipped finished \",\n                        asList(\"starting failed\", \"don't run\", \"deprecated skipped failed\", \"finished failed\") },\n                    {\n                        SuccessfulTest.class,\n                        \"starting succeeded finished \",\n                        asList(\"starting failed\", \"succeeded failed\", \"finished failed\") },\n                    {\n                        ViolatedAssumptionTest.class,\n                        \"starting skipped finished \",\n                        asList(\"starting failed\", \"Test could not be skipped due to other failures\", \"skipped failed\", \"finished failed\") }\n            };\n        }\n\n        @Parameter(0)\n        public Class<?> testClass;\n\n        @Parameter(1)\n        public String expectedCallbacks;\n\n        @Parameter(2)\n        public List<String> expectedFailures;\n\n        private static TestRule selectedRule; //for injecting rule into test classes\n\n        @Test\n        public void correctCallbacksCalled() {\n            StringBuilder log = new StringBuilder();\n            selectedRule = new LoggingTestWatcher(log);\n            JUnitCore.runClasses(testClass);\n            assertEquals(expectedCallbacks, log.toString());\n        }\n\n        @Test\n        public void resultHasAllFailuresThrownByCallbacks() {\n            selectedRule = new ErroneousTestWatcher();\n            PrintableResult result = testResult(testClass);\n            assertThat(result, failureCountIs(expectedFailures.size()));\n            for (String expectedFailure: expectedFailures) {\n                assertThat(result, hasFailureContaining(expectedFailure));\n            }\n        }\n\n        @Test\n        public void testWatcherDoesNotModifyResult() {\n            selectedRule = new NoOpRule();\n            Result resultNoOpRule = JUnitCore.runClasses(testClass);\n            selectedRule = new LoggingTestWatcher(new StringBuilder());\n            Result resultTestWatcher = JUnitCore.runClasses(testClass);\n            assertEquals(\n                    \"was successful\",\n                    resultNoOpRule.wasSuccessful(),\n                    resultTestWatcher.wasSuccessful());\n            assertEquals(\n                    \"failure count\",\n                    resultNoOpRule.getFailureCount(),\n                    resultTestWatcher.getFailureCount());\n            assertEquals(\n                    \"ignore count\",\n                    resultNoOpRule.getIgnoreCount(),\n                    resultTestWatcher.getIgnoreCount());\n            assertEquals(\n                    \"run count\",\n                    resultNoOpRule.getRunCount(),\n                    resultTestWatcher.getRunCount());\n        }\n\n        private static class NoOpRule implements TestRule {\n            public Statement apply(Statement base, Description description) {\n                return base;\n            }\n        }\n\n        private static class ErroneousTestWatcher extends TestWatcher {\n            @Override\n            protected void succeeded(Description description) {\n                throw new RuntimeException(\"succeeded failed\");\n            }\n\n            @Override\n            protected void failed(Throwable e, Description description) {\n                throw new RuntimeException(\"failed failed\");\n            }\n\n            @Override\n            protected void skipped(org.junit.AssumptionViolatedException e, Description description) {\n                throw new RuntimeException(\"skipped failed\");\n            }\n\n            @Override\n            @SuppressWarnings(\"deprecation\")\n            protected void skipped(AssumptionViolatedException e, Description description) {\n                throw new RuntimeException(\"deprecated skipped failed\");\n            }\n\n            @Override\n            protected void starting(Description description) {\n                throw new RuntimeException(\"starting failed\");\n            }\n\n            @Override\n            protected void finished(Description description) {\n                throw new RuntimeException(\"finished failed\");\n            }\n        }\n\n        public static class FailingTest {\n            @Rule\n            public TestRule rule = selectedRule;\n\n            @Test\n            public void test() {\n                fail(\"test failed\");\n            }\n        }\n\n        public static class InternalViolatedAssumptionTest {\n            @Rule\n            public TestRule watcher = selectedRule;\n\n            @SuppressWarnings(\"deprecation\")\n            @Test\n            public void test() {\n                throw new AssumptionViolatedException(\"don't run\");\n            }\n        }\n\n        public static class SuccessfulTest {\n            @Rule\n            public TestRule watcher = selectedRule;\n\n            @Test\n            public void test() {\n            }\n        }\n\n        public static class ViolatedAssumptionTest {\n            @Rule\n            public TestRule watcher = selectedRule;\n\n            @Test\n            public void test() {\n                assumeTrue(false);\n            }\n        }\n    }\n\n    public static class CallbackArguments {\n\n        public static class Succeeded {\n            private static Description catchedDescription;\n\n            @Rule\n            public final TestRule watcher = new TestWatcher() {\n                @Override\n                protected void succeeded(Description description) {\n                    catchedDescription = description;\n                }\n            };\n\n            @Test\n            public void test() {\n            }\n        }\n\n        @Test\n        public void succeeded() {\n            JUnitCore.runClasses(Succeeded.class);\n            assertEquals(\"test(org.junit.rules.TestWatcherTest$CallbackArguments$Succeeded)\",\n                    Succeeded.catchedDescription.getDisplayName());\n        }\n\n        public static class Failed {\n            private static Description catchedDescription;\n            private static Throwable catchedThrowable;\n\n            @Rule\n            public final TestRule watcher = new TestWatcher() {\n                @Override\n                protected void failed(Throwable e, Description description) {\n                    catchedDescription = description;\n                    catchedThrowable = e;\n                }\n            };\n\n            @Test\n            public void test() {\n                fail(\"test failed\");\n            }\n        }\n\n        @Test\n        public void failed() {\n            JUnitCore.runClasses(Failed.class);\n            assertEquals(\"test failed\", Failed.catchedThrowable.getMessage());\n            assertEquals(AssertionError.class, Failed.catchedThrowable.getClass());\n            assertEquals(\"test(org.junit.rules.TestWatcherTest$CallbackArguments$Failed)\",\n                    Failed.catchedDescription.getDisplayName());\n        }\n\n        public static class Skipped {\n            private static Description catchedDescription;\n            private static org.junit.AssumptionViolatedException catchedException;\n\n            @Rule\n            public final TestRule watcher = new TestWatcher() {\n                @Override\n                protected void skipped(org.junit.AssumptionViolatedException e, Description description) {\n                    catchedDescription = description;\n                    catchedException = e;\n                }\n            };\n\n            @Test\n            public void test() {\n                assumeTrue(\"test skipped\", false);\n            }\n        }\n\n        @Test\n        public void skipped() {\n            JUnitCore.runClasses(Skipped.class);\n            assertEquals(\"test skipped\", Skipped.catchedException.getMessage());\n            assertEquals(org.junit.AssumptionViolatedException.class, Skipped.catchedException.getClass());\n            assertEquals(\"test(org.junit.rules.TestWatcherTest$CallbackArguments$Skipped)\",\n                    Skipped.catchedDescription.getDisplayName());\n        }\n\n        public static class DeprecatedSkipped {\n            private static Description catchedDescription;\n            private static AssumptionViolatedException catchedException;\n\n            @Rule\n            public final TestRule watcher = new TestWatcher() {\n                @Override\n                @SuppressWarnings(\"deprecation\")\n                protected void skipped(AssumptionViolatedException e, Description description) {\n                    catchedDescription = description;\n                    catchedException = e;\n                }\n            };\n\n            @SuppressWarnings(\"deprecation\")\n            @Test\n            public void test() {\n                throw new AssumptionViolatedException(\"test skipped\");\n            }\n        }\n\n        @Test\n        public void deprecatedSkipped() {\n            JUnitCore.runClasses(DeprecatedSkipped.class);\n            assertEquals(\"test skipped\", DeprecatedSkipped.catchedException.getMessage());\n            assertEquals(AssumptionViolatedException.class, DeprecatedSkipped.catchedException.getClass());\n            assertEquals(\"test(org.junit.rules.TestWatcherTest$CallbackArguments$DeprecatedSkipped)\",\n                    DeprecatedSkipped.catchedDescription.getDisplayName());\n        }\n\n        public static class Starting {\n            private static Description catchedDescription;\n\n            @Rule\n            public final TestRule watcher = new TestWatcher() {\n                @Override\n                protected void starting(Description description) {\n                    catchedDescription = description;\n                }\n            };\n\n            @Test\n            public void test() {\n            }\n        }\n\n        @Test\n        public void starting() {\n            JUnitCore.runClasses(Starting.class);\n            assertEquals(\"test(org.junit.rules.TestWatcherTest$CallbackArguments$Starting)\",\n                    Starting.catchedDescription.getDisplayName());\n        }\n\n        public static class Finished {\n            private static Description catchedDescription;\n\n            @Rule\n            public final TestRule watcher = new TestWatcher() {\n                @Override\n                protected void finished(Description description) {\n                    catchedDescription = description;\n                }\n            };\n\n            @Test\n            public void test() {\n            }\n        }\n\n        @Test\n        public void finished() {\n            JUnitCore.runClasses(Finished.class);\n            assertEquals(\"test(org.junit.rules.TestWatcherTest$CallbackArguments$Finished)\",\n                    Finished.catchedDescription.getDisplayName());\n        }\n    }\n\n    //The following tests check the information in TestWatcher's Javadoc\n    //regarding interplay with other rules.\n    public static class InterplayWithOtherRules {\n        private static StringBuilder log;\n\n        public static class ExpectedExceptionTest {\n            @Rule(order = Integer.MIN_VALUE)\n            //the field name must be alphabetically lower than \"thrown\" in order\n            //to make the test failing if order is not set\n            public final TestRule a = new LoggingTestWatcher(log);\n\n            @Rule\n            public final ExpectedException thrown = none();\n\n            @Test\n            public void testWithExpectedException() {\n                thrown.expect(RuntimeException.class);\n                throw new RuntimeException(\"expected exception\");\n            }\n        }\n\n        @Test\n        public void expectedExceptionIsSeenAsSuccessfulTest() {\n            log = new StringBuilder();\n            JUnitCore.runClasses(ExpectedExceptionTest.class);\n            assertEquals(\"starting succeeded finished \", log.toString());\n        }\n\n        public static class ErrorCollectorTest {\n            @Rule(order = Integer.MIN_VALUE)\n            //the field name must be alphabetically lower than \"collector\" in\n            //order to make the test failing if order is not set\n            public final TestRule a = new LoggingTestWatcher(log);\n\n            @Rule\n            public final ErrorCollector collector = new ErrorCollector();\n\n            @Test\n            public void test() {\n                collector.addError(new RuntimeException(\"expected exception\"));\n            }\n        }\n\n        @Test\n        public void testIsSeenAsFailedBecauseOfCollectedError() {\n            log = new StringBuilder();\n            JUnitCore.runClasses(ErrorCollectorTest.class);\n            assertEquals(\"starting failed finished \", log.toString());\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/TestWatchmanTest.java",
    "content": "package org.junit.rules;\n\nimport static junit.framework.Assert.fail;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assume.assumeTrue;\nimport static org.junit.runner.JUnitCore.runClasses;\nimport org.junit.BeforeClass;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runners.model.FrameworkMethod;\n\n@SuppressWarnings(\"deprecation\")\npublic class TestWatchmanTest {\n    public static class ViolatedAssumptionTest {\n        static StringBuilder log;\n\n        @BeforeClass\n        public static void initLog() {\n            log = new StringBuilder();\n        }\n\n        @Rule\n        public LoggingTestWatchman watchman = new LoggingTestWatchman(log);\n\n        @Test\n        public void succeeds() {\n            assumeTrue(false);\n        }\n    }\n\n    @Test\n    public void neitherLogSuccessNorFailedForViolatedAssumption() {\n        runClasses(ViolatedAssumptionTest.class);\n        assertThat(ViolatedAssumptionTest.log.toString(),\n                is(\"starting finished \"));\n    }\n\n    public static class FailingTest {\n        static StringBuilder log;\n\n        @BeforeClass\n        public static void initLog() {\n            log = new StringBuilder();\n        }\n\n        @Rule\n        public LoggingTestWatchman watchman = new LoggingTestWatchman(log);\n\n        @Test\n        public void succeeds() {\n            fail();\n        }\n    }\n\n    @Test\n    public void logFailingTest() {\n        runClasses(FailingTest.class);\n        assertThat(FailingTest.log.toString(),\n                is(\"starting failed finished \"));\n    }\n\n    private static class LoggingTestWatchman extends TestWatchman {\n        private final StringBuilder log;\n\n        private LoggingTestWatchman(StringBuilder log) {\n            this.log = log;\n        }\n\n        @Override\n        public void succeeded(FrameworkMethod method) {\n            log.append(\"succeeded \");\n        }\n\n        @Override\n        public void failed(Throwable e, FrameworkMethod method) {\n            log.append(\"failed \");\n        }\n\n        @Override\n        public void starting(FrameworkMethod method) {\n            log.append(\"starting \");\n        }\n\n        @Override\n        public void finished(FrameworkMethod method) {\n            log.append(\"finished \");\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/rules/TimeoutRuleTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.InterruptedIOException;\nimport java.io.RandomAccessFile;\nimport java.nio.ByteBuffer;\nimport java.nio.channels.FileChannel;\nimport java.util.Random;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.locks.ReentrantLock;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\n\npublic class TimeoutRuleTest {\n    private static final ReentrantLock run1Lock = new ReentrantLock();\n\n    private static volatile boolean run4done = false;\n\n    public abstract static class AbstractTimeoutTest {\n        public static final StringBuffer logger = new StringBuffer();\n\n        @Rule\n        public final TemporaryFolder tmpFile = new TemporaryFolder();\n\n        @Test\n        public void run1() throws InterruptedException {\n            logger.append(\"run1\");\n            TimeoutRuleTest.run1Lock.lockInterruptibly();\n            TimeoutRuleTest.run1Lock.unlock();\n        }\n\n        @Test\n        public void run2() throws InterruptedException {\n            logger.append(\"run2\");\n            Thread.currentThread().join();\n        }\n\n        @Test\n        public synchronized void run3() throws InterruptedException {\n            logger.append(\"run3\");\n            wait();\n        }\n\n        @Test\n        public void run4() {\n            logger.append(\"run4\");\n            while (!run4done) {\n            }\n        }\n\n        @Test\n        public void run5() throws IOException {\n            logger.append(\"run5\");\n            Random rnd = new Random();\n            byte[] data = new byte[1024];\n            File tmp = tmpFile.newFile();\n            while (true) {\n                RandomAccessFile randomAccessFile = new RandomAccessFile(tmp, \"rw\");\n                try {\n                    FileChannel channel = randomAccessFile.getChannel();\n                    rnd.nextBytes(data);\n                    ByteBuffer buffer = ByteBuffer.wrap(data);\n                    // Interrupted thread closes channel and throws ClosedByInterruptException.\n                    channel.write(buffer);\n                } finally {\n                    randomAccessFile.close();\n                }\n                tmp.delete();\n            }\n        }\n\n        @Test\n        public void run6() throws InterruptedIOException {\n            logger.append(\"run6\");\n            // Java IO throws InterruptedIOException only on SUN machines.\n            throw new InterruptedIOException();\n        }\n    }\n\n    public static class HasGlobalLongTimeout extends AbstractTimeoutTest {\n\n        @Rule\n        public final TestRule globalTimeout = Timeout.millis(200);\n    }\n\n    public static class HasGlobalTimeUnitTimeout extends AbstractTimeoutTest {\n\n        @Rule\n        public final TestRule globalTimeout = new Timeout(200, TimeUnit.MILLISECONDS);\n    }\n    \n    public static class HasNullTimeUnit {\n\n        @Rule\n        public final TestRule globalTimeout = new Timeout(200, null);\n        \n        @Test\n        public void wouldPass() {\n        }\n    }\n\n    @Before\n    public void before() {\n        run4done = false;\n        run1Lock.lock();\n    }\n\n    @After\n    public void after() {\n        // set run4done to make sure that the thread won't continue at run4()\n        run4done = true;\n        run1Lock.unlock();\n    }\n\n    @Test\n    public void timeUnitTimeout() {\n        HasGlobalTimeUnitTimeout.logger.setLength(0);\n        Result result = JUnitCore.runClasses(HasGlobalTimeUnitTimeout.class);\n        assertEquals(6, result.getFailureCount());\n        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString(\"run1\"));\n        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString(\"run2\"));\n        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString(\"run3\"));\n        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString(\"run4\"));\n        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString(\"run5\"));\n        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString(\"run6\"));\n    }\n\n    @Test\n    public void longTimeout() {\n        HasGlobalLongTimeout.logger.setLength(0);\n        Result result = JUnitCore.runClasses(HasGlobalLongTimeout.class);\n        assertEquals(6, result.getFailureCount());\n        assertThat(HasGlobalLongTimeout.logger.toString(), containsString(\"run1\"));\n        assertThat(HasGlobalLongTimeout.logger.toString(), containsString(\"run2\"));\n        assertThat(HasGlobalLongTimeout.logger.toString(), containsString(\"run3\"));\n        assertThat(HasGlobalLongTimeout.logger.toString(), containsString(\"run4\"));\n        assertThat(HasGlobalLongTimeout.logger.toString(), containsString(\"run5\"));\n        assertThat(HasGlobalLongTimeout.logger.toString(), containsString(\"run6\"));\n    }\n\n    @Test\n    public void nullTimeUnit() {\n        Result result = JUnitCore.runClasses(HasNullTimeUnit.class);\n        assertEquals(1, result.getFailureCount());\n        Failure failure = result.getFailures().get(0);\n        assertThat(failure.getException().getMessage(),\n                containsString(\"Invalid parameters for Timeout\"));\n        Throwable cause = failure.getException().getCause();\n        assertThat(cause.getMessage(), containsString(\"TimeUnit cannot be null\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/rules/VerifierRuleTest.java",
    "content": "package org.junit.rules;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport org.junit.Rule;\nimport org.junit.Test;\n\npublic class VerifierRuleTest {\n\n    private static String sequence;\n\n    public static class UsesVerifier {\n        @Rule\n        public Verifier collector = new Verifier() {\n            @Override\n            protected void verify() {\n                sequence += \"verify \";\n            }\n        };\n\n        @Test\n        public void example() {\n            sequence += \"test \";\n        }\n    }\n\n    @Test\n    public void verifierRunsAfterTest() {\n        sequence = \"\";\n        assertThat(testResult(UsesVerifier.class), isSuccessful());\n        assertEquals(\"test verify \", sequence);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/AllRunnerTests.java",
    "content": "package org.junit.runner;\n\n\nimport org.junit.runner.notification.AllNotificationTests;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllNotificationTests.class,\n        FilterFactoriesTest.class,\n        FilterOptionIntegrationTest.class,\n        OrderWithValidatorTest.class,\n        JUnitCommandLineParseResultTest.class,\n        JUnitCoreTest.class, RequestTest.class\n})\npublic class AllRunnerTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/FilterFactoriesTest.java",
    "content": "package org.junit.runner;\r\n\r\nimport static org.hamcrest.CoreMatchers.instanceOf;\r\nimport static org.hamcrest.CoreMatchers.is;\r\nimport static org.hamcrest.CoreMatchers.startsWith;\r\nimport static org.hamcrest.MatcherAssert.assertThat;\r\nimport static org.junit.Assume.assumeThat;\r\nimport org.junit.Rule;\r\nimport org.junit.Test;\r\nimport org.junit.experimental.categories.ExcludeCategories;\r\nimport org.junit.rules.ExpectedException;\r\nimport org.junit.rules.TestName;\r\nimport org.junit.runner.manipulation.Filter;\r\nimport org.junit.runners.Suite;\r\nimport org.junit.runners.Suite.SuiteClasses;\r\n\r\npublic class FilterFactoriesTest {\r\n    @Rule\r\n    public ExpectedException expectedException = ExpectedException.none();\r\n\r\n    @Rule\r\n    public TestName testName = new TestName();\r\n\r\n    private Request createSuiteRequest() {\r\n        return Request.aClass(DummySuite.class);\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFilterWithArguments() throws Exception {\r\n        Filter filter = FilterFactories.createFilterFromFilterSpec(\r\n                createSuiteRequest(),\r\n                ExcludeCategories.class.getName() + \"=\" + DummyCategory.class.getName());\r\n\r\n        assertThat(filter.describe(), startsWith(\"excludes \"));\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFilterWithNoArguments() throws Exception {\r\n        Filter filter = FilterFactories.createFilterFromFilterSpec(\r\n                createSuiteRequest(), FilterFactoryStub.class.getName());\r\n\r\n        assertThat(filter, instanceOf(DummyFilter.class));\r\n    }\r\n\r\n    @Test\r\n    public void shouldPassOnDescriptionToFilterFactory() throws Exception {\r\n        Request request = createSuiteRequest();\r\n        Description description = request.getRunner().getDescription();\r\n        Filter filter = FilterFactories.createFilterFromFilterSpec(\r\n                request, FilterFactoryStub.class.getName());\r\n\r\n        // This assumption tested in shouldCreateFilterWithNoArguments()\r\n        assumeThat(filter, instanceOf(DummyFilter.class));\r\n\r\n        DummyFilter dummyFilter = (DummyFilter) filter;\r\n        assertThat(dummyFilter.getTopLevelDescription(), is(description));\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFilter() throws Exception {\r\n        Filter filter = FilterFactories.createFilter(\r\n                FilterFactoryStub.class,\r\n                new FilterFactoryParams(\r\n                        Description.createSuiteDescription(testName.getMethodName()),\r\n                        \"\"));\r\n\r\n        assertThat(filter, instanceOf(DummyFilter.class));\r\n    }\r\n\r\n    @Test\r\n    public void shouldThrowExceptionIfNotFilterFactory() throws Exception {\r\n        expectedException.expect(FilterFactory.FilterNotCreatedException.class);\r\n\r\n        FilterFactories.createFilterFactory(NonFilterFactory.class.getName());\r\n    }\r\n\r\n    @Test\r\n    public void shouldThrowExceptionIfNotInstantiable() throws Exception {\r\n        expectedException.expect(FilterFactory.FilterNotCreatedException.class);\r\n\r\n        FilterFactories.createFilterFactory(NonInstantiableFilterFactory.class);\r\n    }\r\n\r\n    public static class NonFilterFactory {\r\n    }\r\n\r\n    public static class NonInstantiableFilterFactory implements FilterFactory {\r\n        private NonInstantiableFilterFactory() {\r\n        }\r\n\r\n        public Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException {\r\n            throw new FilterNotCreatedException(new Exception(\"not implemented\"));\r\n        }\r\n    }\r\n\r\n    public static class FilterFactoryStub implements FilterFactory {\r\n        public Filter createFilter(FilterFactoryParams params) {\r\n            return new DummyFilter(params.getTopLevelDescription());\r\n        }\r\n    }\r\n\r\n    private static class DummyFilter extends Filter {\r\n        private final Description fTopLevelDescription;\r\n\r\n        public DummyFilter(Description topLevelDescription) {\r\n            fTopLevelDescription = topLevelDescription;\r\n        }\r\n\r\n        public Description getTopLevelDescription() {\r\n            return fTopLevelDescription;\r\n        }\r\n\r\n        @Override\r\n        public boolean shouldRun(Description description) {\r\n            return false;\r\n        }\r\n\r\n        @Override\r\n        public String describe() {\r\n            return null;\r\n        }\r\n    }\r\n\r\n    public static class DummyCategory {\r\n    }\r\n\r\n    @RunWith(Suite.class)\r\n    @SuiteClasses(DummyTest.class)\r\n    public static class DummySuite {\r\n    }\r\n\r\n    public static class DummyTest {\r\n        @Test\r\n        public void passes() {\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/test/java/org/junit/runner/FilterOptionIntegrationTest.java",
    "content": "package org.junit.runner;\n\nimport java.util.HashSet;\nimport java.util.Set;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.experimental.categories.Category;\nimport org.junit.experimental.categories.ExcludeCategories;\nimport org.junit.experimental.categories.IncludeCategories;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.tests.TestSystem;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\n\npublic class FilterOptionIntegrationTest {\n    private static final String INCLUDES_DUMMY_CATEGORY_0 = \"--filter=\" +\n            IncludeCategories.class.getName() + \"=\" + DummyCategory0.class.getName();\n    private static final String EXCLUDES_DUMMY_CATEGORY_1 = \"--filter=\" +\n            ExcludeCategories.class.getName() + \"=\" + DummyCategory1.class.getName();\n\n    private JUnitCore jUnitCore = new JUnitCore();\n    private TestListener testListener = new TestListener();\n\n    @Before\n    public void setUp() {\n        jUnitCore.addListener(testListener);\n    }\n\n    @Test\n    public void shouldRunAllTests() {\n        Result result = runJUnit(\n                DummyTestClass.class.getName(),\n                DummyTestClass0.class.getName(),\n                DummyTestClass1.class.getName(),\n                DummyTestClass01.class.getName(),\n                DummyTestClass0TestMethod1.class.getName());\n\n        assertWasRun(DummyTestClass.class);\n        assertWasRun(DummyTestClass0.class);\n        assertWasRun(DummyTestClass1.class);\n        assertWasRun(DummyTestClass01.class);\n        assertWasRun(DummyTestClass0TestMethod1.class);\n        assertThat(\"runCount does not match\", result.getRunCount(), is(5));\n        assertThat(\"failureCount does not match\", result.getFailureCount(), is(0));\n    }\n\n    @Test\n    public void shouldExcludeSomeTests() {\n        Result result = runJUnit(\n                EXCLUDES_DUMMY_CATEGORY_1,\n                DummyTestClass.class.getName(),\n                DummyTestClass0.class.getName(),\n                DummyTestClass1.class.getName(),\n                DummyTestClass01.class.getName(),\n                DummyTestClass0TestMethod1.class.getName());\n\n        assertWasRun(DummyTestClass.class);\n        assertWasRun(DummyTestClass0.class);\n        assertWasNotRun(DummyTestClass1.class);\n        assertWasNotRun(DummyTestClass01.class);\n        assertWasNotRun(DummyTestClass0TestMethod1.class);\n        assertThat(\"runCount does not match\", result.getRunCount(), is(2));\n        assertThat(\"failureCount does not match\", result.getFailureCount(), is(0));\n    }\n\n    @Test\n    public void shouldIncludeSomeTests() {\n        Result result = runJUnit(\n                INCLUDES_DUMMY_CATEGORY_0,\n                DummyTestClass.class.getName(),\n                DummyTestClass0.class.getName(),\n                DummyTestClass1.class.getName(),\n                DummyTestClass01.class.getName(),\n                DummyTestClass0TestMethod1.class.getName());\n\n        assertWasNotRun(DummyTestClass.class);\n        assertWasRun(DummyTestClass0.class);\n        assertWasNotRun(DummyTestClass1.class);\n        assertWasRun(DummyTestClass01.class);\n        assertWasRun(DummyTestClass0TestMethod1.class);\n        assertThat(\"runCount does not match\", result.getRunCount(), is(3));\n        assertThat(\"failureCount does not match\", result.getFailureCount(), is(0));\n    }\n\n    @Test\n    public void shouldCombineFilters() {\n        Result result = runJUnit(\n                INCLUDES_DUMMY_CATEGORY_0,\n                EXCLUDES_DUMMY_CATEGORY_1,\n                DummyTestClass.class.getName(),\n                DummyTestClass0.class.getName(),\n                DummyTestClass1.class.getName(),\n                DummyTestClass01.class.getName(),\n                DummyTestClass0TestMethod1.class.getName());\n\n        assertWasNotRun(DummyTestClass.class);\n        assertWasRun(DummyTestClass0.class);\n        assertWasNotRun(DummyTestClass1.class);\n        assertWasNotRun(DummyTestClass01.class);\n        assertWasNotRun(DummyTestClass0TestMethod1.class);\n        assertThat(\"runCount does not match\", result.getRunCount(), is(1));\n        assertThat(\"failureCount does not match\", result.getFailureCount(), is(0));\n    }\n\n    private Result runJUnit(final String... args) {\n        return jUnitCore.runMain(new TestSystem(), args);\n    }\n\n    private void assertWasRun(Class<?> testClass) {\n        assertTrue(testClass.getName() + \" expected to finish but did not\", testListener.wasRun(testClass));\n    }\n\n    private void assertWasNotRun(Class<?> testClass) {\n        assertFalse(\n                testClass.getName() + \" expected not to have been started but was\",\n                testListener.wasRun(testClass));\n    }\n\n    private static class TestListener extends RunListener {\n        private Set<String> startedTests = new HashSet<String>();\n        private Set<String> finishedTests = new HashSet<String>();\n\n        @Override\n        public void testFinished(final Description description) {\n            finishedTests.add(description.getClassName());\n        }\n\n        private boolean testFinished(final Class<?> testClass) {\n            return finishedTests.contains(testClass.getName());\n        }\n\n        @Override\n        public void testStarted(final Description description) {\n            startedTests.add(description.getClassName());\n        }\n\n        private boolean testStarted(final Class<?> testClass) {\n            return startedTests.contains(testClass.getName());\n        }\n\n        public boolean wasRun(final Class<?> testClass) {\n            return testStarted(testClass) && testFinished(testClass);\n        }\n    }\n\n    public static class DummyTestClass {\n        @Test\n        public void dummyTest() {\n        }\n    }\n\n    @Category(DummyCategory0.class)\n    public static class DummyTestClass0 {\n        @Test\n        public void dummyTest() {\n        }\n    }\n\n    @Category(DummyCategory1.class)\n    public static class DummyTestClass1 {\n        @Test\n        public void dummyTest() {\n        }\n    }\n\n    @Category({DummyCategory0.class, DummyCategory1.class})\n    public static class DummyTestClass01 {\n        @Test\n        public void dummyTest() {\n        }\n    }\n\n    @Category(DummyCategory0.class)\n    public static class DummyTestClass0TestMethod1 {\n        @Category(DummyCategory1.class)\n        @Test\n        public void dummyTest() {\n        }\n    }\n\n    public static interface DummyCategory0 {\n    }\n\n    public static interface DummyCategory1 {\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/JUnitCommandLineParseResultTest.java",
    "content": "package org.junit.runner;\r\n\r\nimport static org.hamcrest.CoreMatchers.containsString;\r\nimport static org.hamcrest.CoreMatchers.hasItems;\r\nimport static org.hamcrest.CoreMatchers.is;\r\nimport static org.hamcrest.MatcherAssert.assertThat;\r\n\r\nimport java.util.List;\r\n\r\nimport org.junit.Rule;\r\nimport org.junit.Test;\r\nimport org.junit.experimental.categories.IncludeCategories;\r\nimport org.junit.rules.ExpectedException;\r\nimport org.junit.runner.manipulation.Filter;\r\n\r\npublic class JUnitCommandLineParseResultTest {\r\n    @Rule\r\n    public ExpectedException expectedException = ExpectedException.none();\r\n\r\n    private final JUnitCommandLineParseResult jUnitCommandLineParseResult = new JUnitCommandLineParseResult();\r\n\r\n    @Test\r\n    public void shouldStopParsingOptionsUponDoubleHyphenArg() throws Exception {\r\n        String[] restOfArgs = jUnitCommandLineParseResult.parseOptions(\r\n                \"--0\", \"--1\", \"--\", \"--2\", \"--3\");\r\n\r\n        assertThat(restOfArgs, is(new String[]{\"--2\", \"--3\"}));\r\n    }\r\n\r\n    @Test\r\n    public void shouldParseFilterArgWithEqualsSyntax() throws Exception {\r\n        String value= IncludeCategories.class.getName() + \"=\" + DummyCategory0.class.getName();\r\n        jUnitCommandLineParseResult.parseOptions(\"--filter=\" + value);\r\n\r\n        List<String> specs= jUnitCommandLineParseResult.getFilterSpecs();\r\n\r\n        assertThat(specs, hasItems(value));\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFailureUponBaldFilterOptionNotFollowedByValue() {\r\n        jUnitCommandLineParseResult.parseOptions(\"--filter\");\r\n\r\n        Runner runner = jUnitCommandLineParseResult.createRequest(new Computer()).getRunner();\r\n        Description description = runner.getDescription().getChildren().get(0);\r\n\r\n        assertThat(description.toString(), containsString(\"initializationError\"));\r\n    }\r\n\r\n    @Test\r\n    public void shouldParseFilterArgInWhichValueIsASeparateArg() throws Exception {\r\n        String value= IncludeCategories.class.getName() + \"=\" + DummyCategory0.class.getName();\r\n        jUnitCommandLineParseResult.parseOptions(\"--filter\", value);\r\n\r\n        List<String> specs= jUnitCommandLineParseResult.getFilterSpecs();\r\n\r\n        assertThat(specs, hasItems(value));\r\n    }\r\n\r\n    @Test\r\n    public void shouldStopParsingOptionsUponNonOption() throws Exception {\r\n        String[] restOfArgs = jUnitCommandLineParseResult.parseOptions(new String[]{\r\n                \"--0\", \"--1\", \"2\", \"3\"\r\n        });\r\n\r\n        assertThat(restOfArgs, is(new String[]{\"2\", \"3\"}));\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFailureUponUnknownOption() throws Exception {\r\n        String unknownOption = \"--unknown-option\";\r\n        jUnitCommandLineParseResult.parseOptions(new String[]{\r\n                unknownOption\r\n        });\r\n\r\n        Runner runner = jUnitCommandLineParseResult.createRequest(new Computer()).getRunner();\r\n        Description description = runner.getDescription().getChildren().get(0);\r\n\r\n        assertThat(description.toString(), containsString(\"initializationError\"));\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFailureUponUncreatedFilter() throws Exception {\r\n        jUnitCommandLineParseResult.parseOptions(new String[]{\r\n                \"--filter=\" + FilterFactoryStub.class.getName()\r\n        });\r\n\r\n        Runner runner = jUnitCommandLineParseResult.createRequest(new Computer()).getRunner();\r\n        Description description = runner.getDescription().getChildren().get(0);\r\n\r\n        assertThat(description.toString(), containsString(\"initializationError\"));\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFailureUponUnfoundFilterFactory() throws Exception {\r\n        String nonExistentFilterFactory = \"NonExistentFilterFactory\";\r\n        jUnitCommandLineParseResult.parseOptions(new String[]{\r\n                \"--filter=\" + nonExistentFilterFactory\r\n        });\r\n\r\n        Runner runner = jUnitCommandLineParseResult.createRequest(new Computer()).getRunner();\r\n        Description description = runner.getDescription().getChildren().get(0);\r\n\r\n        assertThat(description.toString(), containsString(\"initializationError\"));\r\n    }\r\n\r\n    @Test\r\n    public void shouldAddToClasses() {\r\n        jUnitCommandLineParseResult.parseParameters(new String[]{\r\n                DummyTest.class.getName()\r\n        });\r\n\r\n        List<Class<?>> classes = jUnitCommandLineParseResult.getClasses();\r\n        Class<?> testClass = classes.get(0);\r\n\r\n        assertThat(testClass.getName(), is(DummyTest.class.getName()));\r\n    }\r\n\r\n    @Test\r\n    public void shouldCreateFailureUponUnknownTestClass() throws Exception {\r\n        String unknownTestClass = \"UnknownTestClass\";\r\n        jUnitCommandLineParseResult.parseParameters(new String[]{\r\n                unknownTestClass\r\n        });\r\n\r\n        Runner runner = jUnitCommandLineParseResult.createRequest(new Computer()).getRunner();\r\n        Description description = runner.getDescription().getChildren().get(0);\r\n\r\n        assertThat(description.toString(), containsString(\"initializationError\"));\r\n    }\r\n\r\n    public static class FilterFactoryStub implements FilterFactory {\r\n        public Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException {\r\n            throw new FilterNotCreatedException(new Exception(\"stub\"));\r\n        }\r\n    }\r\n\r\n    public static interface DummyCategory0 {\r\n    }\r\n\r\n    public static class DummyTest {\r\n        @Test\r\n        public void dummyTest() {\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/test/java/org/junit/runner/JUnitCoreTest.java",
    "content": "package org.junit.runner;\n\nimport org.junit.Test;\nimport org.junit.tests.TestSystem;\n\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\npublic class JUnitCoreTest {\n    @Test\n    public void shouldAddFailuresToResult() {\n        JUnitCore jUnitCore = new JUnitCore();\n\n        Result result = jUnitCore.runMain(new TestSystem(), \"NonExistentTest\");\n\n        assertThat(result.getFailureCount(), is(1));\n        assertThat(result.getFailures().get(0).getException(), instanceOf(IllegalArgumentException.class));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/MainRunner.java",
    "content": "package org.junit.runner;\n\nimport java.io.OutputStream;\nimport java.io.PrintStream;\n\npublic class MainRunner {\n\n    public static int runMain(String... args) {\n        PrintStream oldOut = System.out;\n        System.setOut(new PrintStream(new NullOutputStream()));\n        try {\n            return JUnitCore.runMain(args);\n        } finally {\n            System.setOut(oldOut);\n        }\n    }\n\n    static class NullOutputStream extends OutputStream {\n        public void write(int b) {\n            // do nothing\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/OrderWithValidatorTest.java",
    "content": "package org.junit.runner;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\nimport java.util.List;\n\nimport org.junit.FixMethodOrder;\nimport org.junit.Test;\nimport org.junit.runner.manipulation.Alphanumeric;\nimport org.junit.runners.JUnit4;\nimport org.junit.runners.MethodSorters;\nimport org.junit.runners.model.TestClass;\n\npublic class OrderWithValidatorTest {\n    private final OrderWithValidator validator = new OrderWithValidator();\n\n    @RunWith(JUnit4.class)\n    @OrderWith(Alphanumeric.class)\n    public static class TestWithNoValidationErrors {\n        @Test\n        public void passes() {}\n    }\n\n    @RunWith(JUnit4.class)\n    @OrderWith(Alphanumeric.class)\n    @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n    public static class TestAnnotatedWithFixMethodOrder {\n        @Test\n        public void passes() {}\n    }\n\n    @Test\n    public void noErrorIsAddedForTestWithoutValdationErrors() {\n        List<Exception> errors = validator.validateAnnotatedClass(\n                new TestClass(TestWithNoValidationErrors.class));\n        \n        assertThat(errors.size(), is(0));\n    }\n \n    @Test\n    public void errorIsAddedWhenTestAnnotatedWithFixMethodOrder() {\n        List<Exception> errors = validator.validateAnnotatedClass(\n                new TestClass(TestAnnotatedWithFixMethodOrder.class));\n        \n        assertThat(errors.size(), is(1));\n        Exception exception = errors.get(0);\n        assertThat(exception.getMessage(), is(\"@FixMethodOrder cannot be combined with @OrderWith\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/RequestTest.java",
    "content": "package org.junit.runner;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.rules.EventCollector.hasSingleFailureWithMessage;\n\nimport org.junit.Test;\nimport org.junit.rules.EventCollector;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class RequestTest {\n\n    /**\n     * #1320 A root of a {@link Description} produced by\n     * {@link Request#classes(Class...)} should be named \"classes\"\n     */\n    @Test\n    public void createsADescriptionWithANameForClasses() {\n        Description description = Request\n                .classes(RequestTest.class, RequestTest.class).getRunner()\n                .getDescription();\n        assertThat(description.toString(), is(\"classes\"));\n    }\n\n    @Test\n    public void reportsInitializationErrorThrownWhileCreatingSuite() {\n        EventCollector collector = new EventCollector();\n        JUnitCore core = new JUnitCore();\n        core.addListener(collector);\n\n        core.run(new FailingComputer(), FooTest.class, BarTest.class);\n\n        assertThat(collector, hasSingleFailureWithMessage(\"cannot create suite\"));\n    }\n\n    private static class FailingComputer extends Computer {\n        @Override\n        public Runner getSuite(RunnerBuilder builder, Class<?>[] classes)\n                throws InitializationError {\n            throw new InitializationError(\"cannot create suite\");\n        }\n    }\n\n    private static class FooTest {\n    }\n\n    private static class BarTest {\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/RunnerSpy.java",
    "content": "package org.junit.runner;\n\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class RunnerSpy extends Runner {\n    public static final Description DESCRIPTION = Description.TEST_MECHANISM;\n\n    private RunnerBuilder invokedRunnerBuilder;\n    private Class<?> invokedTestClass;\n\n    public RunnerSpy(Class<?> testClass) {\n        invokedTestClass = testClass;\n    }\n\n    public RunnerSpy(Class<?> testClass, RunnerBuilder runnerBuilder) {\n        invokedTestClass = testClass;\n        invokedRunnerBuilder = runnerBuilder;\n    }\n\n    @Override\n    public Description getDescription() {\n        return DESCRIPTION;\n    }\n\n    @Override\n    public void run(RunNotifier runNotifier) {\n    }\n\n    public RunnerBuilder getInvokedRunnerBuilder() {\n        return invokedRunnerBuilder;\n    }\n\n    public Class<?> getInvokedTestClass() {\n        return invokedTestClass;\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/runner/notification/AllNotificationTests.java",
    "content": "package org.junit.runner.notification;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        ConcurrentRunNotifierTest.class,\n        RunNotifierTest.class,\n        SynchronizedRunListenerTest.class\n})\npublic class AllNotificationTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/notification/ConcurrentRunNotifierTest.java",
    "content": "package org.junit.runner.notification;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\n\nimport java.util.Random;\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.CyclicBarrier;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.atomic.AtomicBoolean;\nimport java.util.concurrent.atomic.AtomicInteger;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.hamcrest.core.Is.is;\nimport static org.junit.Assert.assertTrue;\n\n/**\n * Testing RunNotifier in concurrent access.\n *\n * @author Tibor Digana (tibor17)\n * @version 4.12\n * @since 4.12\n */\npublic final class ConcurrentRunNotifierTest {\n    private static final long TIMEOUT = 3;\n    private final RunNotifier fNotifier = new RunNotifier();\n\n    private static class ConcurrentRunListener extends RunListener {\n        final AtomicInteger fTestStarted = new AtomicInteger(0);\n\n        @Override\n        public void testStarted(Description description) throws Exception {\n            fTestStarted.incrementAndGet();\n        }\n    }\n\n    @Test\n    public void realUsage() throws Exception {\n        ConcurrentRunListener listener1 = new ConcurrentRunListener();\n        ConcurrentRunListener listener2 = new ConcurrentRunListener();\n        fNotifier.addListener(listener1);\n        fNotifier.addListener(listener2);\n\n        final int numParallelTests = 4;\n        ExecutorService pool = Executors.newFixedThreadPool(numParallelTests);\n        for (int i = 0; i < numParallelTests; ++i) {\n            pool.submit(new Runnable() {\n                public void run() {\n                    fNotifier.fireTestStarted(null);\n                }\n            });\n        }\n        pool.shutdown();\n        assertTrue(pool.awaitTermination(TIMEOUT, TimeUnit.SECONDS));\n\n        fNotifier.removeListener(listener1);\n        fNotifier.removeListener(listener2);\n\n        assertThat(listener1.fTestStarted.get(), is(numParallelTests));\n        assertThat(listener2.fTestStarted.get(), is(numParallelTests));\n    }\n\n    private static class ExaminedListener extends RunListener {\n        final boolean throwFromTestStarted;\n        volatile boolean hasTestFailure = false;\n\n        ExaminedListener(boolean throwFromTestStarted) {\n            this.throwFromTestStarted = throwFromTestStarted;\n        }\n\n        @Override\n        public void testStarted(Description description) throws Exception {\n            if (throwFromTestStarted) {\n                throw new Exception();\n            }\n        }\n\n        @Override\n        public void testFailure(Failure failure) throws Exception {\n            hasTestFailure = true;\n        }\n    }\n\n    private abstract class AbstractConcurrentFailuresTest {\n\n        protected abstract void addListener(ExaminedListener listener);\n\n        public void test() throws Exception {\n            int totalListenersFailures = 0;\n\n            Random random = new Random(42);\n            ExaminedListener[] examinedListeners = new ExaminedListener[1000];\n            for (int i = 0; i < examinedListeners.length; ++i) {\n                boolean fail = random.nextDouble() >= 0.5d;\n                if (fail) {\n                    ++totalListenersFailures;\n                }\n                examinedListeners[i] = new ExaminedListener(fail);\n            }\n\n            final AtomicBoolean condition = new AtomicBoolean(true);\n            final CyclicBarrier trigger = new CyclicBarrier(2);\n            final CountDownLatch latch = new CountDownLatch(10);\n\n            ExecutorService notificationsPool = Executors.newFixedThreadPool(4);\n            notificationsPool.submit(new Callable<Void>() {\n                public Void call() throws Exception {\n                    trigger.await();\n                    while (condition.get()) {\n                        fNotifier.fireTestStarted(null);\n                        latch.countDown();\n                    }\n                    fNotifier.fireTestStarted(null);\n                    return null;\n                }\n            });\n\n            // Wait for callable to start\n            trigger.await(TIMEOUT, TimeUnit.SECONDS);\n\n            // Wait for callable to fire a few events\n            latch.await(TIMEOUT, TimeUnit.SECONDS);\n\n            for (ExaminedListener examinedListener : examinedListeners) {\n              addListener(examinedListener);\n            }\n\n            notificationsPool.shutdown();\n            condition.set(false);\n            assertTrue(notificationsPool.awaitTermination(TIMEOUT, TimeUnit.SECONDS));\n\n            if (totalListenersFailures != 0) {\n                // If no listener failures, then all the listeners do not report any failure.\n                int countTestFailures = examinedListeners.length - countReportedTestFailures(examinedListeners);\n                assertThat(totalListenersFailures, is(countTestFailures));\n            }\n        }\n    }\n\n    /**\n     * Verifies that listeners added while tests are run concurrently are\n     * notified about test failures.\n     */\n    @Test\n    public void reportConcurrentFailuresAfterAddListener() throws Exception {\n        new AbstractConcurrentFailuresTest() {\n            @Override\n            protected void addListener(ExaminedListener listener) {\n                fNotifier.addListener(listener);\n            }\n        }.test();\n    }\n\n    /**\n     * Verifies that listeners added with addFirstListener() while tests are run concurrently are\n     * notified about test failures.\n     */\n    @Test\n    public void reportConcurrentFailuresAfterAddFirstListener() throws Exception {\n        new AbstractConcurrentFailuresTest() {\n            @Override\n            protected void addListener(ExaminedListener listener) {\n                fNotifier.addFirstListener(listener);\n            }\n        }.test();\n    }\n\n    private static int countReportedTestFailures(ExaminedListener[] listeners) {\n        int count = 0;\n        for (ExaminedListener listener : listeners) {\n            if (listener.hasTestFailure) {\n                ++count;\n            }\n        }\n        return count;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/notification/RunNotifierTest.java",
    "content": "package org.junit.runner.notification;\n\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.assertSame;\n\nimport java.util.concurrent.atomic.AtomicInteger;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.Result;\n\npublic class RunNotifierTest {\n    private final RunNotifier fNotifier = new RunNotifier();\n\n    @Test\n    public void notifiesSecondListenerIfFirstThrowsException() {\n        FailureListener failureListener = new FailureListener();\n        fNotifier.addListener(new CorruptListener());\n        fNotifier.addListener(failureListener);\n        fNotifier.fireTestFailure(new Failure(null, null));\n        assertNotNull(\"The FailureListener registered no failure.\",\n                failureListener.failure);\n    }\n\n    @Test\n    public void hasNoProblemsWithFailingListeners() { // see issues 209 and 395\n        fNotifier.addListener(new CorruptListener());\n        fNotifier.addListener(new FailureListener());\n        fNotifier.addListener(new CorruptListener());\n        fNotifier.fireTestRunFinished(new Result());\n    }\n\n    private static class CorruptListener extends RunListener {\n        @Override\n        public void testRunFinished(Result result) throws Exception {\n            throw new RuntimeException();\n        }\n\n        @Override\n        public void testFailure(Failure failure) throws Exception {\n            throw new RuntimeException();\n        }\n    }\n    \n    @Test\n    public void addAndRemoveWithNonThreadSafeListener() {\n        CountingListener listener = new CountingListener();\n        assertThat(listener.fTestStarted.get(), is(0));\n        fNotifier.addListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n        fNotifier.removeListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n    }\n\n    @Test\n    public void addFirstAndRemoveWithNonThreadSafeListener() {\n        CountingListener listener = new CountingListener();\n        assertThat(listener.fTestStarted.get(), is(0));\n        fNotifier.addFirstListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n        fNotifier.removeListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n    }\n    \n    @Test\n    public void addAndRemoveWithThreadSafeListener() {\n        ThreadSafeListener listener = new ThreadSafeListener();\n        assertThat(listener.fTestStarted.get(), is(0));\n        fNotifier.addListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n        fNotifier.removeListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n    }\n\n    @Test\n    public void addFirstAndRemoveWithThreadSafeListener() {\n        ThreadSafeListener listener = new ThreadSafeListener();\n        assertThat(listener.fTestStarted.get(), is(0));\n        fNotifier.addFirstListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n        fNotifier.removeListener(listener);\n        fNotifier.fireTestStarted(null);\n        assertThat(listener.fTestStarted.get(), is(1));\n    }\n\n    @Test\n    public void wrapIfNotThreadSafeShouldNotWrapThreadSafeListeners() {\n        ThreadSafeListener listener = new ThreadSafeListener();\n        assertSame(listener, new RunNotifier().wrapIfNotThreadSafe(listener));\n    }\n\n    @Test\n    public void wrapIfNotThreadSafeShouldWrapNonThreadSafeListeners() {\n        CountingListener listener = new CountingListener();\n        RunListener wrappedListener = new RunNotifier().wrapIfNotThreadSafe(listener);\n        assertThat(wrappedListener, instanceOf(SynchronizedRunListener.class));\n    }\n\n    private static class FailureListener extends RunListener {\n        private Failure failure;\n\n        @Override\n        public void testFailure(Failure failure) throws Exception {\n            this.failure = failure;\n        }\n    }\n    \n    private static class CountingListener extends RunListener {\n        final AtomicInteger fTestStarted = new AtomicInteger(0);\n\n        @Override\n        public void testStarted(Description description) throws Exception {\n            fTestStarted.incrementAndGet();\n        }\n    }\n    \n    @RunListener.ThreadSafe\n    private static class ThreadSafeListener extends CountingListener {\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runner/notification/SynchronizedRunListenerTest.java",
    "content": "package org.junit.runner.notification;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertNotEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport java.lang.reflect.Method;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.junit.Test;\n\n/**\n * Tests for {@link SynchronizedRunListener}.\n *\n * @author kcooney (Kevin Cooney)\n */\npublic class SynchronizedRunListenerTest {\n\n    private static class MethodSignature {\n        private final Method fMethod;\n        private final String fName;\n        private final List<Class<?>> fParameterTypes;\n\n        public MethodSignature(Method method) {\n            fMethod = method;\n            fName = method.getName();\n            fParameterTypes = Arrays.asList(method.getParameterTypes());\n        }\n\n        @Override\n        public String toString() {\n            return fMethod.toString();\n        }\n\n        @Override\n        public int hashCode() {\n            return fName.hashCode();\n        }\n\n        @Override\n        public boolean equals(Object obj) {\n            if (this == obj) {\n                return true;\n            }\n            if (!(obj instanceof MethodSignature)) {\n                return false;\n            }\n            MethodSignature that = (MethodSignature) obj;\n            return fName.equals(that.fName) && fParameterTypes.equals(that.fParameterTypes);\n        }\n    }\n\n    private Set<MethodSignature> getAllDeclaredMethods(Class<?> type) {\n        Set<MethodSignature> methods = new HashSet<MethodSignature>();\n        for (Method method : type.getDeclaredMethods()) {\n          methods.add(new MethodSignature(method));\n        }\n        return methods;\n    }\n\n    @Test\n    public void overridesAllMethodsInRunListener() {\n        Set<MethodSignature> runListenerMethods = getAllDeclaredMethods(RunListener.class);\n        Set<MethodSignature> synchronizedRunListenerMethods = getAllDeclaredMethods(\n                SynchronizedRunListener.class);\n\n        assertTrue(synchronizedRunListenerMethods.containsAll(runListenerMethods));\n    }\n\n    private static class NamedListener extends RunListener {\n        private final String fName;\n\n        public NamedListener(String name) {\n            fName = name;\n        }\n\n        @Override\n        public String toString() {\n          return \"NamedListener\";\n        }\n\n        @Override\n        public int hashCode() {\n            return fName.hashCode();\n        }\n\n        @Override\n        public boolean equals(Object obj) {\n            if (this == obj) {\n                return true;\n            }\n            if (!(obj instanceof NamedListener)) {\n                return false;\n            }\n            NamedListener that = (NamedListener) obj;\n            return this.fName.equals(that.fName);\n        }\n    }\n\n    @Test\n    public void namedListenerCorrectlyImplementsEqualsAndHashCode() {\n        NamedListener listener1 = new NamedListener(\"blue\");\n        NamedListener listener2 = new NamedListener(\"blue\");\n        NamedListener listener3 = new NamedListener(\"red\");\n\n        assertTrue(listener1.equals(listener1));\n        assertTrue(listener2.equals(listener2));\n        assertTrue(listener3.equals(listener3));\n\n        assertFalse(listener1.equals(null));\n        assertFalse(listener1.equals(new Object()));\n\n        assertTrue(listener1.equals(listener2));\n        assertTrue(listener2.equals(listener1));\n        assertFalse(listener1.equals(listener3));\n        assertFalse(listener3.equals(listener1));\n\n        assertEquals(listener1.hashCode(), listener2.hashCode());\n        assertNotEquals(listener1.hashCode(), listener3.hashCode());\n    }\n\n    @Test\n    public void toStringDelegates() {\n        NamedListener listener = new NamedListener(\"blue\");\n\n        assertEquals(\"NamedListener\", listener.toString());\n        assertEquals(\"NamedListener (with synchronization wrapper)\", wrap(listener).toString());\n    }\n\n    @Test\n    public void equalsDelegates() {\n        NamedListener listener1 = new NamedListener(\"blue\");\n        NamedListener listener2 = new NamedListener(\"blue\");\n        NamedListener listener3 = new NamedListener(\"red\");\n\n        assertEquals(wrap(listener1), wrap(listener1));\n        assertEquals(wrap(listener1), wrap(listener2));\n        assertNotEquals(wrap(listener1), wrap(listener3));\n        assertNotEquals(wrap(listener1), listener1);\n        assertNotEquals(listener1, wrap(listener1));\n    }\n\n    @Test\n    public void hashCodeDelegates() {\n        NamedListener listener = new NamedListener(\"blue\");\n        assertEquals(listener.hashCode(), wrap(listener).hashCode());\n    }\n\n    private SynchronizedRunListener wrap(RunListener listener) {\n        return new SynchronizedRunListener(listener, this);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/AllRunnersTests.java",
    "content": "package org.junit.runners;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.runners.model.AllModelTests;\nimport org.junit.runners.parameterized.AllParameterizedTests;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllModelTests.class,\n        AllParameterizedTests.class,\n        RuleContainerTest.class,\n        CustomBlockJUnit4ClassRunnerTest.class\n})\npublic class AllRunnersTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/CustomBlockJUnit4ClassRunnerTest.java",
    "content": "package org.junit.runners;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.concurrent.atomic.AtomicInteger;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.Statement;\n\n/**\n * Tests that verify proper behavior for custom runners that extend\n * {@link BlockJUnit4ClassRunner}.\n *\n * @author Sam Brannen\n * @since 4.13\n */\npublic class CustomBlockJUnit4ClassRunnerTest {\n\n\t@Test\n\tpublic void exceptionsFromMethodBlockMustNotResultInUnrootedTests() throws Exception {\n\t\tTrackingRunListener listener = new TrackingRunListener();\n\t\tRunNotifier notifier = new RunNotifier();\n\t\tnotifier.addListener(listener);\n\n\t\tnew CustomBlockJUnit4ClassRunner(CustomBlockJUnit4ClassRunnerTestCase.class).run(notifier);\n\t\tassertEquals(\"tests started.\", 2, listener.testStartedCount.get());\n\t\tassertEquals(\"tests failed.\", 1, listener.testFailureCount.get());\n\t\tassertEquals(\"tests finished.\", 2, listener.testFinishedCount.get());\n\t}\n\n\n\tpublic static class CustomBlockJUnit4ClassRunnerTestCase {\n\t\t@Test public void shouldPass() { /* no-op */ }\n\t\t@Test public void throwException() { /* no-op */ }\n\t}\n\n\t/**\n\t * Custom extension of {@link BlockJUnit4ClassRunner} that always throws\n\t * an exception from the {@code methodBlock()} if a test method is named\n\t * exactly {@code \"throwException\"}.\n\t */\n\tprivate static class CustomBlockJUnit4ClassRunner extends BlockJUnit4ClassRunner {\n\n\t\tCustomBlockJUnit4ClassRunner(Class<?> testClass) throws InitializationError {\n\t\t\tsuper(testClass);\n\t\t}\n\n\t\t@Override\n\t\tprotected Statement methodBlock(FrameworkMethod method) {\n\t\t\tif (\"throwException\".equals(method.getName())) {\n\t\t\t\tthrow new RuntimeException(\"throwException() test method invoked\");\n\t\t\t}\n\t\t\treturn super.methodBlock(method);\n\t\t}\n\t}\n\n\t/**\n\t * Simple {@link RunListener} that tracks the number of times that\n\t * certain callbacks are invoked.\n\t */\n\tprivate static class TrackingRunListener extends RunListener {\n\n\t\tfinal AtomicInteger testStartedCount = new AtomicInteger();\n\t\tfinal AtomicInteger testFailureCount = new AtomicInteger();\n\t\tfinal AtomicInteger testFinishedCount = new AtomicInteger();\n\n\n\t\t@Override\n\t\tpublic void testStarted(Description description) throws Exception {\n\t\t\ttestStartedCount.incrementAndGet();\n\t\t}\n\n\t\t@Override\n\t\tpublic void testFailure(Failure failure) throws Exception {\n\t\t\ttestFailureCount.incrementAndGet();\n\t\t}\n\n\t\t@Override\n\t\tpublic void testFinished(Description description) throws Exception {\n\t\t\ttestFinishedCount.incrementAndGet();\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/RuleContainerTest.java",
    "content": "package org.junit.runners;\n\nimport static org.junit.Assert.assertEquals;\n\nimport org.junit.Test;\nimport org.junit.rules.MethodRule;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\npublic class RuleContainerTest {\n    private final RuleContainer container = new RuleContainer();\n\n    @Test\n    public void methodRulesOnly() {\n        container.add(MRule.M1);\n        container.add(MRule.M2);\n        assertEquals(\"[M1, M2]\", container.getSortedRules().toString());\n        container.setOrder(MRule.M2, 1);\n        assertEquals(\"[M2, M1]\", container.getSortedRules().toString());\n    }\n\n    @Test\n    public void testRuleAroundMethodRule() {\n        container.add(MRule.M1);\n        container.add(Rule.A);\n        assertEquals(\"[M1, A]\", container.getSortedRules().toString());\n    }\n\n    @Test\n    public void ordering1() {\n        container.add(MRule.M1);\n        container.add(Rule.A);\n        container.setOrder(Rule.A, 1);\n        assertEquals(\"[A, M1]\", container.getSortedRules().toString());\n    }\n\n    @Test\n    public void ordering2() {\n        container.add(Rule.A);\n        container.add(Rule.B);\n        container.add(Rule.C);\n        assertEquals(\"[A, B, C]\", container.getSortedRules().toString());\n        container.setOrder(Rule.B, 1);\n        container.setOrder(Rule.C, 2);\n        assertEquals(\"[C, B, A]\", container.getSortedRules().toString());\n    }\n\n    private enum Rule implements TestRule {\n        A,\n        B,\n        C;\n\n        public Statement apply(Statement base, Description description) {\n            return base;\n        }\n    }\n\n    private enum MRule implements MethodRule {\n        M1,\n        M2;\n\n        public Statement apply(Statement base, FrameworkMethod method, Object target) {\n            return base;\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/model/AllModelTests.java",
    "content": "package org.junit.runners.model;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        FrameworkFieldTest.class,\n        FrameworkMethodTest.class,\n        InvalidTestClassErrorTest.class,\n        TestClassTest.class\n})\npublic class AllModelTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/model/FrameworkFieldTest.java",
    "content": "package org.junit.runners.model;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.nullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.rules.ExpectedException.none;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Field;\n\nimport org.junit.ClassRule;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExpectedException;\n\npublic class FrameworkFieldTest {\n    @Rule\n    public final ExpectedException thrown = none();\n\n    @Test\n    public void cannotBeCreatedWithoutUnderlyingField() {\n        thrown.expect(NullPointerException.class);\n        thrown.expectMessage(\"FrameworkField cannot be created without an underlying field.\");\n        new FrameworkField(null);\n    }\n\n    @Test\n    public void hasToStringWhichPrintsFieldName() throws Exception {\n        Field field = ClassWithDummyField.class.getField(\"dummyField\");\n        FrameworkField frameworkField = new FrameworkField(field);\n        assertTrue(frameworkField.toString().contains(\"dummyField\"));\n    }\n\n    @Test\n    public void presentAnnotationIsAvailable() throws Exception {\n        Field field = ClassWithDummyField.class.getField(\"annotatedField\");\n        FrameworkField frameworkField = new FrameworkField(field);\n        Annotation annotation = frameworkField.getAnnotation(Rule.class);\n        assertTrue(Rule.class.isAssignableFrom(annotation.getClass()));\n    }\n\n    @Test\n    public void missingAnnotationIsNotAvailable() throws Exception {\n        Field field = ClassWithDummyField.class.getField(\"annotatedField\");\n        FrameworkField frameworkField = new FrameworkField(field);\n        Annotation annotation = frameworkField.getAnnotation(ClassRule.class);\n        assertThat(annotation, is(nullValue()));\n    }\n\n    private static class ClassWithDummyField {\n        @SuppressWarnings(\"unused\")\n        public final int dummyField = 0;\n\n        @Rule\n        public final int annotatedField = 0;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/model/FrameworkMethodTest.java",
    "content": "package org.junit.runners.model;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.nullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.rules.ExpectedException.none;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Method;\n\nimport org.junit.ClassRule;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExpectedException;\n\npublic class FrameworkMethodTest {\n    @Rule\n    public final ExpectedException thrown = none();\n\n    @Test\n    public void cannotBeCreatedWithoutUnderlyingField() {\n        thrown.expect(NullPointerException.class);\n        thrown.expectMessage(\"FrameworkMethod cannot be created without an underlying method.\");\n        new FrameworkMethod(null);\n    }\n\n    @Test\n    public void hasToStringWhichPrintsMethodName() throws Exception {\n        Method method = ClassWithDummyMethod.class.getMethod(\"dummyMethod\");\n        FrameworkMethod frameworkMethod = new FrameworkMethod(method);\n        assertTrue(frameworkMethod.toString().contains(\"dummyMethod\"));\n    }\n\n    @Test\n    public void presentAnnotationIsAvailable() throws Exception {\n        Method method = ClassWithDummyMethod.class.getMethod(\"annotatedDummyMethod\");\n        FrameworkMethod frameworkMethod = new FrameworkMethod(method);\n        Annotation annotation = frameworkMethod.getAnnotation(Rule.class);\n        assertTrue(Rule.class.isAssignableFrom(annotation.getClass()));\n    }\n\n    @Test\n    public void missingAnnotationIsNotAvailable() throws Exception {\n        Method method = ClassWithDummyMethod.class.getMethod(\"annotatedDummyMethod\");\n        FrameworkMethod frameworkMethod = new FrameworkMethod(method);\n        Annotation annotation = frameworkMethod.getAnnotation(ClassRule.class);\n        assertThat(annotation, is(nullValue()));\n    }\n\n    private static class ClassWithDummyMethod {\n        @SuppressWarnings(\"unused\")\n        public void dummyMethod() {\n        }\n\n        @Rule\n        public void annotatedDummyMethod() {\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/model/InvalidTestClassErrorTest.java",
    "content": "package org.junit.runners.model;\n\nimport org.junit.Test;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\npublic class InvalidTestClassErrorTest {\n\n    @Test\n    public void invalidTestClassErrorShouldListAllValidationErrorsInItsMessage() {\n        InvalidTestClassError sut = new InvalidTestClassError(SampleTestClass.class,\n                asList(new Throwable(\"validation error 1\"), new Throwable(\"validation error 2\")));\n\n        assertThat(sut.getMessage(), equalTo(\"Invalid test class '\" + SampleTestClass.class.getName() + \"':\" +\n                \"\\n  1. validation error 1\" +\n                \"\\n  2. validation error 2\"));\n    }\n\n    private static class SampleTestClass {\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/runners/model/RunnerBuilderStub.java",
    "content": "package org.junit.runners.model;\n\nimport org.junit.runner.Runner;\nimport org.junit.runner.RunnerSpy;\n\npublic class RunnerBuilderStub extends RunnerBuilder {\n    @Override\n    public Runner runnerForClass(Class<?> testClass) throws Throwable {\n        return new RunnerSpy(testClass, this);\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/runners/model/TestClassTest.java",
    "content": "package org.junit.runners.model;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.hamcrest.Matchers.*;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\n\nimport java.lang.annotation.Annotation;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.Ignore;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExpectedException;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.RunWith;\n\npublic class TestClassTest {\n\n    @Rule\n    public ExpectedException exception = ExpectedException.none();\n\n    public static class TwoConstructors {\n        public TwoConstructors() {\n        }\n\n        public TwoConstructors(int x) {\n        }\n    }\n\n    @Test(expected = IllegalArgumentException.class)\n    public void complainIfMultipleConstructors() {\n        new TestClass(TwoConstructors.class);\n    }\n\n    public static class SuperclassWithField {\n        @Rule\n        public TestRule x;\n    }\n\n    public static class SubclassWithField extends SuperclassWithField {\n        @Rule\n        public TestRule x;\n    }\n\n    @Test\n    public void fieldsOnSubclassesShadowSuperclasses() {\n        assertThat(new TestClass(SubclassWithField.class).getAnnotatedFields(\n                Rule.class).size(), is(1));\n    }\n\n    public static class OuterClass {\n        public class NonStaticInnerClass {\n        }\n    }\n\n    @Test\n    public void identifyNonStaticInnerClass() {\n        assertThat(\n                new TestClass(OuterClass.NonStaticInnerClass.class)\n                        .isANonStaticInnerClass(),\n                is(true));\n    }\n\n    public static class OuterClass2 {\n        public static class StaticInnerClass {\n        }\n    }\n\n    @Test\n    public void dontMarkStaticInnerClassAsNonStatic() {\n        assertThat(\n                new TestClass(OuterClass2.StaticInnerClass.class)\n                        .isANonStaticInnerClass(),\n                is(false));\n    }\n\n    public static class SimpleClass {\n    }\n\n    @Test\n    public void dontMarkNonInnerClassAsInnerClass() {\n        assertThat(new TestClass(SimpleClass.class).isANonStaticInnerClass(),\n                is(false));\n    }\n\n    public static class FieldAnnotated {\n        @Rule\n        public String fieldC= \"andromeda\";\n\n        @Rule\n        public boolean fieldA;\n\n        @Rule\n        public boolean fieldB;\n    }\n\n    @Test\n    public void providesAnnotatedFieldsSortedByName() {\n        TestClass tc= new TestClass(FieldAnnotated.class);\n        List<FrameworkField> annotatedFields= tc.getAnnotatedFields();\n        assertThat(\"Wrong number of annotated fields.\", annotatedFields.size(), is(3));\n        assertThat(\"First annotated field is wrong.\", annotatedFields\n            .iterator().next().getName(), is(\"fieldA\"));\n    }\n\n    @Test\n    public void annotatedFieldValues() {\n        TestClass tc = new TestClass(FieldAnnotated.class);\n        List<String> values = tc.getAnnotatedFieldValues(new FieldAnnotated(), Rule.class, String.class);\n        assertThat(values, hasItem(\"andromeda\"));\n        assertThat(values.size(), is(1));\n    }\n\n    public static class MethodsAnnotated {\n        @Ignore\n        @Test\n        public int methodC() {\n            return 0;\n        }\n\n        @Ignore\n        @Test\n        public String methodA() {\n            return \"jupiter\";\n        }\n\n        @Ignore\n        @Test\n        public int methodB() {\n            return 0;\n        }\n\n        public int methodWithoutAnnotation() {\n            return 0;\n        }\n    }\n\n    @Test\n    public void providesAnnotatedMethodsSortedByName() {\n        TestClass tc = new TestClass(MethodsAnnotated.class);\n        List<FrameworkMethod> annotatedMethods = tc.getAnnotatedMethods();\n        List<String> methodNames = extractNames(annotatedMethods);\n        assertThat(methodNames.indexOf(\"methodA\"),\n            lessThan(methodNames.indexOf(\"methodB\")));\n    }\n\n    @Test\n    public void getAnnotatedMethodsDoesNotReturnMethodWithoutAnnotation() {\n        TestClass tc = new TestClass(MethodsAnnotated.class);\n        List<FrameworkMethod> annotatedMethods = tc.getAnnotatedMethods();\n        List<String> methodNames = extractNames(annotatedMethods);\n        assertThat(methodNames, not(hasItem(\"methodWithoutAnnotation\")));\n    }\n\n    private List<String> extractNames(List<FrameworkMethod> methods) {\n        List<String> names = new ArrayList<String>();\n        for (FrameworkMethod method: methods) {\n            names.add(method.getName());\n        }\n        return names;\n    }\n\n    @Test\n    public void annotatedMethodValues() {\n        TestClass tc = new TestClass(MethodsAnnotated.class);\n        List<String> values = tc.getAnnotatedMethodValues(\n            new MethodsAnnotated(), Ignore.class, String.class);\n        assertThat(values, hasItem(\"jupiter\"));\n        assertThat(values.size(), is(1));\n    }\n\n    @Test\n    public void isEqualToTestClassThatWrapsSameJavaClass() {\n        TestClass testClass = new TestClass(DummyClass.class);\n        TestClass testClassThatWrapsSameJavaClass = new TestClass(\n                DummyClass.class);\n        assertTrue(testClass.equals(testClassThatWrapsSameJavaClass));\n    }\n\n    @Test\n    public void isEqualToTestClassThatWrapsNoJavaClassToo() {\n        TestClass testClass = new TestClass(null);\n        TestClass testClassThatWrapsNoJavaClassToo = new TestClass(null);\n        assertTrue(testClass.equals(testClassThatWrapsNoJavaClassToo));\n    }\n\n    @Test\n    public void isNotEqualToTestClassThatWrapsADifferentJavaClass() {\n        TestClass testClass = new TestClass(DummyClass.class);\n        TestClass testClassThatWrapsADifferentJavaClass = new TestClass(\n                AnotherDummyClass.class);\n        assertFalse(testClass.equals(testClassThatWrapsADifferentJavaClass));\n    }\n\n    @Test\n    public void isNotEqualToNull() {\n        TestClass testClass = new TestClass(DummyClass.class);\n        assertFalse(testClass.equals(null));\n    }\n\n    private static class DummyClass {\n    }\n\n    private static class AnotherDummyClass {\n    }\n\n    @Test\n    public void hasSameHashCodeAsTestClassThatWrapsSameJavaClass() {\n        TestClass testClass = new TestClass(DummyClass.class);\n        TestClass testClassThatWrapsSameJavaClass = new TestClass(\n                DummyClass.class);\n        assertEquals(testClass.hashCode(),\n                testClassThatWrapsSameJavaClass.hashCode());\n    }\n\n    @Test\n    public void hasHashCodeWithoutJavaClass() {\n        TestClass testClass = new TestClass(null);\n        testClass.hashCode();\n        // everything is fine if no exception is thrown.\n    }\n\n    public static class PublicClass {\n\n    }\n\n    @Test\n    public void identifiesPublicModifier() {\n        TestClass tc = new TestClass(PublicClass.class);\n        assertEquals(\"Wrong flag 'public',\", true, tc.isPublic());\n    }\n\n    static class NonPublicClass {\n\n    }\n    \n    @Test\n    public void identifiesNonPublicModifier() {\n        TestClass tc = new TestClass(NonPublicClass.class);\n        assertEquals(\"Wrong flag 'public',\", false, tc.isPublic());\n    }\n\n    @Ignore\n    static class AnnotatedClass {\n    }\n\n    @Test\n    public void presentAnnotationIsAvailable() {\n        TestClass tc = new TestClass(AnnotatedClass.class);\n        Annotation annotation = tc.getAnnotation(Ignore.class);\n        assertTrue(Ignore.class.isAssignableFrom(annotation.getClass()));\n    }\n\n    @Test\n    public void missingAnnotationIsNotAvailable() {\n        TestClass tc = new TestClass(AnnotatedClass.class);\n        Annotation annotation = tc.getAnnotation(RunWith.class);\n        assertThat(annotation, is(nullValue()));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/parameterized/AllParameterizedTests.java",
    "content": "package org.junit.runners.parameterized;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        BlockJUnit4ClassRunnerWithParametersTest.class,\n        ParameterizedNamesTest.class,\n        TestWithParametersTest.class\n})\npublic class AllParameterizedTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParametersTest.java",
    "content": "package org.junit.runners.parameterized;\n\nimport static java.util.Collections.emptyList;\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.rules.ExpectedException.none;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExpectedException;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.model.TestClass;\n\npublic class BlockJUnit4ClassRunnerWithParametersTest {\n    private static final List<Object> NO_PARAMETERS = emptyList();\n\n    @Rule\n    public final ExpectedException thrown = none();\n\n    @RunWith(Parameterized.class)\n    @DummyAnnotation\n    public static class ClassWithParameterizedAnnotation {\n        @Test\n        public void dummyTest() {\n        }\n    }\n\n    @Test\n    public void hasAllAnnotationsExceptRunWith() throws Exception {\n        TestWithParameters testWithParameters = new TestWithParameters(\n                \"dummy name\", new TestClass(\n                        ClassWithParameterizedAnnotation.class), NO_PARAMETERS);\n        BlockJUnit4ClassRunnerWithParameters runner = new BlockJUnit4ClassRunnerWithParameters(\n                testWithParameters);\n        Annotation[] annotations = runner.getRunnerAnnotations();\n        assertEquals(1, annotations.length);\n        assertEquals(annotations[0].annotationType(), DummyAnnotation.class);\n    }\n\n    @Retention(RetentionPolicy.RUNTIME)\n    @Target(ElementType.TYPE)\n    private static @interface DummyAnnotation {\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ClassWithPrivateParameter {\n        @Parameterized.Parameter\n        private String parameter;\n\n        @Test\n        public void dummyTest() {\n        }\n    }\n\n    @Test\n    public void providesHelpfulMessageIfParameterFieldCannotBeSet()\n            throws Exception {\n        TestWithParameters testWithParameters = new TestWithParameters(\n                \"dummy name\",\n                new TestClass(ClassWithPrivateParameter.class),\n                Collections.<Object>singletonList(\"dummy parameter\"));\n        BlockJUnit4ClassRunnerWithParameters runner = new BlockJUnit4ClassRunnerWithParameters(\n                testWithParameters);\n\n        thrown.expect(IllegalAccessException.class);\n        thrown.expectCause(instanceOf(IllegalAccessException.class));\n        thrown.expectMessage(\"Cannot set parameter 'parameter'. Ensure that the field 'parameter' is public.\");\n\n        runner.createTest();\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/runners/parameterized/ParameterizedNamesTest.java",
    "content": "package org.junit.runners.parameterized;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.Request;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\n\nimport java.util.Arrays;\nimport java.util.Collection;\n\nimport static org.junit.Assert.assertEquals;\n\n/**\n * @author Dmitry Baev charlie@yandex-team.ru\n *         Date: 03.05.14\n */\npublic class ParameterizedNamesTest {\n    @RunWith(Parameterized.class)\n    public static class ParameterizedWithSpecialCharsInName {\n\n        public ParameterizedWithSpecialCharsInName(String s) {\n        }\n\n        @Parameterized.Parameters(name = \"{0}\")\n        public static Collection<Object[]> data() {\n            return Arrays.asList(\n                    new Object[]{\"\\n\"},\n                    new Object[]{\"\\r\\n\"},\n                    new Object[]{\"\\r\"},\n                    new Object[]{\"\\u0085\"},\n                    new Object[]{\"\\u2028\"},\n                    new Object[]{\"\\u2029\"}\n            );\n        }\n\n        @Test\n        public void test() {\n        }\n    }\n\n    @Test\n    public void parameterizedTestsWithSpecialCharsInName() {\n        Request request = Request.aClass(ParameterizedWithSpecialCharsInName.class);\n        for (Description parent : request.getRunner().getDescription().getChildren()) {\n            for (Description description : parent.getChildren()) {\n                assertEquals(\"test\" + parent.getDisplayName(), description.getMethodName());\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/runners/parameterized/TestWithParametersTest.java",
    "content": "package org.junit.runners.parameterized;\n\nimport static java.util.Arrays.asList;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotEquals;\nimport static org.junit.rules.ExpectedException.none;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExpectedException;\nimport org.junit.runners.model.TestClass;\n\npublic class TestWithParametersTest {\n    private static final String DUMMY_NAME = \"dummy name\";\n\n    private static final TestClass DUMMY_TEST_CLASS = new TestClass(\n            DummyClass.class);\n\n    private static final List<Object> DUMMY_PARAMETERS = Arrays\n            .<Object> asList(\"a\", \"b\");\n\n    @Rule\n    public final ExpectedException thrown = none();\n\n    @Test\n    public void cannotBeCreatedWithoutAName() {\n        thrown.expect(NullPointerException.class);\n        thrown.expectMessage(\"The name is missing.\");\n        new TestWithParameters(null, DUMMY_TEST_CLASS, DUMMY_PARAMETERS);\n    }\n\n    @Test\n    public void cannotBeCreatedWithoutTestClass() {\n        thrown.expect(NullPointerException.class);\n        thrown.expectMessage(\"The test class is missing.\");\n        new TestWithParameters(DUMMY_NAME, null, DUMMY_PARAMETERS);\n    }\n\n    @Test\n    public void cannotBeCreatedWithoutParameters() {\n        thrown.expect(NullPointerException.class);\n        thrown.expectMessage(\"The parameters are missing.\");\n        new TestWithParameters(DUMMY_NAME, DUMMY_TEST_CLASS,\n                (List<Object>) null);\n    }\n\n    @Test\n    public void doesNotAllowToModifyProvidedParameters() {\n        TestWithParameters test = new TestWithParameters(DUMMY_NAME,\n                DUMMY_TEST_CLASS, DUMMY_PARAMETERS);\n        thrown.expect(UnsupportedOperationException.class);\n        test.getParameters().set(0, \"another parameter\");\n    }\n\n    @Test\n    public void doesNotConsiderParametersWhichChangedAfterTestInstantiation() {\n        List<Object> parameters = Arrays.<Object> asList(\"dummy parameter\");\n        TestWithParameters test = new TestWithParameters(DUMMY_NAME,\n                DUMMY_TEST_CLASS, parameters);\n        parameters.set(0, \"another parameter\");\n        assertEquals(asList(\"dummy parameter\"), test.getParameters());\n    }\n\n    @Test\n    public void isEqualToTestWithSameNameAndTestClassAndParameters() {\n        TestWithParameters firstTest = new TestWithParameters(DUMMY_NAME,\n                new TestClass(DummyClass.class), Arrays.<Object> asList(\"a\",\n                        \"b\"));\n        TestWithParameters secondTest = new TestWithParameters(DUMMY_NAME,\n                new TestClass(DummyClass.class), Arrays.<Object> asList(\"a\",\n                        \"b\"));\n        assertEquals(firstTest, secondTest);\n    }\n\n    @Test\n    public void isNotEqualToTestWithDifferentName() {\n        TestWithParameters firstTest = new TestWithParameters(\"name\",\n                DUMMY_TEST_CLASS, DUMMY_PARAMETERS);\n        TestWithParameters secondTest = new TestWithParameters(\"another name\",\n                DUMMY_TEST_CLASS, DUMMY_PARAMETERS);\n        assertNotEquals(firstTest, secondTest);\n    }\n\n    @Test\n    public void isNotEqualToTestWithDifferentTestClass() {\n        TestWithParameters firstTest = new TestWithParameters(DUMMY_NAME,\n                new TestClass(DummyClass.class), DUMMY_PARAMETERS);\n        TestWithParameters secondTest = new TestWithParameters(DUMMY_NAME,\n                new TestClass(AnotherDummyClass.class), DUMMY_PARAMETERS);\n        assertNotEquals(firstTest, secondTest);\n    }\n\n    @Test\n    public void isNotEqualToTestWithDifferentParameters() {\n        TestWithParameters firstTest = new TestWithParameters(DUMMY_NAME,\n                DUMMY_TEST_CLASS, Arrays.<Object> asList(\"a\"));\n        TestWithParameters secondTest = new TestWithParameters(DUMMY_NAME,\n                DUMMY_TEST_CLASS, Arrays.<Object> asList(\"b\"));\n        assertNotEquals(firstTest, secondTest);\n    }\n\n    @Test\n    public void isNotEqualToObjectWithDifferentClass() {\n        TestWithParameters test = new TestWithParameters(DUMMY_NAME,\n                DUMMY_TEST_CLASS, DUMMY_PARAMETERS);\n        assertNotEquals(test, Integer.valueOf(3));\n    }\n\n    @Test\n    public void hasSameHashCodeAsEqualTest() {\n        TestWithParameters firstTest = new TestWithParameters(DUMMY_NAME,\n                DUMMY_TEST_CLASS, DUMMY_PARAMETERS);\n        TestWithParameters secondTest = new TestWithParameters(DUMMY_NAME,\n                DUMMY_TEST_CLASS, DUMMY_PARAMETERS);\n        assertEquals(firstTest.hashCode(), secondTest.hashCode());\n    }\n\n    @Test\n    public void hasMeaningfulToString() {\n        TestWithParameters test = new TestWithParameters(\"name\", new TestClass(\n                DummyClass.class), Arrays.<Object> asList(\"first parameter\",\n                \"second parameter\"));\n        assertEquals(\n                \"Wrong toString().\",\n                \"org.junit.runners.parameterized.TestWithParametersTest$DummyClass 'name' with parameters [first parameter, second parameter]\",\n                test.toString());\n    }\n\n    private static class DummyClass {\n    }\n\n    private static class AnotherDummyClass {\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/samples/AllSamplesTests.java",
    "content": "package org.junit.samples;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.samples.money.MoneyTest;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        ListTest.class,\n        MoneyTest.class\n})\npublic class AllSamplesTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/samples/ListTest.java",
    "content": "package org.junit.samples;\n\nimport static org.junit.Assert.assertTrue;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport junit.framework.JUnit4TestAdapter;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n/**\n * A sample test case, testing {@link java.util.ArrayList}.\n */\npublic class ListTest {\n    protected List<Integer> fEmpty;\n    protected List<Integer> fFull;\n    protected static List<Integer> fgHeavy;\n\n    public static void main(String... args) {\n        junit.textui.TestRunner.run(suite());\n    }\n\n    @BeforeClass\n    public static void setUpOnce() {\n        fgHeavy = new ArrayList<Integer>();\n        for (int i = 0; i < 1000; i++) {\n            fgHeavy.add(i);\n        }\n    }\n\n    @Before\n    public void setUp() {\n        fEmpty = new ArrayList<Integer>();\n        fFull = new ArrayList<Integer>();\n        fFull.add(1);\n        fFull.add(2);\n        fFull.add(3);\n    }\n\n    public static junit.framework.Test suite() {\n        return new JUnit4TestAdapter(ListTest.class);\n    }\n\n    @Ignore(\"not today\")\n    @Test\n    public void capacity() {\n        int size = fFull.size();\n        for (int i = 0; i < 100; i++) {\n            fFull.add(i);\n        }\n        assertTrue(fFull.size() == 100 + size);\n    }\n\n    @Test\n    public void testCopy() {\n        List<Integer> copy = new ArrayList<Integer>(fFull.size());\n        copy.addAll(fFull);\n        assertTrue(copy.size() == fFull.size());\n        assertTrue(copy.contains(1));\n    }\n\n    @Test\n    public void contains() {\n        assertTrue(fFull.contains(1));\n        assertTrue(!fEmpty.contains(1));\n    }\n\n    @Test(expected = IndexOutOfBoundsException.class)\n    public void elementAt() {\n        int i = fFull.get(0);\n        assertTrue(i == 1);\n        fFull.get(fFull.size()); // Should throw IndexOutOfBoundsException\n    }\n\n    @Test\n    public void removeAll() {\n        fFull.removeAll(fFull);\n        fEmpty.removeAll(fEmpty);\n        assertTrue(fFull.isEmpty());\n        assertTrue(fEmpty.isEmpty());\n    }\n\n    @Test\n    public void removeElement() {\n        fFull.remove(Integer.valueOf(3));\n        assertTrue(!fFull.contains(3));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/samples/SimpleTest.java",
    "content": "package org.junit.samples;\n\nimport static org.junit.Assert.assertEquals;\n\nimport junit.framework.JUnit4TestAdapter;\nimport org.junit.Before;\nimport org.junit.Test;\n\n/**\n * Some simple tests.\n *\n * <p>This test is expected to fail.\n */\npublic class SimpleTest {\n    protected int fValue1;\n    protected int fValue2;\n\n    @Before\n    public void setUp() {\n        fValue1 = 2;\n        fValue2 = 3;\n    }\n\n    public static junit.framework.Test suite() {\n        return new JUnit4TestAdapter(SimpleTest.class);\n    }\n\n    public int unused;\n\n    @Test\n    public void divideByZero() {\n        int zero = 0;\n        int result = 8 / zero;\n        unused = result; // avoid warning for not using result\n    }\n\n    @Test\n    public void testEquals() {\n        assertEquals(12, 12);\n        assertEquals(12L, 12L);\n        assertEquals(Long.valueOf(12), Long.valueOf(12));\n\n        assertEquals(\"Size\", 12, 13);\n        assertEquals(\"Capacity\", 12.0, 11.99, 0.0);\n    }\n\n}"
  },
  {
    "path": "src/test/java/org/junit/samples/money/MoneyTest.java",
    "content": "package org.junit.samples.money;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.samples.money.IMoney;\nimport junit.samples.money.Money;\nimport junit.samples.money.MoneyBag;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class MoneyTest {\n    private Money f12CHF;\n    private Money f14CHF;\n    private Money f7USD;\n    private Money f21USD;\n\n    private IMoney fMB1;\n    private IMoney fMB2;\n\n    public static junit.framework.Test suite() {\n        return new JUnit4TestAdapter(MoneyTest.class);\n    }\n\n    @Before\n    public void setUp() {\n        f12CHF = new Money(12, \"CHF\");\n        f14CHF = new Money(14, \"CHF\");\n        f7USD = new Money(7, \"USD\");\n        f21USD = new Money(21, \"USD\");\n\n        fMB1 = MoneyBag.create(f12CHF, f7USD);\n        fMB2 = MoneyBag.create(f14CHF, f21USD);\n    }\n\n    @Test\n    public void testBagMultiply() {\n        // {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]}\n        IMoney expected = MoneyBag.create(new Money(24, \"CHF\"), new Money(14, \"USD\"));\n        assertEquals(expected, fMB1.multiply(2));\n        assertEquals(fMB1, fMB1.multiply(1));\n        assertTrue(fMB1.multiply(0).isZero());\n    }\n\n    @Test\n    public void testBagNegate() {\n        // {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]}\n        IMoney expected = MoneyBag.create(new Money(-12, \"CHF\"), new Money(-7, \"USD\"));\n        assertEquals(expected, fMB1.negate());\n    }\n\n    @Test\n    public void testBagSimpleAdd() {\n        // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]}\n        IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), new Money(7, \"USD\"));\n        assertEquals(expected, fMB1.add(f14CHF));\n    }\n\n    @Test\n    public void testBagSubtract() {\n        // {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]}\n        IMoney expected = MoneyBag.create(new Money(-2, \"CHF\"), new Money(-14, \"USD\"));\n        assertEquals(expected, fMB1.subtract(fMB2));\n    }\n\n    @Test\n    public void testBagSumAdd() {\n        // {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]}\n        IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), new Money(28, \"USD\"));\n        assertEquals(expected, fMB1.add(fMB2));\n    }\n\n    @Test\n    public void testIsZero() {\n        assertTrue(fMB1.subtract(fMB1).isZero());\n        assertTrue(MoneyBag.create(new Money(0, \"CHF\"), new Money(0, \"USD\")).isZero());\n    }\n\n    @Test\n    public void testMixedSimpleAdd() {\n        // [12 CHF] + [7 USD] == {[12 CHF][7 USD]}\n        IMoney expected = MoneyBag.create(f12CHF, f7USD);\n        assertEquals(expected, f12CHF.add(f7USD));\n    }\n\n    @Test\n    public void testBagNotEquals() {\n        IMoney bag = MoneyBag.create(f12CHF, f7USD);\n        assertFalse(bag.equals(new Money(12, \"DEM\").add(f7USD)));\n    }\n\n    @Test\n    public void testMoneyBagEquals() {\n        assertTrue(!fMB1.equals(null));\n\n        assertEquals(fMB1, fMB1);\n        IMoney equal = MoneyBag.create(new Money(12, \"CHF\"), new Money(7, \"USD\"));\n        assertTrue(fMB1.equals(equal));\n        assertTrue(!fMB1.equals(f12CHF));\n        assertTrue(!f12CHF.equals(fMB1));\n        assertTrue(!fMB1.equals(fMB2));\n    }\n\n    @Test\n    public void testMoneyBagHash() {\n        IMoney equal = MoneyBag.create(new Money(12, \"CHF\"), new Money(7, \"USD\"));\n        assertEquals(fMB1.hashCode(), equal.hashCode());\n    }\n\n    @Test\n    public void testMoneyEquals() {\n        assertTrue(!f12CHF.equals(null));\n        Money equalMoney = new Money(12, \"CHF\");\n        assertEquals(f12CHF, f12CHF);\n        assertEquals(f12CHF, equalMoney);\n        assertEquals(f12CHF.hashCode(), equalMoney.hashCode());\n        assertTrue(!f12CHF.equals(f14CHF));\n    }\n\n    @Test\n    public void zeroMoniesAreEqualRegardlessOfCurrency() {\n        Money zeroDollars = new Money(0, \"USD\");\n        Money zeroFrancs = new Money(0, \"CHF\");\n\n        assertEquals(zeroDollars, zeroFrancs);\n        assertEquals(zeroDollars.hashCode(), zeroFrancs.hashCode());\n    }\n\n    @Test\n    public void testMoneyHash() {\n        assertTrue(!f12CHF.equals(null));\n        Money equal = new Money(12, \"CHF\");\n        assertEquals(f12CHF.hashCode(), equal.hashCode());\n    }\n\n    @Test\n    public void testSimplify() {\n        IMoney money = MoneyBag.create(new Money(26, \"CHF\"), new Money(28, \"CHF\"));\n        assertEquals(new Money(54, \"CHF\"), money);\n    }\n\n    @Test\n    public void testNormalize2() {\n        // {[12 CHF][7 USD]} - [12 CHF] == [7 USD]\n        Money expected = new Money(7, \"USD\");\n        assertEquals(expected, fMB1.subtract(f12CHF));\n    }\n\n    @Test\n    public void testNormalize3() {\n        // {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD]\n        IMoney ms1 = MoneyBag.create(new Money(12, \"CHF\"), new Money(3, \"USD\"));\n        Money expected = new Money(4, \"USD\");\n        assertEquals(expected, fMB1.subtract(ms1));\n    }\n\n    @Test\n    public void testNormalize4() { // [12 CHF] - {[12 CHF][3 USD]} == [-3 USD]\n        IMoney ms1 = MoneyBag.create(new Money(12, \"CHF\"), new Money(3, \"USD\"));\n        Money expected = new Money(-3, \"USD\");\n        assertEquals(expected, f12CHF.subtract(ms1));\n    }\n\n    @Test\n    public void testPrint() {\n        assertEquals(\"[12 CHF]\", f12CHF.toString());\n    }\n\n    @Test\n    public void testSimpleAdd() {\n        // [12 CHF] + [14 CHF] == [26 CHF]\n        Money expected = new Money(26, \"CHF\");\n        assertEquals(expected, f12CHF.add(f14CHF));\n    }\n\n    @Test\n    public void testSimpleBagAdd() {\n        // [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]}\n        IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), new Money(7, \"USD\"));\n        assertEquals(expected, f14CHF.add(fMB1));\n    }\n\n    @Test\n    public void testSimpleMultiply() {\n        // [14 CHF] *2 == [28 CHF]\n        Money expected = new Money(28, \"CHF\");\n        assertEquals(expected, f14CHF.multiply(2));\n    }\n\n    @Test\n    public void testSimpleNegate() {\n        // [14 CHF] negate == [-14 CHF]\n        Money expected = new Money(-14, \"CHF\");\n        assertEquals(expected, f14CHF.negate());\n    }\n\n    @Test\n    public void testSimpleSubtract() {\n        // [14 CHF] - [12 CHF] == [2 CHF]\n        Money expected = new Money(2, \"CHF\");\n        assertEquals(expected, f14CHF.subtract(f12CHF));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/samples/money/package-info.java",
    "content": "/**\n * JUnit v4.x Test for the Money example.\n *\n * @since 4.0\n * @see junit.samples.money.Money\n */\npackage org.junit.samples.money;"
  },
  {
    "path": "src/test/java/org/junit/samples/package-info.java",
    "content": "/**\n * Provides examples on how to use JUnit 4.\n *\n * @since 4.0\n */\npackage org.junit.samples;"
  },
  {
    "path": "src/test/java/org/junit/tests/AllTests.java",
    "content": "package org.junit.tests;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.Test;\nimport org.junit.AssumptionViolatedExceptionTest;\nimport org.junit.internal.AllInternalTests;\nimport org.junit.rules.AllRulesTests;\nimport org.junit.runner.AllRunnerTests;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.AllRunnersTests;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.samples.AllSamplesTests;\nimport org.junit.tests.assertion.AllAssertionTests;\nimport org.junit.tests.deprecated.AllDeprecatedTests;\nimport org.junit.tests.description.AllDescriptionTests;\nimport org.junit.tests.experimental.AllExperimentalTests;\nimport org.junit.tests.junit3compatibility.AllJUnit3CompatibilityTests;\nimport org.junit.tests.listening.AllListeningTests;\nimport org.junit.tests.manipulation.AllManipulationTests;\nimport org.junit.tests.running.AllRunningTests;\nimport org.junit.tests.validation.AllValidationTests;\nimport org.junit.validator.AllValidatorTests;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllAssertionTests.class,\n        AllDeprecatedTests.class,\n        AllDescriptionTests.class,\n        AllExperimentalTests.class,\n        AllInternalTests.class,\n        AllJUnit3CompatibilityTests.class,\n        AllListeningTests.class,\n        AllManipulationTests.class,\n        AllRulesTests.class,\n        AllRunnersTests.class,\n        AllRunnerTests.class,\n        AllRunningTests.class,\n        AllSamplesTests.class,\n        AllValidationTests.class,\n        AllValidatorTests.class,\n        AssumptionViolatedExceptionTest.class,\n        ObjectContractTest.class\n})\npublic class AllTests {\n    public static Test suite() {\n        return new JUnit4TestAdapter(AllTests.class);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/ObjectContractTest.java",
    "content": "package org.junit.tests;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assume.assumeNotNull;\nimport static org.junit.Assume.assumeThat;\n\nimport java.lang.reflect.Method;\n\nimport org.junit.Test;\nimport org.junit.Test.None;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.model.FrameworkMethod;\n\n@RunWith(Theories.class)\npublic class ObjectContractTest {\n    @DataPoints\n    public static Object[] objects = {new FrameworkMethod(toStringMethod()),\n            new FrameworkMethod(toStringMethod()), 3, null};\n\n    @Theory\n    @Test(expected = None.class)\n    public void equalsThrowsNoException(Object a, Object b) {\n        assumeNotNull(a);\n        a.equals(b);\n    }\n\n    @Theory\n    public void equalsMeansEqualHashCodes(Object a, Object b) {\n        assumeNotNull(a, b);\n        assumeThat(a, is(b));\n        assertThat(a.hashCode(), is(b.hashCode()));\n    }\n\n    private static Method toStringMethod() {\n        try {\n            return Object.class.getMethod(\"toString\");\n        } catch (SecurityException e) {\n        } catch (NoSuchMethodException e) {\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/SampleJUnit4Tests.java",
    "content": "package org.junit.tests;\n\nimport org.junit.Before;\nimport org.junit.ClassRule;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.MethodRule;\nimport org.junit.rules.TestRule;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.Statement;\n\nimport java.lang.reflect.Method;\n\n/**\n * Container for sample JUnit4-style tests used in integration tests.\n */\npublic class SampleJUnit4Tests {\n\n    public static class TestWithOneThrowingTestMethod {\n        \n        @Test\n        public void alwaysThrows() {\n            new FakeClassUnderTest().throwsExceptionWithoutCause();\n        }\n    }\n\n    public static class TestWithOneThrowingTestMethodWithCause {\n        \n        @Test\n        public void alwaysThrows() {\n            new FakeClassUnderTest().throwsExceptionWithCause();\n        }\n    }\n\n    public static class TestWithThrowingBeforeMethod {\n\n        @Before\n        public void alwaysThrows() {\n            new FakeClassUnderTest().throwsExceptionWithoutCause();\n        }\n\n        @Test\n        public void alwaysPasses() {\n        }\n    }\n\n    public static class ThrowingTestRule implements TestRule {\n\n        public Statement apply(\n                Statement base, org.junit.runner.Description description) {\n            new FakeClassUnderTest().throwsExceptionWithoutCause();\n            return base;\n        }\n    }\n\n    public static class TestWithThrowingTestRule {\n\n        @Rule\n        public final TestRule rule = new ThrowingTestRule();\n\n        @Test\n        public void alwaysPasses() {\n        }\n    }\n\n    public static class TestWithThrowingClassRule {\n\n        @ClassRule\n        public static final TestRule rule = new ThrowingTestRule();\n\n        @Test\n        public void alwaysPasses() {\n        }\n    }\n\n    public static class ThrowingMethodRule implements MethodRule {\n\n        public Statement apply(\n                Statement base, FrameworkMethod method, Object target) {\n            new FakeClassUnderTest().throwsExceptionWithoutCause();\n            return base;\n        }\n    }\n\n    public static class TestWithThrowingMethodRule {\n\n        @Rule\n        public final ThrowingMethodRule rule = new ThrowingMethodRule();\n\n        @Test\n        public void alwaysPasses() {\n        }\n    }\n\n    public static class TestWithSuppressedException {\n        public static final Method addSuppressed = initAddSuppressed();\n\n        static Method initAddSuppressed() {\n            try {\n                return Throwable.class.getMethod(\"addSuppressed\", Throwable.class);\n            } catch (Throwable e) {\n                return null;\n            }\n        }\n\n        @Test\n        public void alwaysThrows() throws Exception {\n            final RuntimeException exception = new RuntimeException(\"error\");\n            addSuppressed.invoke(exception, new RuntimeException(\"suppressed\"));\n            throw exception;\n        }\n    }\n\n    private static class FakeClassUnderTest {\n        \n        public void throwsExceptionWithCause() {\n            doThrowExceptionWithCause();\n        }\n\n        public void throwsExceptionWithoutCause() {\n            doThrowExceptionWithoutCause();\n        }\n\n        private void doThrowExceptionWithCause() {\n            try {\n                throwsExceptionWithoutCause();\n            } catch (Exception e) {\n                throw new RuntimeException(\"outer\", e);\n            }\n        }\n\n        private void doThrowExceptionWithoutCause() {\n            throw new RuntimeException(\"cause\");\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/TestSystem.java",
    "content": "package org.junit.tests;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.OutputStream;\nimport java.io.PrintStream;\n\nimport org.junit.internal.JUnitSystem;\n\npublic class TestSystem implements JUnitSystem {\n    private PrintStream out;\n    public int fCode;\n    private ByteArrayOutputStream fOutContents;\n\n    public TestSystem() {\n        fOutContents = new ByteArrayOutputStream();\n        out = new PrintStream(fOutContents);\n    }\n\n    /**\n     * Will be removed in the next major release\n     */\n    @Deprecated\n    public void exit(int code) {\n        fCode = code;\n    }\n\n    public PrintStream out() {\n        return out;\n    }\n\n    public OutputStream outContents() {\n        return fOutContents;\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/assertion/AllAssertionTests.java",
    "content": "package org.junit.tests.assertion;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AssertionTest.class,\n        ComparisonFailureTest.class,\n        MultipleFailureExceptionTest.class\n})\npublic class AllAssertionTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/assertion/AssertionTest.java",
    "content": "package org.junit.tests.assertion;\n\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.junit.Assert.assertArrayEquals;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotEquals;\nimport static org.junit.Assert.assertNotSame;\nimport static org.junit.Assert.assertNull;\nimport static org.junit.Assert.assertSame;\nimport static org.junit.Assert.assertThat;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.assertThrows;\nimport static org.junit.Assert.fail;\n\nimport java.io.IOException;\nimport java.math.BigDecimal;\n\nimport org.junit.Assert;\nimport org.junit.ComparisonFailure;\nimport org.junit.Test;\nimport org.junit.function.ThrowingRunnable;\nimport org.junit.internal.ArrayComparisonFailure;\n\n/**\n * Tests for {@link org.junit.Assert}\n */\npublic class AssertionTest {\n// If you want to use 1.4 assertions, they will be reported correctly.\n// However, you need to add the -ea VM argument when running.\n\n// @Test (expected=AssertionError.class) public void error() {\n//      assert false;\n//  }\n\n    private static final String ASSERTION_ERROR_EXPECTED = \"AssertionError expected\";\n\n    @Test(expected = AssertionError.class)\n    public void fails() {\n        Assert.fail();\n    }\n\n    @Test\n    public void failWithNoMessageToString() {\n        try {\n            Assert.fail();\n        } catch (AssertionError exception) {\n            assertEquals(\"java.lang.AssertionError\", exception.toString());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void failWithMessageToString() {\n        try {\n            Assert.fail(\"woops!\");\n        } catch (AssertionError exception) {\n            assertEquals(\"java.lang.AssertionError: woops!\", exception.toString());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void arraysNotEqual() {\n        assertArrayEqualsFailure(\n                new Object[]{\"right\"},\n                new Object[]{\"wrong\"},\n                \"arrays first differed at element [0]; expected:<[right]> but was:<[wrong]>\");\n    }\n\n    @Test\n    public void arraysNotEqualWithMessage() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[]{\"right\"},\n                new Object[]{\"wrong\"},\n                \"not equal: arrays first differed at element [0]; expected:<[right]> but was:<[wrong]>\");\n    }\n\n    @Test\n    public void arraysExpectedNullMessage() {\n        try {\n            assertArrayEquals(\"not equal\", null, new Object[]{new Object()});\n        } catch (AssertionError exception) {\n            assertEquals(\"not equal: expected array was null\", exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void arraysActualNullMessage() {\n        try {\n            assertArrayEquals(\"not equal\", new Object[]{new Object()}, null);\n        } catch (AssertionError exception) {\n            assertEquals(\"not equal: actual array was null\", exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void arraysDifferentLengthDifferingAtStartMessage() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[]{true},\n                new Object[]{false, true},\n                \"not equal: array lengths differed, expected.length=1 actual.length=2; arrays first differed at element [0]; expected:<true> but was:<false>\");\n    }\n\n    @Test\n    public void arraysDifferentLengthDifferingAtEndMessage() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[]{true},\n                new Object[]{true, false},\n                \"not equal: array lengths differed, expected.length=1 actual.length=2; arrays first differed at element [1]; expected:<end of array> but was:<false>\");\n    }\n\n    @Test\n    public void arraysDifferentLengthDifferingAtEndAndExpectedArrayLongerMessage() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[]{true, false},\n                new Object[]{true},\n                \"not equal: array lengths differed, expected.length=2 actual.length=1; arrays first differed at element [1]; expected:<false> but was:<end of array>\");\n    }\n\n    @Test\n    public void arraysElementsDiffer() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[]{\"this is a very long string in the middle of an array\"},\n                new Object[]{\"this is another very long string in the middle of an array\"},\n                \"not equal: arrays first differed at element [0]; expected:<this is a[] very long string in...> but was:<this is a[nother] very long string in...>\");\n    }\n\n    @Test\n    public void arraysDifferAtElement0nullMessage() {\n        assertArrayEqualsFailure(\n                new Object[]{true},\n                new Object[]{false},\n                \"arrays first differed at element [0]; expected:<true> but was:<false>\"\n        );\n    }\n\n    @Test\n    public void arraysDifferAtElement1nullMessage() {\n        assertArrayEqualsFailure(\n                new Object[]{true, true},\n                new Object[]{true, false},\n                \"arrays first differed at element [1]; expected:<true> but was:<false>\"\n        );\n    }\n\n    @Test\n    public void arraysDifferAtElement0withMessage() {\n        assertArrayEqualsFailure(\n                \"message\",\n                new Object[]{true},\n                new Object[]{false},\n                \"message: arrays first differed at element [0]; expected:<true> but was:<false>\"\n        );\n    }\n\n    @Test\n    public void arraysDifferAtElement1withMessage() {\n        assertArrayEqualsFailure(\n                \"message\",\n                new Object[]{true, true},\n                new Object[]{true, false},\n                \"message: arrays first differed at element [1]; expected:<true> but was:<false>\"\n        );\n    }\n\n    @Test\n    public void multiDimensionalArraysAreEqual() {\n        assertArrayEquals((new Object[][]{{true, true}, {false, false}}), (new Object[][]{{true, true}, {false, false}}));\n    }\n\n    @Test\n    public void multiDimensionalIntArraysAreEqual() {\n        int[][] int1 = {{1, 2, 3}, {4, 5, 6}};\n        int[][] int2 = {{1, 2, 3}, {4, 5, 6}};\n        assertArrayEquals(int1, int2);\n    }\n\n    @Test\n    public void oneDimensionalPrimitiveArraysAreEqual() {\n        assertArrayEquals(new boolean[]{true}, new boolean[]{true});\n        assertArrayEquals(new byte[]{1}, new byte[]{1});\n        assertArrayEquals(new char[]{1}, new char[]{1});\n        assertArrayEquals(new short[]{1}, new short[]{1});\n        assertArrayEquals(new int[]{1}, new int[]{1});\n        assertArrayEquals(new long[]{1}, new long[]{1});\n        assertArrayEquals(new double[]{1.0}, new double[]{1.0}, 1.0);\n        assertArrayEquals(new float[]{1.0f}, new float[]{1.0f}, 1.0f);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void oneDimensionalDoubleArraysAreNotEqual() {\n        assertArrayEquals(new double[]{1.0}, new double[]{2.5}, 1.0);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void oneDimensionalFloatArraysAreNotEqual() {\n        assertArrayEquals(new float[]{1.0f}, new float[]{2.5f}, 1.0f);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void oneDimensionalBooleanArraysAreNotEqual() {\n        assertArrayEquals(new boolean[]{true}, new boolean[]{false});\n    }\n\n    @Test(expected = AssertionError.class)\n    public void IntegerDoesNotEqualLong() {\n        assertEquals(Integer.valueOf(1), Long.valueOf(1));\n    }\n\n    @Test\n    public void intsEqualLongs() {\n        assertEquals(1, 1L);\n    }\n\n    @Test\n    public void multiDimensionalArraysDeclaredAsOneDimensionalAreEqual() {\n        assertArrayEquals((new Object[]{new Object[]{true, true}, new Object[]{false, false}}), (new Object[]{new Object[]{true, true}, new Object[]{false, false}}));\n    }\n\n    @Test\n    public void multiDimensionalArraysAreNotEqual() {\n        assertArrayEqualsFailure(\n                \"message\",\n                new Object[][]{{true, true}, {false, false}},\n                new Object[][]{{true, true}, {true, false}},\n                \"message: arrays first differed at element [1][0]; expected:<false> but was:<true>\");\n    }\n\n    @Test\n    public void multiDimensionalArraysAreNotEqualNoMessage() {\n        assertArrayEqualsFailure(\n                new Object[][]{{true, true}, {false, false}},\n                new Object[][]{{true, true}, {true, false}},\n                \"arrays first differed at element [1][0]; expected:<false> but was:<true>\");\n    }\n\n    @Test\n    public void twoDimensionalArraysDifferentOuterLengthNotEqual() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{true}, {}},\n                new Object[][]{{}},\n                \"not equal: array lengths differed, expected.length=1 actual.length=0; arrays first differed at element [0][0]; expected:<true> but was:<end of array>\");\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{}, {true}},\n                new Object[][]{{}},\n                \"not equal: array lengths differed, expected.length=2 actual.length=1; arrays first differed at element [1]; expected:<java.lang.Object[1]> but was:<end of array>\");\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{}},\n                new Object[][]{{true}, {}},\n                \"not equal: array lengths differed, expected.length=0 actual.length=1; arrays first differed at element [0][0]; expected:<end of array> but was:<true>\");\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{}},\n                new Object[][]{{}, {true}},\n                \"not equal: array lengths differed, expected.length=1 actual.length=2; arrays first differed at element [1]; expected:<end of array> but was:<java.lang.Object[1]>\");\n    }\n\n    @Test\n    public void primitiveArraysConvertedToStringCorrectly() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new boolean[][]{{}, {true}},\n                new boolean[][]{{}},\n                \"not equal: array lengths differed, expected.length=2 actual.length=1; arrays first differed at element [1]; expected:<boolean[1]> but was:<end of array>\");\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new int[][]{{}, {23}},\n                new int[][]{{}},\n                \"not equal: array lengths differed, expected.length=2 actual.length=1; arrays first differed at element [1]; expected:<int[1]> but was:<end of array>\");\n    }\n\n    @Test\n    public void twoDimensionalArraysConvertedToStringCorrectly() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][][]{{}, {{true}}},\n                new Object[][][]{{}},\n                \"not equal: array lengths differed, expected.length=2 actual.length=1; arrays first differed at element [1]; expected:<java.lang.Object[][1]> but was:<end of array>\");\n    }\n\n    @Test\n    public void twoDimensionalArraysDifferentInnerLengthNotEqual() {\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{true}, {}},\n                new Object[][]{{}, {}},\n                \"not equal: array lengths differed, expected.length=1 actual.length=0; arrays first differed at element [0][0]; expected:<true> but was:<end of array>\");\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{}, {true}},\n                new Object[][]{{}, {}},\n                \"not equal: array lengths differed, expected.length=1 actual.length=0; arrays first differed at element [1][0]; expected:<true> but was:<end of array>\");\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{}, {}},\n                new Object[][]{{true}, {}},\n                \"not equal: array lengths differed, expected.length=0 actual.length=1; arrays first differed at element [0][0]; expected:<end of array> but was:<true>\");\n        assertArrayEqualsFailure(\n                \"not equal\",\n                new Object[][]{{}, {}},\n                new Object[][]{{}, {true}},\n                \"not equal: array lengths differed, expected.length=0 actual.length=1; arrays first differed at element [1][0]; expected:<end of array> but was:<true>\");\n    }\n\n    private void assertArrayEqualsFailure(Object[] expecteds, Object[] actuals, String expectedMessage) {\n        try {\n            assertArrayEquals(expecteds, actuals);\n        } catch (ArrayComparisonFailure e) {\n            assertEquals(expectedMessage, e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    private void assertArrayEqualsFailure(String message, Object[] expecteds, Object[] actuals, String expectedMessage) {\n        try {\n            assertArrayEquals(message, expecteds, actuals);\n        } catch (ArrayComparisonFailure e) {\n            assertEquals(expectedMessage, e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void multiDimensionalArraysDifferentLengthMessage() {\n        try {\n            assertArrayEquals(\"message\", new Object[][]{{true, true}, {false, false}}, new Object[][]{{true, true}, {false}});\n        } catch (AssertionError exception) {\n            assertEquals(\"message: array lengths differed, expected.length=2 actual.length=1; arrays first differed at element [1][1]; expected:<false> but was:<end of array>\", exception.getMessage());\n            return;\n        }\n\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void multiDimensionalArraysDifferentLengthNoMessage() {\n        try {\n            assertArrayEquals(new Object[][]{{true, true}, {false, false}}, new Object[][]{{true, true}, {false}});\n        } catch (AssertionError exception) {\n            assertEquals(\"array lengths differed, expected.length=2 actual.length=1; arrays first differed at element [1][1]; expected:<false> but was:<end of array>\", exception.getMessage());\n            return;\n        }\n\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void arraysWithNullElementEqual() {\n        Object[] objects1 = new Object[]{null};\n        Object[] objects2 = new Object[]{null};\n        assertArrayEquals(objects1, objects2);\n    }\n\n    @Test\n    public void stringsDifferWithUserMessage() {\n        try {\n            assertEquals(\"not equal\", \"one\", \"two\");\n        } catch (ComparisonFailure exception) {\n            assertEquals(\"not equal expected:<[one]> but was:<[two]>\", exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void arraysEqual() {\n        Object element = new Object();\n        Object[] objects1 = new Object[]{element};\n        Object[] objects2 = new Object[]{element};\n        assertArrayEquals(objects1, objects2);\n    }\n\n    @Test\n    public void arraysEqualWithMessage() {\n        Object element = new Object();\n        Object[] objects1 = new Object[]{element};\n        Object[] objects2 = new Object[]{element};\n        assertArrayEquals(\"equal\", objects1, objects2);\n    }\n\n    @Test\n    public void equals() {\n        Object o = new Object();\n        assertEquals(o, o);\n        assertEquals(\"abc\", \"abc\");\n        assertEquals(true, true);\n        assertEquals((byte) 1, (byte) 1);\n        assertEquals('a', 'a');\n        assertEquals((short) 1, (short) 1);\n        assertEquals(1, 1); // int by default, cast is unnecessary\n        assertEquals(1l, 1l);\n        assertEquals(1.0, 1.0, 0.0);\n        assertEquals(1.0d, 1.0d, 0.0d);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void notEqualsObjectWithNull() {\n        assertEquals(new Object(), null);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void notEqualsNullWithObject() {\n        assertEquals(null, new Object());\n    }\n\n    @Test\n    public void notEqualsObjectWithNullWithMessage() {\n        Object o = new Object();\n        try {\n            assertEquals(\"message\", null, o);\n        } catch (AssertionError e) {\n            assertEquals(\"message expected:<null> but was:<\" + o.toString() + \">\", e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void notEqualsNullWithObjectWithMessage() {\n        Object o = new Object();\n        try {\n            assertEquals(\"message\", o, null);\n        } catch (AssertionError e) {\n            assertEquals(\"message expected:<\" + o.toString() + \"> but was:<null>\", e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void objectsNotEquals() {\n        assertEquals(new Object(), new Object());\n    }\n\n    @Test(expected = ComparisonFailure.class)\n    public void stringsNotEqual() {\n        assertEquals(\"abc\", \"def\");\n    }\n\n    @Test(expected = AssertionError.class)\n    public void booleansNotEqual() {\n        assertEquals(true, false);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void bytesNotEqual() {\n        assertEquals((byte) 1, (byte) 2);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void charsNotEqual() {\n        assertEquals('a', 'b');\n    }\n\n    @Test(expected = AssertionError.class)\n    public void shortsNotEqual() {\n        assertEquals((short) 1, (short) 2);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void intsNotEqual() {\n        assertEquals(1, 2);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void longsNotEqual() {\n        assertEquals(1l, 2l);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void floatsNotEqual() {\n        assertEquals(1.0, 2.0, 0.9);\n    }\n\n    @SuppressWarnings(\"deprecation\")\n    @Test(expected = AssertionError.class)\n    public void floatsNotEqualWithoutDelta() {\n        assertEquals(1.0, 1.1);\n    }\n\n    @Test\n    public void floatsNotDoublesInArrays() {\n        float delta = 4.444f;\n        float[] f1 = new float[]{1.111f};\n        float[] f2 = new float[]{5.555f};\n        Assert.assertArrayEquals(f1, f2, delta);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void bigDecimalsNotEqual() {\n        assertEquals(new BigDecimal(\"123.4\"), new BigDecimal(\"123.0\"));\n    }\n\n\n    @Test(expected = AssertionError.class)\n    public void doublesNotEqual() {\n        assertEquals(1.0d, 2.0d, 0.9d);\n    }\n\n    @Test\n    public void naNsAreEqual() {\n        assertEquals(Float.NaN, Float.NaN, Float.POSITIVE_INFINITY);\n        assertEquals(Double.NaN, Double.NaN, Double.POSITIVE_INFINITY);\n    }\n\n    @SuppressWarnings(\"unused\")\n    @Test\n    public void nullNullmessage() {\n        try {\n            assertNull(\"junit\");\n        } catch (AssertionError e) {\n            assertEquals(\"expected null, but was:<junit>\", e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @SuppressWarnings(\"unused\")\n    @Test\n    public void nullWithMessage() {\n        try {\n            assertNull(\"message\", \"hello\");\n        } catch (AssertionError exception) {\n            assertEquals(\"message expected null, but was:<hello>\", exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void same() {\n        Object o1 = new Object();\n        assertSame(o1, o1);\n    }\n\n    @Test\n    public void notSame() {\n        Object o1 = new Object();\n        Object o2 = new Object();\n        assertNotSame(o1, o2);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void objectsNotSame() {\n        assertSame(new Object(), new Object());\n    }\n\n    @Test(expected = AssertionError.class)\n    public void objectsAreSame() {\n        Object o = new Object();\n        assertNotSame(o, o);\n    }\n\n    @Test\n    public void sameWithMessage() {\n        try {\n            assertSame(\"not same\", \"hello\", \"good-bye\");\n        } catch (AssertionError exception) {\n            assertEquals(\"not same expected same:<hello> was not:<good-bye>\",\n                    exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void sameNullMessage() {\n        try {\n            assertSame(\"hello\", \"good-bye\");\n        } catch (AssertionError exception) {\n            assertEquals(\"expected same:<hello> was not:<good-bye>\", exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void notSameWithMessage() {\n        Object o = new Object();\n        try {\n            assertNotSame(\"message\", o, o);\n        } catch (AssertionError exception) {\n            assertEquals(\"message expected not same\", exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void notSameNullMessage() {\n        Object o = new Object();\n        try {\n            assertNotSame(o, o);\n        } catch (AssertionError exception) {\n            assertEquals(\"expected not same\", exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void nullMessage() {\n        try {\n            fail(null);\n        } catch (AssertionError exception) {\n            // we used to expect getMessage() to return \"\"; see failWithNoMessageToString()\n            assertNull(exception.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void nullMessageDisappearsWithStringAssertEquals() {\n        try {\n            assertEquals(null, \"a\", \"b\");\n        } catch (ComparisonFailure e) {\n            assertEquals(\"expected:<[a]> but was:<[b]>\", e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void nullMessageDisappearsWithAssertEquals() {\n        try {\n            assertEquals(null, 1, 2);\n        } catch (AssertionError e) {\n            assertEquals(\"expected:<1> but was:<2>\", e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void arraysDeclaredAsObjectAreComparedAsObjects() {\n        Object a1 = new Object[]{\"abc\"};\n        Object a2 = new Object[]{\"abc\"};\n        assertEquals(a1, a2);\n    }\n\n    @Test\n    public void implicitTypecastEquality() {\n        byte b = 1;\n        short s = 1;\n        int i = 1;\n        long l = 1L;\n        float f = 1.0f;\n        double d = 1.0;\n\n        assertEquals(b, s);\n        assertEquals(b, i);\n        assertEquals(b, l);\n        assertEquals(s, i);\n        assertEquals(s, l);\n        assertEquals(i, l);\n        assertEquals(f, d, 0);\n    }\n\n    @Test\n    public void errorMessageDistinguishesDifferentValuesWithSameToString() {\n        try {\n            assertEquals(\"4\", Integer.valueOf(4));\n        } catch (AssertionError e) {\n            assertEquals(\"expected: java.lang.String<4> but was: java.lang.Integer<4>\", e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThatIncludesDescriptionOfTestedValueInErrorMessage() {\n        String expected = \"expected\";\n        String actual = \"actual\";\n\n        String expectedMessage = \"identifier\\nExpected: \\\"expected\\\"\\n     but: was \\\"actual\\\"\";\n\n        try {\n            assertThat(\"identifier\", actual, equalTo(expected));\n        } catch (AssertionError e) {\n            assertEquals(expectedMessage, e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThatIncludesAdvancedMismatch() {\n        String expectedMessage = \"identifier\\nExpected: is an instance of java.lang.Integer\\n     but: \\\"actual\\\" is a java.lang.String\";\n\n        try {\n            assertThat(\"identifier\", \"actual\", is(instanceOf(Integer.class)));\n        } catch (AssertionError e) {\n            assertEquals(expectedMessage, e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThatDescriptionCanBeElided() {\n        String expected = \"expected\";\n        String actual = \"actual\";\n\n        String expectedMessage = \"\\nExpected: \\\"expected\\\"\\n     but: was \\\"actual\\\"\";\n\n        try {\n            assertThat(actual, equalTo(expected));\n        } catch (AssertionError e) {\n            assertEquals(expectedMessage, e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void nullAndStringNullPrintCorrectError() {\n        try {\n            assertEquals(null, \"null\");\n        } catch (AssertionError e) {\n            assertEquals(\"expected: null<null> but was: java.lang.String<null>\", e.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void stringNullAndNullWorksToo() {\n        assertEquals(\"null\", null);\n    }\n\n    private static class NullToString {\n        @Override\n        public String toString() {\n            return null;\n        }\n    }\n\n    @Test\n    public void nullToString() {\n        try {\n            assertEquals(new NullToString(), new NullToString());\n        } catch (AssertionError e) {\n            assertEquals(\"expected: org.junit.tests.assertion.AssertionTest$NullToString<null> but \"\n                            + \"was: org.junit.tests.assertion.AssertionTest$NullToString<null>\",\n                    e.getMessage());\n            return;\n        }\n\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void compareBigDecimalAndInteger() {\n        final BigDecimal bigDecimal = new BigDecimal(\"1.2\");\n        final Integer integer = Integer.valueOf(\"1\");\n        assertEquals(bigDecimal, integer);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void sameObjectIsNotEqual() {\n        Object o = new Object();\n        assertNotEquals(o, o);\n    }\n\n    @Test\n    public void objectsWithDifferentReferencesAreNotEqual() {\n        assertNotEquals(new Object(), new Object());\n    }\n\n    @Test\n    public void assertNotEqualsIncludesCorrectMessage() {\n        Integer value1 = 1;\n        Integer value2 = 1;\n        String message = \"The values should be different\";\n\n        try {\n            assertNotEquals(message, value1, value2);\n        } catch (AssertionError e) {\n            assertEquals(message + \". Actual: \" + value1, e.getMessage());\n            return;\n        }\n\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertNotEqualsIncludesTheValueBeingTested() {\n        Integer value1 = 1;\n        Integer value2 = 1;\n\n        try {\n            assertNotEquals(value1, value2);\n        } catch (AssertionError e) {\n            assertTrue(e.getMessage().contains(value1.toString()));\n            return;\n        }\n\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertNotEqualsWorksWithPrimitiveTypes() {\n        assertNotEquals(1L, 2L);\n        assertNotEquals(\"The values should be different\", 1L, 2L);\n        assertNotEquals(1.0, 2.0, 0);\n        assertNotEquals(\"The values should be different\", 1.0, 2.0, 0);\n        assertNotEquals(1.0f, 2.0f, 0f);\n        assertNotEquals(\"The values should be different\", 1.0f, 2.0f, 0f);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void assertNotEqualsConsidersDeltaCorrectly() {\n        assertNotEquals(1.0, 0.9, 0.1);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void assertNotEqualsConsidersFloatDeltaCorrectly() {\n        assertNotEquals(1.0f, 0.75f, 0.25f);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void assertNotEqualsIgnoresDeltaOnNaN() {\n        assertNotEquals(Double.NaN, Double.NaN, 1);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void assertNotEqualsIgnoresFloatDeltaOnNaN() {\n        assertNotEquals(Float.NaN, Float.NaN, 1f);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void assertThrowsRequiresAnExceptionToBeThrown() {\n        assertThrows(Throwable.class, nonThrowingRunnable());\n    }\n\n    @Test\n    public void assertThrowsIncludesAnInformativeDefaultMessage() {\n        try {\n            assertThrows(Throwable.class, nonThrowingRunnable());\n        } catch (AssertionError ex) {\n            assertEquals(\"expected java.lang.Throwable to be thrown, but nothing was thrown\", ex.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThrowsIncludesTheSpecifiedMessage() {\n        try {\n            assertThrows(\"Foobar\", Throwable.class, nonThrowingRunnable());\n        } catch (AssertionError ex) {\n            assertEquals(\n                    \"Foobar: expected java.lang.Throwable to be thrown, but nothing was thrown\",\n                    ex.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThrowsReturnsTheSameObjectThrown() {\n        NullPointerException npe = new NullPointerException();\n\n        Throwable throwable = assertThrows(Throwable.class, throwingRunnable(npe));\n\n        assertSame(npe, throwable);\n    }\n\n    @Test(expected = AssertionError.class)\n    public void assertThrowsDetectsTypeMismatchesViaExplicitTypeHint() {\n        NullPointerException npe = new NullPointerException();\n\n        assertThrows(IOException.class, throwingRunnable(npe));\n    }\n\n    @Test\n    public void assertThrowsWrapsAndPropagatesUnexpectedExceptions() {\n        NullPointerException npe = new NullPointerException(\"inner-message\");\n\n        try {\n            assertThrows(IOException.class, throwingRunnable(npe));\n        } catch (AssertionError ex) {\n            assertSame(npe, ex.getCause());\n            assertEquals(\"inner-message\", ex.getCause().getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThrowsSuppliesACoherentErrorMessageUponTypeMismatch() {\n        NullPointerException npe = new NullPointerException();\n\n        try {\n            assertThrows(IOException.class, throwingRunnable(npe));\n        } catch (AssertionError error) {\n            assertEquals(\"unexpected exception type thrown; expected:<java.io.IOException> but was:<java.lang.NullPointerException>\",\n                    error.getMessage());\n            assertSame(npe, error.getCause());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThrowsSuppliesTheSpecifiedMessageUponTypeMismatch() {\n        NullPointerException npe = new NullPointerException();\n\n        try {\n            assertThrows(\"Foobar\", IOException.class, throwingRunnable(npe));\n        } catch (AssertionError error) {\n            assertEquals(\"Foobar: unexpected exception type thrown; expected:<java.io.IOException> but was:<java.lang.NullPointerException>\",\n                    error.getMessage());\n            assertSame(npe, error.getCause());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThrowsUsesCanonicalNameUponTypeMismatch() {\n        NullPointerException npe = new NullPointerException();\n\n        try {\n            assertThrows(NestedException.class, throwingRunnable(npe));\n        } catch (AssertionError error) {\n            assertEquals(\n                    \"unexpected exception type thrown; expected:<org.junit.tests.assertion.AssertionTest.NestedException>\"\n                    + \" but was:<java.lang.NullPointerException>\",\n                    error.getMessage());\n            assertSame(npe, error.getCause());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThrowsUsesNameUponTypeMismatchWithAnonymousClass() {\n        NullPointerException npe = new NullPointerException() {\n        };\n\n        try {\n            assertThrows(IOException.class, throwingRunnable(npe));\n        } catch (AssertionError error) {\n            assertEquals(\n                    \"unexpected exception type thrown; expected:<java.io.IOException>\"\n                    + \" but was:<org.junit.tests.assertion.AssertionTest$1>\",\n                    error.getMessage());\n            assertSame(npe, error.getCause());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    @Test\n    public void assertThrowsUsesCanonicalNameWhenRequiredExceptionNotThrown() {\n        try {\n            assertThrows(NestedException.class, nonThrowingRunnable());\n        } catch (AssertionError error) {\n            assertEquals(\n                    \"expected org.junit.tests.assertion.AssertionTest.NestedException to be thrown,\"\n                    + \" but nothing was thrown\", error.getMessage());\n            return;\n        }\n        throw new AssertionError(ASSERTION_ERROR_EXPECTED);\n    }\n\n    private static class NestedException extends RuntimeException {\n        private static final long serialVersionUID = 1L;\n    }\n\n    private static ThrowingRunnable nonThrowingRunnable() {\n        return new ThrowingRunnable() {\n            public void run() throws Throwable {\n            }\n        };\n    }\n\n    private static ThrowingRunnable throwingRunnable(final Throwable t) {\n        return new ThrowingRunnable() {\n            public void run() throws Throwable {\n                throw t;\n            }\n        };\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/assertion/ComparisonFailureTest.java",
    "content": "package org.junit.tests.assertion;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.Arrays;\nimport java.util.Collection;\n\nimport org.junit.ComparisonFailure;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameters;\n\n@RunWith(Parameterized.class)\npublic class ComparisonFailureTest {\n\t\t\n\tprivate String expected, actual, message;\n\t\n\tpublic ComparisonFailureTest(String e, String a, String m) {\n\t\texpected = e;\n\t\tactual = a;\n\t\tmessage = m;\n\t}\n\t\n\t@Parameters(name = \"compact-msg-{index}, exp=\\\"{1}\\\"\")\n\tpublic static Collection<Object[]> data() {\n\t\treturn Arrays.asList(new Object[][] {\n\t\t\t// simple base case\n\t\t\t{ \"a\", \"b\", \"expected:<[a]> but was:<[b]>\" },\n\t\t\t\t\n\t\t\t// common prefix\n\t\t\t{ \"ba\", \"bc\", \"expected:<b[a]> but was:<b[c]>\" },\n\t\t\t\t\n\t\t\t// common suffix\n\t\t\t{ \"ab\", \"cb\", \"expected:<[a]b> but was:<[c]b>\" },\n\t\t\t\t\n\t\t\t// common pre and suffix\n\t\t\t{ \"abc\", \"adc\", \"expected:<a[b]c> but was:<a[d]c>\" },\n\t\t\t\n\t\t\t// expected is subset of actual\n\t\t\t{ \"ab\", \"abc\", \"expected:<ab[]> but was:<ab[c]>\" },\n\n\t\t\t// expected is superset of actual\n\t\t\t{ \"abc\", \"ab\", \"expected:<ab[c]> but was:<ab[]>\" },\n\t\t\t\n\t\t\t// overlapping matches.\n\t\t\t{ \"abc\", \"abbc\", \"expected:<ab[]c> but was:<ab[b]c>\" },\n\n\t\t\t// long prefix yielding \"...\"\n\t\t\t{ \"01234567890123456789PRE:hello:POST\", \n\t\t\t\t\"01234567890123456789PRE:world:POST\",\n\t\t\t\t\"expected:<...4567890123456789PRE:[hello]:POST> but was:<...4567890123456789PRE:[world]:POST>\" },\n\t\t\t\t\t\n\t\t\t// long suffix\tyielding \"...\"\n\t\t\t{ \"PRE:hello:01234567890123456789POST\",\n\t\t\t\t\"PRE:world:01234567890123456789POST\",\n\t\t\t\t\"expected:<PRE:[hello]:0123456789012345678...> but was:<PRE:[world]:0123456789012345678...>\"\t\n\t\t\t},\n\t\t\t\t\t\n\t\t\t// bug609972\n\t\t\t{ \"S&P500\", \"0\", \"expected:<[S&P50]0> but was:<[]0>\" },\n\t\t\t\n\t\t\t// empty expected string\n\t\t\t{ \"\", \"a\", \"expected:<[]> but was:<[a]>\" },\n\n\t\t\t// empty actual string\n\t\t\t{ \"a\", \"\", \"expected:<[a]> but was:<[]>\" }\n\n\t\t});\t\n\t}\n\n\t@Test\n\tpublic void compactFailureMessage() {\n\t\tComparisonFailure failure = new ComparisonFailure(\"\", expected, actual);\n\t\tassertEquals(message, failure.getMessage());\n\t}\n\t\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/assertion/MultipleFailureExceptionTest.java",
    "content": "package org.junit.tests.assertion;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.CoreMatchers.instanceOf;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertSame;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\n\nimport java.lang.annotation.AnnotationFormatError;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.hamcrest.CoreMatchers;\nimport org.junit.Test;\nimport org.junit.TestCouldNotBeSkippedException;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runners.model.MultipleFailureException;\n\n\n/**\n * Tests for {@link org.junit.runners.model.MultipleFailureException}\n *\n * @author kcooney@google.com (Kevin Cooney)\n */\npublic class MultipleFailureExceptionTest {\n    private static final String LINE_SEPARATOR = System.getProperty(\"line.separator\");\n\n    @Test\n    public void assertEmptyDoesNotThrowForEmptyList() throws Exception {\n        MultipleFailureException.assertEmpty(Collections.<Throwable>emptyList());\n    }\n\n    @Test\n    public void assertEmptyRethrowsSingleRuntimeException() throws Exception {\n        Throwable exception= new ExpectedException(\"pesto\");\n        List<Throwable> errors= Collections.singletonList(exception);\n        try {\n            MultipleFailureException.assertEmpty(errors);\n            fail();\n        } catch (ExpectedException e) {\n            assertSame(e, exception);\n        }\n    }\n\n    @Test\n    public void assertEmptyRethrowsSingleError() throws Exception {\n        Throwable exception= new AnnotationFormatError(\"changeo\");\n        List<Throwable> errors= Collections.singletonList(exception);\n        try {\n            MultipleFailureException.assertEmpty(errors);\n            fail();\n        } catch (AnnotationFormatError e) {\n            assertSame(e, exception);\n        }\n    }\n\n    @Test\n    public void assertEmptyThrowsMultipleFailureExceptionForManyThrowables() throws Exception {\n        List<Throwable> errors = new ArrayList<Throwable>();\n        errors.add(new ExpectedException(\"basil\"));\n        errors.add(new RuntimeException(\"garlic\"));\n\n        try {\n            MultipleFailureException.assertEmpty(errors);\n            fail();\n        } catch (MultipleFailureException expected) {\n            assertThat(expected.getFailures(), equalTo(errors));\n            assertTrue(expected.getMessage().startsWith(\"There were 2 errors:\" + LINE_SEPARATOR));\n            assertTrue(expected.getMessage().contains(\"ExpectedException(basil)\" + LINE_SEPARATOR));\n            assertTrue(expected.getMessage().contains(\"RuntimeException(garlic)\"));\n        }\n    }\n\n    @Test\n    public void assertEmptyErrorListConstructorFailure() {\n        try {\n            new MultipleFailureException(Collections.<Throwable>emptyList());\n            fail();\n        } catch (IllegalArgumentException expected) {\n            assertThat(expected.getMessage(),\n                    containsString(\"List of Throwables must not be empty\"));\n        }\n    }\n\n    @Test\n    public void assertEmptyWrapsAssumptionFailuresForManyThrowables() throws Exception {\n        List<Throwable> errors = new ArrayList<Throwable>();\n        AssumptionViolatedException assumptionViolatedException = new AssumptionViolatedException(\"skip it\");\n        errors.add(assumptionViolatedException);\n        errors.add(new RuntimeException(\"garlic\"));\n\n        try {\n            MultipleFailureException.assertEmpty(errors);\n            fail();\n        } catch (MultipleFailureException expected) {\n            assertThat(expected.getFailures().size(), equalTo(2));\n            assertTrue(expected.getMessage().startsWith(\"There were 2 errors:\" + LINE_SEPARATOR));\n            assertTrue(expected.getMessage().contains(\"TestCouldNotBeSkippedException(Test could not be skipped\"));\n            assertTrue(expected.getMessage().contains(\"RuntimeException(garlic)\"));\n            Throwable first = expected.getFailures().get(0);\n            assertThat(first, instanceOf(TestCouldNotBeSkippedException.class));\n            Throwable cause = ((TestCouldNotBeSkippedException) first).getCause();\n            assertThat(cause, instanceOf(AssumptionViolatedException.class));\n            assertThat((AssumptionViolatedException) cause, CoreMatchers.sameInstance(assumptionViolatedException));\n        }\n    }\n\n    private static class ExpectedException extends RuntimeException {\n        private static final long serialVersionUID = 1L;\n\n        public ExpectedException(String message) {\n            super(message);\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/deprecated/AllDeprecatedTests.java",
    "content": "package org.junit.tests.deprecated;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@SuppressWarnings(\"deprecation\")\n@RunWith(Suite.class)\n@SuiteClasses({\n        JUnit4ClassRunnerTest.class\n})\npublic class AllDeprecatedTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/deprecated/JUnit4ClassRunnerTest.java",
    "content": "package org.junit.tests.deprecated;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.fail;\n\nimport org.junit.Test;\nimport org.junit.internal.runners.JUnit4ClassRunner;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\n\n/**\n * @deprecated This is a simple smoke test to make sure the old JUnit4ClassRunner basically works.\n *             Delete this test when JUnit4ClassRunner goes to the Great Heap In The Sky.\n */\n@Deprecated\npublic class JUnit4ClassRunnerTest {\n\n    @SuppressWarnings(\"deprecation\")\n    @RunWith(JUnit4ClassRunner.class)\n    public static class Example {\n        @Test\n        public void success() {\n        }\n\n        @Test\n        public void failure() {\n            fail();\n        }\n    }\n\n    @Test\n    public void runWithOldJUnit4ClassRunner() {\n        Result result = JUnitCore.runClasses(Example.class);\n        assertThat(result.getRunCount(), is(2));\n        assertThat(result.getFailureCount(), is(1));\n    }\n\n    @SuppressWarnings(\"deprecation\")\n    @RunWith(JUnit4ClassRunner.class)\n    public static class UnconstructableExample {\n        public UnconstructableExample() {\n            throw new UnsupportedOperationException();\n        }\n\n        @Test\n        public void success() {\n        }\n\n        @Test\n        public void failure() {\n            fail();\n        }\n    }\n\n\n    @Test\n    public void runWithOldJUnit4ClassRunnerAndBadConstructor() {\n        Result result = JUnitCore.runClasses(UnconstructableExample.class);\n        assertThat(result.getRunCount(), is(2));\n        assertThat(result.getFailureCount(), is(2));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/description/AllDescriptionTests.java",
    "content": "package org.junit.tests.description;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AnnotatedDescriptionTest.class,\n        SuiteDescriptionTest.class,\n        TestDescriptionMethodNameTest.class,\n        TestDescriptionTest.class\n})\npublic class AllDescriptionTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/description/AnnotatedDescriptionTest.java",
    "content": "package org.junit.tests.description;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.Request;\n\npublic class AnnotatedDescriptionTest {\n    @Retention(RetentionPolicy.RUNTIME)\n    public @interface MyOwnAnnotation {\n\n    }\n\n    @MyOwnAnnotation\n    public static class AnnotatedClass {\n        @Test\n        public void a() {\n        }\n    }\n\n    @Test\n    public void annotationsExistOnDescriptionsOfClasses() {\n        assertTrue((describe(AnnotatedClass.class).getAnnotation(\n                MyOwnAnnotation.class) != null));\n    }\n\n    @Test\n    public void getAnnotationsReturnsAllAnnotations() {\n        assertEquals(1, describe(ValueAnnotatedClass.class).getAnnotations()\n                .size());\n    }\n\n    @Ignore\n    public static class IgnoredClass {\n        @Test\n        public void a() {\n        }\n    }\n\n    @Test\n    public void annotationsExistOnDescriptionsOfIgnoredClass() {\n        assertTrue((describe(IgnoredClass.class).getAnnotation(Ignore.class) != null));\n    }\n\n    @Retention(RetentionPolicy.RUNTIME)\n    public @interface ValuedAnnotation {\n        String value();\n    }\n\n    @ValuedAnnotation(\"hello\")\n    public static class ValueAnnotatedClass {\n        @Test\n        public void a() {\n        }\n    }\n\n    @Test\n    public void descriptionOfTestClassHasValuedAnnotation() {\n        Description description = describe(ValueAnnotatedClass.class);\n        assertEquals(\"hello\", description.getAnnotation(ValuedAnnotation.class)\n                .value());\n    }\n\n    @Test\n    public void childlessCopyOfDescriptionStillHasAnnotations() {\n        Description description = describe(ValueAnnotatedClass.class);\n        assertEquals(\"hello\", description.childlessCopy().getAnnotation(ValuedAnnotation.class)\n                .value());\n    }\n\n    @Test\n    public void characterizeCreatingMyOwnAnnotation() {\n        Annotation annotation = new Ignore() {\n            public String value() {\n                return \"message\";\n            }\n\n            public Class<? extends Annotation> annotationType() {\n                return Ignore.class;\n            }\n        };\n\n        assertEquals(Ignore.class, annotation.annotationType());\n    }\n\n    private Description describe(Class<?> testClass) {\n        return Request.aClass(testClass).getRunner().getDescription();\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/description/SuiteDescriptionTest.java",
    "content": "package org.junit.tests.description;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\n\npublic class SuiteDescriptionTest {\n    Description childless = Description.createSuiteDescription(\"a\");\n    Description anotherChildless = Description.createSuiteDescription(\"a\");\n    Description namedB = Description.createSuiteDescription(\"b\");\n\n    Description twoKids = descriptionWithTwoKids(\"foo\", \"bar\");\n    Description anotherTwoKids = descriptionWithTwoKids(\"foo\", \"baz\");\n\n    @Test\n    public void equalsIsCorrect() {\n        assertEquals(childless, anotherChildless);\n        assertFalse(childless.equals(namedB));\n        assertEquals(childless, twoKids);\n        assertEquals(twoKids, anotherTwoKids);\n        assertFalse(twoKids.equals(Integer.valueOf(5)));\n    }\n\n    @Test\n    public void hashCodeIsReasonable() {\n        assertEquals(childless.hashCode(), anotherChildless.hashCode());\n        assertFalse(childless.hashCode() == namedB.hashCode());\n    }\n\n    private Description descriptionWithTwoKids(String first, String second) {\n        Description twoKids = Description.createSuiteDescription(\"a\");\n        twoKids.addChild(Description.createTestDescription(getClass(), first));\n        twoKids.addChild(Description.createTestDescription(getClass(), second));\n        return twoKids;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/description/TestDescriptionMethodNameTest.java",
    "content": "package org.junit.tests.description;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Parameterized;\n\nimport java.util.Arrays;\nimport java.util.Collection;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotNull;\n\n/**\n * @author Dmitry Baev charlie@yandex-team.ru\n *         Date: 03.05.14\n */\n@RunWith(Parameterized.class)\npublic class TestDescriptionMethodNameTest {\n\n    private String methodName;\n\n    public TestDescriptionMethodNameTest(String methodName) {\n        this.methodName = methodName;\n    }\n\n    @Parameterized.Parameters\n    public static Collection<Object[]> getMethodNames() {\n        return Arrays.asList(\n                new Object[]{\"simple\"},\n                new Object[]{\"with space\"},\n                new Object[]{\"[]!@#$%^&*()\"},\n                new Object[]{\"\"},\n                new Object[]{\"\\t\"},\n                new Object[]{\"\\n\"},\n                new Object[]{\"\\r\\n\"},\n                new Object[]{\"\\r\"},\n                new Object[]{\"\\u0085\"},\n                new Object[]{\"\\u2028\"},\n                new Object[]{\"\\u2029\"}\n        );\n    }\n\n    @Test\n    public void methodNameTest() throws Exception {\n        Description description = Description.createTestDescription(\"some-class-name\", methodName);\n        assertNotNull(\"Method name should be not null\", description.getMethodName());\n        assertEquals(methodName, description.getMethodName());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/description/TestDescriptionTest.java",
    "content": "package org.junit.tests.description;\n\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\n\npublic class TestDescriptionTest {\n    @Test\n    public void equalsIsFalseForNonTestDescription() {\n        assertFalse(Description.createTestDescription(getClass(), \"a\").equals(Integer.valueOf(5)));\n    }\n\n    @Test\n    public void equalsIsTrueForSameNameAndNoExplicitUniqueId() {\n        assertTrue(Description.createSuiteDescription(\"Hello\").equals(Description.createSuiteDescription(\"Hello\")));\n    }\n\n    @Test\n    public void equalsIsFalseForSameNameAndDifferentUniqueId() {\n        assertFalse(Description.createSuiteDescription(\"Hello\", 2).equals(Description.createSuiteDescription(\"Hello\", 3)));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/AllExperimentalTests.java",
    "content": "package org.junit.tests.experimental;\n\nimport org.junit.experimental.categories.AllCategoriesTests;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.tests.experimental.max.AllMaxTests;\nimport org.junit.tests.experimental.parallel.AllParallelTests;\nimport org.junit.tests.experimental.results.AllResultsTests;\nimport org.junit.tests.experimental.theories.AllTheoriesTests;\nimport org.junit.tests.experimental.theories.extendingwithstubs.StubbedTheoriesTest;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllCategoriesTests.class,\n        AllMaxTests.class,\n        AllParallelTests.class,\n        AllResultsTests.class,\n        AllTheoriesTests.class,\n        AssumptionTest.class,\n        MatcherTest.class,\n        StubbedTheoriesTest.class\n})\npublic class AllExperimentalTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/AssumptionTest.java",
    "content": "package org.junit.tests.experimental;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertSame;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.junit.Assume.assumeNoException;\nimport static org.junit.Assume.assumeNotNull;\nimport static org.junit.Assume.assumeThat;\nimport static org.junit.Assume.assumeTrue;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.Assume;\nimport org.junit.AssumptionViolatedException;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\n\npublic class AssumptionTest {\n    public static class HasFailingAssumption {\n        @Test\n        public void assumptionsFail() {\n            assumeThat(3, is(4));\n            fail();\n        }\n    }\n\n    @Test\n    public void failedAssumptionsMeanPassing() {\n        Result result = JUnitCore.runClasses(HasFailingAssumption.class);\n        assertThat(result.getRunCount(), is(1));\n        assertThat(result.getIgnoreCount(), is(0));\n        assertThat(result.getFailureCount(), is(0));\n    }\n\n    private static int assumptionFailures = 0;\n\n    @Test\n    public void failedAssumptionsCanBeDetectedByListeners() {\n        assumptionFailures = 0;\n        JUnitCore core = new JUnitCore();\n        core.addListener(new RunListener() {\n            @Override\n            public void testAssumptionFailure(Failure failure) {\n                assumptionFailures++;\n            }\n        });\n        core.run(HasFailingAssumption.class);\n\n        assertThat(assumptionFailures, is(1));\n    }\n\n    public static class HasPassingAssumption {\n        @Test\n        public void assumptionsFail() {\n            assumeThat(3, is(3));\n            fail();\n        }\n    }\n\n    @Test\n    public void passingAssumptionsScootThrough() {\n        Result result = JUnitCore.runClasses(HasPassingAssumption.class);\n        assertThat(result.getRunCount(), is(1));\n        assertThat(result.getIgnoreCount(), is(0));\n        assertThat(result.getFailureCount(), is(1));\n    }\n\n    @Test\n    public void assumeThatWorks() {\n        try {\n            assumeThat(1, is(2));\n            fail(\"should throw AssumptionViolatedException\");\n        } catch (AssumptionViolatedException e) {\n            // expected\n        }\n    }\n\n    @Test\n    public void assumeThatPasses() {\n        assumeThat(1, is(1));\n        assertCompletesNormally();\n    }\n\n    @Test\n    public void assumeThatPassesOnStrings() {\n        assumeThat(\"x\", is(\"x\"));\n        assertCompletesNormally();\n    }\n\n    @Test\n    public void assumeNotNullThrowsException() {\n        Object[] objects = {1, 2, null};\n        try {\n            assumeNotNull(objects);\n            fail(\"should throw AssumptionViolatedException\");\n        } catch (AssumptionViolatedException e) {\n            // expected\n        }\n    }\n\n    @Test\n    public void assumeNotNullThrowsExceptionForNullArray() {\n        try {\n            assumeNotNull((Object[]) null);\n            fail(\"should throw AssumptionViolatedException\");\n        } catch (AssumptionViolatedException e) {\n            // expected\n        }\n    }\n\n    @Test\n    public void assumeNotNullPasses() {\n        Object[] objects = {1, 2};\n        assumeNotNull(objects);\n        assertCompletesNormally();\n    }\n\n    @Test\n    public void assumeNotNullIncludesParameterList() {\n        try {\n            Object[] objects = {1, 2, null};\n            assumeNotNull(objects);\n        } catch (AssumptionViolatedException e) {\n            assertThat(e.getMessage(), containsString(\"1, 2, null\"));\n        } catch (Exception e) {\n            fail(\"Should have thrown AssumptionViolatedException\");\n        }\n    }\n\n    @Test\n    public void assumeNoExceptionThrows() {\n        final Throwable exception = new NullPointerException();\n        try {\n            assumeNoException(exception);\n            fail(\"Should have thrown exception\");\n        } catch (AssumptionViolatedException e) {\n            assertThat(e.getCause(), is(exception));\n        }\n    }\n\n    private void assertCompletesNormally() {\n    }\n\n    @Test\n    public void assumeTrueWorks() {\n        try {\n            Assume.assumeTrue(false);\n            fail(\"should throw AssumptionViolatedException\");\n        } catch (AssumptionViolatedException e) {\n            assertEquals(\"got: <false>, expected: is <true>\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void assumeFalseWorks() {\n        try {\n            Assume.assumeFalse(true);\n            fail(\"should throw AssumptionViolatedException\");\n        } catch (AssumptionViolatedException e) {\n            assertEquals(\"got: <true>, expected: is <false>\", e.getMessage());\n        }\n    }\n\n    public static class HasFailingAssumeInBefore {\n        @Before\n        public void checkForSomethingThatIsntThere() {\n            assumeTrue(false);\n        }\n\n        @Test\n        public void failing() {\n            fail();\n        }\n    }\n\n    @Test\n    public void failingAssumptionInBeforePreventsTestRun() {\n        assertThat(testResult(HasFailingAssumeInBefore.class), isSuccessful());\n    }\n\n    public static class HasFailingAssumeInBeforeClass {\n        @BeforeClass\n        public static void checkForSomethingThatIsntThere() {\n            assumeTrue(false);\n        }\n\n        @Test\n        public void failing() {\n            fail();\n        }\n    }\n\n    @Test\n    public void failingAssumptionInBeforeClassIgnoresClass() {\n        assertThat(testResult(HasFailingAssumeInBeforeClass.class), isSuccessful());\n    }\n\n    public static class AssumptionFailureInConstructor {\n        public AssumptionFailureInConstructor() {\n            assumeTrue(false);\n        }\n\n        @Test\n        public void shouldFail() {\n            fail();\n        }\n    }\n\n    @Test\n    public void failingAssumptionInConstructorIgnoresClass() {\n        assertThat(testResult(AssumptionFailureInConstructor.class), isSuccessful());\n    }\n\n    public static class TestClassWithAssumptionFailure {\n\n        @Test(expected = IllegalArgumentException.class)\n        public void assumeWithExpectedException() {\n            assumeTrue(false);\n        }\n    }\n\n    @Test\n    public void assumeWithExpectedExceptionShouldThrowAssumptionViolatedException() {\n        Result result = JUnitCore.runClasses(TestClassWithAssumptionFailure.class);\n        assertThat(result.getAssumptionFailureCount(), is(1));\n    }\n\n    static final String message = \"Some random message string.\";\n    static final Throwable e = new Throwable();\n\n    /**\n     * @see AssumptionTest#assumptionsWithMessage()\n     */\n    public static class HasAssumeWithMessage {\n        @Test\n        public void testMethod() {\n            assumeTrue(message, false);\n        }\n    }\n\n    @Test\n    public void assumptionsWithMessage() {\n        final List<Failure> failures =\n                runAndGetAssumptionFailures(HasAssumeWithMessage.class);\n\n        assertTrue(failures.get(0).getMessage().contains(message));\n    }\n\n    /**\n     * @see AssumptionTest#assumptionsWithMessageAndCause()\n     */\n    public static class HasAssumeWithMessageAndCause {\n        @Test\n        public void testMethod() {\n            assumeNoException(message, e);\n        }\n    }\n\n    @Test\n    public void assumptionsWithMessageAndCause() {\n        final List<Failure> failures =\n                runAndGetAssumptionFailures(HasAssumeWithMessageAndCause.class);\n        assertTrue(failures.get(0).getMessage().contains(message));\n        assertSame(failures.get(0).getException().getCause(), e);\n    }\n\n    public static class HasFailingAssumptionWithMessage {\n        @Test\n        public void assumptionsFail() {\n            assumeThat(message, 3, is(4));\n            fail();\n        }\n    }\n\n    @Test\n    public void failedAssumptionsWithMessage() {\n        final List<Failure> failures =\n                runAndGetAssumptionFailures(HasFailingAssumptionWithMessage.class);\n\n        assertEquals(1, failures.size());\n        assertTrue(failures.get(0).getMessage().contains(message));\n    }\n\n    /**\n     * Helper method that runs tests on <code>clazz</code> and returns any\n     * {@link Failure} objects that were {@link AssumptionViolatedException}s.\n     */\n    private static List<Failure> runAndGetAssumptionFailures(Class<?> clazz) {\n        final List<Failure> failures = new ArrayList<Failure>();\n        final JUnitCore core = new JUnitCore();\n        core.addListener(new RunListener() {\n            @Override\n            public void testAssumptionFailure(Failure failure) {\n                failures.add(failure);\n            }\n        });\n        core.run(clazz);\n        return failures;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/MatcherTest.java",
    "content": "package org.junit.tests.experimental;\n\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assume.assumeThat;\nimport static org.junit.experimental.results.ResultMatchers.hasFailureContaining;\nimport static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining;\n\nimport java.util.Arrays;\n\nimport org.hamcrest.Matcher;\nimport org.junit.experimental.results.PrintableResult;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.Description;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.notification.Failure;\n\n@RunWith(Theories.class)\npublic class MatcherTest {\n    @DataPoint\n    public static Matcher<Object> SINGLE_FAILURE = hasSingleFailureContaining(\"cheese\");\n\n    @DataPoint\n    public static Matcher<PrintableResult> ANY_FAILURE = hasFailureContaining(\"cheese\");\n\n    @DataPoint\n    public static PrintableResult TWO_FAILURES_ONE_CHEESE = new PrintableResult(\n            Arrays.asList(failure(\"cheese\"), failure(\"mustard\")));\n\n    @Theory\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    public void differentMatchersHaveDifferentDescriptions(\n            Matcher matcher1, Matcher matcher2, Object value) {\n        assumeThat(value, matcher1);\n        assumeThat(value, not(matcher2));\n        assertThat(matcher1.toString(), not(matcher2.toString()));\n    }\n\n    private static Failure failure(String string) {\n        return new Failure(Description.EMPTY, new Error(string));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/max/AllMaxTests.java",
    "content": "package org.junit.tests.experimental.max;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        DescriptionTest.class,\n        JUnit38SortingTest.class,\n        MaxStarterTest.class\n})\npublic class AllMaxTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/max/DescriptionTest.java",
    "content": "package org.junit.tests.experimental.max;\n\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNull;\n\nimport java.lang.annotation.Annotation;\nimport java.net.URL;\nimport java.net.URLClassLoader;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.runner.Description;\n\npublic class DescriptionTest {\n\n    @Test\n    public void parseClass_whenCantParse() {\n        assertNull(Description.TEST_MECHANISM.getTestClass());\n    }\n\n    @Test\n    public void parseMethod_whenCantParse() {\n        assertNull(Description.TEST_MECHANISM.getMethodName());\n    }\n\n    @Test(expected = IllegalArgumentException.class)\n    public void createSuiteDescription_whenZeroLength() {\n        Description.createSuiteDescription(\"\");\n    }\n\n    @Test(expected = IllegalArgumentException.class)\n    public void createSuiteDescription_whenNull() {\n        Description.createSuiteDescription((String) null);\n    }\n\n    @Test\n    public void parseClassAndMethodNoAnnotations() throws Exception {\n        Description description = Description.createTestDescription(Description.class, \"aTestMethod\");\n\n        assertThat(description.getClassName(), equalTo(\"org.junit.runner.Description\"));\n        assertThat(description.getMethodName(), equalTo(\"aTestMethod\"));\n        assertThat(description.getAnnotations().size(), equalTo(0));\n    }\n\n    @Test\n    public void parseClassAndMethodWithAnnotations() throws Exception {\n        Annotation[] annotations =\n                DescriptionTest.class.getMethod(\"parseClassAndMethodWithAnnotations\").getDeclaredAnnotations();\n\n        Description description = Description.createTestDescription(Description.class, \"aTestMethod\", annotations);\n\n        assertThat(description.getClassName(), equalTo(\"org.junit.runner.Description\"));\n        assertThat(description.getMethodName(), equalTo(\"aTestMethod\"));\n        assertThat(description.getAnnotations().size(), equalTo(1));\n    }\n\n    @Test\n    public void parseClassNameAndMethodUniqueId() throws Exception {\n        Description description = Description.createTestDescription(\"not a class name\", \"aTestMethod\", 123);\n\n        assertThat(description.getClassName(), equalTo(\"not a class name\"));\n        assertThat(description.getMethodName(), equalTo(\"aTestMethod\"));\n        assertThat(description.getAnnotations().size(), equalTo(0));\n    }\n\n    @Test\n    public void sameNamesButDifferentUniqueIdAreNotEqual() throws Exception {\n        assertThat(Description.createTestDescription(\"not a class name\", \"aTestMethod\", 1),\n                not(equalTo(Description.createTestDescription(\"not a class name\", \"aTestMethod\", 2))));\n    }\n\n    @Test\n    public void usesPassedInClassObject() throws Exception {\n        class URLClassLoader2 extends URLClassLoader {\n            URLClassLoader2(URL... urls) {\n                super(urls);\n            }\n\n            @Override // just making public\n            public Class<?> findClass(String name) throws ClassNotFoundException {\n                return super.findClass(name);\n            }\n        }\n        URL classpath = Sweet.class.getProtectionDomain().getCodeSource().getLocation();\n        URLClassLoader2 loader = new URLClassLoader2(classpath);\n        Class<?> clazz = loader.findClass(Sweet.class.getName());\n        assertEquals(loader, clazz.getClassLoader());\n\n        Description d = Description.createSuiteDescription(clazz);\n        assertEquals(clazz, d.getTestClass());\n        assertNull(d.getMethodName());\n        assertEquals(1, d.getAnnotations().size());\n        assertEquals(Ignore.class, d.getAnnotations().iterator().next().annotationType());\n\n        d = Description.createTestDescription(clazz, \"tessed\");\n        assertEquals(clazz, d.getTestClass());\n        assertEquals(\"tessed\", d.getMethodName());\n        assertEquals(0, d.getAnnotations().size());\n\n        d = Description.createTestDescription(clazz, \"tessed\", clazz.getMethod(\"tessed\").getAnnotations());\n        assertEquals(clazz, d.getTestClass());\n        assertEquals(\"tessed\", d.getMethodName());\n        assertEquals(1, d.getAnnotations().size());\n        assertEquals(Test.class, d.getAnnotations().iterator().next().annotationType());\n\n        d = d.childlessCopy();\n        assertEquals(clazz, d.getTestClass());\n        assertEquals(\"tessed\", d.getMethodName());\n        assertEquals(1, d.getAnnotations().size());\n        assertEquals(Test.class, d.getAnnotations().iterator().next().annotationType());\n    }\n\n    @Ignore\n    private static class Sweet {\n        @Test\n        public void tessed() {\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/max/JUnit38SortingTest.java",
    "content": "package org.junit.tests.experimental.max;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.io.File;\nimport java.util.List;\n\nimport junit.framework.TestCase;\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.experimental.max.MaxCore;\nimport org.junit.runner.Description;\nimport org.junit.runner.Request;\n\npublic class JUnit38SortingTest {\n    private MaxCore fMax;\n    private File fMaxFile;\n\n    @Before\n    public void createMax() {\n        fMaxFile = new File(\"MaxCore.ser\");\n        if (fMaxFile.exists()) {\n            fMaxFile.delete();\n        }\n        fMax = MaxCore.storedLocally(fMaxFile);\n    }\n\n    @After\n    public void forgetMax() {\n        fMaxFile.delete();\n    }\n\n    public static class JUnit4Test {\n        @Test\n        public void pass() {\n        }\n    }\n\n    public static class JUnit38Test extends TestCase {\n        public void testFails() {\n            fail();\n        }\n\n        public void testSucceeds() {\n        }\n\n        public void testSucceedsToo() {\n        }\n    }\n\n    @Test\n    public void preferRecentlyFailed38Test() {\n        Request request = Request.classes(JUnit4Test.class, JUnit38Test.class);\n        fMax.run(request);\n        List<Description> tests = fMax.sortedLeavesForTest(request);\n        Description dontSucceed = Description.createTestDescription(\n                JUnit38Test.class, \"testFails\");\n        assertEquals(dontSucceed, tests.get(0));\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/max/MaxStarterTest.java",
    "content": "package org.junit.tests.experimental.max;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport junit.framework.TestCase;\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.experimental.max.MaxCore;\nimport org.junit.internal.runners.JUnit38ClassRunner;\nimport org.junit.runner.Computer;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.tests.AllTests;\n\npublic class MaxStarterTest {\n    private MaxCore fMax;\n\n    private File fMaxFile;\n\n    @Before\n    public void createMax() {\n        fMaxFile = new File(\"MaxCore.ser\");\n        if (fMaxFile.exists()) {\n            fMaxFile.delete();\n        }\n        fMax = MaxCore.storedLocally(fMaxFile);\n    }\n\n    @After\n    public void forgetMax() {\n        fMaxFile.delete();\n    }\n\n    public static class TwoTests {\n        @Test\n        public void succeed() {\n        }\n\n        @Test\n        public void dontSucceed() {\n            fail();\n        }\n    }\n\n    @Test\n    public void twoTestsNotRunComeBackInRandomOrder() {\n        Request request = Request.aClass(TwoTests.class);\n        List<Description> things = fMax.sortedLeavesForTest(request);\n        Description succeed = Description.createTestDescription(TwoTests.class,\n                \"succeed\");\n        Description dontSucceed = Description.createTestDescription(\n                TwoTests.class, \"dontSucceed\");\n        assertTrue(things.contains(succeed));\n        assertTrue(things.contains(dontSucceed));\n        assertEquals(2, things.size());\n    }\n\n    @Test\n    public void preferNewTests() {\n        Request one = Request.method(TwoTests.class, \"succeed\");\n        fMax.run(one);\n        Request two = Request.aClass(TwoTests.class);\n        List<Description> things = fMax.sortedLeavesForTest(two);\n        Description dontSucceed = Description.createTestDescription(\n                TwoTests.class, \"dontSucceed\");\n        assertEquals(dontSucceed, things.get(0));\n        assertEquals(2, things.size());\n    }\n\n    // This covers a seemingly-unlikely case, where you had a test that failed\n    // on the\n    // last run and you also introduced new tests. In such a case it pretty much\n    // doesn't matter\n    // which order they run, you just want them both to be early in the sequence\n    @Test\n    public void preferNewTestsOverTestsThatFailed() {\n        Request one = Request.method(TwoTests.class, \"dontSucceed\");\n        fMax.run(one);\n        Request two = Request.aClass(TwoTests.class);\n        List<Description> things = fMax.sortedLeavesForTest(two);\n        Description succeed = Description.createTestDescription(TwoTests.class,\n                \"succeed\");\n        assertEquals(succeed, things.get(0));\n        assertEquals(2, things.size());\n    }\n\n    @Test\n    public void preferRecentlyFailed() {\n        Request request = Request.aClass(TwoTests.class);\n        fMax.run(request);\n        List<Description> tests = fMax.sortedLeavesForTest(request);\n        Description dontSucceed = Description.createTestDescription(\n                TwoTests.class, \"dontSucceed\");\n        assertEquals(dontSucceed, tests.get(0));\n    }\n\n    @Test\n    public void sortTestsInMultipleClasses() {\n        Request request = Request.classes(Computer.serial(), TwoTests.class,\n                TwoTests.class);\n        fMax.run(request);\n        List<Description> tests = fMax.sortedLeavesForTest(request);\n        Description dontSucceed = Description.createTestDescription(\n                TwoTests.class, \"dontSucceed\");\n        assertEquals(dontSucceed, tests.get(0));\n        assertEquals(dontSucceed, tests.get(1));\n    }\n\n    public static class TwoUnEqualTests {\n        @Test\n        public void slow() throws InterruptedException {\n            Thread.sleep(100);\n            fail();\n        }\n\n        @Test\n        public void fast() {\n            fail();\n        }\n\n    }\n\n    @Test\n    public void rememberOldRuns() {\n        fMax.run(TwoUnEqualTests.class);\n\n        MaxCore reincarnation = MaxCore.storedLocally(fMaxFile);\n        List<Failure> failures = reincarnation.run(TwoUnEqualTests.class)\n                .getFailures();\n        assertEquals(\"fast\", failures.get(0).getDescription().getMethodName());\n        assertEquals(\"slow\", failures.get(1).getDescription().getMethodName());\n    }\n\n    @Test\n    public void preferFast() {\n        Request request = Request.aClass(TwoUnEqualTests.class);\n        fMax.run(request);\n        Description thing = fMax.sortedLeavesForTest(request).get(1);\n        assertEquals(Description.createTestDescription(TwoUnEqualTests.class,\n                \"slow\"), thing);\n    }\n\n    @Test\n    public void listenersAreCalledCorrectlyInTheFaceOfFailures()\n            throws Exception {\n        JUnitCore core = new JUnitCore();\n        final List<Failure> failures = new ArrayList<Failure>();\n        core.addListener(new RunListener() {\n            @Override\n            public void testRunFinished(Result result) throws Exception {\n                failures.addAll(result.getFailures());\n            }\n        });\n        fMax.run(Request.aClass(TwoTests.class), core);\n        assertEquals(1, failures.size());\n    }\n\n    @Test\n    public void testsAreOnlyIncludedOnceWhenExpandingForSorting()\n            throws Exception {\n        Result result = fMax.run(Request.aClass(TwoTests.class));\n        assertEquals(2, result.getRunCount());\n    }\n\n    public static class TwoOldTests extends TestCase {\n        public void testOne() {\n        }\n\n        public void testTwo() {\n        }\n    }\n\n    @Test\n    public void junit3TestsAreRunOnce() throws Exception {\n        Result result = fMax.run(Request.aClass(TwoOldTests.class),\n                new JUnitCore());\n        assertEquals(2, result.getRunCount());\n    }\n\n    @Test\n    public void filterSingleMethodFromOldTestClass() throws Exception {\n        final Description method = Description.createTestDescription(\n                TwoOldTests.class, \"testOne\");\n        Filter filter = Filter.matchMethodDescription(method);\n        JUnit38ClassRunner child = new JUnit38ClassRunner(TwoOldTests.class);\n        child.filter(filter);\n        assertEquals(1, child.testCount());\n    }\n\n    @Test\n    public void testCountsStandUpToFiltration() {\n        assertFilterLeavesTestUnscathed(AllTests.class);\n    }\n\n    private void assertFilterLeavesTestUnscathed(Class<?> testClass) {\n        Request oneClass = Request.aClass(testClass);\n        Request filtered = oneClass.filterWith(new Filter() {\n            @Override\n            public boolean shouldRun(Description description) {\n                return true;\n            }\n\n            @Override\n            public String describe() {\n                return \"Everything\";\n            }\n        });\n\n        int filterCount = filtered.getRunner().testCount();\n        int coreCount = oneClass.getRunner().testCount();\n        assertEquals(\"Counts match up in \" + testClass, coreCount, filterCount);\n    }\n\n    private static class MalformedJUnit38Test {\n        private MalformedJUnit38Test() {\n        }\n\n        @SuppressWarnings(\"unused\")\n        public void testSucceeds() {\n        }\n    }\n\n    @Test\n    public void maxShouldSkipMalformedJUnit38Classes() {\n        Request request = Request.aClass(MalformedJUnit38Test.class);\n        fMax.run(request);\n    }\n\n    public static class MalformedJUnit38TestMethod extends TestCase {\n        @SuppressWarnings(\"unused\")\n        private void testNothing() {\n        }\n    }\n\n    @Test\n    public void correctErrorFromMalformedTest() {\n        Request request = Request.aClass(MalformedJUnit38TestMethod.class);\n        JUnitCore core = new JUnitCore();\n        Request sorted = fMax.sortRequest(request);\n        Runner runner = sorted.getRunner();\n        Result result = core.run(runner);\n        Failure failure = result.getFailures().get(0);\n        assertThat(failure.toString(), containsString(\"MalformedJUnit38TestMethod\"));\n        assertThat(failure.toString(), containsString(\"testNothing\"));\n        assertThat(failure.toString(), containsString(\"isn't public\"));\n    }\n\n    public static class HalfMalformedJUnit38TestMethod extends TestCase {\n        public void testSomething() {\n        }\n\n        @SuppressWarnings(\"unused\")\n        private void testNothing() {\n        }\n    }\n\n    @Test\n    public void halfMalformed() {\n        assertThat(JUnitCore.runClasses(HalfMalformedJUnit38TestMethod.class)\n                .getFailureCount(), is(1));\n    }\n\n\n    @Test\n    public void correctErrorFromHalfMalformedTest() {\n        Request request = Request.aClass(HalfMalformedJUnit38TestMethod.class);\n        JUnitCore core = new JUnitCore();\n        Request sorted = fMax.sortRequest(request);\n        Runner runner = sorted.getRunner();\n        Result result = core.run(runner);\n        Failure failure = result.getFailures().get(0);\n        assertThat(failure.toString(), containsString(\"MalformedJUnit38TestMethod\"));\n        assertThat(failure.toString(), containsString(\"testNothing\"));\n        assertThat(failure.toString(), containsString(\"isn't public\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/parallel/AllParallelTests.java",
    "content": "package org.junit.tests.experimental.parallel;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        ParallelClassTest.class,\n        ParallelMethodTest.class\n})\npublic class AllParallelTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/parallel/ParallelClassTest.java",
    "content": "package org.junit.tests.experimental.parallel;\n\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.core.IsNot.not;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.assertTrue;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.TimeUnit;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.experimental.ParallelComputer;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\n\npublic class ParallelClassTest {\n    private static final long TIMEOUT = 15;\n    private static volatile Thread fExample1One = null;\n    private static volatile Thread fExample1Two = null;\n    private static volatile Thread fExample2One = null;\n    private static volatile Thread fExample2Two = null;\n    private static volatile CountDownLatch fSynchronizer;\n\n    public static class Example1 {\n        @Test\n        public void one() throws InterruptedException {\n            fSynchronizer.countDown();\n            assertTrue(fSynchronizer.await(TIMEOUT, TimeUnit.SECONDS));\n            fExample1One = Thread.currentThread();\n        }\n\n        @Test\n        public void two() throws InterruptedException {\n            fSynchronizer.countDown();\n            assertTrue(fSynchronizer.await(TIMEOUT, TimeUnit.SECONDS));\n            fExample1Two = Thread.currentThread();\n        }\n    }\n\n    public static class Example2 {\n        @Test\n        public void one() throws InterruptedException {\n            fSynchronizer.countDown();\n            assertTrue(fSynchronizer.await(TIMEOUT, TimeUnit.SECONDS));\n            fExample2One = Thread.currentThread();\n        }\n\n        @Test\n        public void two() throws InterruptedException {\n            fSynchronizer.countDown();\n            assertTrue(fSynchronizer.await(TIMEOUT, TimeUnit.SECONDS));\n            fExample2Two = Thread.currentThread();\n        }\n    }\n\n    @Before\n    public void init() {\n        fExample1One = null;\n        fExample1Two = null;\n        fExample2One = null;\n        fExample2Two = null;\n        fSynchronizer = new CountDownLatch(2);\n    }\n\n    @Test\n    public void testsRunInParallel() {\n        Result result = JUnitCore.runClasses(ParallelComputer.classes(), Example1.class, Example2.class);\n        assertTrue(result.wasSuccessful());\n        assertNotNull(fExample1One);\n        assertNotNull(fExample1Two);\n        assertNotNull(fExample2One);\n        assertNotNull(fExample2Two);\n        assertThat(fExample1One, is(fExample1Two));\n        assertThat(fExample2One, is(fExample2Two));\n        assertThat(fExample1One, is(not(fExample2One)));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/parallel/ParallelMethodTest.java",
    "content": "package org.junit.tests.experimental.parallel;\n\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.core.IsNot.not;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.assertTrue;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.TimeUnit;\n\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.experimental.ParallelComputer;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\n\npublic class ParallelMethodTest {\n    private static final long TIMEOUT = 15;\n    private static volatile Thread fOne = null;\n    private static volatile Thread fTwo = null;\n\n    public static class Example {\n        private static volatile CountDownLatch fSynchronizer;\n\n        @BeforeClass\n        public static void init() {\n            fSynchronizer = new CountDownLatch(2);\n        }\n\n        @Test\n        public void one() throws InterruptedException {\n            fSynchronizer.countDown();\n            assertTrue(fSynchronizer.await(TIMEOUT, TimeUnit.SECONDS));\n            fOne = Thread.currentThread();\n        }\n\n        @Test\n        public void two() throws InterruptedException {\n            fSynchronizer.countDown();\n            assertTrue(fSynchronizer.await(TIMEOUT, TimeUnit.SECONDS));\n            fTwo = Thread.currentThread();\n        }\n    }\n\n    @Before\n    public void init() {\n        fOne = null;\n        fTwo = null;\n    }\n\n    @Test\n    public void testsRunInParallel() {\n        Result result = JUnitCore.runClasses(ParallelComputer.methods(), Example.class);\n        assertTrue(result.wasSuccessful());\n        assertNotNull(fOne);\n        assertNotNull(fTwo);\n        assertThat(fOne, is(not(fTwo)));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/results/AllResultsTests.java",
    "content": "package org.junit.tests.experimental.results;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        PrintableResultTest.class,\n        ResultMatchersTest.class\n})\npublic class AllResultsTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/results/PrintableResultTest.java",
    "content": "package org.junit.tests.experimental.results;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\nimport java.util.Arrays;\n\nimport org.junit.experimental.results.PrintableResult;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.Description;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.notification.Failure;\n\n@RunWith(Theories.class)\npublic class PrintableResultTest {\n    @Theory(nullsAccepted = false)\n    public void backTraceHasGoodToString(String descriptionName,\n            final String stackTraceClassName) {\n        Failure failure = new Failure(Description\n                .createSuiteDescription(descriptionName), new Throwable() {\n            private static final long serialVersionUID = 1L;\n\n            @Override\n            public StackTraceElement[] getStackTrace() {\n                return new StackTraceElement[]{new StackTraceElement(\n                        stackTraceClassName, \"methodName\", \"fileName\", 1)};\n            }\n        });\n\n        assertThat(new PrintableResult(asList(failure)).toString(), allOf(\n                containsString(descriptionName), containsString(stackTraceClassName)));\n    }\n\n    @DataPoint\n    public static String SHELL_POINT = \"Shell Point\";\n\n    @Theory\n    public void includeMultipleFailures(String secondExceptionName) {\n        PrintableResult backtrace = new PrintableResult(Arrays.asList(\n                new Failure(Description.createSuiteDescription(\"firstName\"),\n                        new RuntimeException(\"firstException\")), new Failure(\n                Description.createSuiteDescription(\"secondName\"),\n                new RuntimeException(secondExceptionName))));\n        assertThat(backtrace.toString(), containsString(secondExceptionName));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/results/ResultMatchersTest.java",
    "content": "package org.junit.tests.experimental.results;\n\nimport org.junit.Test;\nimport org.junit.experimental.results.PrintableResult;\nimport org.junit.experimental.results.ResultMatchers;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.Failure;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\npublic class ResultMatchersTest {\n\n    @Test\n    public void hasFailuresHasGoodDescription() {\n        assertThat(ResultMatchers.failureCountIs(3).toString(),\n                is(\"has 3 failures\"));\n    }\n\n    @Theory\n    public void hasFailuresDescriptionReflectsInput(int i) {\n        assertThat(ResultMatchers.failureCountIs(i).toString(),\n                containsString(\"\" + i));\n    }\n\n    @Test\n    public void hasFailureContaining_givenResultWithNoFailures() {\n        PrintableResult resultWithNoFailures = new PrintableResult(new ArrayList<Failure>());\n\n        assertThat(ResultMatchers.hasFailureContaining(\"\").matches(resultWithNoFailures), is(false));\n    }\n\n    @Test\n    public void hasFailureContaining_givenResultWithOneFailure() {\n        PrintableResult resultWithOneFailure = new PrintableResult(Collections.singletonList(\n                new Failure(Description.EMPTY, new RuntimeException(\"my failure\"))));\n\n        assertThat(ResultMatchers.hasFailureContaining(\"my failure\").matches(resultWithOneFailure), is(true));\n        assertThat(ResultMatchers.hasFailureContaining(\"his failure\").matches(resultWithOneFailure), is(false));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/AllTheoriesTests.java",
    "content": "package org.junit.tests.experimental.theories;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.tests.experimental.theories.internal.AllTheoriesInternalTests;\nimport org.junit.tests.experimental.theories.runner.AllTheoriesRunnerTests;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllTheoriesInternalTests.class,\n        AllTheoriesRunnerTests.class,\n        ParameterSignatureTest.class,\n        TestedOnSupplierTest.class,\n        AssumingInTheoriesTest.class,\n        PotentialAssignmentTest.class\n})\npublic class AllTheoriesTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/AssumingInTheoriesTest.java",
    "content": "package org.junit.tests.experimental.theories;\n\nimport static org.junit.tests.experimental.theories.TheoryTestUtils.runTheoryClass;\nimport org.junit.Assert;\nimport org.junit.Assume;\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.model.InitializationError;\n\n@RunWith(Theories.class)\npublic class AssumingInTheoriesTest {\n\n    @Test\n    public void noTheoryAnnotationMeansAssumeShouldIgnore() {\n        Assume.assumeTrue(false);\n    }\n\n    @Test\n    public void theoryMeansOnlyAssumeShouldFail() throws InitializationError {\n        Result result = runTheoryClass(TheoryWithNoUnassumedParameters.class);\n        Assert.assertEquals(1, result.getFailureCount());\n    }\n\n    /**\n     * Simple class that SHOULD fail because no parameters are met.\n     */\n    public static class TheoryWithNoUnassumedParameters {\n\n        @DataPoint\n        public static final boolean FALSE = false;\n\n        @Theory\n        public void theoryWithNoUnassumedParameters(boolean value) {\n            Assume.assumeTrue(value);\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/ParameterSignatureTest.java",
    "content": "package org.junit.tests.experimental.theories;\n\nimport static org.hamcrest.CoreMatchers.isA;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assume.assumeTrue;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.reflect.Method;\nimport java.util.List;\n\nimport org.hamcrest.CoreMatchers;\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.experimental.theories.suppliers.TestedOn;\nimport org.junit.runner.RunWith;\n\n@RunWith(Theories.class)\npublic class ParameterSignatureTest {\n    @DataPoint\n    public static Method getType() throws SecurityException,\n            NoSuchMethodException {\n        return ParameterSignatureTest.class.getMethod(\"getType\", Method.class,\n                int.class);\n    }\n\n    @DataPoint\n    public static int ZERO = 0;\n\n    @DataPoint\n    public static int ONE = 1;\n\n    @Theory\n    public void getType(Method method, int index) {\n        assumeTrue(index < method.getParameterTypes().length);\n        assertEquals(method.getParameterTypes()[index], ParameterSignature\n                .signatures(method).get(index).getType());\n    }\n\n    public void foo(@TestedOn(ints = {1, 2, 3}) int x) {\n    }\n\n    @Test\n    public void getAnnotations() throws SecurityException,\n            NoSuchMethodException {\n        Method method = getClass().getMethod(\"foo\", int.class);\n        List<Annotation> annotations = ParameterSignature.signatures(method)\n                .get(0).getAnnotations();\n        assertThat(annotations,\n                CoreMatchers.<TestedOn>hasItem(isA(TestedOn.class)));\n    }\n    \n    public void intMethod(int param) {\n    }\n    \n    public void integerMethod(Integer param) {\n    }\n    \n    public void numberMethod(Number param) {\n    }\n\n    @Test\n    public void primitiveTypesShouldBeAcceptedAsWrapperTypes() throws Exception {\n        List<ParameterSignature> signatures = ParameterSignature\n                .signatures(getClass().getMethod(\"integerMethod\", Integer.class));\n        ParameterSignature integerSignature = signatures.get(0);\n\n        assertTrue(integerSignature.canAcceptType(int.class));\n    }\n    \n    @Test\n    public void primitiveTypesShouldBeAcceptedAsWrapperTypeAssignables() throws Exception {\n        List<ParameterSignature> signatures = ParameterSignature\n                .signatures(getClass().getMethod(\"numberMethod\", Number.class));\n        ParameterSignature numberSignature = signatures.get(0);\n\n        assertTrue(numberSignature.canAcceptType(int.class));\n    }\n    \n    @Test\n    public void wrapperTypesShouldBeAcceptedAsPrimitiveTypes() throws Exception {\n        List<ParameterSignature> signatures = ParameterSignature\n                .signatures(getClass().getMethod(\"intMethod\", int.class));\n        ParameterSignature intSignature = signatures.get(0);\n\n        assertTrue(intSignature.canAcceptType(Integer.class));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/PotentialAssignmentTest.java",
    "content": "package org.junit.tests.experimental.theories;\n\nimport static org.junit.Assert.*;\nimport org.junit.Test;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.PotentialAssignment.CouldNotGenerateValueException;\n\npublic class PotentialAssignmentTest {\n\n    @Test\n    public void shouldUseQuotedValueInDescription() throws CouldNotGenerateValueException {\n        String name = \"stringDatapoint\";\n        Object value = new Object() {\n            @Override\n            public String toString() {\n                return \"string value\";\n            }\n        };\n\n        PotentialAssignment assignment = PotentialAssignment.forValue(name, value);\n\n        assertEquals(\"\\\"string value\\\" <from stringDatapoint>\", assignment.getDescription());\n    }\n\n    @Test\n    public void shouldNotUseQuotesForNullValueDescriptions() throws CouldNotGenerateValueException {\n        String name = \"nullDatapoint\";\n        Object value = null;\n\n        PotentialAssignment assignment = PotentialAssignment.forValue(name, value);\n\n        assertEquals(\"null <from nullDatapoint>\", assignment.getDescription());\n    }\n\n    @Test\n    public void shouldIncludeFailureInDescriptionIfToStringFails() throws CouldNotGenerateValueException {\n        String name = \"explodingValue\";\n        Object value = new Object() {\n            @Override\n            public String toString() {\n                throw new RuntimeException(\"Oh no!\");\n            }\n        };\n\n        PotentialAssignment assignment = PotentialAssignment.forValue(name, value);\n\n        assertEquals(\"[toString() threw RuntimeException: Oh no!] <from explodingValue>\", assignment.getDescription());\n    }\n\n    @Test\n    public void shouldReturnGivenValue() throws CouldNotGenerateValueException {\n        Object value = new Object();\n        PotentialAssignment assignment = PotentialAssignment.forValue(\"name\", value);\n        assertEquals(value, assignment.getValue());\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/TestedOnSupplierTest.java",
    "content": "package org.junit.tests.experimental.theories;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\nimport java.lang.reflect.Method;\nimport java.util.List;\n\nimport org.junit.Test;\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.suppliers.TestedOn;\nimport org.junit.experimental.theories.suppliers.TestedOnSupplier;\n\npublic class TestedOnSupplierTest {\n\n    public void foo(@TestedOn(ints = {1}) int x) {\n    }\n\n    @Test\n    public void descriptionStatesParameterName() throws Exception {\n        TestedOnSupplier supplier = new TestedOnSupplier();\n        List<PotentialAssignment> assignments = supplier.getValueSources(signatureOfFoo());\n        assertThat(assignments.get(0).getDescription(), is(\"\\\"1\\\" <from ints>\"));\n    }\n\n    private ParameterSignature signatureOfFoo() throws NoSuchMethodException {\n        Method method = getClass().getMethod(\"foo\", int.class);\n        return ParameterSignature.signatures(method).get(0);\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/TheoryTestUtils.java",
    "content": "package org.junit.tests.experimental.theories;\n\nimport java.lang.reflect.Method;\nimport java.util.List;\n\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.internal.Assignments;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.Runner;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.TestClass;\n\npublic final class TheoryTestUtils {\n    \n    private TheoryTestUtils() { }\n    \n    public static List<PotentialAssignment> potentialAssignments(Method method)\n            throws Throwable {\n        return Assignments.allUnassigned(method,\n                new TestClass(method.getDeclaringClass()))\n                .potentialsForNextUnassigned();\n    }\n    \n    public static Result runTheoryClass(Class<?> testClass) throws InitializationError {\n        Runner theoryRunner = new Theories(testClass);\n        Request request = Request.runner(theoryRunner);\n        return new JUnitCore().run(request);\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/Correspondent.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\npublic interface Correspondent {\n\n    String getAnswer(String question, String... bucket);\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/Guesser.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\nimport java.lang.reflect.InvocationHandler;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Proxy;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map.Entry;\nimport java.util.Random;\n\nimport org.hamcrest.BaseDescription;\nimport org.hamcrest.Description;\nimport org.junit.internal.AssumptionViolatedException;\n\npublic class Guesser<T> extends ReguessableValue {\n    static class GuessMap extends HashMap<MethodCall, Object> implements\n            InvocationHandler {\n        private static final long serialVersionUID = 1L;\n\n        public GuessMap(GuessMap guesses) {\n            super(guesses);\n        }\n\n        public GuessMap() {\n        }\n\n        GuessMap replaceGuess(Object oldValue, Object newValue) {\n            GuessMap newGuesses = new GuessMap(this);\n            for (Entry<MethodCall, Object> entry : newGuesses.entrySet()) {\n                if (entry.getValue().equals(oldValue)) {\n                    entry.setValue(newValue);\n                }\n            }\n            return newGuesses;\n        }\n\n        protected Object generateGuess(Class<?> returnType) {\n            if (returnType.equals(String.class)) {\n                return \"GUESS\" + new Random().nextInt();\n            }\n            if (returnType.equals(Integer.class)\n                    || returnType.equals(int.class)) {\n                return new Random().nextInt();\n            }\n            return null;\n        }\n\n        Object getGuess(MethodCall call) {\n            if (!containsKey(call)) {\n                put(call, generateGuess(call.getReturnType()));\n            }\n            return get(call);\n        }\n\n        public Object invoke(Object proxy, Method method, Object[] args)\n                throws Throwable {\n            return getGuess(new MethodCall(method, args));\n        }\n    }\n\n    private final GuessMap guesses;\n\n    private final Class<? extends T> type;\n\n    public Guesser(Class<? extends T> type) {\n        this(type, new GuessMap());\n    }\n\n    public Guesser(Class<? extends T> type2, GuessMap guesses) {\n        this.type = type2;\n        this.guesses = guesses;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public T getProxy() {\n        return (T) Proxy.newProxyInstance(getClass().getClassLoader(),\n                new Class[]{getType()}, guesses);\n    }\n\n    @Override\n    public List<ReguessableValue> reguesses(AssumptionViolatedException e) {\n        final ArrayList<ReguessableValue> returnThis = new ArrayList<ReguessableValue>();\n        e.describeTo(new BaseDescription() {\n            @Override\n            protected void append(char arg0) {\n            }\n\n            boolean expectedSeen = false;\n            Object expected = null;\n\n            @Override\n            public Description appendValue(Object value) {\n                noteValue(value);\n                return super.appendValue(value);\n            }\n\n            private void noteValue(Object value) {\n                if (!expectedSeen) {\n                    expected = value;\n                    expectedSeen = true;\n                    return;\n                }\n\n                GuessMap newGuesses = guesses.replaceGuess(expected, value);\n                returnThis.add(new Guesser<T>(getType(), newGuesses));\n            }\n        });\n        return returnThis;\n    }\n\n    @Override\n    public Object getValue() throws CouldNotGenerateValueException {\n        return getProxy();\n    }\n\n    public Class<? extends T> getType() {\n        return type;\n    }\n\n    @Override\n    public String getDescription() throws CouldNotGenerateValueException {\n        return \"guesser[\" + type + \"]\";\n    }\n\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/GuesserQueue.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.internal.AssumptionViolatedException;\n\npublic class GuesserQueue extends ArrayList<ReguessableValue> {\n    static class ReguessableDecorator extends ReguessableValue {\n        private final PotentialAssignment delegate;\n\n        public ReguessableDecorator(PotentialAssignment delegate) {\n            this.delegate = delegate;\n        }\n\n        @Override\n        public List<ReguessableValue> reguesses(AssumptionViolatedException e) {\n            return Collections.emptyList();\n        }\n\n        @Override\n        public Object getValue() throws CouldNotGenerateValueException {\n            return delegate.getValue();\n        }\n\n        @Override\n        public String getDescription() throws CouldNotGenerateValueException {\n            return delegate.getDescription();\n        }\n    }\n\n    static GuesserQueue forSingleValues(\n            List<PotentialAssignment> potentials) {\n        GuesserQueue returnThis = new GuesserQueue();\n        for (PotentialAssignment potentialParameterValue : potentials) {\n            returnThis\n                    .add(new GuesserQueue.ReguessableDecorator(potentialParameterValue));\n        }\n        return returnThis;\n    }\n\n    private static final long serialVersionUID = 1L;\n    private ReguessableValue lastRemoved;\n\n    public void update(AssumptionViolatedException e) {\n        if (lastRemoved != null) {\n            addAll(lastRemoved.reguesses(e));\n        }\n    }\n\n    @Override\n    public ReguessableValue remove(int index) {\n        lastRemoved = super.remove(index);\n        return lastRemoved;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/MethodCall.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\nimport java.lang.reflect.Method;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class MethodCall {\n    private final Method method;\n    private final Object[] args;\n\n    public MethodCall(Method method, Object... args) {\n        this.method = method;\n        this.args = args;\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        MethodCall call = (MethodCall) obj;\n        return call.method.equals(method) && Arrays.deepEquals(call.args, args);\n    }\n\n    @Override\n    public int hashCode() {\n        return 1;\n    }\n\n    public Class<?> getReturnType() {\n        return method.getReturnType();\n    }\n\n    @Override\n    public String toString() {\n        return String.format(\"%s(%s)\", method.getName(), argListString());\n    }\n\n    private String argListString() {\n        if (args == null) {\n            return null;\n        }\n        return argList().toString().substring(1, argList().toString().length() - 1);\n    }\n\n    private List<Object> argList() {\n        ArrayList<Object> list = new ArrayList<Object>();\n        for (Object arg : args) {\n            list.add(new StringableObject(arg));\n        }\n        return list;\n    }\n\n    public Object stringableObject(Object arg) {\n        return new StringableObject(arg).stringableObject();\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/ReguessableValue.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\nimport java.util.List;\n\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.internal.AssumptionViolatedException;\n\npublic abstract class ReguessableValue extends PotentialAssignment {\n\n    public ReguessableValue() {\n        super();\n    }\n\n    public abstract List<ReguessableValue> reguesses(\n            AssumptionViolatedException e);\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/StringableObject.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\nimport java.util.Arrays;\n\npublic class StringableObject {\n    public Object obj;\n\n    public StringableObject(Object obj) {\n        this.obj = obj;\n    }\n\n    public Object stringableObject() {\n        if (isListableArray()) {\n            return Arrays.asList((Object[]) obj);\n        } else {\n            return obj;\n        }\n    }\n\n    private boolean isListableArray() {\n        Class<?> type = obj.getClass();\n        return type.isArray() && !type.getComponentType().isPrimitive();\n    }\n\n    @Override\n    public String toString() {\n        return stringableObject().toString();\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/Stub.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\n\n@Retention(RetentionPolicy.RUNTIME)\npublic @interface Stub {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/StubbedTheories.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.internal.Assignments;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.Statement;\nimport org.junit.runners.model.TestClass;\n\npublic class StubbedTheories extends Theories {\n    public StubbedTheories(Class<?> klass) throws InitializationError {\n        super(klass);\n    }\n\n    @Override\n    public Statement methodBlock(FrameworkMethod method) {\n        return new StubbedTheoryAnchor(method, getTestClass());\n    }\n\n    public static class StubbedTheoryAnchor extends TheoryAnchor {\n        public StubbedTheoryAnchor(FrameworkMethod method, TestClass testClass) {\n            super(method, testClass);\n        }\n\n        private List<GuesserQueue> queues = new ArrayList<GuesserQueue>();\n\n        @Override\n        protected void handleAssumptionViolation(AssumptionViolatedException e) {\n            super.handleAssumptionViolation(e);\n            for (GuesserQueue queue : queues) {\n                queue.update(e);\n            }\n        }\n\n        @Override\n        protected void runWithIncompleteAssignment(Assignments incomplete)\n                throws Throwable {\n            GuesserQueue guessers = createGuesserQueue(incomplete);\n            queues.add(guessers);\n            while (!guessers.isEmpty())\n                runWithAssignment(incomplete.assignNext(guessers.remove(0)));\n            queues.remove(guessers);\n        }\n\n        private GuesserQueue createGuesserQueue(Assignments incomplete)\n                throws Throwable {\n            ParameterSignature nextUnassigned = incomplete.nextUnassigned();\n\n            if (nextUnassigned.hasAnnotation(Stub.class)) {\n                GuesserQueue queue = new GuesserQueue();\n                queue.add(new Guesser<Object>(nextUnassigned.getType()));\n                return queue;\n            }\n\n            return GuesserQueue.forSingleValues(incomplete.potentialsForNextUnassigned());\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/StubbedTheoriesTest.java",
    "content": "package org.junit.tests.experimental.theories.extendingwithstubs;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.junit.Assume.assumeThat;\n\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\n@RunWith(StubbedTheories.class)\npublic class StubbedTheoriesTest {\n    @Theory\n    public void ask(@Stub Correspondent correspondent) {\n        assumeThat(correspondent.getAnswer(\"What is five?\", \"four\", \"five\"),\n                is(\"five\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/internal/AllMembersSupplierTest.java",
    "content": "package org.junit.tests.experimental.theories.internal;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotEquals;\nimport static org.junit.tests.experimental.theories.TheoryTestUtils.potentialAssignments;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.experimental.theories.internal.AllMembersSupplier;\nimport org.junit.rules.ExpectedException;\nimport org.junit.runners.model.TestClass;\n\npublic class AllMembersSupplierTest {\n    @Rule\n    public ExpectedException expected = ExpectedException.none();\n    \n    public static class HasDataPointsArrayField {\n        @DataPoints\n        public static String[] list = new String[] { \"qwe\", \"asd\" };\n\n        @Theory\n        public void theory(String param) {\n        }\n    }\n    \n    @Test\n    public void dataPointsArrayShouldBeRecognized() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(\n                HasDataPointsArrayField.class.getMethod(\"theory\", String.class));\n        \n        assertEquals(2, assignments.size());\n    }\n    \n    public static class HasDataPointsArrayWithMatchingButInaccurateTypes {\n        @DataPoints\n        public static Object[] objects = {1, \"string!\", 2};\n\n        @Theory\n        public void theory(Integer param) {\n        }\n    }\n\n    @Test\n    public void dataPointsArrayShouldBeRecognizedOnValueTypeNotFieldType() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(\n                HasDataPointsArrayWithMatchingButInaccurateTypes.class.getMethod(\"theory\", Integer.class));\n        \n        assertEquals(2, assignments.size());\n    }\n    \n    public static class HasDataPointMethodWithOverlyGeneralTypes {\n        @DataPoint\n        public static Integer object() {\n            return 1;\n        }\n\n        @Theory\n        public void theory(Object param) {\n        }\n    }\n\n    @Test\n    public void dataPointMethodShouldBeRecognizedForOverlyGeneralParameters() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(\n                HasDataPointMethodWithOverlyGeneralTypes.class.getMethod(\"theory\", Object.class));\n        \n        assertEquals(1, assignments.size());\n    }\n    \n    public static class HasDataPointsWithObjectParameter {\n        @DataPoints\n        public static Object[] objectField = {1, 2};\n\n        @Theory\n        public void theory(Object obj) {\n        }\n    }\n\n    @Test\n    public void dataPointsAnnotationMeansTreatAsArrayOnly() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(\n                HasDataPointsWithObjectParameter.class.getMethod(\"theory\", Object.class));\n        \n        assertEquals(2, assignments.size());\n        for (PotentialAssignment assignment : assignments) {\n            assertNotEquals(HasDataPointsWithObjectParameter.objectField, assignment.getValue());\n        }\n    }\n\n    public static class HasDataPointsFieldWithNullValue {\n        @DataPoints\n        public static Object[] objects = {null, \"a\"};\n\n        public HasDataPointsFieldWithNullValue(Object obj) {\n        }\n    }\n\n    @Test\n    public void dataPointsArrayFieldMayContainNullValue() throws Throwable {\n        List<PotentialAssignment> valueSources = allMemberValuesFor(\n                HasDataPointsFieldWithNullValue.class, Object.class);\n        assertThat(valueSources.size(), is(2));\n    }\n\n    public static class HasDataPointsMethodWithNullValue {\n        @DataPoints\n        public static Integer[] getObjects() {\n            return new Integer[] {null, 1};\n        }\n\n        public HasDataPointsMethodWithNullValue(Integer i) {\n        }\n    }\n\n    @Test\n    public void dataPointsArrayMethodMayContainNullValue() throws Throwable {\n        List<PotentialAssignment> valueSources = allMemberValuesFor(\n                HasDataPointsMethodWithNullValue.class, Integer.class);\n        assertThat(valueSources.size(), is(2));\n    }\n    \n    public static class HasFailingDataPointsArrayMethod {\n        @DataPoints\n        public static Object[] objects() {\n            throw new RuntimeException(\"failing method\");\n        }\n\n        public HasFailingDataPointsArrayMethod(Object obj) {\n        }\n    }\n\n    @Test\n    public void allMembersFailsOnFailingDataPointsArrayMethod() throws Throwable {\n        expected.expect(RuntimeException.class);\n        expected.expectMessage(\"failing method\");\n        allMemberValuesFor(HasFailingDataPointsArrayMethod.class, Object.class);\n    }\n\n    private List<PotentialAssignment> allMemberValuesFor(Class<?> testClass,\n            Class<?>... constructorParameterTypes) throws Throwable {\n        return new AllMembersSupplier(new TestClass(testClass))\n                .getValueSources(ParameterSignature.signatures(\n                        testClass.getConstructor(constructorParameterTypes))\n                        .get(0));\n    }\n    \n    public static class HasDataPointsListField {\n        @DataPoints\n        public static List<String> list = Arrays.asList(\"one\", \"two\");\n\n        @Theory\n        public void theory(String param) {\n        }\n    }\n\n    @Test\n    public void dataPointsCollectionFieldsShouldBeRecognized() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(\n            HasDataPointsListField.class.getMethod(\"theory\", String.class));\n\n        assertEquals(2, assignments.size());\n    }\n    \n    public static class HasDataPointsListMethod {\n        @DataPoints\n        public static List<String> getList() {\n            return Arrays.asList(\"one\", \"two\");\n        }\n\n        @Theory\n        public void theory(String param) {\n        }\n    }\n\n    @Test\n    public void dataPointsCollectionMethodShouldBeRecognized() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(\n            HasDataPointsListMethod.class.getMethod(\"theory\", String.class));\n\n        assertEquals(2, assignments.size());\n    }\n    \n    public static class HasDataPointsListFieldWithOverlyGenericTypes {\n        @DataPoints\n        public static List<Object> list = Arrays.asList(\"string\", new Object());\n\n        @Theory\n        public void theory(String param) {\n        }\n    }\n\n    @Test\n    public void dataPointsCollectionShouldBeRecognizedIgnoringStrangeTypes() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(\n            HasDataPointsListFieldWithOverlyGenericTypes.class.getMethod(\"theory\", String.class));\n\n        assertEquals(1, assignments.size());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/internal/AllTheoriesInternalTests.java",
    "content": "package org.junit.tests.experimental.theories.internal;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllMembersSupplierTest.class,\n        ParameterizedAssertionErrorTest.class,\n        SpecificDataPointsSupplierTest.class\n})\npublic class AllTheoriesInternalTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/internal/ParameterizedAssertionErrorTest.java",
    "content": "package org.junit.tests.experimental.theories.internal;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assume.assumeThat;\n\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.experimental.theories.internal.ParameterizedAssertionError;\nimport org.junit.runner.RunWith;\n\n@RunWith(Theories.class)\npublic class ParameterizedAssertionErrorTest {\n    @DataPoint\n    public static final String METHOD_NAME = \"methodName\";\n\n    @DataPoint\n    public static final NullPointerException NULL_POINTER_EXCEPTION = new NullPointerException();\n\n    @DataPoint\n    public static Object[] NO_OBJECTS = new Object[0];\n\n    @DataPoint\n    public static ParameterizedAssertionError A = new ParameterizedAssertionError(\n            NULL_POINTER_EXCEPTION, METHOD_NAME);\n\n    @DataPoint\n    public static ParameterizedAssertionError B = new ParameterizedAssertionError(\n            NULL_POINTER_EXCEPTION, METHOD_NAME);\n\n    @DataPoint\n    public static ParameterizedAssertionError B2 = new ParameterizedAssertionError(\n            NULL_POINTER_EXCEPTION, \"methodName2\");\n\n    @Theory\n    public void equalParameterizedAssertionErrorsHaveSameToString(\n            ParameterizedAssertionError a, ParameterizedAssertionError b) {\n        assumeThat(a, is(b));\n        assertThat(a.toString(), is(b.toString()));\n    }\n\n    @Theory\n    public void differentParameterizedAssertionErrorsHaveDifferentToStrings(\n            ParameterizedAssertionError a, ParameterizedAssertionError b) {\n        assumeThat(a, not(b));\n        assertThat(a.toString(), not(b.toString()));\n    }\n\n    @Theory\n    public void equalsReturnsTrue(Throwable targetException, String methodName,\n            Object[] params) {\n        assertThat(\n                new ParameterizedAssertionError(targetException, methodName, params),\n                is(new ParameterizedAssertionError(targetException, methodName, params)));\n    }\n\n    @Theory\n    public void sameHashCodeWhenEquals(Throwable targetException, String methodName,\n            Object[] params) {\n        ParameterizedAssertionError one = new ParameterizedAssertionError(\n                targetException, methodName, params);\n        ParameterizedAssertionError two = new ParameterizedAssertionError(\n                targetException, methodName, params);\n        assumeThat(one, is(two));\n\n        assertThat(one.hashCode(), is(two.hashCode()));\n    }\n\n    @Theory(nullsAccepted = false)\n    public void buildParameterizedAssertionError(String methodName, String param) {\n        assertThat(new ParameterizedAssertionError(\n                new RuntimeException(), methodName, param).toString(),\n                containsString(methodName));\n    }\n\n    @Theory\n    public void isNotEqualToNull(ParameterizedAssertionError a) {\n        assertFalse(a.equals(null));\n    }\n\n    @Test\n    public void canJoinWhenToStringFails() {\n        assertThat(ParameterizedAssertionError.join(\" \", new Object() {\n            @Override\n            public String toString() {\n                throw new UnsupportedOperationException();\n            }\n        }), is(\"[toString failed]\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/internal/SpecificDataPointsSupplierTest.java",
    "content": "package org.junit.tests.experimental.theories.internal;\n\nimport static org.hamcrest.CoreMatchers.hasItem;\nimport static org.hamcrest.CoreMatchers.hasItems;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.FromDataPoints;\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.PotentialAssignment.CouldNotGenerateValueException;\nimport org.junit.experimental.theories.internal.SpecificDataPointsSupplier;\nimport org.junit.runners.model.TestClass;\n\npublic class SpecificDataPointsSupplierTest {\n\n    public static class TestClassWithNamedDataPoints {\n\n        @DataPoints({\"field\", \"named\"})\n        public static String[] values = new String[] { \"named field\" };\n\n        @DataPoints\n        public static String[] otherValues = new String[] { \"other\" };\n        \n        @DataPoints({\"method\", \"named\"})\n        public static String[] getValues() {\n            return new String[] { \"named method\" };\n        }\n        \n        @DataPoint({\"single\", \"named\"})\n        public static String singleValue = \"named single value\";\n        \n        @DataPoint\n        public static String otherSingleValue = \"other value\";\n        \n        @DataPoint({\"singlemethod\", \"named\"})\n        public static String getSingleValue() { \n            return \"named single method value\";\n        }\n        \n        @DataPoint\n        public static String getSingleOtherValue() {\n            return \"other single method value\";\n        }\n         \n        @DataPoints\n        public static String[] getOtherValues() {\n            return new String[] { \"other method\" };\n        }\n    }\n\n    @Test\n    public void shouldReturnOnlyTheNamedDataPoints() throws Throwable {\n        SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));\n\n        List<PotentialAssignment> assignments = supplier.getValueSources(signature(\"methodWantingAllNamedStrings\"));\n        List<String> assignedStrings = getStringValuesFromAssignments(assignments);\n\n        assertEquals(4, assignedStrings.size());\n        assertThat(assignedStrings, hasItems(\"named field\", \"named method\", \"named single value\", \"named single method value\"));\n    }\n    \n    @Test\n    public void shouldReturnOnlyTheNamedFieldDataPoints() throws Throwable {\n        SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));\n\n        List<PotentialAssignment> assignments = supplier.getValueSources(signature(\"methodWantingNamedFieldString\"));\n        List<String> assignedStrings = getStringValuesFromAssignments(assignments);\n\n        assertEquals(1, assignedStrings.size());\n        assertThat(assignedStrings, hasItem(\"named field\"));\n    }\n\n    @Test\n    public void shouldReturnOnlyTheNamedMethodDataPoints() throws Throwable {\n        SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));\n\n        List<PotentialAssignment> assignments = supplier.getValueSources(signature(\"methodWantingNamedMethodString\"));\n        List<String> assignedStrings = getStringValuesFromAssignments(assignments);\n\n        assertEquals(1, assignedStrings.size());\n        assertThat(assignedStrings, hasItem(\"named method\"));\n    }\n    \n    @Test\n    public void shouldReturnOnlyTheNamedSingleFieldDataPoints() throws Throwable {\n        SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));\n\n        List<PotentialAssignment> assignments = supplier.getValueSources(signature(\"methodWantingNamedSingleFieldString\"));\n        List<String> assignedStrings = getStringValuesFromAssignments(assignments);\n\n        assertEquals(1, assignedStrings.size());\n        assertThat(assignedStrings, hasItem(\"named single value\"));\n    }\n\n    @Test\n    public void shouldReturnOnlyTheNamedSingleMethodDataPoints() throws Throwable {\n        SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));\n\n        List<PotentialAssignment> assignments = supplier.getValueSources(signature(\"methodWantingNamedSingleMethodString\"));\n        List<String> assignedStrings = getStringValuesFromAssignments(assignments);\n\n        assertEquals(1, assignedStrings.size());\n        assertThat(assignedStrings, hasItem(\"named single method value\"));\n    }    \n    \n    @Test\n    public void shouldReturnNothingIfTheNamedDataPointsAreMissing() throws Throwable {\n        SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));\n\n        List<PotentialAssignment> assignments = supplier.getValueSources(signature(\"methodWantingWrongNamedString\"));\n        List<String> assignedStrings = getStringValuesFromAssignments(assignments);\n\n        assertEquals(0, assignedStrings.size());\n    }\n\n    private List<String> getStringValuesFromAssignments(List<PotentialAssignment> assignments) throws CouldNotGenerateValueException {\n        List<String> stringValues = new ArrayList<String>();\n        for (PotentialAssignment assignment : assignments) {\n            stringValues.add((String) assignment.getValue());\n        }\n        return stringValues;\n    }\n\n    private ParameterSignature signature(String methodName) throws Exception {\n        return ParameterSignature.signatures(this.getClass().getMethod(methodName, String.class)).get(0);\n    }\n\n    public void methodWantingAnyString(String input) {\n    }\n\n    public void methodWantingNamedFieldString(@FromDataPoints(\"field\") String input) {\n    }\n    \n    public void methodWantingNamedMethodString(@FromDataPoints(\"method\") String input) {\n    }\n    \n    public void methodWantingNamedSingleFieldString(@FromDataPoints(\"single\") String input) {\n    }\n    \n    public void methodWantingNamedSingleMethodString(@FromDataPoints(\"singlemethod\") String input) {\n    }\n    \n    public void methodWantingAllNamedStrings(@FromDataPoints(\"named\") String input) {\n    }\n\n    public void methodWantingWrongNamedString(@FromDataPoints(\"invalid name\") String input) {\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/AllTheoriesRunnerTests.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        FailingDataPointMethods.class,\n        SuccessfulWithDataPointFields.class,\n        TheoriesPerformanceTest.class,\n        TypeMatchingBetweenMultiDataPointsMethod.class,\n        UnsuccessfulWithDataPointFields.class,\n        WhenNoParametersMatch.class,\n        WithAutoGeneratedDataPoints.class,\n        WithDataPointMethod.class,\n        WithExtendedParameterSources.class,\n        WithNamedDataPoints.class,\n        WithOnlyTestAnnotations.class,\n        WithParameterSupplier.class,\n        WithUnresolvedGenericTypeVariablesOnTheoryParms.class\n})\npublic class AllTheoriesRunnerTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/FailingDataPointMethods.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\npublic class FailingDataPointMethods {\n    \n    @RunWith(Theories.class)\n    public static class HasFailingSingleDataPointMethod {\n        @DataPoint\n        public static int num = 10;\n\n        @DataPoint\n        public static int failingDataPoint() {\n            throw new RuntimeException();\n        }\n\n        @Theory\n        public void theory(int x) {\n        }\n    }\n\n    @Test\n    public void shouldFailFromExceptionsInSingleDataPointMethods() {\n        assertThat(testResult(HasWronglyIgnoredFailingSingleDataPointMethod.class), not(isSuccessful()));\n    }\n    \n    @RunWith(Theories.class)\n    public static class HasFailingDataPointArrayMethod {\n        @DataPoints\n        public static int[] num = { 1, 2, 3 };\n\n        @DataPoints\n        public static int[] failingDataPoints() {\n            throw new RuntimeException();\n        }\n\n        @Theory\n        public void theory(int x) {\n        }\n    }\n\n    @Test\n    public void shouldFailFromExceptionsInDataPointArrayMethods() {\n        assertThat(testResult(HasFailingDataPointArrayMethod.class), not(isSuccessful()));\n    }\n    \n    @RunWith(Theories.class)\n    public static class HasIgnoredFailingSingleDataPointMethod {\n        @DataPoint\n        public static int num = 10;\n\n        @DataPoint(ignoredExceptions=Throwable.class)\n        public static int failingDataPoint() {\n            throw new RuntimeException();\n        }\n\n        @Theory\n        public void theory(int x) {\n        }\n    }\n    \n    @Test\n    public void shouldIgnoreSingleDataPointMethodExceptionsOnRequest() {\n        assertThat(testResult(HasIgnoredFailingSingleDataPointMethod.class), isSuccessful());\n    }\n    \n    @RunWith(Theories.class)\n    public static class HasIgnoredFailingMultipleDataPointMethod {\n        @DataPoint\n        public static int num = 10;\n\n        @DataPoints(ignoredExceptions=Throwable.class)\n        public static int[] failingDataPoint() {\n            throw new RuntimeException();\n        }\n\n        @Theory\n        public void theory(int x) {\n        }\n    }\n    \n    @Test\n    public void shouldIgnoreMultipleDataPointMethodExceptionsOnRequest() {\n        assertThat(testResult(HasIgnoredFailingMultipleDataPointMethod.class), isSuccessful());\n    }\n    \n    @RunWith(Theories.class)\n    public static class HasWronglyIgnoredFailingSingleDataPointMethod {\n        @DataPoint\n        public static int num = 10;\n\n        @DataPoint(ignoredExceptions=NullPointerException.class)\n        public static int failingDataPoint() {\n            throw new RuntimeException();\n        }\n\n        @Theory\n        public void theory(int x) {\n        }\n    }    \n    \n    @Test\n    public void shouldNotIgnoreNonMatchingSingleDataPointExceptions() {\n        assertThat(testResult(HasWronglyIgnoredFailingSingleDataPointMethod.class), not(isSuccessful()));\n    }\n    \n    @RunWith(Theories.class)\n    public static class HasWronglyIgnoredFailingMultipleDataPointMethod {\n        @DataPoint\n        public static int num = 10;\n\n        @DataPoint(ignoredExceptions=NullPointerException.class)\n        public static int failingDataPoint() {\n            throw new RuntimeException();\n        }\n\n        @Theory\n        public void theory(int x) {\n        }\n    }    \n    \n    @Test\n    public void shouldNotIgnoreNonMatchingMultipleDataPointExceptions() {\n        assertThat(testResult(HasWronglyIgnoredFailingMultipleDataPointMethod.class), not(isSuccessful()));\n    }\n    \n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/SuccessfulWithDataPointFields.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assume.assumeTrue;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.experimental.runners.Enclosed;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\n@RunWith(Enclosed.class)\npublic class SuccessfulWithDataPointFields {\n    @RunWith(Theories.class)\n    public static class HasATwoParameterTheory {\n        @DataPoint\n        public static int ONE = 1;\n\n        @Theory\n        public void allIntsAreEqual(int x, int y) {\n            assertThat(x, is(y));\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class BeforeAndAfterOnSameInstance {\n        @DataPoint\n        public static String A = \"A\";\n\n        private int befores = 0;\n\n        @Before\n        public void incrementBefore() {\n            befores++;\n        }\n\n        @Theory\n        public void stringsAreOK(String string) {\n            assertTrue(befores == 1);\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class NewObjectEachTime {\n        @DataPoint\n        public static String A = \"A\";\n\n        @DataPoint\n        public static String B = \"B\";\n\n        private List<String> list = new ArrayList<String>();\n\n        @Theory\n        public void addToEmptyList(String string) {\n            list.add(string);\n            assertThat(list.size(), is(1));\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class PositiveInts {\n        @DataPoint\n        public static final int ONE = 1;\n\n        private int x;\n\n        public PositiveInts(int x) {\n            assumeTrue(x > 0);\n            this.x = x;\n        }\n\n        @Theory\n        public void haveAPostiveSquare() {\n            assertTrue(x * x > 0);\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class PositiveIntsWithNegativeField {\n        @DataPoint\n        public static final int ONE = 1;\n        @DataPoint\n        public static final int NEGONE = -1;\n\n        private int x;\n\n        public PositiveIntsWithNegativeField(int x) {\n            assumeTrue(x > 0);\n            this.x = x;\n        }\n\n        @Theory\n        public void haveAPostiveSquare() {\n            assertTrue(x > 0);\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class PositiveIntsWithMethodParams {\n        @DataPoint\n        public static final int ONE = 1;\n\n        private int x;\n\n        public PositiveIntsWithMethodParams(int x) {\n            assumeTrue(x > 0);\n            this.x = x;\n        }\n\n        @Theory\n        public void haveAPostiveSquare(int y) {\n            assumeTrue(y > 0);\n            assertTrue(x * y > 0);\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class DifferentTypesInConstructor {\n        @DataPoint\n        public static final int ONE = 1;\n\n        @DataPoint\n        public static final String A = \"A\";\n\n        public DifferentTypesInConstructor(int x) {\n        }\n\n        @Theory\n        public void yesIndeed(String a) {\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class BeforeAndAfterEachTime {\n        public static int befores = 0;\n\n        @DataPoint\n        public static String A = \"A\";\n\n        @DataPoint\n        public static String B = \"B\";\n\n        @Before\n        public void incrementBefore() {\n            befores++;\n        }\n\n        @BeforeClass\n        public static void resetCalls() {\n            befores = 0;\n        }\n\n        @Theory\n        public void stringsAreOK(String string) {\n        }\n\n        @AfterClass\n        public static void calledTwice() {\n            assertEquals(2, befores);\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class OneTestTwoAnnotations {\n        public static int tests = 0;\n\n        @DataPoint\n        public static String A = \"A\";\n\n        @BeforeClass\n        public static void resetCalls() {\n            tests = 0;\n        }\n\n        @Theory\n        @Test\n        public void stringsAreOK(String string) {\n            tests++;\n        }\n\n        @AfterClass\n        public static void calledTwice() {\n            assertEquals(1, tests);\n        }\n    }\n\n    @RunWith(Theories.class)\n    public static class StaticPublicNonDataPoints {\n        // DataPoint which passes the test\n        @DataPoint\n        public static int ZERO = 0;\n\n        // Not annotated as a DataPoint and therefore should be ignored:\n        public static int ONE = 1;\n\n        @Theory\n        public void onlyAnnotatedFields(int i) {\n            assertTrue(i == 0);\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/TheoriesPerformanceTest.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assume.assumeTrue;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\npublic class TheoriesPerformanceTest {\n    @RunWith(Theories.class)\n    public static class UpToTen {\n        @DataPoints\n        public static int[] ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\n\n        @Theory\n        public void threeInts(int x, int y, int z) {\n            // pass always\n        }\n    }\n\n    private static final boolean TESTING_PERFORMANCE = false;\n\n    // If we do not share the same instance of TestClass, repeatedly parsing the\n    // class's annotations looking for @Befores and @Afters gets really costly.\n    //\n    // Likewise, the TestClass must be passed into AllMembersSupplier, or the\n    // annotation parsing is again costly.\n    @Test\n    public void tryCombinationsQuickly() {\n        assumeTrue(TESTING_PERFORMANCE);\n        assertThat(testResult(UpToTen.class), isSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/TypeMatchingBetweenMultiDataPointsMethod.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\npublic class TypeMatchingBetweenMultiDataPointsMethod {\n\n    @RunWith(Theories.class)\n    public static class WithWrongfullyTypedDataPointsMethod {\n        @DataPoint\n        public static String[] correctlyTyped = {\"Good\", \"Morning\"};\n\n        @DataPoints\n        public static String[] wrongfullyTyped() {\n            return new String[]{\"Hello\", \"World\"};\n        }\n\n        @Theory\n        public void testTheory(String[] array) {\n        }\n    }\n\n    @Test\n    public void ignoreWrongTypedDataPointsMethod() {\n        assertThat(testResult(WithWrongfullyTypedDataPointsMethod.class), isSuccessful());\n    }\n\n    @RunWith(Theories.class)\n    public static class WithCorrectlyTypedDataPointsMethod {\n        @DataPoint\n        public static String[] correctlyTyped = {\"Good\", \"Morning\"};\n\n        @DataPoints\n        public static String[][] anotherCorrectlyTyped() {\n            return new String[][]{\n                    {\"Hello\", \"World\"}\n            };\n        }\n\n        @Theory\n        public void testTheory(String[] array) {\n        }\n    }\n\n    @Test\n    public void pickUpMultiPointDataPointMethods() throws Exception {\n        assertThat(testResult(WithCorrectlyTypedDataPointsMethod.class), isSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/UnsuccessfulWithDataPointFields.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.hasFailureContaining;\nimport static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining;\nimport org.hamcrest.CoreMatchers;\nimport org.junit.Test;\nimport org.junit.experimental.results.PrintableResult;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.model.TestClass;\n\npublic class UnsuccessfulWithDataPointFields {\n    @RunWith(Theories.class)\n    public static class HasAFailingTheory {\n        @DataPoint\n        public static int ONE = 1;\n\n        @Theory\n        public void everythingIsZero(int x) {\n            assertThat(x, is(0));\n        }\n    }\n\n    @Test\n    public void theoryClassMethodsShowUp() throws Exception {\n        assertThat(new Theories(HasAFailingTheory.class).getDescription()\n                .getChildren().size(), is(1));\n    }\n\n    @Test\n    public void theoryAnnotationsAreRetained() throws Exception {\n        assertThat(new TestClass(HasAFailingTheory.class).getAnnotatedMethods(\n                Theory.class).size(), is(1));\n    }\n\n    @Test\n    public void canRunTheories() throws Exception {\n        assertThat(testResult(HasAFailingTheory.class),\n                hasSingleFailureContaining(\"Expected\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class DoesntUseParams {\n        @DataPoint\n        public static int ONE = 1;\n\n        @Theory\n        public void everythingIsZero(int x, int y) {\n            assertThat(2, is(3));\n        }\n    }\n\n    @Test\n    public void reportBadParams() throws Exception {\n        assertThat(testResult(DoesntUseParams.class),\n                hasSingleFailureContaining(\"everythingIsZero(\\\"1\\\" <from ONE>, \\\"1\\\" <from ONE>)\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class NullsOK {\n        @DataPoint\n        public static String NULL = null;\n\n        @DataPoint\n        public static String A = \"A\";\n\n        @Theory\n        public void everythingIsA(String a) {\n            assertThat(a, is(\"A\"));\n        }\n    }\n\n    @Test\n    public void nullsUsedUnlessProhibited() throws Exception {\n        assertThat(testResult(NullsOK.class),\n                hasSingleFailureContaining(\"null\"));\n    }\n    \n    @RunWith(Theories.class)\n    public static class TheoriesMustBePublic {\n        @DataPoint\n        public static int THREE = 3;\n\n        @Theory\n        void numbers(int x) {\n\n        }\n    }\n\n    @Test\n    public void theoriesMustBePublic() {\n        assertThat(\n                testResult(TheoriesMustBePublic.class),\n                hasSingleFailureContaining(\"public\"));\n    }    \n\n    @RunWith(Theories.class)\n    public static class DataPointFieldsMustBeStatic {\n        @DataPoint\n        public int THREE = 3;\n        \n        @DataPoints\n        public int[] FOURS = new int[] { 4 };\n        \n        @Theory\n        public void numbers(int x) {\n\n        }\n    }\n\n    @Test\n    public void dataPointFieldsMustBeStatic() {\n        assertThat(\n                testResult(DataPointFieldsMustBeStatic.class),\n                CoreMatchers.<PrintableResult>both(hasFailureContaining(\"DataPoint field THREE must be static\"))\n                        .and(hasFailureContaining(\"DataPoint field FOURS must be static\")));\n    }\n    \n    @RunWith(Theories.class)\n    public static class DataPointMethodsMustBeStatic {\n        @DataPoint\n        public int singleDataPointMethod() {\n            return 1;\n        }\n        \n        @DataPoints\n        public int[] dataPointArrayMethod() {\n            return new int[] { 1, 2, 3 };\n        }\n\n        @Theory\n        public void numbers(int x) {\n            \n        }\n    }\n    \n    @Test\n    public void dataPointMethodsMustBeStatic() {\n        assertThat(\n                testResult(DataPointMethodsMustBeStatic.class),\n                CoreMatchers.<PrintableResult>both(\n                        hasFailureContaining(\"DataPoint method singleDataPointMethod must be static\"))\n                .and(\n                        hasFailureContaining(\"DataPoint method dataPointArrayMethod must be static\")));\n    }\n\n    @RunWith(Theories.class)\n    public static class DataPointFieldsMustBePublic {\n        @DataPoint\n        static int THREE = 3;\n        \n        @DataPoints\n        static int[] THREES = new int[] { 3 };\n\n        @DataPoint\n        protected static int FOUR = 4;\n        \n        @DataPoints\n        protected static int[] FOURS = new int[] { 4 };\n\n        @DataPoint\n        private static int FIVE = 5;\n        \n        @DataPoints\n        private static int[] FIVES = new int[] { 5 };\n\n        @Theory\n        public void numbers(int x) {\n        \t\n        }\n    }\n\n    @Test\n    public void dataPointFieldsMustBePublic() {\n        PrintableResult result = testResult(DataPointFieldsMustBePublic.class);        \n\n        assertThat(result,\n                allOf(hasFailureContaining(\"DataPoint field THREE must be public\"),\n                      hasFailureContaining(\"DataPoint field THREES must be public\"),\n                      hasFailureContaining(\"DataPoint field FOUR must be public\"),\n                      hasFailureContaining(\"DataPoint field FOURS must be public\"),\n                      hasFailureContaining(\"DataPoint field FIVE must be public\"),\n                      hasFailureContaining(\"DataPoint field FIVES must be public\")));\n    }\n\n    @RunWith(Theories.class)\n    public static class DataPointMethodsMustBePublic {\n        @DataPoint\n        static int three() {\n            return 3;\n        }\n        \n        @DataPoints\n        static int[] threes() { \n            return new int[] { 3 };\n        }\n\n        @DataPoint\n        protected static int four() {\n            return 4;\n        }\n        \n        @DataPoints\n        protected static int[] fours() {\n            return new int[] { 4 };\n        }\n\n        @DataPoint\n        private static int five() {\n            return 5;\n        }\n        \n        @DataPoints\n        private static int[] fives() {\n            return new int[] { 5 };\n        }\n\n        @Theory\n        public void numbers(int x) {\n        \t\n        }\n    }\n    \n    @Test\n    public void dataPointMethodsMustBePublic() {\n        PrintableResult result = testResult(DataPointMethodsMustBePublic.class);        \n\n        assertThat(result,\n                allOf(hasFailureContaining(\"DataPoint method three must be public\"),\n                      hasFailureContaining(\"DataPoint method threes must be public\"),\n                      hasFailureContaining(\"DataPoint method four must be public\"),\n                      hasFailureContaining(\"DataPoint method fours must be public\"),\n                      hasFailureContaining(\"DataPoint method five must be public\"),\n                      hasFailureContaining(\"DataPoint method fives must be public\")));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WhenNoParametersMatch.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assume.assumeThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\n\nimport org.hamcrest.Matcher;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\n@RunWith(Theories.class)\npublic class WhenNoParametersMatch {\n    @DataPoints\n    public static int[] ints = {0, 1, 3, 5, 1776};\n\n    @DataPoints\n    public static Matcher<?>[] matchers = {not(0), is(1)};\n\n    @RunWith(Theories.class)\n    public static class AssumptionsFail {\n        @DataPoint\n        public static int DATA = 0;\n\n        @DataPoint\n        public static Matcher<Integer> MATCHER = null;\n\n        @Theory\n        public void nonZeroIntsAreFun(int x) {\n            assumeThat(x, MATCHER);\n        }\n    }\n\n    @Theory\n    public void showFailedAssumptionsWhenNoParametersFound(int data,\n            Matcher<Integer> matcher) throws Exception {\n        assumeThat(data, not(matcher));\n        AssumptionsFail.DATA = data;\n        AssumptionsFail.MATCHER = matcher;\n\n        String result = testResult(AssumptionsFail.class).toString();\n\n        assertThat(result, containsString(matcher.toString()));\n        assertThat(result, containsString(\"\" + data));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WithAutoGeneratedDataPoints.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.tests.experimental.theories.TheoryTestUtils.potentialAssignments;\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.runner.RunWith;\n\npublic class WithAutoGeneratedDataPoints {\n\n    private enum ENUM { VALUE, OTHER_VALUE, THIRD_VALUE }\n    \n    @RunWith(Theories.class)\n    public static class TheoryTestClassWithAutogeneratedParameterValues {\n        \n        public void theory(ENUM e) {\n        }\n        \n        public void theory(boolean b) {\n        }\n        \n    }\n    \n    @Test\n    public void shouldAutomaticallyGenerateEnumDataPoints() throws Throwable {\n        assertEquals(ENUM.values().length, potentialAssignments(\n                TheoryTestClassWithAutogeneratedParameterValues.class.getMethod(\"theory\", ENUM.class)).size());\n    }\n    \n    @Test\n    public void shouldAutomaticallyGenerateBooleanDataPoints() throws Throwable {\n        assertEquals(2, potentialAssignments(\n                TheoryTestClassWithAutogeneratedParameterValues.class.getMethod(\"theory\", boolean.class)).size());\n    }\n    \n    @RunWith(Theories.class)\n    public static class TheoryTestClassWithSpecificEnumDataPoint {\n        \n        @DataPoint\n        public static ENUM value = ENUM.OTHER_VALUE;\n        \n        public void theory(ENUM e) {\n        }\n        \n    }\n    \n    @Test\n    public void shouldNotAutogenerateEnumDataPointsWhenSpecificDataPointGiven() throws Throwable {\n        assertEquals(1, potentialAssignments(\n                TheoryTestClassWithSpecificEnumDataPoint.class.getMethod(\"theory\", ENUM.class)).size());\n    }\n    \n    @RunWith(Theories.class)\n    public static class TheoryTestClassWithSpecificBooleanDataPoint {\n        \n        @DataPoint\n        public static boolean value = true;\n        \n        public void theory(boolean b) {\n        }\n        \n    }\n    \n    @Test\n    public void shouldNotAutogenerateBooleanDataPointsWhenSpecificDataPointGiven() throws Throwable {\n        assertEquals(1, potentialAssignments(\n                TheoryTestClassWithSpecificBooleanDataPoint.class.getMethod(\"theory\", boolean.class)).size());\n    }    \n    \n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WithDataPointMethod.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.everyItem;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.CoreMatchers.nullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\nimport static org.junit.tests.experimental.theories.TheoryTestUtils.potentialAssignments;\n\nimport java.util.ArrayList;\nimport java.util.Date;\nimport java.util.List;\n\nimport org.hamcrest.Matcher;\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.notification.Failure;\n\npublic class WithDataPointMethod {\n    @RunWith(Theories.class)\n    public static class HasDataPointMethod {\n        @DataPoint\n        public static int oneHundred() {\n            return 100;\n        }\n\n        @Theory\n        public void allIntsOk(int x) {\n        }\n    }\n\n    @Test\n    public void pickUpDataPointMethods() {\n        assertThat(testResult(HasDataPointMethod.class), isSuccessful());\n    }\n\n    @RunWith(Theories.class)\n    public static class DataPointMethodReturnsMutableObject {\n        @DataPoint\n        public static List<Object> empty() {\n            return new ArrayList<Object>();\n        }\n\n        @DataPoint\n        public static int ONE = 1;\n\n        @DataPoint\n        public static int TWO = 2;\n\n        @Theory\n        public void everythingsEmpty(List<Object> first, int number) {\n            assertThat(first.size(), is(0));\n            first.add(\"a\");\n        }\n    }\n\n    @Test\n    public void mutableObjectsAreCreatedAfresh() {\n        assertThat(failures(DataPointMethodReturnsMutableObject.class), empty());\n    }\n\n    @RunWith(Theories.class)\n    public static class HasDateMethod {\n        @DataPoint\n        public static int oneHundred() {\n            return 100;\n        }\n\n        public static Date notADataPoint() {\n            return new Date();\n        }\n\n        @Theory\n        public void allIntsOk(int x) {\n        }\n\n        @Theory\n        public void onlyStringsOk(String s) {\n        }\n\n        @Theory\n        public void onlyDatesOk(Date d) {\n        }\n    }\n\n    @Test\n    public void ignoreDataPointMethodsWithWrongTypes() throws Throwable {\n        assertThat(potentialAssignments(\n                HasDateMethod.class.getMethod(\"onlyStringsOk\", String.class))\n                .toString(), not(containsString(\"100\")));\n    }\n\n    @Test\n    public void ignoreDataPointMethodsWithoutAnnotation() throws Throwable {\n        assertThat(potentialAssignments(\n                HasDateMethod.class.getMethod(\"onlyDatesOk\", Date.class))\n                .size(), is(0));\n    }\n\n    private List<Failure> failures(Class<?> type) {\n        return JUnitCore.runClasses(type).getFailures();\n    }\n\n    private Matcher<Iterable<Failure>> empty() {\n        return everyItem(nullValue(Failure.class));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WithExtendedParameterSources.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.CoreMatchers.notNullValue;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport org.junit.Test;\nimport org.junit.experimental.results.ResultMatchers;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.experimental.theories.suppliers.TestedOn;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.RunWith;\n\npublic class WithExtendedParameterSources {\n    @RunWith(Theories.class)\n    public static class ParameterAnnotations {\n        @Theory\n        public void everythingIsOne(@TestedOn(ints = {1})\n        int number) {\n            assertThat(number, is(1));\n        }\n    }\n\n    @Test\n    public void testedOnLimitsParameters() throws Exception {\n        assertThat(testResult(ParameterAnnotations.class), ResultMatchers\n                .isSuccessful());\n    }\n\n    @RunWith(Theories.class)\n    public static class ShouldFilterOutNullSingleDataPoints {\n\n        @DataPoint\n        public static String A = \"a\";\n        \n        @DataPoint\n        public static String NULL = null;\n\n        @Theory(nullsAccepted = false)\n        public void allStringsAreNonNull(String s) {\n            assertThat(s, notNullValue());\n        }\n    }\n\n    @Test\n    public void shouldFilterOutNullSingleDataPoints() {\n        assertThat(testResult(ShouldFilterOutNullSingleDataPoints.class), isSuccessful());\n    }\n\n    @RunWith(Theories.class)\n    public static class ShouldFilterOutNullElementsFromDataPointArrays {\n        @DataPoints\n        public static String[] SOME_NULLS = { \"non-null\", null };\n\n        @Theory(nullsAccepted = false)\n        public void allStringsAreNonNull(String s) {\n            assertThat(s, notNullValue());\n        }\n    }\n\n    @Test\n    public void shouldFilterOutNullElementsFromDataPointArrays() {\n        assertThat(testResult(ShouldFilterOutNullElementsFromDataPointArrays.class), isSuccessful());\n    }\n    \n    @RunWith(Theories.class)\n    public static class ShouldRejectTheoriesWithOnlyDisallowedNullData {\n        @DataPoints\n        public static String value = null;\n\n        @Theory(nullsAccepted = false)\n        public void allStringsAreNonNull(String s) {\n        }\n    }\n\n    @Test\n    public void ShouldRejectTheoriesWithOnlyDisallowedNullData() {\n        assertThat(testResult(ShouldRejectTheoriesWithOnlyDisallowedNullData.class), not(isSuccessful()));\n    }    \n\n    @RunWith(Theories.class)\n    public static class DataPointArrays {\n        public static String log = \"\";\n\n        @DataPoints\n        public static String[] STRINGS = new String[]{\"A\", \"B\"};\n\n        @Theory\n        public void addToLog(String string) {\n            log += string;\n        }\n    }\n\n    @Test\n    public void getDataPointsFromArray() {\n        DataPointArrays.log = \"\";\n        JUnitCore.runClasses(DataPointArrays.class);\n        assertThat(DataPointArrays.log, is(\"AB\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class DataPointArrayMethod {\n        public static String log = \"\";\n\n        @DataPoints\n        public static String[] STRINGS() {\n            return new String[]{\"A\", \"B\"};\n        }\n\n        @Theory\n        public void addToLog(String string) {\n            log += string;\n        }\n    }\n\n    @Test\n    public void getDataPointsFromArrayMethod() {\n        DataPointArrayMethod.log = \"\";\n        JUnitCore.runClasses(DataPointArrayMethod.class);\n        assertThat(DataPointArrayMethod.log, is(\"AB\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class DataPointMalformedArrayMethods {\n        public static String log = \"\";\n\n        @DataPoints\n        public static String[] STRINGS() {\n            return new String[]{\"A\", \"B\"};\n        }\n\n        @DataPoints\n        public static String STRING() {\n            return \"C\";\n        }\n\n        @DataPoints\n        public static int[] INTS() {\n            return new int[]{1, 2, 3};\n        }\n\n        @Theory\n        public void addToLog(String string) {\n            log += string;\n        }\n    }\n\n    @Test\n    public void getDataPointsFromArrayMethodInSpiteOfMalformedness() {\n        DataPointArrayMethod.log = \"\";\n        JUnitCore.runClasses(DataPointArrayMethod.class);\n        assertThat(DataPointArrayMethod.log, is(\"AB\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class DataPointArrayToBeUsedForWholeParameter {\n        public static String log = \"\";\n\n        @DataPoint\n        public static String[] STRINGS = new String[]{\"A\", \"B\"};\n\n        @Theory\n        public void addToLog(String[] strings) {\n            log += strings[0];\n        }\n    }\n\n    @Test\n    public void dataPointCanBeArray() {\n        DataPointArrayToBeUsedForWholeParameter.log = \"\";\n        JUnitCore.runClasses(DataPointArrayToBeUsedForWholeParameter.class);\n        assertThat(DataPointArrayToBeUsedForWholeParameter.log, is(\"A\"));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WithNamedDataPoints.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.tests.experimental.theories.TheoryTestUtils.potentialAssignments;\n\nimport java.util.List;\n\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.FromDataPoints;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\npublic class WithNamedDataPoints {\n\n    @RunWith(Theories.class)\n    public static class HasSpecificDatapointsParameters {\n        \n        @DataPoints\n        public static String[] badStrings = new String[] { \"bad\" };\n        \n        @DataPoint\n        public static String badString = \"also bad\";\n        \n        @DataPoints(\"named\")\n        public static String[] goodStrings = new String[] { \"expected\", \"also expected\" };\n        \n        @DataPoint(\"named\")\n        public static String goodString = \"expected single value\";\n        \n        @DataPoints(\"named\")\n        public static String[] methodStrings() {\n            return new String[] { \"expected method value\" };\n        }\n        \n        @DataPoint(\"named\")\n        public static String methodString() {\n            return \"expected single method string\";\n        }\n        \n        @DataPoints\n        public static String[] otherMethod() {\n            return new String[] { \"other method value\" };\n        }\n        \n        @DataPoint\n        public static String otherSingleValueMethod() {\n            return \"other single value string\";\n        }\n        \n        @Theory\n        public void theory(@FromDataPoints(\"named\") String param) {\n        }\n        \n    }\n    \n    @Test\n    public void onlyUseSpecificDataPointsIfSpecified() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(HasSpecificDatapointsParameters.class\n                .getMethod(\"theory\", String.class));\n        \n        assertEquals(5, assignments.size());\n        for (PotentialAssignment assignment : assignments) {\n            assertThat((String) assignment.getValue(), containsString(\"expected\"));\n        }\n    }\n    \n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WithOnlyTestAnnotations.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.failureCountIs;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport org.junit.Test;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\n\npublic class WithOnlyTestAnnotations {\n    @RunWith(Theories.class)\n    public static class HonorExpectedException {\n        @Test(expected = NullPointerException.class)\n        public void shouldThrow() {\n\n        }\n    }\n\n    @Test\n    public void honorExpected() throws Exception {\n        assertThat(testResult(HonorExpectedException.class).failureCount(), is(1));\n    }\n\n    @RunWith(Theories.class)\n    public static class HonorExpectedExceptionPasses {\n        @Test(expected = NullPointerException.class)\n        public void shouldThrow() {\n            throw new NullPointerException();\n        }\n    }\n\n    @Test\n    public void honorExpectedPassing() throws Exception {\n        assertThat(testResult(HonorExpectedExceptionPasses.class), isSuccessful());\n    }\n\n    @RunWith(Theories.class)\n    public static class HonorTimeout {\n        @Test(timeout = 5)\n        public void shouldStop() {\n            while (true) {\n                try {\n                    Thread.sleep(1000);\n                } catch (InterruptedException e) {\n\n                }\n            }\n        }\n    }\n\n    @Test\n    public void honorTimeout() throws Exception {\n        assertThat(testResult(HonorTimeout.class), failureCountIs(1));\n    }\n\n    @RunWith(Theories.class)\n    static public class ErrorWhenTestHasParametersDespiteTheories {\n        @DataPoint\n        public static int ZERO = 0;\n\n        @Test\n        public void testMethod(int i) {\n        }\n    }\n\n    @Test\n    public void testErrorWhenTestHasParametersDespiteTheories() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(ErrorWhenTestHasParametersDespiteTheories.class);\n        assertEquals(1, result.getFailureCount());\n        String message = result.getFailures().get(0).getMessage();\n        assertThat(message, containsString(\"should have no parameters\"));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WithParameterSupplier.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.tests.experimental.theories.TheoryTestUtils.potentialAssignments;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.experimental.theories.ParameterSignature;\nimport org.junit.experimental.theories.ParameterSupplier;\nimport org.junit.experimental.theories.ParametersSuppliedBy;\nimport org.junit.experimental.theories.PotentialAssignment;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.rules.ExpectedException;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.TestClass;\n\npublic class WithParameterSupplier {\n    \n    @Rule\n    public ExpectedException expected = ExpectedException.none();\n\n    private static class SimplePotentialAssignment extends PotentialAssignment {\n        private String description;\n        private Object value;\n\n        public SimplePotentialAssignment(Object value, String description) {\n            this.value = value;\n            this.description = description;\n        }\n\n        @Override\n        public Object getValue() throws CouldNotGenerateValueException {\n            return value;\n        }\n\n        @Override\n        public String getDescription() throws CouldNotGenerateValueException {\n            return description;\n        }\n    }\n\n    private static final List<String> DATAPOINTS = Arrays.asList(\"qwe\", \"asd\");\n\n    public static class SimpleSupplier extends ParameterSupplier {\n\n        @Override\n        public List<PotentialAssignment> getValueSources(ParameterSignature sig) {\n            List<PotentialAssignment> assignments = new ArrayList<PotentialAssignment>();\n\n            for (String datapoint : DATAPOINTS) {\n                assignments.add(new SimplePotentialAssignment(datapoint,\n                        datapoint));\n            }\n\n            return assignments;\n        }\n\n    }\n\n    @RunWith(Theories.class)\n    public static class TestClassUsingParameterSupplier {\n\n        @Theory\n        public void theoryMethod(@ParametersSuppliedBy(SimpleSupplier.class) String param) {\n        }\n\n    }\n\n    @Test\n    public void shouldPickUpDataPointsFromParameterSupplier() throws Throwable {\n        List<PotentialAssignment> assignments = potentialAssignments(TestClassUsingParameterSupplier.class\n                .getMethod(\"theoryMethod\", String.class));\n\n        assertEquals(2, assignments.size());\n        assertEquals(DATAPOINTS.get(0), assignments.get(0).getValue());\n        assertEquals(DATAPOINTS.get(1), assignments.get(1).getValue());\n    }\n    \n    public static class SupplierWithUnknownConstructor extends ParameterSupplier {\n        \n        public SupplierWithUnknownConstructor(String param) {\n        }\n\n        @Override\n        public List<PotentialAssignment> getValueSources(ParameterSignature sig) {\n            return null;\n        }\n\n    }\n\n    @RunWith(Theories.class)\n    public static class TestClassUsingSupplierWithUnknownConstructor {\n\n        @Theory\n        public void theory(@ParametersSuppliedBy(SupplierWithUnknownConstructor.class) String param) {\n        }\n\n    }\n    \n    @Test\n    public void shouldRejectSuppliersWithUnknownConstructors() throws Exception {\n        expected.expect(InitializationError.class);\n        new Theories(TestClassUsingSupplierWithUnknownConstructor.class);\n    }\n    \n    public static class SupplierWithTwoConstructors extends ParameterSupplier {\n        \n        public SupplierWithTwoConstructors(String param) {\n        }\n\n        @Override\n        public List<PotentialAssignment> getValueSources(ParameterSignature sig) {\n            return null;\n        }\n\n    }\n\n    @RunWith(Theories.class)\n    public static class TestClassUsingSupplierWithTwoConstructors {\n\n        @Theory\n        public void theory(@ParametersSuppliedBy(SupplierWithTwoConstructors.class) String param) {\n        }\n\n    }\n    \n    @Test\n    public void shouldRejectSuppliersWithTwoConstructors() throws Exception {\n        expected.expect(InitializationError.class);\n        new Theories(TestClassUsingSupplierWithTwoConstructors.class);\n    }\n    \n    public static class SupplierWithTestClassConstructor extends ParameterSupplier {\n        \n        public SupplierWithTestClassConstructor(TestClass param) {\n        }\n\n        @Override\n        public List<PotentialAssignment> getValueSources(ParameterSignature sig) {\n            return null;\n        }\n\n    }\n\n    @RunWith(Theories.class)\n    public static class TestClassUsingSupplierWithTestClassConstructor {\n\n        @Theory\n        public void theory(@ParametersSuppliedBy(SupplierWithTestClassConstructor.class) String param) {\n        }\n\n    }\n    \n    @Test\n    public void shouldAcceptSuppliersWithTestClassConstructor() throws Exception {\n        Theories unused = new Theories(TestClassUsingSupplierWithTestClassConstructor.class);\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/experimental/theories/runner/WithUnresolvedGenericTypeVariablesOnTheoryParms.java",
    "content": "package org.junit.tests.experimental.theories.runner;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.failureCountIs;\nimport static org.junit.experimental.results.ResultMatchers.hasFailureContaining;\nimport static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.junit.Test;\nimport org.junit.experimental.results.PrintableResult;\nimport org.junit.experimental.theories.DataPoint;\nimport org.junit.experimental.theories.DataPoints;\nimport org.junit.experimental.theories.Theories;\nimport org.junit.experimental.theories.Theory;\nimport org.junit.runner.RunWith;\n\npublic class WithUnresolvedGenericTypeVariablesOnTheoryParms {\n    @Test\n    public void whereTypeVariableIsOnTheTheory() {\n        PrintableResult result = testResult(TypeVariableOnTheoryOnly.class);\n        assertThat(result, isSuccessful());\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnTheoryOnly {\n        @DataPoint\n        public static List<String> strings = Arrays.asList(\"foo\", \"bar\");\n\n        @Theory\n        public <T> void forItems(Collection<?> items) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariableIsOnTheoryParm() {\n        PrintableResult result = testResult(TypeVariableOnTheoryParm.class);\n        assertThat(result, hasSingleFailureContaining(\"unresolved type variable T\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnTheoryParm {\n        @DataPoint\n        public static String string = \"foo\";\n\n        @Theory\n        public <T> void forItem(T item) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariableIsOnParameterizedTheoryParm() {\n        PrintableResult result = testResult(TypeVariableOnParameterizedTheoryParm.class);\n        assertThat(result, hasSingleFailureContaining(\"unresolved type variable T\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnParameterizedTheoryParm {\n        @DataPoint\n        public static List<String> strings = Arrays.asList(\"foo\", \"bar\");\n\n        @Theory\n        public <T> void forItems(Collection<T> items) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariableIsOnWildcardUpperBoundOnTheoryParm() {\n        PrintableResult result = testResult(TypeVariableOnWildcardUpperBoundOnTheoryParm.class);\n        assertThat(result, hasSingleFailureContaining(\"unresolved type variable U\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnWildcardUpperBoundOnTheoryParm {\n        @DataPoint\n        public static List<String> strings = Arrays.asList(\"foo\", \"bar\");\n\n        @Theory\n        public <U> void forItems(Collection<? extends U> items) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariableIsOnWildcardLowerBoundOnTheoryParm() {\n        PrintableResult result = testResult(TypeVariableOnWildcardLowerBoundOnTheoryParm.class);\n        assertThat(result, hasSingleFailureContaining(\"unresolved type variable V\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnWildcardLowerBoundOnTheoryParm {\n        @DataPoint\n        public static List<String> strings = Arrays.asList(\"foo\", \"bar\");\n\n        @Theory\n        public <V> void forItems(Collection<? super V> items) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariableIsOnArrayTypeOnTheoryParm() {\n        PrintableResult result = testResult(TypeVariableOnArrayTypeOnTheoryParm.class);\n        assertThat(result, hasSingleFailureContaining(\"unresolved type variable T\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnArrayTypeOnTheoryParm {\n        @DataPoints\n        public static String[][] items() {\n            return new String[][]{new String[]{\"foo\"}, new String[]{\"bar\"}};\n        }\n\n        @Theory\n        public <T> void forItems(T[] items) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariableIsOnComponentOfArrayTypeOnTheoryParm() {\n        PrintableResult result = testResult(TypeVariableOnComponentOfArrayTypeOnTheoryParm.class);\n        assertThat(result, hasSingleFailureContaining(\"unresolved type variable U\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnComponentOfArrayTypeOnTheoryParm {\n        @DataPoints\n        public static List<?>[][] items() {\n            return new List<?>[][]{\n                    new List<?>[]{Arrays.asList(\"foo\")},\n                    new List<?>[]{Arrays.asList(\"bar\")}\n            };\n        }\n\n        @Theory\n        public <U> void forItems(Collection<U>[] items) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariableIsOnTheoryClass() {\n        PrintableResult result = testResult(TypeVariableOnTheoryClass.class);\n        assertThat(result, hasSingleFailureContaining(\"unresolved type variable T\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariableOnTheoryClass<T> {\n        @DataPoint\n        public static String item = \"bar\";\n\n        @Theory\n        public void forItem(T item) {\n        }\n    }\n\n    @Test\n    public void whereTypeVariablesAbound() {\n        PrintableResult result = testResult(TypeVariablesAbound.class);\n        assertThat(result, failureCountIs(1));\n        assertThat(result, hasFailureContaining(\"unresolved type variable A\"));\n        assertThat(result, hasFailureContaining(\"unresolved type variable B\"));\n        assertThat(result, hasFailureContaining(\"unresolved type variable C\"));\n        assertThat(result, hasFailureContaining(\"unresolved type variable D\"));\n        assertThat(result, hasFailureContaining(\"unresolved type variable E\"));\n        assertThat(result, hasFailureContaining(\"unresolved type variable F\"));\n        assertThat(result, hasFailureContaining(\"unresolved type variable G\"));\n    }\n\n    @RunWith(Theories.class)\n    public static class TypeVariablesAbound<A, B extends A, C extends Collection<B>> {\n        @Theory\n        public <D, E extends D, F, G> void forItem(A first, Collection<B> second,\n                Map<C, ? extends D> third, List<? super E> fourth, F[] fifth,\n                Collection<G>[] sixth) {\n        }\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/AllJUnit3CompatibilityTests.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllTestsTest.class,\n        ClassRequestTest.class,\n        ForwardCompatibilityPrintingTest.class,\n        ForwardCompatibilityTest.class,\n        InitializationErrorForwardCompatibilityTest.class,\n        JUnit38ClassRunnerTest.class,\n        JUnit4TestAdapterTest.class,\n        OldTestClassAdaptingListenerTest.class,\n        OldTests.class,\n        SuiteMethodTest.class\n})\npublic class AllJUnit3CompatibilityTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/AllTestsTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.AllTests;\n\npublic class AllTestsTest {\n\n    private static boolean run;\n\n    public static class OneTest extends TestCase {\n        public void testSomething() {\n            run = true;\n        }\n    }\n\n    @RunWith(AllTests.class)\n    public static class All {\n        public static junit.framework.Test suite() {\n            TestSuite suite = new TestSuite();\n            suite.addTestSuite(OneTest.class);\n            return suite;\n        }\n    }\n\n    @org.junit.Test\n    public void ensureTestIsRun() {\n        JUnitCore runner = new JUnitCore();\n        run = false; // Have to explicitly set run here because the runner might independently run OneTest above\n        runner.run(All.class);\n        assertTrue(run);\n    }\n\n    @org.junit.Test\n    public void correctTestCount() throws Throwable {\n        AllTests tests = new AllTests(All.class);\n        assertEquals(1, tests.testCount());\n    }\n\n    @org.junit.Test\n    public void someUsefulDescription() throws Throwable {\n        AllTests tests = new AllTests(All.class);\n        assertThat(tests.getDescription().toString(), containsString(\"OneTest\"));\n    }\n\n    public static class JUnit4Test {\n        @org.junit.Test\n        public void testSomething() {\n            run = true;\n        }\n    }\n\n    @RunWith(AllTests.class)\n    public static class AllJUnit4 {\n        public static junit.framework.Test suite() {\n            TestSuite suite = new TestSuite();\n            suite.addTest(new JUnit4TestAdapter(JUnit4Test.class));\n            return suite;\n        }\n    }\n\n    @org.junit.Test\n    public void correctTestCountAdapted() throws Throwable {\n        AllTests tests = new AllTests(AllJUnit4.class);\n        assertEquals(1, tests.testCount());\n    }\n\n    @RunWith(AllTests.class)\n    public static class BadSuiteMethod {\n        public static junit.framework.Test suite() {\n            throw new RuntimeException(\"can't construct\");\n        }\n    }\n\n    @org.junit.Test(expected = RuntimeException.class)\n    public void exceptionThrownWhenSuiteIsBad() throws Throwable {\n        new AllTests(BadSuiteMethod.class);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/ClassRequestTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport static org.junit.Assert.assertNull;\n\nimport org.junit.Test;\nimport org.junit.internal.builders.SuiteMethodBuilder;\n\npublic class ClassRequestTest {\n    public static class PrivateSuiteMethod {\n        static junit.framework.Test suite() {\n            return null;\n        }\n    }\n\n    @Test\n    public void noSuiteMethodIfMethodPrivate() throws Throwable {\n        assertNull(new SuiteMethodBuilder()\n                .runnerForClass(PrivateSuiteMethod.class));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/ForwardCompatibilityPrintingTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.OutputStream;\nimport java.io.PrintStream;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\nimport junit.textui.ResultPrinter;\nimport junit.textui.TestRunner;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class ForwardCompatibilityPrintingTest extends TestCase {\n    static class TestResultPrinter extends ResultPrinter {\n        TestResultPrinter(PrintStream writer) {\n            super(writer);\n        }\n\n        /*\n           * Spoof printing time so the tests are deterministic\n           */\n        @Override\n        protected String elapsedTimeAsString(long runTime) {\n            return \"0\";\n        }\n    }\n\n    public void testError() {\n        ByteArrayOutputStream output = new ByteArrayOutputStream();\n        TestRunner runner = new TestRunner(new TestResultPrinter(\n                new PrintStream(output)));\n\n        String expected = expected(new String[]{\".E\", \"Time: 0\",\n                \"Errors here\", \"\", \"FAILURES!!!\",\n                \"Tests run: 1,  Failures: 0,  Errors: 1\", \"\"});\n        ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {\n            @Override\n            public void printErrors(TestResult result) {\n                getWriter().println(\"Errors here\");\n            }\n        };\n        runner.setPrinter(printer);\n        TestSuite suite = new TestSuite();\n        suite.addTest(new TestCase() {\n            @Override\n            public void runTest() throws Exception {\n                throw new Exception();\n            }\n        });\n        runner.doRun(suite);\n        assertEquals(expected, output.toString());\n    }\n\n    public static class ATest {\n        @Test\n        public void error() {\n            Assert.fail();\n        }\n    }\n\n    public void testErrorAdapted() {\n        ByteArrayOutputStream output = new ByteArrayOutputStream();\n        TestRunner runner = new TestRunner(new TestResultPrinter(\n                new PrintStream(output)));\n\n        String expected = expected(new String[]{\".E\", \"Time: 0\",\n                \"Errors here\", \"\", \"FAILURES!!!\",\n                \"Tests run: 1,  Failures: 0,  Errors: 1\", \"\"});\n        ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {\n            @Override\n            public void printErrors(TestResult result) {\n                getWriter().println(\"Errors here\");\n            }\n        };\n        runner.setPrinter(printer);\n        runner.doRun(new JUnit4TestAdapter(ATest.class));\n        assertEquals(expected, output.toString());\n    }\n\n    private String expected(String[] lines) {\n        OutputStream expected = new ByteArrayOutputStream();\n        PrintStream expectedWriter = new PrintStream(expected);\n        for (int i = 0; i < lines.length; i++) {\n            expectedWriter.println(lines[i]);\n        }\n        return expected.toString();\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/ForwardCompatibilityTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestCase;\nimport junit.framework.TestFailure;\nimport junit.framework.TestListener;\nimport junit.framework.TestResult;\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.RunNotifier;\n\npublic class ForwardCompatibilityTest extends TestCase {\n    static String fLog;\n\n    public static class NewTest {\n        @Before\n        public void before() {\n            fLog += \"before \";\n        }\n\n        @After\n        public void after() {\n            fLog += \"after \";\n        }\n\n        @Test\n        public void test() {\n            fLog += \"test \";\n        }\n    }\n\n    public void testCompatibility() {\n        fLog = \"\";\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(NewTest.class);\n        adapter.run(result);\n        assertEquals(\"before test after \", fLog);\n    }\n\n    public void testToString() {\n        JUnit4TestAdapter adapter = new JUnit4TestAdapter(NewTest.class);\n        junit.framework.Test test = adapter.getTests().get(0);\n        assertEquals(String.format(\"test(%s)\", NewTest.class.getName()), test.toString());\n    }\n\n    public void testUseGlobalCache() {\n        JUnit4TestAdapter adapter1 = new JUnit4TestAdapter(NewTest.class);\n        JUnit4TestAdapter adapter2 = new JUnit4TestAdapter(NewTest.class);\n        assertSame(adapter1.getTests().get(0), adapter2.getTests().get(0));\n    }\n\n    static Exception exception = new Exception();\n\n    public static class ErrorTest {\n        @Test\n        public void error() throws Exception {\n            throw exception;\n        }\n    }\n\n    public void testException() {\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(ErrorTest.class);\n        adapter.run(result);\n        assertEquals(exception, result.errors().nextElement().thrownException());\n    }\n\n    public void testNotifyResult() {\n        JUnit4TestAdapter adapter = new JUnit4TestAdapter(ErrorTest.class);\n        TestResult result = new TestResult();\n        final StringBuffer log = new StringBuffer();\n        result.addListener(new TestListener() {\n\n            public void startTest(junit.framework.Test test) {\n                log.append(\" start \").append(test);\n            }\n\n            public void endTest(junit.framework.Test test) {\n                log.append(\" end \").append(test);\n            }\n\n            public void addFailure(junit.framework.Test test, AssertionFailedError t) {\n                log.append(\" failure \").append(test);\n            }\n\n            public void addError(junit.framework.Test test, Throwable e) {\n                log.append(\" error \" + test);\n            }\n        });\n        adapter.run(result);\n        String testName = String.format(\"error(%s)\", ErrorTest.class.getName());\n        assertEquals(String.format(\" start %s error %s end %s\", testName, testName, testName), log.toString());\n    }\n\n\n    public static class NoExceptionTest {\n        @Test(expected = Exception.class)\n        public void succeed() throws Exception {\n        }\n    }\n\n    public void testNoException() {\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(NoExceptionTest.class);\n        adapter.run(result);\n        assertFalse(result.wasSuccessful());\n    }\n\n    public static class ExpectedTest {\n        @Test(expected = Exception.class)\n        public void expected() throws Exception {\n            throw new Exception();\n        }\n    }\n\n    public void testExpected() {\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(ExpectedTest.class);\n        adapter.run(result);\n        assertTrue(result.wasSuccessful());\n    }\n\n    public static class UnExpectedExceptionTest {\n        @Test(expected = Exception.class)\n        public void expected() throws Exception {\n            throw new Error();\n        }\n    }\n\n    static String log;\n\n    public static class BeforeClassTest {\n        @BeforeClass\n        public static void beforeClass() {\n            log += \"before class \";\n        }\n\n        @Before\n        public void before() {\n            log += \"before \";\n        }\n\n        @Test\n        public void one() {\n            log += \"test \";\n        }\n\n        @Test\n        public void two() {\n            log += \"test \";\n        }\n\n        @After\n        public void after() {\n            log += \"after \";\n        }\n\n        @AfterClass\n        public static void afterClass() {\n            log += \"after class \";\n        }\n    }\n\n    public void testBeforeAndAfterClass() {\n        log = \"\";\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(BeforeClassTest.class);\n        adapter.run(result);\n        assertEquals(\"before class before test after before test after after class \", log);\n    }\n\n    public static class ExceptionInBeforeTest {\n        @Before\n        public void error() {\n            throw new Error();\n        }\n\n        @Test\n        public void nothing() {\n        }\n    }\n\n    public void testExceptionInBefore() {\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(ExceptionInBeforeTest.class);\n        adapter.run(result);\n        assertEquals(1, result.errorCount());\n    }\n\n    public static class InvalidMethodTest {\n        @BeforeClass\n        public void shouldBeStatic() {\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    public void testInvalidMethod() {\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(InvalidMethodTest.class);\n        adapter.run(result);\n        assertEquals(1, result.errorCount());\n        TestFailure failure = result.errors().nextElement();\n        assertTrue(failure.exceptionMessage().contains(\"Method shouldBeStatic() should be static\"));\n    }\n\n    private static boolean wasRun = false;\n\n    public static class MarkerRunner extends Runner {\n        public MarkerRunner(Class<?> klass) {\n        }\n\n        @Override\n        public void run(RunNotifier notifier) {\n            wasRun = true;\n        }\n\n        @Override\n        public int testCount() {\n            return 0;\n        }\n\n        @Override\n        public Description getDescription() {\n            return Description.EMPTY;\n        }\n    }\n\n    @RunWith(MarkerRunner.class)\n    public static class NoTests {\n    }\n\n    public void testRunWithClass() {\n        wasRun = false;\n        TestResult result = new TestResult();\n        junit.framework.Test adapter = new JUnit4TestAdapter(NoTests.class);\n        adapter.run(result);\n        assertTrue(wasRun);\n    }\n\n    public void testToStringSuite() {\n        junit.framework.Test adapter = new JUnit4TestAdapter(NoTests.class);\n        assertEquals(NoTests.class.getName(), adapter.toString());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/InitializationErrorForwardCompatibilityTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.assertTrue;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestListener;\nimport junit.framework.TestResult;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\npublic class InitializationErrorForwardCompatibilityTest {\n    public static class CantInitialize extends Runner {\n        private static final String UNIQUE_ERROR_MESSAGE = \"Unique error message\";\n\n        public CantInitialize(Class<?> klass) throws Exception {\n            throw new Exception(UNIQUE_ERROR_MESSAGE);\n        }\n\n        @Override\n        public Description getDescription() {\n            return Description.EMPTY;\n        }\n\n        @Override\n        public void run(RunNotifier notifier) {\n        }\n    }\n\n    @RunWith(CantInitialize.class)\n    public static class CantInitializeTests {\n    }\n\n    private JUnit4TestAdapter fAdapter;\n\n    @Before\n    public void createAdapter() {\n        fAdapter = new JUnit4TestAdapter(\n                CantInitializeTests.class);\n    }\n\n    @Test\n    public void initializationErrorsShowUpAsWarnings() {\n        assertEquals(1, fAdapter.getTests().size());\n    }\n\n    @Test\n    public void initializationErrorsAreThrownAtRuntime() {\n        TestResult result = new TestResult();\n        fAdapter.run(result);\n        assertEquals(1, result.errorCount());\n        assertEquals(CantInitialize.UNIQUE_ERROR_MESSAGE, result.errors()\n                .nextElement().exceptionMessage());\n    }\n\n    private final class ErrorRememberingListener implements TestListener {\n        private junit.framework.Test fError;\n\n        public void addError(junit.framework.Test test, Throwable e) {\n            fError = test;\n        }\n\n        public void addFailure(junit.framework.Test test,\n                AssertionFailedError t) {\n        }\n\n        public void endTest(junit.framework.Test test) {\n        }\n\n        public void startTest(junit.framework.Test test) {\n        }\n\n        public junit.framework.Test getError() {\n            return fError;\n        }\n    }\n\n    @Test\n    public void generatedErrorTestsMatchUp() {\n        junit.framework.Test shouldFail = fAdapter.getTests().get(0);\n        TestResult result = new TestResult();\n        ErrorRememberingListener listener = new ErrorRememberingListener();\n        result.addListener(listener);\n        fAdapter.run(result);\n        assertNotNull(listener.getError());\n        assertTrue(shouldFail == listener.getError());\n    }\n\n    public static class InitializesWithError extends BlockJUnit4ClassRunner {\n        public InitializesWithError(Class<?> klass) throws Exception {\n            super(klass);\n            throw new Exception();\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/JUnit38ClassRunnerTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNull;\nimport static org.junit.Assert.assertNotNull;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\nimport junit.extensions.TestDecorator;\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\nimport org.junit.Assert;\nimport org.junit.Test;\nimport org.junit.internal.runners.JUnit38ClassRunner;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.NoTestsRemainException;\n\npublic class JUnit38ClassRunnerTest {\n    public static class MyTest extends TestCase {\n        public void testA() {\n\n        }\n    }\n\n    @Test\n    public void plansDecoratorCorrectly() {\n        JUnit38ClassRunner runner = new JUnit38ClassRunner(new TestDecorator(new TestSuite(MyTest.class)));\n        assertEquals(1, runner.testCount());\n    }\n\n    public static class AnnotatedTest {\n        @Test\n        public void foo() {\n            Assert.fail();\n        }\n    }\n\n    @Test\n    public void canUnadaptAnAdapter() {\n        JUnit38ClassRunner runner = new JUnit38ClassRunner(new JUnit4TestAdapter(AnnotatedTest.class));\n        Result result = new JUnitCore().run(runner);\n        Failure failure = result.getFailures().get(0);\n        assertEquals(Description.createTestDescription(AnnotatedTest.class, \"foo\"), failure.getDescription());\n    }\n\n    static int count;\n\n    public static class OneTest extends TestCase {\n        public void testOne() {\n        }\n    }\n\n    @Test\n    public void testListener() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        RunListener listener = new RunListener() {\n            @Override\n            public void testStarted(Description description) {\n                assertEquals(Description.createTestDescription(OneTest.class, \"testOne\"),\n                        description);\n                count++;\n            }\n        };\n\n        runner.addListener(listener);\n        count = 0;\n        Result result = runner.run(OneTest.class);\n        assertEquals(1, count);\n        assertEquals(1, result.getRunCount());\n    }\n\n    public static class ClassWithInvalidMethod extends TestCase {\n        @SuppressWarnings(\"unused\")\n        private void testInvalid() {\n        }\n    }\n\n    @Test\n    public void invalidTestMethodReportedCorrectly() {\n        Result result = JUnitCore.runClasses(ClassWithInvalidMethod.class);\n        Failure failure = result.getFailures().get(0);\n        assertEquals(\"warning\", failure.getDescription().getMethodName());\n        assertEquals(\"junit.framework.TestSuite$1\", failure.getDescription().getClassName());\n    }\n\n    @Retention(RetentionPolicy.RUNTIME)\n    @Target(ElementType.METHOD)\n    public static @interface MyAnnotation {\n    }\n\n    public static class JUnit3ClassWithAnnotatedMethod extends TestCase {\n        @MyAnnotation\n        public void testAnnotated() {\n        }\n\n        public void testNotAnnotated() {\n        }\n    }\n\n    public static class DerivedAnnotatedMethod extends JUnit3ClassWithAnnotatedMethod {\n    }\n\n    @Test\n    public void getDescriptionWithAnnotation() {\n        JUnit38ClassRunner runner = new JUnit38ClassRunner(JUnit3ClassWithAnnotatedMethod.class);\n        assertAnnotationFiltering(runner);\n    }\n    \n    @Test\n    public void getDescriptionWithAnnotationInSuper() {\n        JUnit38ClassRunner runner = new JUnit38ClassRunner(DerivedAnnotatedMethod.class);\n        assertAnnotationFiltering(runner);\n    }\n\n    private void assertAnnotationFiltering(JUnit38ClassRunner runner) {\n        Description d = runner.getDescription();\n        assertEquals(2, d.testCount());\n        for (Description methodDesc : d.getChildren()) {\n            if (methodDesc.getMethodName().equals(\"testAnnotated\")) {\n                assertNotNull(methodDesc.getAnnotation(MyAnnotation.class));\n            } else {\n                assertNull(methodDesc.getAnnotation(MyAnnotation.class));\n            }\n        }\n    }\n\n    public static class RejectAllTestsFilter extends Filter {\n        @Override\n        public boolean shouldRun(Description description) {\n            return description.isSuite();\n        }\n\n        @Override\n        public String describe() {\n            return \"filter all\";\n        }\n    }\n\n    /**\n     * Test that NoTestsRemainException is thrown when all methods have been filtered.\n     */\n    @Test(expected = NoTestsRemainException.class) \n    public void filterNoTestsRemain() throws NoTestsRemainException {\n        JUnit38ClassRunner runner = new JUnit38ClassRunner(OneTest.class);\n        runner.filter(new RejectAllTestsFilter());  \n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/JUnit4TestAdapterTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.Collections;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestCase;\nimport junit.framework.TestResult;\nimport junit.framework.TestSuite;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\npublic class JUnit4TestAdapterTest {\n\n    private static void doTest(Class<?> clazz) {\n        // JUnit 4 runner:\n        Result result = JUnitCore.runClasses(clazz);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n        assertEquals(0, result.getIgnoreCount());\n\n        // JUnit 3 runner:\n        TestResult testResult = new TestResult();\n        new JUnit4TestAdapter(clazz).run(testResult);\n        assertEquals(1, testResult.runCount());\n        assertEquals(0, testResult.failureCount());\n        assertEquals(Collections.emptyList(), Collections.list(testResult.errors()));\n    }\n\n    public static class Test4 {\n        @Test\n        public void pass() throws Exception {\n            //pass\n        }\n    }\n\n    @RunWith(Suite.class)\n    @Suite.SuiteClasses(Test4.class)\n    public static class TestSuiteFor4 {\n    }\n\n    @Test\n    public void testJUnit4Suite() {\n        doTest(TestSuiteFor4.class);\n    }\n\n    public static class Test3 extends TestCase {\n        public void testPass() throws Exception {\n            //pass\n        }\n    }\n\n    @RunWith(Suite.class)\n    @Suite.SuiteClasses(Test3.class)\n    public static class TestSuiteFor3 {\n    }\n\n    @Test\n    public void testJUnit3Suite() {\n        doTest(TestSuiteFor3.class);\n    }\n\n    public static class TestSuite3 {\n        public static junit.framework.Test suite() {\n            return new TestSuite(Test3.class);\n        }\n    }\n\n    @RunWith(Suite.class)\n    @Suite.SuiteClasses(TestSuite3.class)\n    public static class TestSuite4ForTestSuite3 {\n    }\n\n    @Test\n    public void testJUnit4SuiteThatContainsJUnit3SuiteClass() {\n        doTest(TestSuite4ForTestSuite3.class);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/OldTestClassAdaptingListenerTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport static org.junit.Assert.assertEquals;\n\nimport junit.framework.AssertionFailedError;\nimport junit.framework.TestCase;\nimport junit.framework.TestListener;\nimport org.junit.Test;\nimport org.junit.internal.runners.JUnit38ClassRunner;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runner.notification.RunNotifier;\n\npublic class OldTestClassAdaptingListenerTest {\n    @Test\n    public void addFailureDelegatesToNotifier() {\n        Result result = new Result();\n        RunListener listener = result.createListener();\n        RunNotifier notifier = new RunNotifier();\n        notifier.addFirstListener(listener);\n        TestCase testCase = new TestCase() {\n        };\n        TestListener adaptingListener = new JUnit38ClassRunner(testCase)\n                .createAdaptingListener(notifier);\n        adaptingListener.addFailure(testCase, new AssertionFailedError());\n        assertEquals(1, result.getFailureCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/OldTests.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport junit.framework.Test;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.AllTests;\n\n@RunWith(AllTests.class)\npublic class OldTests {\n    public static Test suite() {\n        return junit.tests.AllTests.suite();\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/junit3compatibility/SuiteMethodTest.java",
    "content": "package org.junit.tests.junit3compatibility;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\n\npublic class SuiteMethodTest {\n    public static boolean wasRun;\n\n    public static class OldTest extends TestCase {\n        public OldTest(String name) {\n            super(name);\n        }\n\n        public static junit.framework.Test suite() {\n            TestSuite suite = new TestSuite();\n            suite.addTest(new OldTest(\"notObviouslyATest\"));\n            return suite;\n        }\n\n        public void notObviouslyATest() {\n            wasRun = true;\n        }\n    }\n\n    @Test\n    public void makeSureSuiteIsCalled() {\n        wasRun = false;\n        JUnitCore.runClasses(OldTest.class);\n        assertTrue(wasRun);\n    }\n\n    public static class NewTest {\n        @Test\n        public void sample() {\n            wasRun = true;\n        }\n\n        public static junit.framework.Test suite() {\n            return new JUnit4TestAdapter(NewTest.class);\n        }\n    }\n\n    @Test\n    public void makeSureSuiteWorksWithJUnit4Classes() {\n        wasRun = false;\n        JUnitCore.runClasses(NewTest.class);\n        assertTrue(wasRun);\n    }\n\n\n    public static class CompatibilityTest {\n        @Ignore\n        @Test\n        public void ignored() {\n        }\n\n        public static junit.framework.Test suite() {\n            return new JUnit4TestAdapter(CompatibilityTest.class);\n        }\n    }\n\n    // when executing as JUnit 3, ignored tests are stripped out before execution\n    @Test\n    public void descriptionAndRunNotificationsAreConsistent() {\n        Result result = JUnitCore.runClasses(CompatibilityTest.class);\n        assertEquals(0, result.getIgnoreCount());\n\n        Description description = Request.aClass(CompatibilityTest.class).getRunner().getDescription();\n        assertEquals(0, description.getChildren().size());\n    }\n\n    public static class NewTestSuiteFails {\n        @Test\n        public void sample() {\n            wasRun = true;\n        }\n\n        public static junit.framework.Test suite() {\n            fail(\"called with JUnit 4 runner\");\n            return null;\n        }\n    }\n\n    @Test\n    public void suiteIsUsedWithJUnit4Classes() {\n        wasRun = false;\n        Result result = JUnitCore.runClasses(NewTestSuiteFails.class);\n        assertEquals(1, result.getFailureCount());\n        assertFalse(wasRun);\n    }\n\n    public static class NewTestSuiteNotUsed {\n        private static boolean wasIgnoredRun;\n\n        @Test\n        public void sample() {\n            wasRun = true;\n        }\n\n        @Ignore\n        @Test\n        public void ignore() {\n            wasIgnoredRun = true;\n        }\n\n        public static junit.framework.Test suite() {\n            return new JUnit4TestAdapter(NewTestSuiteNotUsed.class);\n        }\n    }\n\n    @Test\n    public void makeSureSuiteNotUsedWithJUnit4Classes2() {\n        wasRun = false;\n        NewTestSuiteNotUsed.wasIgnoredRun = false;\n        Result res = JUnitCore.runClasses(NewTestSuiteNotUsed.class);\n        assertTrue(wasRun);\n        assertFalse(NewTestSuiteNotUsed.wasIgnoredRun);\n        assertEquals(0, res.getFailureCount());\n        assertEquals(1, res.getRunCount());\n        assertEquals(0, res.getIgnoreCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/listening/AllListeningTests.java",
    "content": "package org.junit.tests.listening;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        ListenerTest.class,\n        RunnerTest.class,\n        TestListenerTest.class,\n        TextListenerTest.class,\n        UserStopTest.class\n})\npublic class AllListeningTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/listening/ListenerTest.java",
    "content": "package org.junit.tests.listening;\n\nimport static org.junit.Assert.assertEquals;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.notification.RunListener;\n\npublic class ListenerTest {\n    private static String log;\n\n    public static class OneTest {\n        @Test\n        public void nothing() {\n        }\n    }\n\n    @Test\n    public void notifyListenersInTheOrderInWhichTheyAreAdded() {\n        JUnitCore core = new JUnitCore();\n        log = \"\";\n        core.addListener(new RunListener() {\n            @Override\n            public void testRunStarted(Description description) throws Exception {\n                log += \"first \";\n            }\n        });\n        core.addListener(new RunListener() {\n            @Override\n            public void testRunStarted(Description description) throws Exception {\n                log += \"second \";\n            }\n        });\n        core.run(OneTest.class);\n        assertEquals(\"first second \", log);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/listening/RunnerTest.java",
    "content": "package org.junit.tests.listening;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport junit.framework.TestCase;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.notification.RunListener;\n\npublic class RunnerTest {\n\n    private boolean wasRun;\n\n    public class MyListener extends RunListener {\n\n        int testCount;\n\n        @Override\n        public void testRunStarted(Description description) {\n            this.testCount = description.testCount();\n        }\n    }\n\n    public static class Example {\n        @Test\n        public void empty() {\n        }\n    }\n\n    @Test\n    public void newTestCount() {\n        JUnitCore runner = new JUnitCore();\n        MyListener listener = new MyListener();\n        runner.addListener(listener);\n        runner.run(Example.class);\n        assertEquals(1, listener.testCount);\n    }\n\n    public static class ExampleTest extends TestCase {\n        public void testEmpty() {\n        }\n    }\n\n    @Test\n    public void oldTestCount() {\n        JUnitCore runner = new JUnitCore();\n        MyListener listener = new MyListener();\n        runner.addListener(listener);\n        runner.run(ExampleTest.class);\n        assertEquals(1, listener.testCount);\n    }\n\n    public static class NewExample {\n        @Test\n        public void empty() {\n        }\n    }\n\n    @Test\n    public void testFinished() {\n        JUnitCore runner = new JUnitCore();\n        wasRun = false;\n        RunListener listener = new MyListener() {\n            @Override\n            public void testFinished(Description description) {\n                wasRun = true;\n            }\n        };\n        runner.addListener(listener);\n        runner.run(NewExample.class);\n        assertTrue(wasRun);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/listening/TestListenerTest.java",
    "content": "package org.junit.tests.listening;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotSame;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\n\npublic class TestListenerTest {\n\n    int count;\n\n    class ErrorListener extends RunListener {\n        @Override\n        public void testRunStarted(Description description) throws Exception {\n            throw new Error();\n        }\n    }\n\n    public static class OneTest {\n        @Test\n        public void nothing() {\n        }\n    }\n\n    @Test(expected = Error.class)\n    public void failingListener() {\n        JUnitCore runner = new JUnitCore();\n        runner.addListener(new ErrorListener());\n        runner.run(OneTest.class);\n    }\n\n    class ExceptionListener extends ErrorListener {\n        @Override\n        public void testRunStarted(Description description) throws Exception {\n            count++;\n            throw new Exception();\n        }\n    }\n\n    @Test\n    public void reportsFailureOfListener() {\n        JUnitCore core = new JUnitCore();\n        core.addListener(new ExceptionListener());\n\n        count = 0;\n        Result result = core.run(OneTest.class);\n        assertEquals(1, count);\n        assertEquals(1, result.getFailureCount());\n        Failure testFailure = result.getFailures().get(0);\n        assertEquals(Description.TEST_MECHANISM, testFailure.getDescription());\n    }\n\n    @Test\n    public void freshResultEachTime() {\n        JUnitCore core = new JUnitCore();\n        Result first = core.run(OneTest.class);\n        Result second = core.run(OneTest.class);\n        assertNotSame(first, second);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/listening/TextListenerTest.java",
    "content": "package org.junit.tests.listening;\n\nimport static org.hamcrest.core.IsNot.not;\nimport static org.hamcrest.core.StringContains.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.OutputStream;\nimport java.io.PrintStream;\n\nimport junit.framework.TestCase;\nimport org.junit.Test;\nimport org.junit.internal.TextListener;\nimport org.junit.runner.JUnitCore;\nimport org.junit.tests.TestSystem;\n\npublic class TextListenerTest extends TestCase {\n\n    private JUnitCore runner;\n    private OutputStream results;\n\n    @Override\n    public void setUp() {\n        runner = new JUnitCore();\n        TestSystem system = new TestSystem();\n        results = system.outContents();\n        runner.addListener(new TextListener(system));\n    }\n\n    public static class OneTest {\n        @Test\n        public void one() {\n        }\n    }\n\n    public void testSuccess() throws Exception {\n        runner.run(OneTest.class);\n        assertTrue(results.toString().startsWith(convert(\".\\nTime: \")));\n        assertTrue(results.toString().endsWith(convert(\"\\n\\nOK (1 test)\\n\\n\")));\n    }\n\n    public static class ErrorTest {\n        @Test\n        public void error() throws Exception {\n            throw new Exception();\n        }\n    }\n\n    public void testError() throws Exception {\n        runner.run(ErrorTest.class);\n        assertTrue(results.toString().startsWith(convert(\".E\\nTime: \")));\n        assertTrue(results.toString().indexOf(convert(\"\\nThere was 1 failure:\\n1) error(org.junit.tests.listening.TextListenerTest$ErrorTest)\\njava.lang.Exception\")) != -1);\n    }\n\n    public static class Time {\n        @Test\n        public void time() {\n        }\n    }\n\n    public void testTime() {\n        runner.run(Time.class);\n        assertThat(results.toString(), containsString(\"Time: \"));\n        assertThat(results.toString(), not(containsString(convert(\"Time: \\n\"))));\n    }\n\n    private String convert(String string) {\n        OutputStream resultsStream = new ByteArrayOutputStream();\n        PrintStream writer = new PrintStream(resultsStream);\n        writer.println();\n        return string.replace(\"\\n\", resultsStream.toString());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/listening/UserStopTest.java",
    "content": "package org.junit.tests.listening;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.Request;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runner.notification.StoppedByUserException;\n\npublic class UserStopTest {\n    private RunNotifier fNotifier;\n\n    @Before\n    public void createNotifier() {\n        fNotifier = new RunNotifier();\n        fNotifier.pleaseStop();\n    }\n\n    @Test(expected = StoppedByUserException.class)\n    public void userStop() {\n        fNotifier.fireTestStarted(null);\n    }\n\n    public static class OneTest {\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test(expected = StoppedByUserException.class)\n    public void stopClassRunner() throws Exception {\n        Request.aClass(OneTest.class).getRunner().run(fNotifier);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/AllManipulationTests.java",
    "content": "package org.junit.tests.manipulation;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        FilterableTest.class,\n        FilterTest.class,\n        OrderableTest.class,\n        OrderWithTest.class,\n        SingleMethodTest.class,\n        SortableTest.class\n})\npublic class AllManipulationTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/AlphanumericOrdering.java",
    "content": "package org.junit.tests.manipulation;\n\nimport org.junit.runner.manipulation.Ordering;\n\n/**\n * An ordering that orders tests alphanumerically by test name.\n */\npublic final class AlphanumericOrdering implements Ordering.Factory {\n    public static final ComparatorBasedOrdering INSTANCE = new ComparatorBasedOrdering(\n            Comparators.alphanumeric());\n\n    public Ordering create(Ordering.Context context) {\n        return INSTANCE;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/ComparatorBasedOrdering.java",
    "content": "package org.junit.tests.manipulation;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.List;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.manipulation.Ordering;\n\n/**\n * An ordering that internally uses a {@link Comparator}.\n */\nclass ComparatorBasedOrdering extends Ordering {\n    private final Comparator<Description> comparator;\n\n    protected ComparatorBasedOrdering(Comparator<Description> comparator) {\n        this.comparator = comparator;\n    }\n\n    @Override\n    protected List<Description> orderItems(Collection<Description> descriptions) {\n        List<Description> ordered = new ArrayList<Description>(descriptions);\n        Collections.sort(ordered, comparator);\n        return ordered;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/Comparators.java",
    "content": "package org.junit.tests.manipulation;\n\nimport java.util.Comparator;\n\nimport org.junit.runner.Description;\nimport org.junit.runner.manipulation.Alphanumeric;\n\n/**\n * Factory and utility methods for creating {@link Comparator} instances for tests.\n */\nclass Comparators {\n    private static final Comparator<Description> ALPHANUMERIC  = new Alphanumeric();\n\n    private Comparators() {}\n \n    public static Comparator<Description> alphanumeric() {\n        return ALPHANUMERIC;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/FilterTest.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertSame;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.manipulation.Filter;\n\npublic class FilterTest {\n    public static class NamedFilter extends Filter {\n        private final String fName;\n\n        public NamedFilter(String name) {\n            fName = name;\n        }\n\n        @Override\n        public boolean shouldRun(Description description) {\n            return false;\n        }\n\n        @Override\n        public String describe() {\n            return fName;\n        }\n    }\n\n    @Test\n    public void intersectionText() {\n        NamedFilter a = new NamedFilter(\"a\");\n        NamedFilter b = new NamedFilter(\"b\");\n        assertEquals(\"a and b\", a.intersect(b).describe());\n        assertEquals(\"b and a\", b.intersect(a).describe());\n    }\n\n    @Test\n    public void intersectSelf() {\n        NamedFilter a = new NamedFilter(\"a\");\n        assertSame(a, a.intersect(a));\n    }\n\n    @Test\n    public void intersectAll() {\n        NamedFilter a = new NamedFilter(\"a\");\n        assertSame(a, a.intersect(Filter.ALL));\n        assertSame(a, Filter.ALL.intersect(a));\n        assertSame(Filter.ALL, Filter.ALL.intersect(Filter.ALL));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/FilterableTest.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static org.junit.Assert.assertTrue;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.junit.Assert;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameters;\n\npublic class FilterableTest {\n    public static class FilteredRunner extends Parameterized {\n        public FilteredRunner(Class<?> klass) throws Throwable {\n            super(klass);\n            filter(new Filter() {\n\n                @Override\n                public boolean shouldRun(Description description) {\n                    return !description.getDisplayName().contains(\"skip\");\n                }\n\n                @Override\n                public String describe() {\n                    return \"skip methods containing the word 'skip'\";\n                }\n            });\n        }\n    }\n\n    @RunWith(FilteredRunner.class)\n    public static class FilteredTest {\n        @Parameters\n        public static List<Object[]> parameters() {\n            return Arrays.asList(new Object[]{3}, new Object[]{4});\n        }\n\n        public FilteredTest(int x) {\n        }\n\n        @Test\n        public void skipThis() {\n            Assert.fail();\n        }\n\n        @Test\n        public void runThis() {\n        }\n    }\n\n    @Test\n    public void testFilterInRunnerConstructor() {\n        Result result = JUnitCore.runClasses(FilteredTest.class);\n        assertTrue(result.wasSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/OrderWithTest.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static org.junit.Assert.assertEquals;\nimport junit.framework.JUnit4TestAdapter;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.experimental.runners.Enclosed;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.OrderWith;\nimport org.junit.runner.Request;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Alphanumeric;\nimport org.junit.runner.notification.RunNotifier;\n\n@RunWith(Enclosed.class)\npublic class OrderWithTest {\n \n    public static class TestClassRunnerIsOrderableViaOrderWith {\n        private static String log = \"\";\n\n        public static class Unordered {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n\n        @OrderWith(AlphanumericOrdering.class)\n        public static class OrderedAlphanumerically extends Unordered {\n        }\n\n        @OrderWith(ReverseAlphanumericOrdering.class)\n        public static class OrderedReverseAlphanumerically extends Unordered {\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void orderingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(OrderedAlphanumerically.class);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void orderingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(OrderedReverseAlphanumerically.class);\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n\n        @RunWith(Enclosed.class)\n        public static class UnorderedSuite {\n            public static class A {\n                @Test\n                public void a() {\n                    log += \"Aa\";\n                }\n\n                @Test\n                public void b() {\n                    log += \"Ab\";\n                }\n\n                @Test\n                public void c() {\n                    log += \"Ac\";\n                }\n            }\n\n            public static class B {\n                @Test\n                public void a() {\n                    log += \"Ba\";\n                }\n\n                @Test\n                public void b() {\n                    log += \"Bb\";\n                }\n\n                @Test\n                public void c() {\n                    log += \"Bc\";\n                }\n            }\n        }\n\n        @OrderWith(AlphanumericOrdering.class)\n        public static class SuiteOrderedAlphanumerically extends UnorderedSuite {\n        }\n\n        @OrderWith(ReverseAlphanumericOrdering.class)\n        public static class SuiteOrderedReverseAlphanumerically extends UnorderedSuite {\n        }\n\n        @Test\n        public void orderingForwardWorksOnSuite() {\n            Request forward = Request.aClass(SuiteOrderedAlphanumerically.class);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"AaAbAcBaBbBc\", log);\n        }\n\n        @Test\n        public void orderingBackwardWorksOnSuite() {\n            Request backward = Request.aClass(SuiteOrderedReverseAlphanumerically.class);\n\n            new JUnitCore().run(backward);\n            assertEquals(\"BcBbBaAcAbAa\", log);\n        }\n    }\n\n    public static class TestClassRunnerIsSortableViaOrderWith {\n        private static String log = \"\";\n\n        public static class Unordered {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @OrderWith(Alphanumeric.class)\n        public static class SortedAlphanumerically extends Unordered {\n        }\n\n        @OrderWith(ReverseAlphanumericSorter.class)\n        public static class SortedReverseAlphanumerically extends Unordered {\n        }\n \n        @Test\n        public void sortingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(SortedAlphanumerically.class);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void sortingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(SortedReverseAlphanumerically.class);\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n    }\n\n    public static class TestClassRunnerIsOrderableWithSuiteMethod {\n        private static String log = \"\";\n\n        public static class Unordered {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n        \n        @OrderWith(AlphanumericOrdering.class)\n        public static class OrderedAlphanumerically extends Unordered {\n \n            public static junit.framework.Test suite() {\n                return new JUnit4TestAdapter(OrderedAlphanumerically.class);\n            }\n        }\n\n        @OrderWith(ReverseAlphanumericOrdering.class)\n        public static class OrderedReverseAlphanumerically extends Unordered {\n\n            public static junit.framework.Test suite() {\n                return new JUnit4TestAdapter(OrderedReverseAlphanumerically.class);\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void orderingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(OrderedAlphanumerically.class);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void orderingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(OrderedReverseAlphanumerically.class);\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n    }\n\n    public static class UnOrderableRunnersAreHandledWithoutCrashing {\n        public static class UnOrderableRunner extends Runner {\n            public UnOrderableRunner(Class<?> klass) {\n            }\n\n            @Override\n            public Description getDescription() {\n                return Description.EMPTY;\n            }\n\n            @Override\n            public void run(RunNotifier notifier) {\n            }\n        }\n\n        @RunWith(UnOrderableRunner.class)\n        public static class UnOrderable {\n            @Test\n            public void a() {\n            }\n        }\n\n        @Test\n        public void unOrderablesAreHandledWithoutCrashing() {\n            Request unordered = Request.aClass(UnOrderable.class).orderWith(\n                    AlphanumericOrdering.INSTANCE);\n            new JUnitCore().run(unordered);\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/OrderableTest.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static org.junit.Assert.assertEquals;\nimport junit.framework.JUnit4TestAdapter;\nimport org.junit.Before;\nimport org.junit.FixMethodOrder;\nimport org.junit.Test;\nimport org.junit.experimental.runners.Enclosed;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Orderer;\nimport org.junit.runner.manipulation.InvalidOrderingException;\nimport org.junit.runner.manipulation.Orderable;\nimport org.junit.runner.manipulation.Sorter;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.MethodSorters;\n\n@RunWith(Enclosed.class)\npublic class OrderableTest {\n \n    public static class TestClassRunnerIsOrderable {\n        private static String log = \"\";\n\n        public static class OrderMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n\n        @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n        public static class DoNotOrderMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void orderingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(OrderMe.class).orderWith(\n                    AlphanumericOrdering.INSTANCE);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void orderingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(OrderMe.class).orderWith(\n                    new ReverseAlphanumericOrdering());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n        \n        @Test\n        public void orderingBackwardDoesNothingOnTestClassRunnerWithFixMethodOrder() {\n            Request backward = Request.aClass(DoNotOrderMe.class).orderWith(\n                    new ReverseAlphanumericOrdering());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"abc\", log);\n        }\n\n        @RunWith(Enclosed.class)\n        public static class Enclosing {\n            public static class A {\n                @Test\n                public void a() {\n                    log += \"Aa\";\n                }\n\n                @Test\n                public void b() {\n                    log += \"Ab\";\n                }\n\n                @Test\n                public void c() {\n                    log += \"Ac\";\n                }\n            }\n\n            public static class B {\n                @Test\n                public void a() {\n                    log += \"Ba\";\n                }\n\n                @Test\n                public void b() {\n                    log += \"Bb\";\n                }\n\n                @Test\n                public void c() {\n                    log += \"Bc\";\n                }\n            }\n        }\n\n        @Test\n        public void orderingForwardWorksOnSuite() {\n            Request forward = Request.aClass(Enclosing.class).orderWith(\n                    AlphanumericOrdering.INSTANCE);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"AaAbAcBaBbBc\", log);\n        }\n\n        @Test\n        public void orderingBackwardWorksOnSuite() {\n            Request backward = Request.aClass(Enclosing.class).orderWith(\n                    new ReverseAlphanumericOrdering());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"BcBbBaAcAbAa\", log);\n        }\n    }\n\n    public static class TestOrderableClassRunnerIsSortable {\n        private static String log = \"\";\n\n        /**\n         * A Runner that implements {@link Orderable}.\n         */\n        public static class OrderableRunner extends Runner implements Orderable {\n            private final BlockJUnit4ClassRunner delegate;\n\n            public OrderableRunner(Class<?> klass) throws Throwable {\n                delegate = new BlockJUnit4ClassRunner(klass);\n            }\n            \n            @Override\n            public void run(RunNotifier notifier) {\n                delegate.run(notifier);\n            }\n                \n            @Override\n            public Description getDescription() {\n                return delegate.getDescription();\n            }\n\n            public void order(Orderer orderer) throws InvalidOrderingException {\n                delegate.order(orderer);\n            }\n\n            public void sort(Sorter sorter) {\n                delegate.sort(sorter);\n            }\n        }\n\n        @RunWith(OrderableRunner.class)\n        public static class OrderMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void orderingorwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(OrderMe.class).orderWith(\n                    AlphanumericOrdering.INSTANCE);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void orderedBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(OrderMe.class).orderWith(\n                    new ReverseAlphanumericOrdering());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n    }\n\n    public static class TestClassRunnerIsOrderableWithSuiteMethod {\n        private static String log = \"\";\n\n        public static class OrderMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n\n            public static junit.framework.Test suite() {\n                return new JUnit4TestAdapter(OrderMe.class);\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void orderingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(OrderMe.class).orderWith(AlphanumericOrdering.INSTANCE);\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void orderingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(OrderMe.class).orderWith(\n                    new ReverseAlphanumericOrdering());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n    }\n\n    public static class UnOrderableRunnersAreHandledWithoutCrashing {\n        public static class UnOrderableRunner extends Runner {\n            public UnOrderableRunner(Class<?> klass) {\n            }\n\n            @Override\n            public Description getDescription() {\n                return Description.EMPTY;\n            }\n\n            @Override\n            public void run(RunNotifier notifier) {\n            }\n        }\n\n        @RunWith(UnOrderableRunner.class)\n        public static class UnOrderable {\n            @Test\n            public void a() {\n            }\n        }\n\n        @Test\n        public void unOrderablesAreHandledWithoutCrashing() {\n            Request unordered = Request.aClass(UnOrderable.class).orderWith(\n                    AlphanumericOrdering.INSTANCE);\n            new JUnitCore().run(unordered);\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/ReverseAlphanumericOrdering.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static java.util.Collections.reverseOrder;\n\nimport org.junit.runner.manipulation.Ordering;\n\n/**\n * An ordering that orders tests reverse alphanumerically by test name.\n */\npublic final class ReverseAlphanumericOrdering extends ComparatorBasedOrdering\n        implements Ordering.Factory {\n\n    public ReverseAlphanumericOrdering() {\n        super(reverseOrder(Comparators.alphanumeric()));\n    }\n\n    public Ordering create(Context context) {\n        return this;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/ReverseAlphanumericSorter.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static java.util.Collections.reverseOrder;\n\nimport org.junit.runner.manipulation.Ordering;\nimport org.junit.runner.manipulation.Sorter;\n\n/**\n * A sorter that orders tests reverse alphanumerically by test name.\n */\npublic final class ReverseAlphanumericSorter implements Ordering.Factory {\n\n    public Ordering create(Ordering.Context context) {\n        return new Sorter(reverseOrder(Comparators.alphanumeric()));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/SingleMethodTest.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport junit.framework.JUnit4TestAdapter;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.Filterable;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameters;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\npublic class SingleMethodTest {\n    public static int count;\n\n    public static class OneTimeSetup {\n        @BeforeClass\n        public static void once() {\n            count++;\n        }\n\n        @Test\n        public void one() {\n        }\n\n        @Test\n        public void two() {\n        }\n    }\n\n    @Test\n    public void oneTimeSetup() throws Exception {\n        count = 0;\n        Runner runner = Request.method(OneTimeSetup.class, \"one\").getRunner();\n        Result result = new JUnitCore().run(runner);\n\n        assertEquals(1, count);\n        assertEquals(1, result.getRunCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ParameterizedOneTimeSetup {\n        @Parameters\n        public static List<Object[]> params() {\n            return Arrays.asList(new Object[]{1}, new Object[]{2});\n        }\n\n        public ParameterizedOneTimeSetup(int x) {\n        }\n\n        @Test\n        public void one() {\n        }\n    }\n\n    @Test\n    public void parameterizedFilterToSingleMethod() throws Exception {\n        count = 0;\n        Runner runner = Request.method(ParameterizedOneTimeSetup.class,\n                \"one[0]\").getRunner();\n        Result result = new JUnitCore().run(runner);\n\n        assertEquals(1, result.getRunCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ParameterizedOneTimeBeforeClass {\n        @Parameters\n        public static List<Object[]> params() {\n            return Arrays.asList(new Object[]{1}, new Object[]{2});\n        }\n\n        public ParameterizedOneTimeBeforeClass(int x) {\n        }\n\n        @BeforeClass\n        public static void once() {\n            count++;\n        }\n\n        @Test\n        public void one() {\n        }\n    }\n\n\n    @Test\n    public void parameterizedBeforeClass() throws Exception {\n        count = 0;\n        JUnitCore.runClasses(ParameterizedOneTimeBeforeClass.class);\n        assertEquals(1, count);\n    }\n\n    @Test\n    public void filteringAffectsPlan() throws Exception {\n        Runner runner = Request.method(OneTimeSetup.class, \"one\").getRunner();\n        assertEquals(1, runner.testCount());\n    }\n\n    @Test\n    public void nonexistentMethodCreatesFailure() throws Exception {\n        assertEquals(1, new JUnitCore().run(\n                Request.method(OneTimeSetup.class, \"thisMethodDontExist\"))\n                .getFailureCount());\n    }\n\n    @Test(expected = NoTestsRemainException.class)\n    public void filteringAwayEverythingThrowsException() throws NoTestsRemainException {\n        Filterable runner = (Filterable) Request.aClass(OneTimeSetup.class).getRunner();\n        runner.filter(new Filter() {\n            @Override\n            public boolean shouldRun(Description description) {\n                return false;\n            }\n\n            @Override\n            public String describe() {\n                return null;\n            }\n        });\n    }\n\n    public static class TestOne {\n        @Test\n        public void a() {\n        }\n\n        @Test\n        public void b() {\n        }\n    }\n\n    public static class TestTwo {\n        @Test\n        public void a() {\n        }\n\n        @Test\n        public void b() {\n        }\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses({TestOne.class, TestTwo.class})\n    public static class OneTwoSuite {\n    }\n\n    @Test\n    public void eliminateUnnecessaryTreeBranches() throws Exception {\n        Runner runner = Request.aClass(OneTwoSuite.class).filterWith(\n                Description.createTestDescription(TestOne.class, \"a\"))\n                .getRunner();\n        Description description = runner.getDescription();\n        assertEquals(1, description.getChildren().size());\n    }\n\n    public static class HasSuiteMethod {\n        @Test\n        public void a() {\n        }\n\n        @Test\n        public void b() {\n        }\n\n        public static junit.framework.Test suite() {\n            return new JUnit4TestAdapter(HasSuiteMethod.class);\n        }\n    }\n\n    @Test\n    public void classesWithSuiteMethodsAreFiltered() {\n        int testCount = Request.method(HasSuiteMethod.class, \"a\").getRunner().getDescription().testCount();\n        assertThat(testCount, is(1));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/manipulation/SortableTest.java",
    "content": "package org.junit.tests.manipulation;\n\nimport static java.util.Collections.reverseOrder;\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.Comparator;\n\nimport junit.framework.JUnit4TestAdapter;\nimport org.junit.Before;\nimport org.junit.FixMethodOrder;\nimport org.junit.Test;\nimport org.junit.experimental.runners.Enclosed;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Orderable;\nimport org.junit.runner.manipulation.Sortable;\nimport org.junit.runner.manipulation.Sorter;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.MethodSorters;\n\n@RunWith(Enclosed.class)\npublic class SortableTest {\n    private static Comparator<Description> forward() {\n        return Comparators.alphanumeric();\n    }\n\n    private static Comparator<Description> backward() {\n        return reverseOrder(Comparators.alphanumeric());\n    }\n\n    public static class TestClassRunnerIsSortable {\n        private static String log = \"\";\n\n        public static class SortMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n\n        @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n        public static class DoNotSortMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void sortingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(SortMe.class).sortWith(forward());\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void sortingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(SortMe.class).sortWith(backward());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n\n        @Test\n        public void sortingBackwardDoesNothingOnTestClassRunnerWithFixMethodOrder() {\n            Request backward = Request.aClass(DoNotSortMe.class).sortWith(backward());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"abc\", log);\n        }\n\n        @RunWith(Enclosed.class)\n        public static class Enclosing {\n            public static class A {\n                @Test\n                public void a() {\n                    log += \"Aa\";\n                }\n\n                @Test\n                public void b() {\n                    log += \"Ab\";\n                }\n\n                @Test\n                public void c() {\n                    log += \"Ac\";\n                }\n            }\n\n            public static class B {\n                @Test\n                public void a() {\n                    log += \"Ba\";\n                }\n\n                @Test\n                public void b() {\n                    log += \"Bb\";\n                }\n\n                @Test\n                public void c() {\n                    log += \"Bc\";\n                }\n            }\n        }\n\n        @Test\n        public void sortingForwardWorksOnSuite() {\n            Request forward = Request.aClass(Enclosing.class).sortWith(forward());\n\n            new JUnitCore().run(forward);\n            assertEquals(\"AaAbAcBaBbBc\", log);\n        }\n\n        @Test\n        public void sortingBackwardWorksOnSuite() {\n            Request backward = Request.aClass(Enclosing.class).sortWith(backward());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"BcBbBaAcAbAa\", log);\n        }\n    }\n\n    public static class TestClassRunnerIsSortableWithSuiteMethod {\n        private static String log = \"\";\n\n        public static class SortMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n\n            public static junit.framework.Test suite() {\n                return new JUnit4TestAdapter(SortMe.class);\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void sortingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(SortMe.class).sortWith(forward());\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void sortingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(SortMe.class).sortWith(backward());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n    }\n\n    public static class UnsortableRunnersAreHandledWithoutCrashing {\n        public static class UnsortableRunner extends Runner {\n            public UnsortableRunner(Class<?> klass) {\n            }\n\n            @Override\n            public Description getDescription() {\n                return Description.EMPTY;\n            }\n\n            @Override\n            public void run(RunNotifier notifier) {\n            }\n        }\n\n        @RunWith(UnsortableRunner.class)\n        public static class Unsortable {\n            @Test\n            public void a() {\n            }\n        }\n\n        @Test\n        public void unsortablesAreHandledWithoutCrashing() {\n            Request unsorted = Request.aClass(Unsortable.class).sortWith(forward());\n            new JUnitCore().run(unsorted);\n        }\n    }\n\n    public static class TestOnlySortableClassRunnerIsSortable {\n        private static String log = \"\";\n\n        /**\n         * A Runner that implements {@link Sortable} but not {@link Orderable}.\n         */\n        public static class SortableRunner extends Runner implements Sortable {\n            private final BlockJUnit4ClassRunner delegate;\n\n            public SortableRunner(Class<?> klass) throws Throwable {\n                delegate = new BlockJUnit4ClassRunner(klass);\n            }\n\n            @Override\n            public void run(RunNotifier notifier) {\n                delegate.run(notifier);\n            }\n\n            @Override\n            public Description getDescription() {\n                return delegate.getDescription();\n            }\n\n            public void sort(Sorter sorter) {\n                delegate.sort(sorter);\n            }\n        }\n\n        @RunWith(SortableRunner.class)\n        public static class SortMe {\n            @Test\n            public void a() {\n                log += \"a\";\n            }\n\n            @Test\n            public void b() {\n                log += \"b\";\n            }\n\n            @Test\n            public void c() {\n                log += \"c\";\n            }\n\n            public static junit.framework.Test suite() {\n                return new JUnit4TestAdapter(SortMe.class);\n            }\n        }\n\n        @Before\n        public void resetLog() {\n            log = \"\";\n        }\n\n        @Test\n        public void sortingForwardWorksOnTestClassRunner() {\n            Request forward = Request.aClass(SortMe.class).sortWith(forward());\n\n            new JUnitCore().run(forward);\n            assertEquals(\"abc\", log);\n        }\n\n        @Test\n        public void sortingBackwardWorksOnTestClassRunner() {\n            Request backward = Request.aClass(SortMe.class).sortWith(backward());\n\n            new JUnitCore().run(backward);\n            assertEquals(\"cba\", log);\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/package-info.java",
    "content": "/**\n * Tests the JUnit functionality.\n *\n * Corresponds to {@link junit.tests.AllTests} in Junit 3.x.\n *\n * @since 4.0\n */\npackage org.junit.tests;"
  },
  {
    "path": "src/test/java/org/junit/tests/running/AllRunningTests.java",
    "content": "package org.junit.tests.running;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.tests.running.classes.AllClassesTests;\nimport org.junit.tests.running.core.AllCoreTests;\nimport org.junit.tests.running.methods.AllMethodsTests;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AllClassesTests.class,\n        AllCoreTests.class,\n        AllMethodsTests.class\n})\npublic class AllRunningTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/AllClassesTests.java",
    "content": "package org.junit.tests.running.classes;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.tests.running.classes.parent.ParentRunnerClassLoaderTest;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        BlockJUnit4ClassRunnerTest.class,\n        ClassLevelMethodsWithIgnoredTestsTest.class,\n        EnclosedTest.class,\n        IgnoreClassTest.class,\n        ParameterizedTestTest.class,\n        ParentRunnerFilteringTest.class,\n        ParentRunnerTest.class,\n        ParentRunnerClassLoaderTest.class,\n        RunWithTest.class,\n        SuiteTest.class,\n        UseSuiteAsASuperclassTest.class,\n        ThreadsTest.class\n})\npublic class AllClassesTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/BlockJUnit4ClassRunnerTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.List;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.model.InitializationError;\n\npublic class BlockJUnit4ClassRunnerTest {\n    public static class OuterClass {\n        public class Enclosed {\n            @Test\n            public void test() {\n            }\n        }\n    }\n\n    @Test\n    public void detectNonStaticEnclosedClass() throws Exception {\n        try {\n            new BlockJUnit4ClassRunner(OuterClass.Enclosed.class);\n        } catch (InitializationError e) {\n            List<Throwable> causes = e.getCauses();\n            assertEquals(\"Wrong number of causes.\", 1, causes.size());\n            assertEquals(\n                    \"Wrong exception.\",\n                    \"The inner class org.junit.tests.running.classes.BlockJUnit4ClassRunnerTest$OuterClass$Enclosed is not static.\",\n                    causes.get(0).getMessage());\n        }\n    }\n\n    private static String log;\n\n    public static class MethodBlockAfterFireTestStarted {\n        public MethodBlockAfterFireTestStarted() {\n            log += \" init\";\n        }\n\n        @Test\n        public void test() {\n            log += \" test\";\n        }\n    }\n\n    @Test\n    public void methodBlockAfterFireTestStarted() {\n        log = \"\";\n        JUnitCore junit = new JUnitCore();\n        junit.addListener(new RunListener() {\n            @Override\n            public void testStarted(Description description) throws Exception {\n                log += \" testStarted(\" + description.getMethodName() + \")\";\n            }\n\n            @Override\n            public void testFinished(Description description) throws Exception {\n                log += \" testFinished(\" + description.getMethodName() + \")\";\n            }\n        });\n        junit.run(MethodBlockAfterFireTestStarted.class);\n        assertEquals(\" testStarted(test) init test testFinished(test)\", log);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/ClassLevelMethodsWithIgnoredTestsTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.junit.Assert.fail;\n\nimport java.util.List;\n\nimport org.junit.AfterClass;\nimport org.junit.BeforeClass;\nimport org.junit.ClassRule;\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.experimental.categories.Categories.CategoryFilter;\nimport org.junit.experimental.categories.Category;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runners.model.Statement;\n\n/**\n * Tests verifying that class-level fixtures ({@link BeforeClass} and\n * {@link AfterClass}) and rules ({@link ClassRule}) are not executed when there\n * are no test methods to be run in a test class because they have been ignored.\n * \n */\npublic class ClassLevelMethodsWithIgnoredTestsTest {\n    private static final String FAILURE_MESSAGE = \"This should not have happened!\";\n\n    public static class BeforeClassWithIgnoredTest {\n        @BeforeClass\n        public static void beforeClass() {\n            fail(FAILURE_MESSAGE);\n        }\n        \n        @Ignore\n        @Test\n        public void test() throws Exception {\n            fail(\"test() should not run\");\n        }\n    }\n\n    @Test\n    public void beforeClassShouldNotRunWhenAllTestsAreIgnored() {\n        runClassAndVerifyNoFailures(BeforeClassWithIgnoredTest.class,\n                \"BeforeClass should not have been executed because the test method is ignored!\");\n    }\n\n    @Ignore\n    public static class BeforeClassWithIgnoredClass {\n        @BeforeClass\n        public static void beforeClass() {\n            fail(FAILURE_MESSAGE);\n        }\n\n        @Test\n        public void test() throws Exception {\n            fail(\"test() should not run\");\n        }\n    }\n\n    @Test\n    public void beforeClassShouldNotRunWhenWholeClassIsIgnored() {\n        runClassAndVerifyNoFailures(\n                BeforeClassWithIgnoredClass.class,\n                \"BeforeClass should not have been executed because the whole test class is ignored!\");\n    }\n\n    public static class AfterClassWithIgnoredTest {\n        @Ignore\n        @Test\n        public void test() throws Exception {\n            fail(\"test() should not run\");\n        }\n\n        @AfterClass\n        public static void afterClass() {\n            fail(FAILURE_MESSAGE);\n        }\n    }\n\n    @Test\n    public void afterClassShouldNotRunWhenAllTestsAreIgnored() {\n        runClassAndVerifyNoFailures(AfterClassWithIgnoredTest.class,\n                \"AfterClass should not have been executed because the test method is ignored!\");\n    }\n\n    public interface FilteredTests {\n    }\n\n    public static class BeforeClassWithFilteredTest {\n        @BeforeClass\n        public static void setUpClass() {\n            fail(FAILURE_MESSAGE);\n        }\n\n        @Category(FilteredTests.class)\n        @Test\n        public void test() throws Exception {\n            fail(\"test() should not run\");\n        }\n    }\n\n    public static class HasUnfilteredTest {\n        @Test\n        public void unfilteredTest() {\n            // to prevent errors when all other tests have been filtered\n        }\n    }\n\n    @Test\n    public void beforeClassShouldNotRunWhenAllTestsAreFiltered() {\n        Result result = new JUnitCore().run(Request.classes(\n                BeforeClassWithFilteredTest.class, HasUnfilteredTest.class)\n                .filterWith(CategoryFilter.exclude(FilteredTests.class)));\n        analyseResult(\n                result,\n                \"BeforeClass should not have been executed because the test method is filtered!\");\n    }\n\n    public static class BrokenRule implements TestRule {\n        public Statement apply(Statement base, Description description) {\n            throw new RuntimeException(\"this rule is broken\");\n        }\n    }\n\n    public static class ClassRuleWithIgnoredTest {\n        @ClassRule\n        public static BrokenRule brokenRule = new BrokenRule();\n\n        @Ignore\n        @Test\n        public void test() throws Exception {\n            fail(\"test() should not be run\");\n        }\n    }\n\n    @Test\n    public void classRuleShouldNotBeAppliedWhenAllTestsAreIgnored() {\n        runClassAndVerifyNoFailures(ClassRuleWithIgnoredTest.class,\n                \"The class rule should have been applied because the test method is ignored!\");\n    }\n\n    private void runClassAndVerifyNoFailures(Class<?> klass,\n            String testFailureDescription) {\n        Result result = JUnitCore.runClasses(klass);\n        analyseResult(result, testFailureDescription);\n    }\n\n    private void analyseResult(Result result, String testFailureDescription) {\n        List<Failure> failures = result.getFailures();\n        if (failures.isEmpty() == false) {\n            analyzeFailure(failures.get(0), testFailureDescription);\n        }\n    }\n\n    private void analyzeFailure(Failure failure, String testFailureDescription) {\n        String actualFailureMsg = failure.getMessage();\n        if (FAILURE_MESSAGE.equals(actualFailureMsg)) {\n            fail(testFailureDescription);\n        }\n        fail(\"Unexpected failure : \" + actualFailureMsg);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/EnclosedTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.junit.Assert.assertEquals;\n\nimport org.junit.Test;\nimport org.junit.experimental.runners.Enclosed;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\n\npublic class EnclosedTest {\n    @RunWith(Enclosed.class)\n    public static class Enclosing {\n        public static class A {\n            @Test\n            public void a() {}\n\n            @Test\n            public void b() {}\n        }\n        public static class B {\n            @Test\n            public void a() {}\n\n            @Test\n            public void b() {}\n\n            @Test\n            public void c() {}\n        }\n        public abstract static class C {\n            @Test public void a() {}\n        }\n    }\n\n    @Test\n    public void enclosedRunnerPlansConcreteEnclosedClasses() throws Exception {\n        Runner runner= Request.aClass(Enclosing.class).getRunner();\n        assertEquals(5, runner.testCount());\n    }\n\n    @Test\n    public void enclosedRunnerRunsConcreteEnclosedClasses() throws Exception {\n        Result result= JUnitCore.runClasses(Enclosing.class);\n        assertEquals(5, result.getRunCount());\n    }\n\n    @Test\n    public void enclosedRunnerIsNamedForEnclosingClass() throws Exception {\n        assertEquals(Enclosing.class.getName(), Request.aClass(Enclosing.class)\n                .getRunner().getDescription().getDisplayName());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/IgnoreClassTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.fail;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\n\npublic class IgnoreClassTest {\n    @Ignore(\"For a good reason\")\n    public static class IgnoreMe {\n        @Test\n        public void iFail() {\n            fail();\n        }\n\n        @Test\n        public void iFailToo() {\n            fail();\n        }\n    }\n\n    @Test\n    public void ignoreClass() {\n        Result result = JUnitCore.runClasses(IgnoreMe.class);\n        assertEquals(0, result.getFailureCount());\n        assertEquals(1, result.getIgnoreCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/ParameterizedTestTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.junit.Assume.assumeFalse;\nimport static org.junit.experimental.results.PrintableResult.testResult;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.concurrent.atomic.AtomicBoolean;\n\nimport org.junit.AfterClass;\nimport org.junit.BeforeClass;\nimport org.junit.FixMethodOrder;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runners.MethodSorters;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameter;\nimport org.junit.runners.Parameterized.Parameters;\nimport org.junit.runners.Parameterized.UseParametersRunnerFactory;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.parameterized.ParametersRunnerFactory;\nimport org.junit.runners.parameterized.TestWithParameters;\n\npublic class ParameterizedTestTest {\n    @RunWith(Parameterized.class)\n    public static class AdditionTest {\n        @Parameters(name = \"{index}: {0} + {1} = {2}\")\n        public static Iterable<Object[]> data() {\n            return Arrays.asList(new Object[][] { { 0, 0, 0 }, { 1, 1, 2 },\n                    { 3, 2, 5 }, { 4, 3, 7 } });\n        }\n\n        private int firstSummand;\n\n        private int secondSummand;\n\n        private int sum;\n\n        public AdditionTest(int firstSummand, int secondSummand, int sum) {\n            this.firstSummand = firstSummand;\n            this.secondSummand = secondSummand;\n            this.sum = sum;\n        }\n\n        @Test\n        public void test() {\n            assertEquals(sum, firstSummand + secondSummand);\n        }\n    }\n\n    @Test\n    public void countsRuns() {\n        Result result = JUnitCore.runClasses(AdditionTest.class);\n        assertEquals(4, result.getRunCount());\n    }\n\n    @Test\n    public void countBeforeRun() throws Exception {\n        Runner runner = Request.aClass(AdditionTest.class).getRunner();\n        assertEquals(4, runner.testCount());\n    }\n\n    @Test\n    public void plansNamedCorrectly() throws Exception {\n        Runner runner = Request.aClass(AdditionTest.class).getRunner();\n        Description description = runner.getDescription();\n        assertEquals(\"[2: 3 + 2 = 5]\", description.getChildren().get(2)\n                .getDisplayName());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ThreeFailures {\n        @Parameters(name = \"{index}: x={0}\")\n        public static Collection<Integer> data() {\n            return Arrays.asList(1, 2, 3);\n        }\n\n        @Parameter(0)\n        public int unused;\n\n        @Test\n        public void testSomething() {\n            fail();\n        }\n    }\n\n    @Test\n    public void countsFailures() throws Exception {\n        Result result = JUnitCore.runClasses(ThreeFailures.class);\n        assertEquals(3, result.getFailureCount());\n    }\n\n    @Test\n    public void failuresNamedCorrectly() {\n        Result result = JUnitCore.runClasses(ThreeFailures.class);\n        assertEquals(\n                \"testSomething[0: x=1](\" + ThreeFailures.class.getName() + \")\",\n                result.getFailures().get(0).getTestHeader());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ParameterizedWithoutSpecialTestname {\n        @Parameters\n        public static Collection<Object[]> data() {\n            return Arrays.asList(new Object[][]{{3}, {3}});\n        }\n\n        public ParameterizedWithoutSpecialTestname(Object something) {\n        }\n\n        @Test\n        public void testSomething() {\n        }\n    }\n\n    @Test\n    public void usesIndexAsTestName() {\n        Runner runner = Request\n                .aClass(ParameterizedWithoutSpecialTestname.class).getRunner();\n        Description description = runner.getDescription();\n        assertEquals(\"[1]\", description.getChildren().get(1).getDisplayName());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class AdditionTestWithAnnotatedFields {\n        @Parameters(name = \"{index}: {0} + {1} = {2}\")\n        public static Iterable<Object[]> data() {\n            return Arrays.asList(new Object[][] { { 0, 0, 0 }, { 1, 1, 2 },\n                    { 3, 2, 5 }, { 4, 3, 7 } });\n        }\n\n        @Parameter(0)\n        public int firstSummand;\n\n        @Parameter(1)\n        public int secondSummand;\n\n        @Parameter(2)\n        public int sum;\n\n        @Test\n        public void test() {\n            assertEquals(sum, firstSummand + secondSummand);\n        }\n    }\n\n    @Test\n    public void providesDataByAnnotatedFields() {\n        Result result = JUnitCore.runClasses(AdditionTestWithAnnotatedFields.class);\n        assertEquals(4, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class BadIndexForAnnotatedFieldTest {\n        @Parameters\n        public static Collection<Object[]> data() {\n            return Arrays.asList(new Object[][]{{0}});\n        }\n\n        @Parameter(2)\n        public int fInput;\n\n        public int fExpected;\n\n        @Test\n        public void test() {\n            assertEquals(fExpected, fib(fInput));\n        }\n\n        private int fib(int x) {\n            return 0;\n        }\n    }\n\n    @Test\n    public void failureOnInitialization() {\n        Result result = JUnitCore.runClasses(BadIndexForAnnotatedFieldTest.class);\n        assertEquals(1, result.getFailureCount());\n        List<Failure> failures = result.getFailures();\n        assertThat(failures.get(0).getException().getMessage(), allOf(\n                containsString(\"Invalid @Parameter value: 2. @Parameter fields counted: 1. Please use an index between 0 and 0.\"),\n                containsString(\"@Parameter(0) is never used.\")));\n    }\n\n    @RunWith(Parameterized.class)\n    public static class BadNumberOfAnnotatedFieldTest {\n        @Parameters\n        public static Collection<Object[]> data() {\n            return Arrays.asList(new Object[][]{{0, 0}});\n        }\n\n        @Parameter(0)\n        public int fInput;\n\n        public int fExpected;\n\n        @Test\n        public void test() {\n            assertEquals(fExpected, fib(fInput));\n        }\n\n        private int fib(int x) {\n            return 0;\n        }\n    }\n\n    @Test\n    public void numberOfFieldsAndParametersShouldMatch() {\n        Result result = JUnitCore.runClasses(BadNumberOfAnnotatedFieldTest.class);\n        assertEquals(1, result.getFailureCount());\n        List<Failure> failures = result.getFailures();\n        assertTrue(failures.get(0).getException().getMessage().contains(\"Wrong number of parameters and @Parameter fields. @Parameter fields counted: 1, available parameters: 2.\"));\n    }\n\n    private static String fLog;\n\n    @RunWith(Parameterized.class)\n    public static class BeforeAndAfter {\n        @BeforeClass\n        public static void before() {\n            fLog += \"before \";\n        }\n\n        @AfterClass\n        public static void after() {\n            fLog += \"after \";\n        }\n\n        public BeforeAndAfter(int x) {\n\n        }\n\n        @Parameters\n        public static Collection<Object[]> data() {\n            return Arrays.asList(new Object[][]{{3}});\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    @Test\n    public void beforeAndAfterClassAreRun() {\n        fLog = \"\";\n        JUnitCore.runClasses(BeforeAndAfter.class);\n        assertEquals(\"before after \", fLog);\n    }\n\n    @RunWith(Parameterized.class)\n    @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n    public static class BeforeParamAndAfterParam {\n        @BeforeClass\n        public static void before() {\n            fLog += \"beforeClass \";\n        }\n\n        @Parameterized.BeforeParam\n        public static void beforeParam(String x) {\n            fLog += \"before(\" + x + \") \";\n        }\n\n        @Parameterized.AfterParam\n        public static void afterParam() {\n            fLog += \"afterParam \";\n        }\n\n        @AfterClass\n        public static void after() {\n            fLog += \"afterClass \";\n        }\n\n        private final String x;\n\n        public BeforeParamAndAfterParam(String x) {\n            this.x = x;\n        }\n\n        @Parameters\n        public static Collection<String> data() {\n            return Arrays.asList(\"A\", \"B\");\n        }\n\n        @Test\n        public void first() {\n            fLog += \"first(\" + x + \") \";\n        }\n\n        @Test\n        public void second() {\n            fLog += \"second(\" + x + \") \";\n        }\n    }\n\n    @Test\n    public void beforeParamAndAfterParamAreRun() {\n        fLog = \"\";\n        Result result = JUnitCore.runClasses(BeforeParamAndAfterParam.class);\n        assertEquals(0, result.getFailureCount());\n        assertEquals(\"beforeClass before(A) first(A) second(A) afterParam \"\n                + \"before(B) first(B) second(B) afterParam afterClass \", fLog);\n    }\n\n    @RunWith(Parameterized.class)\n    @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n    public static class MultipleBeforeParamAndAfterParam {\n        @Parameterized.BeforeParam\n        public static void before1() {\n            fLog += \"before1() \";\n        }\n\n        @Parameterized.BeforeParam\n        public static void before2(String x) {\n            fLog += \"before2(\" + x + \") \";\n        }\n\n        @Parameterized.AfterParam\n        public static void after2() {\n            fLog += \"after2() \";\n        }\n\n        @Parameterized.AfterParam\n        public static void after1(String x) {\n            fLog += \"after1(\" + x + \") \";\n        }\n\n        private final String x;\n\n        public MultipleBeforeParamAndAfterParam(String x) {\n            this.x = x;\n        }\n\n        @Parameters\n        public static Collection<String> data() {\n            return Arrays.asList(\"A\", \"B\");\n        }\n\n        @Test\n        public void first() {\n            fLog += \"first(\" + x + \") \";\n        }\n\n        @Test\n        public void second() {\n            fLog += \"second(\" + x + \") \";\n        }\n    }\n\n    @Test\n    public void multipleBeforeParamAndAfterParamAreRun() {\n        fLog = \"\";\n        Result result = JUnitCore.runClasses(MultipleBeforeParamAndAfterParam.class);\n        assertEquals(0, result.getFailureCount());\n        assertEquals(\"before1() before2(A) first(A) second(A) after1(A) after2() \"\n                + \"before1() before2(B) first(B) second(B) after1(B) after2() \", fLog);\n    }\n\n    @RunWith(Parameterized.class)\n    @FixMethodOrder(MethodSorters.NAME_ASCENDING)\n    public static class MultipleParametersBeforeParamAndAfterParam {\n        @Parameterized.BeforeParam\n        public static void before(String x, int y) {\n            fLog += \"before(\" + x + \",\" + y + \") \";\n        }\n\n        @Parameterized.AfterParam\n        public static void after(String x, int y) {\n            fLog += \"after(\" + x + \",\" + y + \") \";\n        }\n\n        private final String x;\n        private final int y;\n\n        public MultipleParametersBeforeParamAndAfterParam(String x, int y) {\n            this.x = x;\n            this.y = y;\n        }\n\n        @Parameters\n        public static Collection<Object[]> data() {\n            return Arrays.asList(new Object[]{\"A\", 1}, new Object[]{\"B\", 2});\n        }\n\n        @Test\n        public void first() {\n            fLog += \"first(\" + x + \",\" + y + \") \";\n        }\n\n        @Test\n        public void second() {\n            fLog += \"second(\" + x + \",\" + y + \") \";\n        }\n    }\n\n    @Test\n    public void multipleParametersBeforeParamAndAfterParamAreRun() {\n        fLog = \"\";\n        Result result = JUnitCore.runClasses(MultipleParametersBeforeParamAndAfterParam.class);\n        assertEquals(0, result.getFailureCount());\n        assertEquals(\"before(A,1) first(A,1) second(A,1) after(A,1) \"\n                + \"before(B,2) first(B,2) second(B,2) after(B,2) \", fLog);\n    }\n\n    @RunWith(Parameterized.class)\n    public static class BeforeParamAndAfterParamError {\n        @Parameterized.BeforeParam\n        public void beforeParam(String x) {\n        }\n\n        @Parameterized.AfterParam\n        private static void afterParam() {\n        }\n\n        public BeforeParamAndAfterParamError(String x) {\n        }\n\n        @Parameters\n        public static Collection<String> data() {\n            return Arrays.asList(\"A\", \"B\");\n        }\n\n        @Test\n        public void test() {\n        }\n    }\n\n    @Test\n    public void beforeParamAndAfterParamValidation() {\n        fLog = \"\";\n        Result result = JUnitCore.runClasses(BeforeParamAndAfterParamError.class);\n        assertEquals(1, result.getFailureCount());\n        List<Failure> failures = result.getFailures();\n        assertThat(failures.get(0).getMessage(), containsString(\"beforeParam() should be static\"));\n        assertThat(failures.get(0).getMessage(), containsString(\"afterParam() should be public\"));\n    }\n\n    @RunWith(Parameterized.class)\n    public static class BeforeParamAndAfterParamErrorNumberOfParameters {\n        @Parameterized.BeforeParam\n        public static void beforeParam(String x, String y) {\n        }\n\n        @Parameterized.AfterParam\n        public static void afterParam(String x, String y, String z) {\n        }\n\n        public BeforeParamAndAfterParamErrorNumberOfParameters(String x) {\n        }\n\n        @Parameters\n        public static Collection<String> data() {\n            return Arrays.asList(\"A\", \"B\", \"C\", \"D\");\n        }\n\n        @Test\n        public void test() {\n        }\n    }\n\n    @Test\n    public void beforeParamAndAfterParamValidationNumberOfParameters() {\n        fLog = \"\";\n        Result result = JUnitCore.runClasses(BeforeParamAndAfterParamErrorNumberOfParameters.class);\n        assertEquals(1, result.getFailureCount());\n        List<Failure> failures = result.getFailures();\n        assertThat(failures.get(0).getMessage(),\n                containsString(\"Method beforeParam() should have 0 or 1 parameter(s)\"));\n        assertThat(failures.get(0).getMessage(),\n                containsString(\"Method afterParam() should have 0 or 1 parameter(s)\"));\n    }\n\n    @RunWith(Parameterized.class)\n    public static class EmptyTest {\n        @BeforeClass\n        public static void before() {\n            fLog += \"before \";\n        }\n\n        @AfterClass\n        public static void after() {\n            fLog += \"after \";\n        }\n    }\n\n    @Test\n    public void validateClassCatchesNoParameters() {\n        Result result = JUnitCore.runClasses(EmptyTest.class);\n        assertEquals(1, result.getFailureCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class IncorrectTest {\n        @Test\n        public int test() {\n            return 0;\n        }\n\n        @Parameters\n        public static Collection<Object[]> data() {\n            return Collections.singletonList(new Object[]{1});\n        }\n    }\n\n    @Test\n    public void failuresAddedForBadTestMethod() throws Exception {\n        Result result = JUnitCore.runClasses(IncorrectTest.class);\n        assertEquals(1, result.getFailureCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ProtectedParametersTest {\n        @Parameters\n        protected static Collection<Object[]> data() {\n            return Collections.emptyList();\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    @Test\n    public void meaningfulFailureWhenParametersNotPublic() {\n        assertTestCreatesSingleFailureWithMessage(ProtectedParametersTest.class,\n                \"No public static parameters method on class \"\n                        + ProtectedParametersTest.class.getName());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class ParametersNotIterable {\n        @Parameters\n        public static String data() {\n            return \"foo\";\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    @Test\n    public void meaningfulFailureWhenParametersAreNotAnIterable() {\n        assertThat(\n                testResult(ParametersNotIterable.class).toString(),\n                containsString(\"ParametersNotIterable.data() must return an Iterable of arrays.\"));\n    }\n\n    @RunWith(Parameterized.class)\n    public static class PrivateConstructor {\n        private PrivateConstructor(int x) {\n\n        }\n\n        @Parameters\n        public static Collection<Object[]> data() {\n            return Arrays.asList(new Object[][]{{3}});\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    @Test(expected = InitializationError.class)\n    public void exceptionWhenPrivateConstructor() throws Throwable {\n        new Parameterized(PrivateConstructor.class);\n    }\n\n    @RunWith(Parameterized.class)\n    public static class AdditionTestWithArray {\n        @Parameters(name = \"{index}: {0} + {1} = {2}\")\n        public static Object[][] data() {\n            return new Object[][] { { 0, 0, 0 }, { 1, 1, 2 }, { 3, 2, 5 },\n                    { 4, 3, 7 } };\n        }\n\n        @Parameter(0)\n        public int firstSummand;\n\n        @Parameter(1)\n        public int secondSummand;\n\n        @Parameter(2)\n        public int sum;\n\n        @Test\n        public void test() {\n            assertEquals(sum, firstSummand + secondSummand);\n        }\n    }\n\n    @Test\n    public void runsEveryTestOfArray() {\n        Result result= JUnitCore.runClasses(AdditionTestWithArray.class);\n        assertEquals(4, result.getRunCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class SingleArgumentTestWithArray {\n        @Parameters\n        public static Object[] data() {\n            return new Object[] { \"first test\", \"second test\" };\n        }\n\n        public SingleArgumentTestWithArray(Object argument) {\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    @Test\n    public void runsForEverySingleArgumentOfArray() {\n        Result result= JUnitCore.runClasses(SingleArgumentTestWithArray.class);\n        assertEquals(2, result.getRunCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class SingleArgumentTestWithIterable {\n        private static final AtomicBoolean dataCalled = new AtomicBoolean(false);\n\n        @Parameters\n        public static Iterable<? extends Object> data() {\n            if (!dataCalled.compareAndSet(false, true)) {\n                fail(\"Should not call @Parameters method more than once\");\n            }\n            return new OneShotIterable<String>(asList(\"first test\", \"second test\"));\n        }\n\n        public SingleArgumentTestWithIterable(Object argument) {\n        }\n\n        @Test\n        public void aTest() {\n        }\n  \t}\n\n    private static class OneShotIterable<T> implements Iterable<T> {\n        private final Iterable<T> delegate;\n        private final AtomicBoolean iterated = new AtomicBoolean(false);\n\n        OneShotIterable(Iterable<T> delegate) {\n            this.delegate = delegate;\n        }\n\n        public Iterator<T> iterator() {\n            if (iterated.compareAndSet(false, true)) {\n                return delegate.iterator();\n            }\n            throw new IllegalStateException(\"Cannot call iterator() more than once\");\n        }\n    }\n\n    @Test\n    public void runsForEverySingleArgumentOfIterable() {\n        Result result= JUnitCore\n                .runClasses(SingleArgumentTestWithIterable.class);\n        assertEquals(2, result.getRunCount());\n    }\n\n    @RunWith(Parameterized.class)\n    public static class SingleArgumentTestWithCollection {\n        @Parameters\n        public static Iterable<? extends Object> data() {\n            return Collections.unmodifiableCollection(asList(\"first test\", \"second test\"));\n        }\n\n        public SingleArgumentTestWithCollection(Object argument) {\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    @Test\n    public void runsForEverySingleArgumentOfCollection() {\n        Result result= JUnitCore\n                .runClasses(SingleArgumentTestWithCollection.class);\n        assertEquals(2, result.getRunCount());\n    }\n\n\n    public static class ExceptionThrowingRunnerFactory implements\n            ParametersRunnerFactory {\n        public Runner createRunnerForTestWithParameters(TestWithParameters test)\n                throws InitializationError {\n            throw new InitializationError(\n                    \"Called ExceptionThrowingRunnerFactory.\");\n        }\n    }\n\n    @RunWith(Parameterized.class)\n    @UseParametersRunnerFactory(ExceptionThrowingRunnerFactory.class)\n    public static class TestWithUseParametersRunnerFactoryAnnotation {\n        @Parameters\n        public static Iterable<? extends Object> data() {\n            return asList(\"single test\");\n        }\n\n        public TestWithUseParametersRunnerFactoryAnnotation(Object argument) {\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    @Test\n    public void usesParametersRunnerFactoryThatWasSpecifiedByAnnotation() {\n        assertTestCreatesSingleFailureWithMessage(\n                TestWithUseParametersRunnerFactoryAnnotation.class,\n                \"Called ExceptionThrowingRunnerFactory.\");\n    }\n\n    private void assertTestCreatesSingleFailureWithMessage(Class<?> test, String message) {\n        Result result = JUnitCore.runClasses(test);\n        assertEquals(1, result.getFailures().size());\n        assertEquals(message, result.getFailures().get(0).getMessage());\n    }\n    \n    @RunWith(Parameterized.class)\n    @UseParametersRunnerFactory(ExceptionThrowingRunnerFactory.class)\n    public abstract static class UseParameterizedFactoryAbstractTest {\n        @Parameters\n        public static Iterable<? extends Object> data() {\n            return asList(\"single test\");\n        }\n    }\n    \n    public static class UseParameterizedFactoryTest extends\n            UseParameterizedFactoryAbstractTest {\n\n        public UseParameterizedFactoryTest(String parameter) {\n\n        }\n\n        @Test\n        public void parameterizedTest() {\n        }\n    }\n    \n    @Test\n    public void usesParametersRunnerFactoryThatWasSpecifiedByAnnotationInSuperClass() {\n        assertTestCreatesSingleFailureWithMessage(\n                UseParameterizedFactoryTest.class,\n                \"Called ExceptionThrowingRunnerFactory.\");\n    }\n\n    @RunWith(Parameterized.class)\n    public static class AssumptionInParametersMethod {\n        static boolean assumptionFails;\n\n        @Parameters\n        public static Iterable<String> data() {\n            assumeFalse(assumptionFails);\n            return Collections.singletonList(\"foobar\");\n        }\n\n        public AssumptionInParametersMethod(String parameter) {\n        }\n\n        @Test\n        public void test1() {\n        }\n\n        @Test\n        public void test2() {\n        }\n    }\n\n    @Test\n    public void testsAreExecutedWhenAssumptionInParametersMethodDoesNotFail() {\n        AssumptionInParametersMethod.assumptionFails = false;\n        Result result = JUnitCore.runClasses(AssumptionInParametersMethod.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(0, result.getAssumptionFailureCount());\n        assertEquals(0, result.getIgnoreCount());\n        assertEquals(2, result.getRunCount());\n    }\n\n    @Test\n    public void testsAreNotExecutedWhenAssumptionInParametersMethodFails() {\n        AssumptionInParametersMethod.assumptionFails = true;\n        Result result = JUnitCore.runClasses(AssumptionInParametersMethod.class);\n        assertTrue(result.wasSuccessful());\n        assertEquals(1, result.getAssumptionFailureCount());\n        assertEquals(0, result.getIgnoreCount());\n        assertEquals(0, result.getRunCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/ParentRunnerFilteringTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.fail;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining;\nimport static org.junit.runner.Description.createSuiteDescription;\nimport static org.junit.runner.Description.createTestDescription;\n\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.manipulation.NoTestsRemainException;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerBuilder;\n\npublic class ParentRunnerFilteringTest {\n    private static Filter notThisMethodName(final String methodName) {\n        return new Filter() {\n            @Override\n            public boolean shouldRun(Description description) {\n                return description.getMethodName() == null\n                        || !description.getMethodName().equals(methodName);\n            }\n\n            @Override\n            public String describe() {\n                return \"don't run method name: \" + methodName;\n            }\n        };\n    }\n\n    private static class CountingFilter extends Filter {\n        private final Map<Description, Integer> countMap = new HashMap<Description, Integer>();\n\n        @Override\n        public boolean shouldRun(Description description) {\n            Integer count = countMap.get(description);\n            if (count == null) {\n                countMap.put(description, 1);\n            } else {\n                countMap.put(description, count + 1);\n            }\n            return true;\n        }\n\n        @Override\n        public String describe() {\n            return \"filter counter\";\n        }\n\n        public int getCount(final Description desc) {\n            if (!countMap.containsKey(desc)) {\n                throw new IllegalArgumentException(\"Looking for \" + desc\n                        + \", but only contains: \" + countMap.keySet());\n            }\n            return countMap.get(desc);\n        }\n    }\n\n    public static class ExampleTest {\n        @Test\n        public void test1() throws Exception {\n            // passes\n        }\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses({ExampleTest.class})\n    public static class ExampleSuite {\n    }\n\n    @Test\n    public void testSuiteFiltering() throws Exception {\n        Runner runner = Request.aClass(ExampleSuite.class).getRunner();\n        Filter filter = notThisMethodName(\"test1\");\n        try {\n            filter.apply(runner);\n        } catch (NoTestsRemainException e) {\n            return;\n        }\n        fail(\"Expected 'NoTestsRemainException' due to complete filtering\");\n    }\n\n    public static class SuiteWithUnmodifiableChildList extends Suite {\n\n        public SuiteWithUnmodifiableChildList(\n                Class<?> klass, RunnerBuilder builder)\n                throws InitializationError {\n            super(klass, builder);\n        }\n\n        @Override\n        protected List<Runner> getChildren() {\n            return Collections.unmodifiableList(super.getChildren());\n        }\n    }\n\n    @RunWith(SuiteWithUnmodifiableChildList.class)\n    @SuiteClasses({ExampleTest.class})\n    public static class ExampleSuiteWithUnmodifiableChildList {\n    }\n\n    @Test\n    public void testSuiteFilteringWithUnmodifiableChildList() throws Exception {\n        Runner runner = Request.aClass(ExampleSuiteWithUnmodifiableChildList.class)\n                .getRunner();\n        Filter filter = notThisMethodName(\"test1\");\n        try {\n            filter.apply(runner);\n        } catch (NoTestsRemainException e) {\n            return;\n        }\n        fail(\"Expected 'NoTestsRemainException' due to complete filtering\");\n    }\n\n    @Test\n    public void testRunSuiteFiltering() throws Exception {\n        Request request = Request.aClass(ExampleSuite.class);\n        Request requestFiltered = request.filterWith(notThisMethodName(\"test1\"));\n        assertThat(testResult(requestFiltered),\n                hasSingleFailureContaining(\"don't run method name: test1\"));\n    }\n\n    @Test\n    public void testCountClassFiltering() throws Exception {\n        JUnitCore junitCore = new JUnitCore();\n        Request request = Request.aClass(ExampleTest.class);\n        CountingFilter countingFilter = new CountingFilter();\n        Request requestFiltered = request.filterWith(countingFilter);\n        Result result = junitCore.run(requestFiltered);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n\n        Description desc = createTestDescription(ExampleTest.class, \"test1\");\n        assertEquals(1, countingFilter.getCount(desc));\n    }\n\n    @Test\n    public void testCountSuiteFiltering() throws Exception {\n        Class<ExampleSuite> suiteClazz = ExampleSuite.class;\n        Class<ExampleTest> clazz = ExampleTest.class;\n\n        JUnitCore junitCore = new JUnitCore();\n        Request request = Request.aClass(suiteClazz);\n        CountingFilter countingFilter = new CountingFilter();\n        Request requestFiltered = request.filterWith(countingFilter);\n        Result result = junitCore.run(requestFiltered);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n\n        Description suiteDesc = createSuiteDescription(clazz);\n        assertEquals(1, countingFilter.getCount(suiteDesc));\n\n        Description desc = createTestDescription(ExampleTest.class, \"test1\");\n        assertEquals(1, countingFilter.getCount(desc));\n    }\n}"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/ParentRunnerTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.List;\n\nimport org.hamcrest.Matcher;\nimport org.hamcrest.TypeSafeMatcher;\nimport org.junit.Assert;\nimport org.junit.BeforeClass;\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.manipulation.Filter;\nimport org.junit.runner.notification.Failure;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.ParentRunner;\nimport org.junit.runners.model.InitializationError;\nimport org.junit.runners.model.RunnerScheduler;\nimport org.junit.rules.RuleMemberValidatorTest.TestWithNonStaticClassRule;\nimport org.junit.rules.RuleMemberValidatorTest.TestWithProtectedClassRule;\n\npublic class ParentRunnerTest {\n    public static String log = \"\";\n\n    public static class FruitTest {\n        @Test\n        public void apple() {\n            log += \"apple \";\n        }\n\n        @Test\n        public void /* must hash-sort after \"apple\" */Banana() {\n            log += \"banana \";\n        }\n    }\n\n    @Test\n    public void useChildHarvester() throws InitializationError {\n        log = \"\";\n        ParentRunner<?> runner = new BlockJUnit4ClassRunner(FruitTest.class);\n        runner.setScheduler(new RunnerScheduler() {\n            public void schedule(Runnable childStatement) {\n                log += \"before \";\n                childStatement.run();\n                log += \"after \";\n            }\n\n            public void finished() {\n                log += \"afterAll \";\n            }\n        });\n\n        runner.run(new RunNotifier());\n        assertEquals(\"before apple after before banana after afterAll \", log);\n    }\n\n    @Test\n    public void testMultipleFilters() throws Exception {\n        JUnitCore junitCore = new JUnitCore();\n        Request request = Request.aClass(ExampleTest.class);\n        Request requestFiltered = request.filterWith(new Exclude(\"test1\"));\n        Request requestFilteredFiltered = requestFiltered\n                .filterWith(new Exclude(\"test2\"));\n        Result result = junitCore.run(requestFilteredFiltered);\n        assertThat(result.getFailures(), isEmpty());\n        assertEquals(1, result.getRunCount());\n    }\n\n    private Matcher<List<?>> isEmpty() {\n        return new TypeSafeMatcher<List<?>>() {\n            public void describeTo(org.hamcrest.Description description) {\n                description.appendText(\"is empty\");\n            }\n\n            @Override\n            public boolean matchesSafely(List<?> item) {\n                return item.size() == 0;\n            }\n        };\n    }\n\n    private static class Exclude extends Filter {\n        private final String methodName;\n\n        public Exclude(String methodName) {\n            this.methodName = methodName;\n        }\n\n        @Override\n        public boolean shouldRun(Description description) {\n            return !description.getMethodName().equals(methodName);\n        }\n\n        @Override\n        public String describe() {\n            return \"filter method name: \" + methodName;\n        }\n    }\n\n    public static class ExampleTest {\n        @Test\n        public void test1() throws Exception {\n        }\n\n        @Test\n        public void test2() throws Exception {\n        }\n\n        @Test\n        public void test3() throws Exception {\n        }\n    }\n\n    @Test\n    public void failWithHelpfulMessageForProtectedClassRule() {\n        assertClassHasFailureMessage(TestWithProtectedClassRule.class,\n                \"The @ClassRule 'temporaryFolder' must be public.\");\n    }\n\n    @Test\n    public void failWithHelpfulMessageForNonStaticClassRule() {\n        assertClassHasFailureMessage(TestWithNonStaticClassRule.class,\n                \"The @ClassRule 'temporaryFolder' must be static.\");\n    }\n\n    static class NonPublicTestClass {\n        public NonPublicTestClass() {\n        }\n\n        @Test\n        public void alwaysPasses() {}\n    }\n\n    @Test\n    public void cannotBeCreatedWithNonPublicTestClass() {\n        assertClassHasFailureMessage(\n                NonPublicTestClass.class,\n                \"The class org.junit.tests.running.classes.ParentRunnerTest$NonPublicTestClass is not public.\");\n    }\n\n    private void assertClassHasFailureMessage(Class<?> klass, String message) {\n        JUnitCore junitCore = new JUnitCore();\n        Request request = Request.aClass(klass);\n        Result result = junitCore.run(request);\n        assertThat(result.getFailureCount(), is(1));\n        assertThat(result.getFailures().get(0).getMessage(),\n                containsString(message));\n    }\n\n    public static class AssertionErrorAtParentLevelTest {\n        @BeforeClass\n        public static void beforeClass() throws Throwable {\n            throw new AssertionError(\"Thrown from @BeforeClass\");\n        }\n\n        @Test\n        public void test() {}\n    }\n\n    @Test\n    public void assertionErrorAtParentLevelTest() throws InitializationError {\n        CountingRunListener countingRunListener = runTestWithParentRunner(AssertionErrorAtParentLevelTest.class);\n        Assert.assertEquals(1, countingRunListener.testSuiteStarted);\n        Assert.assertEquals(1, countingRunListener.testSuiteFinished);\n        Assert.assertEquals(1, countingRunListener.testSuiteFailure);\n        Assert.assertEquals(0, countingRunListener.testSuiteAssumptionFailure);\n\n        Assert.assertEquals(0, countingRunListener.testStarted);\n        Assert.assertEquals(0, countingRunListener.testFinished);\n        Assert.assertEquals(0, countingRunListener.testFailure);\n        Assert.assertEquals(0, countingRunListener.testAssumptionFailure);\n        Assert.assertEquals(0, countingRunListener.testIgnored);\n    }\n\n    public static class AssumptionViolatedAtParentLevelTest {\n        @SuppressWarnings(\"deprecation\")\n        @BeforeClass\n        public static void beforeClass() {\n            throw new AssumptionViolatedException(\"Thrown from @BeforeClass\");\n        }\n\n        @Test\n        public void test() {}\n    }\n\n    @Test\n    public void assumptionViolatedAtParentLevel() throws InitializationError {\n        CountingRunListener countingRunListener = runTestWithParentRunner(AssumptionViolatedAtParentLevelTest.class);\n        Assert.assertEquals(1, countingRunListener.testSuiteStarted);\n        Assert.assertEquals(1, countingRunListener.testSuiteFinished);\n        Assert.assertEquals(0, countingRunListener.testSuiteFailure);\n        Assert.assertEquals(1, countingRunListener.testSuiteAssumptionFailure);\n\n        Assert.assertEquals(0, countingRunListener.testStarted);\n        Assert.assertEquals(0, countingRunListener.testFinished);\n        Assert.assertEquals(0, countingRunListener.testFailure);\n        Assert.assertEquals(0, countingRunListener.testAssumptionFailure);\n        Assert.assertEquals(0, countingRunListener.testIgnored);\n    }\n\n    public static class TestTest {\n        @Test\n        public void pass() {}\n\n        @Test\n        public void fail() {\n            throw new AssertionError(\"Thrown from @Test\");\n        }\n\n        @Ignore\n        @Test\n        public void ignore() {}\n\n        @SuppressWarnings(\"deprecation\")\n        @Test\n        public void assumptionFail() {\n            throw new AssumptionViolatedException(\"Thrown from @Test\");\n        }\n    }\n\n    @Test\n    public void parentRunnerTestMethods() throws InitializationError {\n        CountingRunListener countingRunListener = runTestWithParentRunner(TestTest.class);\n        Assert.assertEquals(1, countingRunListener.testSuiteStarted);\n        Assert.assertEquals(1, countingRunListener.testSuiteFinished);\n        Assert.assertEquals(0, countingRunListener.testSuiteFailure);\n        Assert.assertEquals(0, countingRunListener.testSuiteAssumptionFailure);\n\n        Assert.assertEquals(3, countingRunListener.testStarted);\n        Assert.assertEquals(3, countingRunListener.testFinished);\n        Assert.assertEquals(1, countingRunListener.testFailure);\n        Assert.assertEquals(1, countingRunListener.testAssumptionFailure);\n        Assert.assertEquals(1, countingRunListener.testIgnored);\n    }\n\n    private CountingRunListener runTestWithParentRunner(Class<?> testClass) throws InitializationError {\n        CountingRunListener listener = new CountingRunListener();\n        RunNotifier runNotifier = new RunNotifier();\n        runNotifier.addListener(listener);\n        ParentRunner<?> runner = new BlockJUnit4ClassRunner(testClass);\n        runner.run(runNotifier);\n        return listener;\n    }\n\n    private static class CountingRunListener extends RunListener {\n        private int testSuiteStarted = 0;\n        private int testSuiteFinished = 0;\n        private int testSuiteFailure = 0;\n        private int testSuiteAssumptionFailure = 0;\n\n        private int testStarted = 0;\n        private int testFinished = 0;\n        private int testFailure = 0;\n        private int testAssumptionFailure = 0;\n        private int testIgnored = 0;\n\n        @Override\n        public void testSuiteStarted(Description description) throws Exception {\n            testSuiteStarted++;\n        }\n\n        @Override\n        public void testSuiteFinished(Description description) throws Exception {\n            testSuiteFinished++;\n        }\n\n        @Override\n        public void testStarted(Description description) throws Exception {\n            testStarted++;\n        }\n\n        @Override\n        public void testFinished(Description description) throws Exception {\n            testFinished++;\n        }\n\n        @Override\n        public void testFailure(Failure failure) throws Exception {\n            if (failure.getDescription().isSuite()) {\n                testSuiteFailure++;\n            } else {\n                testFailure++;\n            }\n        }\n\n        @Override\n        public void testAssumptionFailure(Failure failure) {\n            if (failure.getDescription().isSuite()) {\n                testSuiteAssumptionFailure++;\n            } else {\n                testAssumptionFailure++;\n            }\n        }\n\n        @Override\n        public void testIgnored(Description description) throws Exception {\n            testIgnored++;\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/RunWithTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runner.notification.RunNotifier;\n\npublic class RunWithTest {\n\n    private static String log;\n\n    public static class ExampleRunner extends Runner {\n        public ExampleRunner(Class<?> klass) {\n            log += \"initialize\";\n        }\n\n        @Override\n        public void run(RunNotifier notifier) {\n            log += \"run\";\n        }\n\n        @Override\n        public int testCount() {\n            log += \"count\";\n            return 0;\n        }\n\n        @Override\n        public Description getDescription() {\n            log += \"plan\";\n            return Description.createSuiteDescription(\"example\");\n        }\n    }\n\n    @RunWith(ExampleRunner.class)\n    public static class ExampleTest {\n    }\n\n    @Test\n    public void run() {\n        log = \"\";\n\n        JUnitCore.runClasses(ExampleTest.class);\n        assertTrue(log.contains(\"plan\"));\n        assertTrue(log.contains(\"initialize\"));\n        assertTrue(log.contains(\"run\"));\n    }\n\n    public static class SubExampleTest extends ExampleTest {\n    }\n\n    @Test\n    public void runWithExtendsToSubclasses() {\n        log = \"\";\n\n        JUnitCore.runClasses(SubExampleTest.class);\n        assertTrue(log.contains(\"run\"));\n    }\n\n    public static class BadRunner extends Runner {\n        @Override\n        public Description getDescription() {\n            return null;\n        }\n\n        @Override\n        public void run(RunNotifier notifier) {\n            // do nothing\n        }\n    }\n\n    @RunWith(BadRunner.class)\n    public static class Empty {\n    }\n\n    @Test\n    public void characterizeErrorMessageFromBadRunner() {\n        assertEquals(\n                \"Custom runner class BadRunner should have a public constructor with signature BadRunner(Class testClass)\",\n                JUnitCore.runClasses(Empty.class).getFailures().get(0)\n                        .getMessage());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/SuiteTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.List;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestResult;\nimport org.junit.AfterClass;\nimport org.junit.Assert;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.Runner;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\npublic class SuiteTest {\n    public static class TestA {\n        @Test\n        public void pass() {\n        }\n    }\n\n    public static class TestB {\n        @Test\n        public void fail() {\n            Assert.fail();\n        }\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses({TestA.class, TestB.class})\n    public static class All {\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses(TestA.class)\n    static class NonPublicSuite {\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses(TestA.class)\n    static class NonPublicSuiteWithBeforeClass {\n        @BeforeClass\n        public static void doesNothing() {}\n    }\n\n    public static class InheritsAll extends All {\n    }\n\n    @Test\n    public void ensureTestIsRun() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(All.class);\n        assertEquals(2, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n    }\n\n    @Test\n    public void ensureInheritedTestIsRun() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(InheritsAll.class);\n        assertEquals(2, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n    }\n\n    @Test\n    public void suiteTestCountIsCorrect() throws Exception {\n        Runner runner = Request.aClass(All.class).getRunner();\n        assertEquals(2, runner.testCount());\n    }\n\n    @Test\n    public void suiteClassDoesNotNeedToBePublic() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(NonPublicSuite.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n\n    @Test\n    public void nonPublicSuiteClassWithBeforeClassPasses() {\n        assertThat(testResult(NonPublicSuiteWithBeforeClass.class), isSuccessful());\n    }\n\n    @Test\n    public void ensureSuitesWorkWithForwardCompatibility() {\n        junit.framework.Test test = new JUnit4TestAdapter(All.class);\n        TestResult result = new TestResult();\n        test.run(result);\n        assertEquals(2, result.runCount());\n    }\n\n    @Test\n    public void forwardCompatibilityWorksWithGetTests() {\n        JUnit4TestAdapter adapter = new JUnit4TestAdapter(All.class);\n        List<? extends junit.framework.Test> tests = adapter.getTests();\n        assertEquals(2, tests.size());\n    }\n\n    @Test\n    public void forwardCompatibilityWorksWithTestCount() {\n        JUnit4TestAdapter adapter = new JUnit4TestAdapter(All.class);\n        assertEquals(2, adapter.countTestCases());\n    }\n\n\n    private static String log = \"\";\n\n    @RunWith(Suite.class)\n    @SuiteClasses({TestA.class, TestB.class})\n    public static class AllWithBeforeAndAfterClass {\n        @BeforeClass\n        public static void before() {\n            log += \"before \";\n        }\n\n        @AfterClass\n        public static void after() {\n            log += \"after \";\n        }\n    }\n\n    @Test\n    public void beforeAndAfterClassRunOnSuite() {\n        log = \"\";\n        JUnitCore.runClasses(AllWithBeforeAndAfterClass.class);\n        assertEquals(\"before after \", log);\n    }\n\n    @RunWith(Suite.class)\n    public static class AllWithOutAnnotation {\n    }\n\n    @Test\n    public void withoutSuiteClassAnnotationProducesFailure() {\n        Result result = JUnitCore.runClasses(AllWithOutAnnotation.class);\n        assertEquals(1, result.getFailureCount());\n        String expected = String.format(\n                \"class '%s' must have a SuiteClasses annotation\",\n                AllWithOutAnnotation.class.getName());\n        assertEquals(expected, result.getFailures().get(0).getMessage());\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses(InfiniteLoop.class)\n    static public class InfiniteLoop {\n    }\n\n    @Test\n    public void whatHappensWhenASuiteHasACycle() {\n        Result result = JUnitCore.runClasses(InfiniteLoop.class);\n        assertEquals(1, result.getFailureCount());\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses({BiInfiniteLoop.class, BiInfiniteLoop.class})\n    static public class BiInfiniteLoop {\n    }\n\n    @Test\n    public void whatHappensWhenASuiteHasAForkingCycle() {\n        Result result = JUnitCore.runClasses(BiInfiniteLoop.class);\n        assertEquals(2, result.getFailureCount());\n    }\n\n    // The interesting case here is that Hydra indirectly contains two copies of\n    // itself (if it only contains one, Java's StackOverflowError eventually\n    // bails us out)\n\n    @RunWith(Suite.class)\n    @SuiteClasses({Hercules.class})\n    static public class Hydra {\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses({Hydra.class, Hydra.class})\n    static public class Hercules {\n    }\n\n    @Test\n    public void whatHappensWhenASuiteContainsItselfIndirectly() {\n        Result result = JUnitCore.runClasses(Hydra.class);\n        assertEquals(2, result.getFailureCount());\n    }\n\n    @RunWith(Suite.class)\n    @SuiteClasses({})\n    public class WithoutDefaultConstructor {\n        public WithoutDefaultConstructor(int i) {\n\n        }\n    }\n\n    @Test\n    public void suiteShouldBeOKwithNonDefaultConstructor() throws Exception {\n        Result result = JUnitCore.runClasses(WithoutDefaultConstructor.class);\n        assertTrue(result.wasSuccessful());\n    }\n\n    @RunWith(Suite.class)\n    public class NoSuiteClassesAnnotation {\n    }\n\n    @Test\n    public void suiteShouldComplainAboutNoSuiteClassesAnnotation() {\n        assertThat(testResult(NoSuiteClassesAnnotation.class), hasSingleFailureContaining(\"SuiteClasses\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/ThreadsTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport org.junit.AfterClass;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.notification.RunListener;\nimport org.junit.runners.BlockJUnit4ClassRunner;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport static java.util.Arrays.asList;\nimport static java.util.Collections.singletonList;\nimport static org.junit.Assert.assertEquals;\n\npublic class ThreadsTest {\n\n    private List<Boolean> interruptedFlags = new ArrayList<Boolean>();\n    private JUnitCore core = new JUnitCore();\n\n    public static class TestWithInterrupt {\n\n        @Test\n        public void interruptCurrentThread() {\n            Thread.currentThread().interrupt();\n        }\n\n        @Test\n        public void otherTestCaseInterruptingCurrentThread() {\n            Thread.currentThread().interrupt();\n        }\n\n    }\n\n    @Test\n    public void currentThreadInterruptedStatusIsClearedAfterEachTestExecution() {\n        core.addListener(new RunListener() {\n            @Override\n            public void testFinished(Description description) {\n                interruptedFlags.add(Thread.currentThread().isInterrupted());\n            }\n        });\n\n        Result result = core.run(TestWithInterrupt.class);\n\n        assertEquals(0, result.getFailureCount());\n        assertEquals(asList(false, false), interruptedFlags);\n    }\n\n    @RunWith(BlockJUnit4ClassRunner.class)\n    public static class TestWithInterruptFromAfterClass {\n        @AfterClass\n        public static void interruptCurrentThread() {\n            Thread.currentThread().interrupt();\n        }\n\n        @Test\n        public void test() {\n            // no-op\n        }\n    }\n\n    @Test\n    public void currentThreadInterruptStatusIsClearedAfterSuiteExecution() {\n        core.addListener(new RunListener() {\n            @Override\n            public void testSuiteFinished(Description description) {\n                interruptedFlags.add(Thread.currentThread().isInterrupted());\n            }\n        });\n\n        Request request = Request.aClass(TestWithInterruptFromAfterClass.class);\n\n        Result result = core.run(request);\n\n        assertEquals(0, result.getFailureCount());\n        assertEquals(singletonList(false), interruptedFlags);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/UseSuiteAsASuperclassTest.java",
    "content": "package org.junit.tests.running.classes;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.fail;\n\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.model.InitializationError;\n\npublic class UseSuiteAsASuperclassTest {\n\n    public static class TestA {\n        @Test\n        public void pass() {\n        }\n    }\n\n    public static class TestB {\n        @Test\n        public void dontPass() {\n            fail();\n        }\n    }\n\n    public static class MySuite extends Suite {\n        public MySuite(Class<?> klass) throws InitializationError {\n            super(klass, new Class[]{TestA.class, TestB.class});\n        }\n    }\n\n    @RunWith(MySuite.class)\n    public static class AllWithMySuite {\n    }\n\n    @Test\n    public void ensureTestsAreRun() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(AllWithMySuite.class);\n        assertEquals(2, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/parent/ParentRunnerClassLoaderTest.java",
    "content": "package org.junit.tests.running.classes.parent;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.lang.reflect.Field;\nimport java.net.URL;\nimport java.net.URLClassLoader;\n\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.notification.RunNotifier;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.ParentRunner;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.InitializationError;\n\npublic class ParentRunnerClassLoaderTest {\n    @Test\n    public void testClassRuleAccessToClassInAnotherClassLoader() throws Exception {\n        Class<?> testClassWithOwnClassLoader = wrapToClassLoader(TestWithClassRule.class);\n\n        runTestWithParentRunner(testClassWithOwnClassLoader);\n\n        Field fieldWithReference = testClassWithOwnClassLoader.getDeclaredField(\"applyTestClass\");\n        Class<?> usedClass = (Class<?>) fieldWithReference.get(null);\n\n        assertEquals(\"JUnitRunner can be located in own classLoader, so, \" +\n                        \"Class.forName org.junit.runner.Description.getTestClass can not see \" +\n                        \"in current classloader by execute Class.forName\",\n                testClassWithOwnClassLoader, usedClass\n        );\n    }\n\n    @Test\n    public void testDescriptionContainCorrectTestClass() throws Exception {\n        Class<?> testClassWithOwnClassLoader = wrapToClassLoader(TestWithClassRule.class);\n        ParentRunner<?> runner = new BlockJUnit4ClassRunner(testClassWithOwnClassLoader);\n\n        Description description = runner.getDescription();\n        assertEquals(\"ParentRunner accept already instantiate Class<?> with tests, if we lost it instance, and will \" +\n                \"use Class.forName we can not find test class again, because tests can be \" +\n                \"located in different ClassLoader\",\n                description.getTestClass(), testClassWithOwnClassLoader\n        );\n    }\n\n    @Test\n    public void testBackwardCompatibilityWithOverrideGetName() throws Exception {\n        final Class<TestWithClassRule> originalTestClass = TestWithClassRule.class;\n        final Class<?> waitClass = ParentRunnerClassLoaderTest.class;\n\n        ParentRunner<FrameworkMethod> subParentRunner = new BlockJUnit4ClassRunner(originalTestClass) {\n            @Override\n            protected String getName() {\n                return waitClass.getName();\n            }\n        };\n\n        Description description = subParentRunner.getDescription();\n        Class<?> result = description.getTestClass();\n\n        assertEquals(\"Subclass of ParentRunner can override getName method and specify another test class for run, \" +\n                \"we should  maintain backwards compatibility with JUnit 4.12\",\n                waitClass, result\n        );\n    }\n\n    private void runTestWithParentRunner(Class<?> testClass) throws InitializationError {\n        ParentRunner<?> runner = new BlockJUnit4ClassRunner(testClass);\n        runner.run(new RunNotifier());\n    }\n\n    private Class<?> wrapToClassLoader(Class<?> sourceClass) throws ClassNotFoundException {\n        URL classpath = sourceClass.getProtectionDomain().getCodeSource().getLocation();\n        VisibleClassLoader loader = new VisibleClassLoader(new URL[]{classpath}, this.getClass().getClassLoader());\n        Class<?> testClassWithOwnClassLoader = loader.findClass(sourceClass.getName());\n\n        assert testClassWithOwnClassLoader != sourceClass;\n\n        return testClassWithOwnClassLoader;\n    }\n\n\n    private static class VisibleClassLoader extends URLClassLoader {\n        public VisibleClassLoader(URL[] urls, ClassLoader parent) {\n            super(urls, parent);\n        }\n\n        @Override // just making public\n        public Class<?> findClass(String name) throws ClassNotFoundException {\n            return super.findClass(name);\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/classes/parent/TestWithClassRule.java",
    "content": "package org.junit.tests.running.classes.parent;\n\nimport org.junit.Assert;\nimport org.junit.ClassRule;\nimport org.junit.Test;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.Description;\nimport org.junit.runners.model.Statement;\n\nimport java.lang.reflect.Field;\n\n/**\n * Test class for validate run tests that was load in own ClassLoader\n */\npublic class TestWithClassRule {\n    public static Class<?> applyTestClass;\n\n    @ClassRule\n    public static TestRule rule = new CustomRule();\n\n    @Test\n    public void testClassRuleExecuted() throws Exception {\n        Assert.assertNotNull(\"Description should contain reference to TestClass\", applyTestClass);\n    }\n\n    public static final class CustomRule implements TestRule {\n\n        public Statement apply(final Statement base, final Description description) {\n            return new Statement() {\n                @Override\n                public void evaluate() throws Throwable {\n                    Class<?> testClass = description.getTestClass();\n                    if(testClass != null) {\n                        Field field = testClass.getDeclaredField(\"applyTestClass\");\n                        field.set(null, description.getTestClass());\n                    }\n                    base.evaluate();\n                }\n            };\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/core/AllCoreTests.java",
    "content": "package org.junit.tests.running.core;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        CommandLineTest.class,\n        JUnitCoreReturnsCorrectExitCodeTest.class,\n        SystemExitTest.class\n})\npublic class AllCoreTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/core/CommandLineTest.java",
    "content": "package org.junit.tests.running.core;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.PrintStream;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.MainRunner;\n\npublic class CommandLineTest {\n    private ByteArrayOutputStream results;\n    private PrintStream oldOut;\n    private static boolean testWasRun;\n\n    @Before\n    public void before() {\n        oldOut = System.out;\n        results = new ByteArrayOutputStream();\n        System.setOut(new PrintStream(results));\n    }\n\n    @After\n    public void after() {\n        System.setOut(oldOut);\n    }\n\n    public static class Example {\n        @Test\n        public void test() {\n            testWasRun = true;\n        }\n    }\n\n    @Test\n    public void runATest() {\n        testWasRun = false;\n        MainRunner.runMain(Example.class.getName());\n        assertTrue(testWasRun);\n    }\n\n    @Test\n    public void runAClass() {\n        testWasRun = false;\n        JUnitCore.runClasses(Example.class);\n        assertTrue(testWasRun);\n    }\n\n    private static int fCount;\n\n    public static class Count {\n        @Test\n        public void increment() {\n            fCount++;\n        }\n    }\n\n    @Test\n    public void runTwoClassesAsArray() {\n        fCount = 0;\n        JUnitCore.runClasses(new Class[]{Count.class, Count.class});\n        assertEquals(2, fCount);\n    }\n\n    @Test\n    public void runTwoClasses() {\n        fCount = 0;\n        JUnitCore.runClasses(Count.class, Count.class);\n        assertEquals(2, fCount);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/core/JUnitCoreReturnsCorrectExitCodeTest.java",
    "content": "package org.junit.tests.running.core;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.fail;\n\nimport org.junit.Test;\nimport org.junit.runner.MainRunner;\n\npublic class JUnitCoreReturnsCorrectExitCodeTest {\n\n    public static class Fail {\n        @Test\n        public void kaboom() {\n            fail();\n        }\n    }\n\n    @Test\n    public void failureCausesExitCodeOf1() throws Exception {\n        runClass(getClass().getName() + \"$Fail\", 1);\n    }\n\n    @Test\n    public void missingClassCausesExitCodeOf1() throws Exception {\n        runClass(\"Foo\", 1);\n    }\n\n    public static class Succeed {\n        @Test\n        public void peacefulSilence() {\n        }\n    }\n\n    @Test\n    public void successCausesExitCodeOf0() throws Exception {\n        runClass(getClass().getName() + \"$Succeed\", 0);\n    }\n\n    private void runClass(final String className, int returnCode) {\n        int exitValue = MainRunner.runMain(className);\n        assertEquals(returnCode, exitValue);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/core/SystemExitTest.java",
    "content": "package org.junit.tests.running.core;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.io.File;\nimport java.io.InputStream;\n\nimport org.junit.Test;\n\n// Make sure System.exit works as expected. We've had problems with this on some platforms.\npublic class SystemExitTest {\n\n    private static final int EXIT_CODE = 5;\n\n    static public class Exit {\n        public static void main(String[] args) {\n            System.exit(EXIT_CODE);\n        }\n    }\n\n    @Test\n    public void failureCausesExitCodeOf1() throws Exception {\n        String java = System.getProperty(\"java.home\") + File.separator + \"bin\" + File.separator + \"java\";\n        String classPath = getClass().getClassLoader().getResource(\".\").getFile() + File.pathSeparator + System.getProperty(\"java.class.path\");\n        String[] cmd = {java, \"-cp\", classPath, getClass().getName() + \"$Exit\"};\n        Process process = Runtime.getRuntime().exec(cmd);\n        InputStream input = process.getInputStream();\n        while ((input.read()) != -1) ;\n        assertEquals(EXIT_CODE, process.waitFor());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/methods/AllMethodsTests.java",
    "content": "package org.junit.tests.running.methods;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AnnotationTest.class,\n        ExpectedTest.class,\n        InheritedTestTest.class,\n        ParameterizedTestMethodTest.class,\n        TestMethodTest.class,\n        TimeoutTest.class\n})\npublic class AllMethodsTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/methods/AnnotationTest.java",
    "content": "package org.junit.tests.running.methods;\n\nimport static org.hamcrest.CoreMatchers.allOf;\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.experimental.results.PrintableResult.testResult;\nimport static org.junit.experimental.results.ResultMatchers.isSuccessful;\n\nimport java.util.Collection;\nimport java.util.HashSet;\n\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.ClassRule;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExternalResource;\nimport org.junit.rules.TestRule;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.JUnit4;\n\npublic class AnnotationTest extends TestCase {\n    static boolean run;\n\n    @Override\n    public void setUp() {\n        run = false;\n    }\n\n    public static class SimpleTest {\n        @Test\n        public void success() {\n            run = true;\n        }\n    }\n\n    public void testAnnotatedMethod() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        runner.run(SimpleTest.class);\n        assertTrue(run);\n    }\n\n    @RunWith(JUnit4.class)\n    public static class SimpleTestWithFutureProofExplicitRunner {\n        @Test\n        public void success() {\n            run = true;\n        }\n    }\n\n    public void testAnnotatedMethodWithFutureProofExplicitRunner() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        runner.run(SimpleTestWithFutureProofExplicitRunner.class);\n        assertTrue(run);\n    }\n\n    public static class SetupTest {\n        @Before\n        public void before() {\n            run = true;\n        }\n\n        @Test\n        public void success() {\n        }\n    }\n\n    public void testSetup() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        runner.run(SetupTest.class);\n        assertTrue(run);\n    }\n\n    public static class TeardownTest {\n        @After\n        public void after() {\n            run = true;\n        }\n\n        @Test\n        public void success() {\n        }\n    }\n\n    public void testTeardown() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        runner.run(TeardownTest.class);\n        assertTrue(run);\n    }\n\n    public static class FailureTest {\n        @Test\n        public void error() throws Exception {\n            org.junit.Assert.fail();\n        }\n    }\n\n    public void testRunFailure() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(FailureTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        assertEquals(AssertionError.class, result.getFailures().get(0).getException().getClass());\n    }\n\n    public static class SetupFailureTest {\n        @Before\n        public void before() {\n            throw new Error();\n        }\n\n        @Test\n        public void test() {\n            run = true;\n        }\n    }\n\n    public void testSetupFailure() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result runner = core.run(SetupFailureTest.class);\n        assertEquals(1, runner.getRunCount());\n        assertEquals(1, runner.getFailureCount());\n        assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());\n        assertFalse(run);\n    }\n\n    public static class TeardownFailureTest {\n        @After\n        public void after() {\n            throw new Error();\n        }\n\n        @Test\n        public void test() {\n        }\n    }\n\n    public void testTeardownFailure() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result runner = core.run(TeardownFailureTest.class);\n        assertEquals(1, runner.getRunCount());\n        assertEquals(1, runner.getFailureCount());\n        assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());\n    }\n\n    public static class TestAndTeardownFailureTest {\n        @After\n        public void after() {\n            throw new Error(\"hereAfter\");\n        }\n\n        @Test\n        public void test() throws Exception {\n            throw new Exception(\"inTest\");\n        }\n    }\n\n    public void testTestAndTeardownFailure() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result runner = core.run(TestAndTeardownFailureTest.class);\n        assertEquals(1, runner.getRunCount());\n        assertEquals(2, runner.getFailureCount());\n        assertThat(runner.getFailures().toString(), allOf(containsString(\"hereAfter\"), containsString(\"inTest\")));\n    }\n\n    public static class TeardownAfterFailureTest {\n        @After\n        public void after() {\n            run = true;\n        }\n\n        @Test\n        public void test() throws Exception {\n            throw new Exception();\n        }\n    }\n\n    public void testTeardownAfterFailure() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        runner.run(TeardownAfterFailureTest.class);\n        assertTrue(run);\n    }\n\n    static int count;\n    static Collection<Object> tests;\n\n    public static class TwoTests {\n        @Test\n        public void one() {\n            count++;\n            tests.add(this);\n        }\n\n        @Test\n        public void two() {\n            count++;\n            tests.add(this);\n        }\n    }\n\n    public void testTwoTests() throws Exception {\n        count = 0;\n        tests = new HashSet<Object>();\n        JUnitCore runner = new JUnitCore();\n        runner.run(TwoTests.class);\n        assertEquals(2, count);\n        assertEquals(2, tests.size());\n    }\n\n    public static class OldTest extends TestCase {\n        public void test() {\n            run = true;\n        }\n    }\n\n    public void testOldTest() throws Exception {\n        JUnitCore runner = new JUnitCore();\n        runner.run(OldTest.class);\n        assertTrue(run);\n    }\n\n    public static class OldSuiteTest extends TestCase {\n        public void testOne() {\n            run = true;\n        }\n    }\n\n    public void testOldSuiteTest() throws Exception {\n        TestSuite suite = new TestSuite(OldSuiteTest.class);\n        JUnitCore runner = new JUnitCore();\n        runner.run(suite);\n        assertTrue(run);\n    }\n\n    public static class ExceptionTest {\n        @Test(expected = Error.class)\n        public void expectedException() {\n            throw new Error();\n        }\n    }\n\n    public void testException() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(ExceptionTest.class);\n        assertEquals(0, result.getFailureCount());\n    }\n\n    public static class NoExceptionTest {\n        @Test(expected = Error.class)\n        public void expectedException() {\n        }\n    }\n\n    public void testExceptionNotThrown() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(NoExceptionTest.class);\n        assertEquals(1, result.getFailureCount());\n        assertEquals(\"Expected exception: java.lang.Error\", result.getFailures().get(0).getMessage());\n    }\n\n    public static class OneTimeSetup {\n        @BeforeClass\n        public static void once() {\n            count++;\n        }\n\n        @Test\n        public void one() {\n        }\n\n        @Test\n        public void two() {\n        }\n    }\n\n    public void testOneTimeSetup() throws Exception {\n        count = 0;\n        JUnitCore core = new JUnitCore();\n        core.run(OneTimeSetup.class);\n        assertEquals(1, count);\n    }\n\n    public static class OneTimeTeardown {\n        @AfterClass\n        public static void once() {\n            count++;\n        }\n\n        @Test\n        public void one() {\n        }\n\n        @Test\n        public void two() {\n        }\n    }\n\n    public void testOneTimeTeardown() throws Exception {\n        count = 0;\n        JUnitCore core = new JUnitCore();\n        core.run(OneTimeTeardown.class);\n        assertEquals(1, count);\n    }\n\n    static String log;\n\n    public static class OrderTest {\n        @BeforeClass\n        public static void onceBefore() {\n            log += \"beforeClass \";\n        }\n\n        @Before\n        public void before() {\n            log += \"before \";\n        }\n\n        @Test\n        public void test() {\n            log += \"test \";\n        }\n\n        @After\n        public void after() {\n            log += \"after \";\n        }\n\n        @AfterClass\n        public static void onceAfter() {\n            log += \"afterClass \";\n        }\n    }\n\n    public void testOrder() throws Exception {\n        log = \"\";\n        JUnitCore core = new JUnitCore();\n        core.run(OrderTest.class);\n        assertEquals(\"beforeClass before test after afterClass \", log);\n    }\n\n    public static class NonStaticOneTimeSetup {\n        @BeforeClass\n        public void once() {\n        }\n\n        @Test\n        public void aTest() {\n        }\n    }\n\n    public void testNonStaticOneTimeSetup() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(NonStaticOneTimeSetup.class);\n        assertEquals(1, result.getFailureCount());\n    }\n\n    public static class ErrorInBeforeClass {\n        @BeforeClass\n        public static void before() throws Exception {\n            throw new Exception();\n        }\n\n        @Test\n        public void test() {\n            run = true;\n        }\n    }\n\n    public void testErrorInBeforeClass() throws Exception {\n        run = false;\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(ErrorInBeforeClass.class);\n        assertFalse(run);\n        assertEquals(1, result.getFailureCount());\n        Description description = result.getFailures().get(0).getDescription();\n        assertEquals(ErrorInBeforeClass.class.getName(), description.getDisplayName());\n    }\n\n    public static class ErrorInAfterClass {\n        @Test\n        public void test() {\n            run = true;\n        }\n\n        @AfterClass\n        public static void after() throws Exception {\n            throw new Exception();\n        }\n    }\n\n    public void testErrorInAfterClass() throws Exception {\n        run = false;\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(ErrorInAfterClass.class);\n        assertTrue(run);\n        assertEquals(1, result.getFailureCount());\n    }\n\n    static class SuperInheritance {\n        @BeforeClass\n        public static void beforeClassSuper() {\n            log += \"Before class super \";\n        }\n\n        @AfterClass\n        public static void afterClassSuper() {\n            log += \"After class super \";\n        }\n\n        @Before\n        public void beforeSuper() {\n            log += \"Before super \";\n        }\n\n        @After\n        public void afterSuper() {\n            log += \"After super \";\n        }\n    }\n\n    public static class SubInheritance extends SuperInheritance {\n        @BeforeClass\n        public static void beforeClassSub() {\n            log += \"Before class sub \";\n        }\n\n        @AfterClass\n        public static void afterClassSub() {\n            log += \"After class sub \";\n        }\n\n        @Before\n        public void beforeSub() {\n            log += \"Before sub \";\n        }\n\n        @After\n        public void afterSub() {\n            log += \"After sub \";\n        }\n\n        @Test\n        public void test() {\n            log += \"Test \";\n        }\n    }\n\n    public void testOrderingOfInheritance() throws Exception {\n        log = \"\";\n        JUnitCore core = new JUnitCore();\n        core.run(SubInheritance.class);\n        assertEquals(\"Before class super Before class sub Before super Before sub Test After sub After super After class sub After class super \", log);\n    }\n\n    public abstract static class SuperShadowing {\n\n        @Rule\n        public TestRule rule() {\n            return new ExternalResource() {\n                @Override\n                protected void before() throws Throwable {\n                    log += \"super.rule().before() \";\n                }\n\n                @Override\n                protected void after() {\n                    log += \"super.rule().after() \";\n                }\n            };\n        }\n\n        @Before\n        public void before() {\n            log += \"super.before() \";\n        }\n\n        @After\n        public void after() {\n            log += \"super.after() \";\n        }\n    }\n\n    public static class SubShadowing extends SuperShadowing {\n\n        @Override\n        @Rule\n        public TestRule rule() {\n            return new ExternalResource() {\n                @Override\n                protected void before() throws Throwable {\n                    log += \"sub.rule().before() \";\n                }\n\n                @Override\n                protected void after() {\n                    log += \"sub.rule().after() \";\n                }\n            };\n        }\n\n        @Override\n        @Before\n        public void before() {\n            super.before();\n            log += \"sub.before() \";\n        }\n\n        @Before\n        public void anotherBefore() {\n            log += \"sub.anotherBefore() \";\n        }\n\n        @Override\n        @After\n        public void after() {\n            log += \"sub.after() \";\n            super.after();\n        }\n\n        @After\n        public void anotherAfter() {\n            log += \"sub.anotherAfter() \";\n        }\n\n        @Test\n        public void test() {\n            log += \"Test \";\n        }\n    }\n\n    public void testShadowing() throws Exception {\n        log = \"\";\n        assertThat(testResult(SubShadowing.class), isSuccessful());\n        assertEquals(\n                \"sub.rule().before() sub.anotherBefore() super.before() sub.before() \"\n                + \"Test \"\n                + \"sub.anotherAfter() sub.after() super.after() sub.rule().after() \",\n                log);\n    }\n\n    public abstract static class SuperStaticMethodShadowing {\n\n        @ClassRule\n        public static TestRule rule() {\n            return new ExternalResource() {\n                @Override\n                protected void before() throws Throwable {\n                    log += \"super.rule().before() \";\n                }\n\n                @Override\n                protected void after() {\n                    log += \"super.rule().after() \";\n                }\n            };\n        }\n    }\n\n    public static class SubStaticMethodShadowing extends SuperStaticMethodShadowing {\n\n        @ClassRule\n        public static TestRule rule() {\n            return new ExternalResource() {\n                @Override\n                protected void before() throws Throwable {\n                    log += \"sub.rule().before() \";\n                }\n\n                @Override\n                protected void after() {\n                    log += \"sub.rule().after() \";\n                }\n            };\n        }\n\n        @Test\n        public void test() {\n            log += \"Test \";\n        }\n    }\n\n    public void testStaticMethodsCanBeTreatedAsShadowed() throws Exception {\n        log = \"\";\n        assertThat(testResult(SubStaticMethodShadowing.class), isSuccessful());\n        assertEquals(\n                \"sub.rule().before() \"\n                + \"Test \"\n                + \"sub.rule().after() \",\n                log);\n    }\n\n    public abstract static class SuperFieldShadowing {\n\n        @Rule\n        public final TestRule rule = new ExternalResource() {\n            @Override\n            protected void before() throws Throwable {\n                log += \"super.rule.before() \";\n            }\n\n            @Override\n            protected void after() {\n                log += \"super.rule.after() \";\n            }\n        };\n    }\n\n    public static class SubFieldShadowing extends SuperFieldShadowing {\n\n        @Rule\n        public final TestRule rule = new ExternalResource() {\n            @Override\n            protected void before() throws Throwable {\n                log += \"sub.rule.before() \";\n            }\n\n            @Override\n            protected void after() {\n                log += \"sub.rule.after() \";\n            }\n        };\n\n        @Test\n        public void test() {\n            log += \"Test \";\n        }\n    }\n\n    public void testFieldsShadowFieldsFromParent() throws Exception {\n        log = \"\";\n        assertThat(testResult(SubFieldShadowing.class), isSuccessful());\n        assertEquals(\n                \"sub.rule.before() \"\n                + \"Test \"\n                + \"sub.rule.after() \",\n                log);\n    }\n\n    public abstract static class SuperStaticFieldShadowing {\n\n        @ClassRule\n        public static TestRule rule = new ExternalResource() {\n            @Override\n            protected void before() throws Throwable {\n                log += \"super.rule.before() \";\n            }\n\n            @Override\n            protected void after() {\n                log += \"super.rule.after() \";\n            }\n        };\n    }\n\n    public static class SubStaticFieldShadowing extends SuperStaticFieldShadowing {\n\n        @ClassRule\n        public static TestRule rule = new ExternalResource() {\n            @Override\n            protected void before() throws Throwable {\n                log += \"sub.rule.before() \";\n            }\n\n            @Override\n            protected void after() {\n                log += \"sub.rule.after() \";\n            }\n        };\n\n        @Test\n        public void test() {\n            log += \"Test \";\n        }\n    }\n\n    public void testStaticFieldsCanBeTreatedAsShadowed() throws Exception {\n        log = \"\";\n        assertThat(testResult(SubStaticFieldShadowing.class), isSuccessful());\n        assertEquals(\n                \"sub.rule.before() \"\n                + \"Test \"\n                + \"sub.rule.after() \",\n                log);\n    }\n\n    public static class SuperTest {\n        @Test\n        public void one() {\n            log += \"Super\";\n        }\n\n        @Test\n        public void two() {\n            log += \"Two\";\n        }\n    }\n\n    public static class SubTest extends SuperTest {\n        @Override\n        @Test\n        public void one() {\n            log += \"Sub\";\n        }\n    }\n\n    public void testTestInheritance() throws Exception {\n        log = \"\";\n        JUnitCore core = new JUnitCore();\n        core.run(SubTest.class);\n        // The order in which the test methods are called is unspecified\n        assertTrue(log.contains(\"Sub\"));\n        assertTrue(log.contains(\"Two\"));\n        assertFalse(log.contains(\"Super\"));\n    }\n\n    public static class RunAllAfters {\n        @Before\n        public void good() {\n        }\n\n        @Before\n        public void bad() {\n            throw new Error();\n        }\n\n        @Test\n        public void empty() {\n        }\n\n        @After\n        public void one() {\n            log += \"one\";\n        }\n\n        @After\n        public void two() {\n            log += \"two\";\n        }\n    }\n\n    public void testRunAllAfters() {\n        log = \"\";\n        JUnitCore core = new JUnitCore();\n        core.run(RunAllAfters.class);\n        assertTrue(log.contains(\"one\"));\n        assertTrue(log.contains(\"two\"));\n    }\n\n    public static class RunAllAftersRegardless {\n        @Test\n        public void empty() {\n        }\n\n        @After\n        public void one() {\n            log += \"one\";\n            throw new Error();\n        }\n\n        @After\n        public void two() {\n            log += \"two\";\n            throw new Error();\n        }\n    }\n\n    public void testRunAllAftersRegardless() {\n        log = \"\";\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(RunAllAftersRegardless.class);\n        assertTrue(log.contains(\"one\"));\n        assertTrue(log.contains(\"two\"));\n        assertEquals(2, result.getFailureCount());\n    }\n\n    public static class RunAllAfterClasses {\n        @Before\n        public void good() {\n        }\n\n        @BeforeClass\n        public static void bad() {\n            throw new Error();\n        }\n\n        @Test\n        public void empty() {\n        }\n\n        @AfterClass\n        public static void one() {\n            log += \"one\";\n        }\n\n        @AfterClass\n        public static void two() {\n            log += \"two\";\n        }\n    }\n\n    public void testRunAllAfterClasses() {\n        log = \"\";\n        JUnitCore core = new JUnitCore();\n        core.run(RunAllAfterClasses.class);\n        assertTrue(log.contains(\"one\"));\n        assertTrue(log.contains(\"two\"));\n    }\n\n    public static class RunAllAfterClassesRegardless {\n        @Test\n        public void empty() {\n        }\n\n        @AfterClass\n        public static void one() {\n            log += \"one\";\n            throw new Error();\n        }\n\n        @AfterClass\n        public static void two() {\n            log += \"two\";\n            throw new Error();\n        }\n    }\n\n    public void testRunAllAfterClassesRegardless() {\n        log = \"\";\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(RunAllAfterClassesRegardless.class);\n        assertTrue(log.contains(\"one\"));\n        assertTrue(log.contains(\"two\"));\n        assertEquals(2, result.getFailureCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/methods/ExpectedTest.java",
    "content": "package org.junit.tests.running.methods;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\n\nimport org.junit.Test;\nimport org.junit.internal.AssumptionViolatedException;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\n\npublic class ExpectedTest {\n\n    public static class Expected {\n        @Test(expected = Exception.class)\n        public void expected() throws Exception {\n            throw new Exception();\n        }\n    }\n\n    @Test\n    public void expected() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(Expected.class);\n        assertTrue(result.wasSuccessful());\n    }\n\n    public static class Unexpected {\n        @Test(expected = Exception.class)\n        public void expected() throws Exception {\n            throw new Error();\n        }\n    }\n\n    @Test\n    public void unexpected() {\n        Result result = JUnitCore.runClasses(Unexpected.class);\n        Failure failure = result.getFailures().get(0);\n        String message = failure.getMessage();\n        assertTrue(message.contains(\"expected<java.lang.Exception> but was<java.lang.Error>\"));\n        assertEquals(Error.class, failure.getException().getCause().getClass());\n    }\n\n    public static class NoneThrown {\n        @Test(expected = Exception.class)\n        public void nothing() {\n        }\n    }\n\n    @Test\n    public void noneThrown() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(NoneThrown.class);\n        assertFalse(result.wasSuccessful());\n        String message = result.getFailures().get(0).getMessage();\n        assertTrue(message.contains(\"Expected exception: java.lang.Exception\"));\n    }\n\n    public static class ExpectSuperclass {\n        @Test(expected = RuntimeException.class)\n        public void throwsSubclass() {\n            throw new ClassCastException();\n        }\n    }\n\n    @Test\n    public void expectsSuperclass() {\n        assertTrue(new JUnitCore().run(ExpectSuperclass.class).wasSuccessful());\n    }\n\n    public static class ExpectAssumptionViolatedException {\n        @Test(expected = AssumptionViolatedException.class)\n        public void throwsAssumptionViolatedException() {\n            throw new AssumptionViolatedException(\"expected\");\n        }\n    }\n\n    @Test\n    public void expectsAssumptionViolatedException() {\n        assertTrue(new JUnitCore().run(ExpectAssumptionViolatedException.class).wasSuccessful());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/methods/InheritedTestTest.java",
    "content": "package org.junit.tests.running.methods;\n\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\n\npublic class InheritedTestTest {\n    public abstract static class Super {\n        @Test\n        public void nothing() {\n        }\n    }\n\n    public static class Sub extends Super {\n    }\n\n    @Test\n    public void subclassWithOnlyInheritedTestsRuns() {\n        Result result = JUnitCore.runClasses(Sub.class);\n        assertTrue(result.wasSuccessful());\n    }\n\n    public static class SubWithBefore extends Super {\n        @Before\n        public void gack() {\n            fail();\n        }\n    }\n\n    @Test\n    public void subclassWithInheritedTestAndOwnBeforeRunsBefore() {\n        assertFalse(JUnitCore.runClasses(SubWithBefore.class).wasSuccessful());\n    }\n} \n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/methods/ParameterizedTestMethodTest.java",
    "content": "package org.junit.tests.running.methods;\n\nimport static org.junit.Assert.assertEquals;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\nimport junit.framework.JUnit4TestAdapter;\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.Parameterized;\nimport org.junit.runners.Parameterized.Parameters;\nimport org.junit.runners.model.InitializationError;\n\n@RunWith(Parameterized.class)\npublic class ParameterizedTestMethodTest {\n\n    @SuppressWarnings(\"all\")\n    public static class EverythingWrong {\n        private EverythingWrong() {\n        }\n\n        @BeforeClass\n        public void notStaticBC() {\n        }\n\n        @BeforeClass\n        static void notPublicBC() {\n        }\n\n        @BeforeClass\n        public static int nonVoidBC() {\n            return 0;\n        }\n\n        @BeforeClass\n        public static void argumentsBC(int i) {\n        }\n\n        @BeforeClass\n        public static void fineBC() {\n        }\n\n        @AfterClass\n        public void notStaticAC() {\n        }\n\n        @AfterClass\n        static void notPublicAC() {\n        }\n\n        @AfterClass\n        public static int nonVoidAC() {\n            return 0;\n        }\n\n        @AfterClass\n        public static void argumentsAC(int i) {\n        }\n\n        @AfterClass\n        public static void fineAC() {\n        }\n\n        @After\n        public static void staticA() {\n        }\n\n        @After\n        void notPublicA() {\n        }\n\n        @After\n        public int nonVoidA() {\n            return 0;\n        }\n\n        @After\n        public void argumentsA(int i) {\n        }\n\n        @After\n        public void fineA() {\n        }\n\n        @Before\n        public static void staticB() {\n        }\n\n        @Before\n        void notPublicB() {\n        }\n\n        @Before\n        public int nonVoidB() {\n            return 0;\n        }\n\n        @Before\n        public void argumentsB(int i) {\n        }\n\n        @Before\n        public void fineB() {\n        }\n\n        @Test\n        public static void staticT() {\n        }\n\n        @Test\n        void notPublicT() {\n        }\n\n        @Test\n        public int nonVoidT() {\n            return 0;\n        }\n\n        @Test\n        public void argumentsT(int i) {\n        }\n\n        @Test\n        public void fineT() {\n        }\n    }\n\n    private Class<?> fClass;\n    private int fErrorCount;\n\n    public static class SuperWrong {\n        @Test\n        void notPublic() {\n        }\n    }\n\n    public static class SubWrong extends SuperWrong {\n        @Test\n        public void justFine() {\n        }\n    }\n\n    public static class SubShadows extends SuperWrong {\n        @Override\n        @Test\n        public void notPublic() {\n        }\n    }\n\n    public ParameterizedTestMethodTest(Class<?> class1, int errorCount) {\n        fClass = class1;\n        fErrorCount = errorCount;\n    }\n\n    @Parameters\n    public static Collection<Object[]> params() {\n        return Arrays.asList(new Object[][]{\n                {EverythingWrong.class, 1 + 4 * 5}, {SubWrong.class, 1},\n                {SubShadows.class, 0}});\n    }\n\n    private List<Throwable> validateAllMethods(Class<?> clazz) {\n        try {\n            new BlockJUnit4ClassRunner(clazz);\n        } catch (InitializationError e) {\n            return e.getCauses();\n        }\n        return Collections.emptyList();\n    }\n\n    @Test\n    public void testFailures() throws Exception {\n        List<Throwable> problems = validateAllMethods(fClass);\n        assertEquals(fErrorCount, problems.size());\n    }\n\n    public static junit.framework.Test suite() {\n        return new JUnit4TestAdapter(ParameterizedTestMethodTest.class);\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/methods/TestMethodTest.java",
    "content": "package org.junit.tests.running.methods;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestResult;\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runners.BlockJUnit4ClassRunner;\nimport org.junit.runners.model.InitializationError;\n\npublic class TestMethodTest {\n\n    @SuppressWarnings(\"all\")\n    public static class EverythingWrong {\n        private EverythingWrong() {\n        }\n\n        @BeforeClass\n        public void notStaticBC() {\n        }\n\n        @BeforeClass\n        static void notPublicBC() {\n        }\n\n        @BeforeClass\n        public static int nonVoidBC() {\n            return 0;\n        }\n\n        @BeforeClass\n        public static void argumentsBC(int i) {\n        }\n\n        @BeforeClass\n        public static void fineBC() {\n        }\n\n        @AfterClass\n        public void notStaticAC() {\n        }\n\n        @AfterClass\n        static void notPublicAC() {\n        }\n\n        @AfterClass\n        public static int nonVoidAC() {\n            return 0;\n        }\n\n        @AfterClass\n        public static void argumentsAC(int i) {\n        }\n\n        @AfterClass\n        public static void fineAC() {\n        }\n\n        @After\n        public static void staticA() {\n        }\n\n        @After\n        void notPublicA() {\n        }\n\n        @After\n        public int nonVoidA() {\n            return 0;\n        }\n\n        @After\n        public void argumentsA(int i) {\n        }\n\n        @After\n        public void fineA() {\n        }\n\n        @Before\n        public static void staticB() {\n        }\n\n        @Before\n        void notPublicB() {\n        }\n\n        @Before\n        public int nonVoidB() {\n            return 0;\n        }\n\n        @Before\n        public void argumentsB(int i) {\n        }\n\n        @Before\n        public void fineB() {\n        }\n\n        @Test\n        public static void staticT() {\n        }\n\n        @Test\n        void notPublicT() {\n        }\n\n        @Test\n        public int nonVoidT() {\n            return 0;\n        }\n\n        @Test\n        public void argumentsT(int i) {\n        }\n\n        @Test\n        public void fineT() {\n        }\n    }\n\n    @Test\n    public void testFailures() throws Exception {\n        List<Throwable> problems = validateAllMethods(EverythingWrong.class);\n        int errorCount = 1 + 4 * 5; // missing constructor plus four invalid methods for each annotation */\n        assertEquals(errorCount, problems.size());\n    }\n\n    static public class SuperWrong {\n        @Test\n        void notPublic() {\n        }\n    }\n\n    static public class SubWrong extends SuperWrong {\n        @Test\n        public void justFine() {\n        }\n    }\n\n    @Test\n    public void validateInheritedMethods() throws Exception {\n        List<Throwable> problems = validateAllMethods(SubWrong.class);\n        assertEquals(1, problems.size());\n    }\n\n    static public class SubShadows extends SuperWrong {\n        @Override\n        @Test\n        public void notPublic() {\n        }\n    }\n\n    @Test\n    public void dontValidateShadowedMethods() throws Exception {\n        List<Throwable> problems = validateAllMethods(SubShadows.class);\n        assertTrue(problems.isEmpty());\n    }\n\n    private List<Throwable> validateAllMethods(Class<?> clazz) {\n        try {\n            new BlockJUnit4ClassRunner(clazz);\n        } catch (InitializationError e) {\n            return e.getCauses();\n        }\n        return Collections.emptyList();\n    }\n\n    static public class IgnoredTest {\n        @Test\n        public void valid() {\n        }\n\n        @Ignore\n        @Test\n        public void ignored() {\n        }\n\n        @Ignore(\"For testing purposes\")\n        @Test\n        public void withReason() {\n        }\n    }\n\n    @Test\n    public void ignoreRunner() {\n        JUnitCore runner = new JUnitCore();\n        Result result = runner.run(IgnoredTest.class);\n        assertEquals(2, result.getIgnoreCount());\n        assertEquals(1, result.getRunCount());\n    }\n\n    @Test\n    public void compatibility() {\n        TestResult result = new TestResult();\n        new JUnit4TestAdapter(IgnoredTest.class).run(result);\n        assertEquals(1, result.runCount());\n    }\n\n    public static class Confused {\n        @Test\n        public void a(Object b) {\n        }\n\n        @Test\n        public void a() {\n        }\n    }\n\n    @Test(expected = InitializationError.class)\n    public void overloaded() throws InitializationError {\n        new BlockJUnit4ClassRunner(Confused.class);\n    }\n\n    public static class ConstructorParameter {\n        public ConstructorParameter(Object something) {\n        }\n\n        @Test\n        public void a() {\n        }\n    }\n\n    @Test(expected = InitializationError.class)\n    public void constructorParameter() throws InitializationError {\n        new BlockJUnit4ClassRunner(ConstructorParameter.class);\n    }\n\n    public static class OnlyTestIsIgnored {\n        @Ignore\n        @Test\n        public void ignored() {\n        }\n    }\n\n    @Test\n    public void onlyIgnoredMethodsIsStillFineTestClass() {\n        Result result = JUnitCore.runClasses(OnlyTestIsIgnored.class);\n        assertEquals(0, result.getFailureCount());\n        assertEquals(1, result.getIgnoreCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/running/methods/TimeoutTest.java",
    "content": "package org.junit.tests.running.methods;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.CoreMatchers.not;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\n\nimport java.io.PrintWriter;\nimport java.io.StringWriter;\nimport java.io.Writer;\nimport java.util.concurrent.TimeUnit;\n\nimport junit.framework.JUnit4TestAdapter;\nimport junit.framework.TestResult;\nimport org.junit.After;\nimport org.junit.Ignore;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.TestRule;\nimport org.junit.rules.Timeout;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\n\npublic class TimeoutTest {\n\n    public static class FailureWithTimeoutTest {\n        @Test(timeout = 1000)\n        public void failure() {\n            fail();\n        }\n    }\n\n    @Test\n    public void failureWithTimeout() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(FailureWithTimeoutTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        assertEquals(AssertionError.class, result.getFailures().get(0).getException().getClass());\n    }\n\n    public static class FailureWithTimeoutRunTimeExceptionTest {\n        @Test(timeout = 1000)\n        public void failure() {\n            throw new NullPointerException();\n        }\n    }\n\n    @Test\n    public void failureWithTimeoutRunTimeException() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(FailureWithTimeoutRunTimeExceptionTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        assertEquals(NullPointerException.class, result.getFailures().get(0).getException().getClass());\n    }\n\n    public static class SuccessWithTimeoutTest {\n        @Test(timeout = 1000)\n        public void success() {\n        }\n    }\n\n    @Test\n    public void successWithTimeout() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(SuccessWithTimeoutTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(0, result.getFailureCount());\n    }\n\n    public static class TimeoutFailureTest {\n        @Test(timeout = 100)\n        public void success() throws InterruptedException {\n            Thread.sleep(40000);\n        }\n    }\n\n    @Ignore(\"was breaking gump\")\n    @Test\n    public void timeoutFailure() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(TimeoutFailureTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        assertEquals(InterruptedException.class, result.getFailures().get(0).getException().getClass());\n    }\n\n    public static class InfiniteLoopTest {\n        @Test(timeout = 100)\n        public void failure() {\n            infiniteLoop();\n        }\n\n        private void infiniteLoop() {\n            for (; ; ) {\n                try {\n                    Thread.sleep(10);\n                } catch (InterruptedException e) {\n                }\n            }\n        }\n    }\n\n    @Test\n    public void infiniteLoop() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(InfiniteLoopTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        Throwable exception = result.getFailures().get(0).getException();\n        assertTrue(exception.getMessage().contains(\"test timed out after 100 milliseconds\"));\n    }\n\n    public static class ImpatientLoopTest {\n        @Test(timeout = 1)\n        public void failure() {\n            infiniteLoop();\n        }\n\n        private void infiniteLoop() {\n            for (; ; ) ;\n        }\n    }\n\n    @Ignore(\"This breaks sporadically with time differences just slightly more than 200ms\")\n    @Test\n    public void infiniteLoopRunsForApproximatelyLengthOfTimeout() throws Exception {\n        // \"prime the pump\": running these beforehand makes the runtimes more predictable\n        //                   (because of class loading?)\n        JUnitCore.runClasses(InfiniteLoopTest.class, ImpatientLoopTest.class);\n        long longTime = runAndTime(InfiniteLoopTest.class);\n        long shortTime = runAndTime(ImpatientLoopTest.class);\n        long difference = longTime - shortTime;\n        assertTrue(String.format(\"Difference was %sms\", difference), difference < 200);\n    }\n\n    private long runAndTime(Class<?> clazz) {\n        JUnitCore core = new JUnitCore();\n        long startTime = System.currentTimeMillis();\n        core.run(clazz);\n        long totalTime = System.currentTimeMillis() - startTime;\n        return totalTime;\n    }\n\n    private String stackForException(Throwable exception) {\n        Writer buffer = new StringWriter();\n        PrintWriter writer = new PrintWriter(buffer);\n        exception.printStackTrace(writer);\n        return buffer.toString();\n    }\n    \n    @Test\n    public void stalledThreadAppearsInStackTrace() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(InfiniteLoopTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        Throwable exception = result.getFailures().get(0).getException();\n        assertThat(stackForException(exception), containsString(\"infiniteLoop\")); // Make sure we have the stalled frame on the stack somewhere\n    }\n\n    public static class InfiniteLoopMultithreaded {\n        \n        private static class ThreadTest implements Runnable {\n            private boolean fStall;\n\n            public ThreadTest(boolean stall) {\n                fStall = stall;\n            }\n\n            public void run() {\n                if (fStall)\n                    for (; ; ) ;   \n                try {\n                    Thread.sleep(500);\n                } catch (InterruptedException e) {\n                }\n            }\n        }\n        \n        public void failure(boolean mainThreadStalls) throws Exception {\n            Thread t1 = new Thread(new ThreadTest(false), \"timeout-thr1\");\n            Thread t2 = new Thread(new ThreadTest(!mainThreadStalls), \"timeout-thr2\");\n            Thread t3 = new Thread(new ThreadTest(false), \"timeout-thr3\");\n            t1.start();\n            t2.start();\n            t3.start();\n            if (mainThreadStalls)\n                for (; ; ) ;\n            t1.join();\n            t2.join();\n            t3.join();\n        }\n   }\n    \n    public static class InfiniteLoopWithStuckThreadTest {\n        @Rule\n        public TestRule globalTimeout = Timeout.builder()\n            .withTimeout(100, TimeUnit.MILLISECONDS)\n            .withLookingForStuckThread(true)\n            .build();\n\n        @Test\n        public void failure() throws Exception {\n            (new InfiniteLoopMultithreaded()).failure(false);\n        }\n    }\n    \n    public static class InfiniteLoopStuckInMainThreadTest {\n        @Rule\n        public TestRule globalTimeout = Timeout.builder()\n            .withTimeout(100, TimeUnit.MILLISECONDS)\n            .withLookingForStuckThread(true)\n            .build();\n\n        @Test\n        public void failure() throws Exception {\n            (new InfiniteLoopMultithreaded()).failure(true);\n        }\n    }\n\n    @Test\n    public void timeoutFailureMultithreaded() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(InfiniteLoopWithStuckThreadTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(2, result.getFailureCount());\n        Throwable exception[] = new Throwable[2];\n        for (int i = 0; i < 2; i++)\n            exception[i] = result.getFailures().get(i).getException();\n        assertThat(exception[0].getMessage(), containsString(\"test timed out after 100 milliseconds\"));\n        assertThat(stackForException(exception[0]), containsString(\"Thread.join\"));\n        assertThat(exception[1].getMessage(), containsString(\"Appears to be stuck in thread timeout-thr2\"));\n    }\n\n    @Test\n    public void timeoutFailureMultithreadedStuckInMain() throws Exception {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(InfiniteLoopStuckInMainThreadTest.class);\n        assertEquals(1, result.getRunCount());\n        assertEquals(1, result.getFailureCount());\n        Throwable exception = result.getFailures().get(0).getException();\n        assertThat(exception.getMessage(), containsString(\"test timed out after 100 milliseconds\"));\n        assertThat(exception.getMessage(), not(containsString(\"Appears to be stuck\")));\n    }\n\n    @Test\n    public void compatibility() {\n        TestResult result = new TestResult();\n        new JUnit4TestAdapter(InfiniteLoopTest.class).run(result);\n        assertEquals(1, result.errorCount());\n    }\n\n    public static class WillTimeOut {\n        static boolean afterWasCalled = false;\n\n        @Test(timeout = 1)\n        public void test() {\n            for (; ; ) {\n                try {\n                    Thread.sleep(10000);\n                } catch (InterruptedException e) {\n                    // ok, tests are over\n                }\n            }\n        }\n\n        @After\n        public void after() {\n            afterWasCalled = true;\n        }\n    }\n\n    @Test\n    public void makeSureAfterIsCalledAfterATimeout() {\n        JUnitCore.runClasses(WillTimeOut.class);\n        assertThat(WillTimeOut.afterWasCalled, is(true));\n    }\n\n    public static class TimeOutZero {\n        @Rule\n        public Timeout timeout = Timeout.seconds(0);\n\n        @Test\n        public void test() {\n            try {\n                Thread.sleep(200); // long enough to suspend thread execution\n            } catch (InterruptedException e) {\n                // Don't care\n            }\n        }\n    }\n\n    @Test\n    public void testZeroTimeoutIsIgnored() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(TimeOutZero.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"Test should not have failed\", 0, result.getFailureCount());\n    }\n\n    private static class TimeoutSubclass extends Timeout {\n\n        public TimeoutSubclass(long timeout, TimeUnit timeUnit) {\n            super(timeout, timeUnit);\n        }\n\n        public long getTimeoutFromSuperclass(TimeUnit unit) {\n            return super.getTimeout(unit);\n        }\n    }\n\n    public static class TimeOutOneSecond {\n        @Rule\n        public TimeoutSubclass timeout = new TimeoutSubclass(1, TimeUnit.SECONDS);\n\n        @Test\n        public void test() {\n            assertEquals(1000, timeout.getTimeoutFromSuperclass(TimeUnit.MILLISECONDS));\n        }\n    }\n\n    @Test\n    public void testGetTimeout() {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(TimeOutOneSecond.class);\n        assertEquals(\"Should run the test\", 1, result.getRunCount());\n        assertEquals(\"Test should not have failed\", 0, result.getFailureCount());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/validation/AllValidationTests.java",
    "content": "package org.junit.tests.validation;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        BadlyFormedClassesTest.class,\n        FailedConstructionTest.class,\n        ValidationTest.class\n})\npublic class AllValidationTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/validation/BadlyFormedClassesTest.java",
    "content": "package org.junit.tests.validation;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.internal.runners.JUnit4ClassRunner;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.RunWith;\nimport org.junit.runner.notification.Failure;\n\n@SuppressWarnings(\"deprecation\")\npublic class BadlyFormedClassesTest {\n    public static class FaultyConstructor {\n        public FaultyConstructor() throws Exception {\n            throw new Exception(\"Thrown during construction\");\n        }\n\n        @Test\n        public void someTest() {\n            /*\n                * Empty test just to fool JUnit and IDEs into running this class as\n                * a JUnit test\n                */\n        }\n    }\n\n    @RunWith(JUnit4ClassRunner.class)\n    public static class BadBeforeMethodWithLegacyRunner {\n        @Before\n        void before() {\n\n        }\n\n        @Test\n        public void someTest() {\n        }\n    }\n\n    public static class NoTests {\n        // class without tests\n    }\n\n    @Test\n    public void constructorException() {\n        String message = exceptionMessageFrom(FaultyConstructor.class);\n        assertEquals(\"Thrown during construction\", message);\n    }\n\n    @Test\n    public void noRunnableMethods() {\n        assertThat(exceptionMessageFrom(NoTests.class), containsString(\"No runnable methods\"));\n    }\n\n    @Test\n    public void badBeforeMethodWithLegacyRunner() {\n        assertEquals(\"Method before should be public\",\n                exceptionMessageFrom(BadBeforeMethodWithLegacyRunner.class));\n    }\n\n    private String exceptionMessageFrom(Class<?> testClass) {\n        JUnitCore core = new JUnitCore();\n        Result result = core.run(testClass);\n        Failure failure = result.getFailures().get(0);\n        String message = failure.getException().getMessage();\n        return message;\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/validation/FailedConstructionTest.java",
    "content": "package org.junit.tests.validation;\n\nimport org.junit.Assert;\nimport org.junit.Test;\nimport org.junit.runner.Description;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\n\npublic class FailedConstructionTest {\n    public static class CantConstruct {\n        public CantConstruct() {\n            throw new RuntimeException();\n        }\n\n        @Test\n        public void foo() {\n        }\n    }\n\n    @Test\n    public void failedConstructionIsTestFailure() {\n        Result result = JUnitCore.runClasses(CantConstruct.class);\n        Failure failure = result.getFailures().get(0);\n        Description expected = Description.createTestDescription(CantConstruct.class, \"foo\");\n        Assert.assertEquals(expected, failure.getDescription());\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/validation/ValidationTest.java",
    "content": "package org.junit.tests.validation;\n\nimport static org.hamcrest.CoreMatchers.containsString;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.junit.Assert.assertEquals;\n\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.runner.JUnitCore;\nimport org.junit.runner.Request;\nimport org.junit.runner.Result;\n\npublic class ValidationTest {\n    public static class WrongBeforeClass {\n        @BeforeClass\n        protected int a() {\n            return 0;\n        }\n    }\n\n    @Test\n    public void initializationErrorIsOnCorrectClass() {\n        assertEquals(WrongBeforeClass.class.getName(),\n                Request.aClass(WrongBeforeClass.class).getRunner().getDescription().getDisplayName());\n    }\n\n    public static class NonStaticBeforeClass {\n        @BeforeClass\n        public void before() {\n        }\n\n        @Test\n        public void hereBecauseEveryTestClassNeedsATest() {\n        }\n    }\n\n    @Test\n    public void nonStaticBeforeClass() {\n        Result result = JUnitCore.runClasses(NonStaticBeforeClass.class);\n        assertThat(result.getFailures().get(0).getMessage(), containsString(\"Method before() should be static\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/validation/anotherpackage/Sub.java",
    "content": "package org.junit.tests.validation.anotherpackage;\n\npublic class Sub extends Super {\n\n}\n"
  },
  {
    "path": "src/test/java/org/junit/tests/validation/anotherpackage/Super.java",
    "content": "package org.junit.tests.validation.anotherpackage;\n\nimport org.junit.Test;\n\nclass Super {\n    @Test\n    public void a() {\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/validator/AllValidatorTests.java",
    "content": "package org.junit.validator;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({\n        AnnotationsValidatorTest.class,\n        AnnotationValidatorFactoryTest.class,\n        PublicClassValidatorTest.class\n})\npublic class AllValidatorTests {\n}\n"
  },
  {
    "path": "src/test/java/org/junit/validator/AnnotationValidatorFactoryTest.java",
    "content": "package org.junit.validator;\n\nimport static org.hamcrest.core.Is.is;\nimport static org.hamcrest.core.IsInstanceOf.instanceOf;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExpectedException;\n\npublic class AnnotationValidatorFactoryTest {\n\n    @Rule\n    public ExpectedException exception = ExpectedException.none();\n\n    @Test\n    public void createAnnotationValidator() {\n        ValidateWith validateWith = SampleAnnotationWithValidator.class.getAnnotation(ValidateWith.class);\n        AnnotationValidator annotationValidator = new AnnotationValidatorFactory().createAnnotationValidator(validateWith);\n        assertThat(annotationValidator, is(instanceOf(Validator.class)));\n    }\n\n    @ValidateWith(value = Validator.class)\n    public @interface SampleAnnotationWithValidator {\n    }\n\n    public static class Validator extends AnnotationValidator {\n    }\n\n    @Test\n    public void exceptionWhenAnnotationValidatorCantBeCreated() {\n        ValidateWith validateWith = SampleAnnotationWithValidatorThatThrowsException.class.getAnnotation(ValidateWith.class);\n        exception.expect(RuntimeException.class);\n        exception.expectMessage(\"Exception received when creating AnnotationValidator class \" +\n                \"org.junit.validator.AnnotationValidatorFactoryTest$ValidatorThatThrowsException\");\n        new AnnotationValidatorFactory().createAnnotationValidator(validateWith);\n    }\n\n    @ValidateWith(value = ValidatorThatThrowsException.class)\n    public @interface SampleAnnotationWithValidatorThatThrowsException {\n    }\n\n    public static class ValidatorThatThrowsException extends AnnotationValidator {\n        public ValidatorThatThrowsException() throws InstantiationException {\n            throw new InstantiationException(\"Simulating exception in test\");\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/validator/AnnotationsValidatorTest.java",
    "content": "package org.junit.validator;\n\nimport static java.util.Arrays.asList;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.junit.Test;\nimport org.junit.runners.model.FrameworkField;\nimport org.junit.runners.model.FrameworkMethod;\nimport org.junit.runners.model.TestClass;\n\npublic class AnnotationsValidatorTest {\n    public static class ExampleAnnotationValidator extends AnnotationValidator {\n        private static final String ANNOTATED_METHOD_CALLED= \"annotated method called\";\n\n        private static final String ANNOTATED_FIELD_CALLED= \"annotated field called\";\n\n        private static final String ANNOTATED_CLASS_CALLED= \"annotated class called\";\n\n        @Override\n        public List<Exception> validateAnnotatedClass(TestClass testClass) {\n            return asList(new Exception(ANNOTATED_CLASS_CALLED));\n        }\n\n        @Override\n        public List<Exception> validateAnnotatedField(FrameworkField field) {\n            return asList(new Exception(ANNOTATED_FIELD_CALLED));\n        }\n\n        @Override\n        public List<Exception> validateAnnotatedMethod(FrameworkMethod method) {\n            return asList(new Exception(ANNOTATED_METHOD_CALLED));\n        }\n    }\n\n    @Retention(RetentionPolicy.RUNTIME)\n    @Inherited\n    @ValidateWith(ExampleAnnotationValidator.class)\n    public @interface ExampleAnnotationWithValidator {\n    }\n\n    public static class AnnotationValidatorMethodTest {\n        @ExampleAnnotationWithValidator\n        @Test\n        public void test() {\n        }\n    }\n\n    public static class AnnotationValidatorFieldTest {\n        @ExampleAnnotationWithValidator\n        private String field;\n\n        @Test\n        public void test() {\n        }\n    }\n\n    @ExampleAnnotationWithValidator\n    public static class AnnotationValidatorClassTest {\n        @Test\n        public void test() {\n        }\n    }\n\n    @Test\n    public void validatorIsCalledForAClass() {\n        assertClassHasFailureMessage(AnnotationValidatorClassTest.class,\n                ExampleAnnotationValidator.ANNOTATED_CLASS_CALLED);\n    }\n\n    @Test\n    public void validatorIsCalledForAMethod() {\n        assertClassHasFailureMessage(AnnotationValidatorMethodTest.class,\n                ExampleAnnotationValidator.ANNOTATED_METHOD_CALLED);\n    }\n\n    @Test\n    public void validatorIsCalledForAField() {\n        assertClassHasFailureMessage(AnnotationValidatorFieldTest.class,\n                ExampleAnnotationValidator.ANNOTATED_FIELD_CALLED);\n    }\n\n    private void assertClassHasFailureMessage(Class<?> klass,\n            String expectedFailure) {\n        AnnotationsValidator validator= new AnnotationsValidator();\n        Collection<Exception> errors= validator\n                .validateTestClass(new TestClass(klass));\n        assertThat(errors.size(), is(1));\n        assertThat(errors.iterator().next().getMessage(),\n                is(expectedFailure));\n    }\n}\n"
  },
  {
    "path": "src/test/java/org/junit/validator/PublicClassValidatorTest.java",
    "content": "package org.junit.validator;\n\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.junit.Test;\nimport org.junit.runners.model.TestClass;\n\npublic class PublicClassValidatorTest {\n    private final PublicClassValidator validator = new PublicClassValidator();\n\n    public static class PublicClass {\n\n    }\n\n    @Test\n    public void acceptsPublicClass() {\n        TestClass testClass = new TestClass(PublicClass.class);\n        List<Exception> validationErrors = validator\n                .validateTestClass(testClass);\n        assertThat(validationErrors,\n                is(equalTo(Collections.<Exception> emptyList())));\n    }\n\n    static class NonPublicClass {\n\n    }\n\n    @Test\n    public void rejectsNonPublicClass() {\n        TestClass testClass = new TestClass(NonPublicClass.class);\n        List<Exception> validationErrors = validator\n                .validateTestClass(testClass);\n        assertThat(\"Wrong number of errors.\", validationErrors.size(),\n                is(equalTo(1)));\n    }\n}\n"
  },
  {
    "path": "to-do.txt",
    "content": "* update documentation\n\t* new cook's tour\n\t* update Test Infected\n* Should there be a \"prefix\" annotation for Suites?\n  * This would allow two Suites with different BeforeClass/AfterClass behaviors,\n    but the same component tests, to co-exist\n\n* update the build process\n    * update site for plug-in version?\n* Ant\n\t* Basic task\n* support testing run once initialization code e.g. class Foo {{...}}\n* Automatically add failing tests to the Known Defects section of the README.html\n\n* Create assume(that()) and assert(that()) \n  (what is a better name for the second one?)\n  \n* Simplify implementation of equality, and organize AssertionTest\n\n* Theories class validation should be much better\n\n* Find a way to make Parameterized a single-class extension\n\n* If a suite() returns a JUnit4TestAdapter, allow Filters and Sorters to operate on \n  the adapted Runner.\n  \n* Every time I add a Filter feature, I have to add an equivalent Sorter feature.  Suspicious.\n"
  }
]