├── .gitignore ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── source_to_parse └── junit-master │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.jdt.ui.prefs │ ├── .travis.yml │ ├── BUILDING │ ├── CODING_STYLE.txt │ ├── CONTRIBUTING.md │ ├── LEGACY_CODING_STYLE.txt │ ├── LICENSE-junit.txt │ ├── NOTICE.txt │ ├── README.md │ ├── acknowledgements.txt │ ├── doc │ ├── ReleaseNotes4.10.html │ ├── ReleaseNotes4.10.md │ ├── ReleaseNotes4.10.txt │ ├── ReleaseNotes4.11.html │ ├── ReleaseNotes4.11.md │ ├── ReleaseNotes4.11.txt │ ├── ReleaseNotes4.12.md │ ├── ReleaseNotes4.13.md │ ├── ReleaseNotes4.4.html │ ├── ReleaseNotes4.4.md │ ├── ReleaseNotes4.4.txt │ ├── ReleaseNotes4.5.html │ ├── ReleaseNotes4.5.md │ ├── ReleaseNotes4.5.txt │ ├── ReleaseNotes4.6.html │ ├── ReleaseNotes4.6.md │ ├── ReleaseNotes4.6.txt │ ├── ReleaseNotes4.7.html │ ├── ReleaseNotes4.7.md │ ├── ReleaseNotes4.7.txt │ ├── ReleaseNotes4.8.1.html │ ├── ReleaseNotes4.8.1.md │ ├── ReleaseNotes4.8.1.txt │ ├── ReleaseNotes4.8.2.html │ ├── ReleaseNotes4.8.2.md │ ├── ReleaseNotes4.8.2.txt │ ├── ReleaseNotes4.8.html │ ├── ReleaseNotes4.8.md │ ├── ReleaseNotes4.8.txt │ ├── ReleaseNotes4.9.1.md │ ├── ReleaseNotes4.9.1.txt │ ├── ReleaseNotes4.9.html │ ├── ReleaseNotes4.9.md │ ├── ReleaseNotes4.9.txt │ ├── building-junit.txt │ ├── cookstour │ │ ├── Image1.gif │ │ ├── Image2.gif │ │ ├── Image3.gif │ │ ├── Image4.gif │ │ ├── Image5.gif │ │ ├── Image6.gif │ │ ├── Image7.gif │ │ └── cookstour.htm │ ├── homepage.html │ ├── index.htm │ ├── markdown.sh │ └── testinfected │ │ ├── IMG00001.GIF │ │ ├── IMG00002.GIF │ │ ├── IMG00003.GIF │ │ ├── logo.gif │ │ └── testing.htm │ ├── epl-v10.html │ ├── lib │ ├── hamcrest-core-1.3-sources.jar │ └── hamcrest-core-1.3.jar │ ├── pom.xml │ ├── src │ ├── changes │ │ └── changes.xml │ ├── main │ │ ├── java │ │ │ ├── junit │ │ │ │ ├── extensions │ │ │ │ │ ├── ActiveTestSuite.java │ │ │ │ │ ├── RepeatedTest.java │ │ │ │ │ ├── TestDecorator.java │ │ │ │ │ ├── TestSetup.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── framework │ │ │ │ │ ├── Assert.java │ │ │ │ │ ├── AssertionFailedError.java │ │ │ │ │ ├── ComparisonCompactor.java │ │ │ │ │ ├── ComparisonFailure.java │ │ │ │ │ ├── JUnit4TestAdapter.java │ │ │ │ │ ├── JUnit4TestAdapterCache.java │ │ │ │ │ ├── JUnit4TestCaseFacade.java │ │ │ │ │ ├── Protectable.java │ │ │ │ │ ├── Test.java │ │ │ │ │ ├── TestCase.java │ │ │ │ │ ├── TestFailure.java │ │ │ │ │ ├── TestListener.java │ │ │ │ │ ├── TestResult.java │ │ │ │ │ ├── TestSuite.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── runner │ │ │ │ │ ├── BaseTestRunner.java │ │ │ │ │ ├── TestRunListener.java │ │ │ │ │ ├── Version.java │ │ │ │ │ ├── Version.java.template │ │ │ │ │ └── package-info.java │ │ │ │ └── textui │ │ │ │ │ ├── ResultPrinter.java │ │ │ │ │ ├── TestRunner.java │ │ │ │ │ └── package-info.java │ │ │ └── org │ │ │ │ └── junit │ │ │ │ ├── After.java │ │ │ │ ├── AfterClass.java │ │ │ │ ├── Assert.java │ │ │ │ ├── Assume.java │ │ │ │ ├── AssumptionViolatedException.java │ │ │ │ ├── Before.java │ │ │ │ ├── BeforeClass.java │ │ │ │ ├── ClassRule.java │ │ │ │ ├── ComparisonFailure.java │ │ │ │ ├── FixMethodOrder.java │ │ │ │ ├── Ignore.java │ │ │ │ ├── Rule.java │ │ │ │ ├── Test.java │ │ │ │ ├── experimental │ │ │ │ ├── ParallelComputer.java │ │ │ │ ├── categories │ │ │ │ │ ├── Categories.java │ │ │ │ │ ├── Category.java │ │ │ │ │ ├── CategoryFilterFactory.java │ │ │ │ │ ├── CategoryValidator.java │ │ │ │ │ ├── ExcludeCategories.java │ │ │ │ │ └── IncludeCategories.java │ │ │ │ ├── max │ │ │ │ │ ├── CouldNotReadCoreException.java │ │ │ │ │ ├── MaxCore.java │ │ │ │ │ └── MaxHistory.java │ │ │ │ ├── results │ │ │ │ │ ├── FailureList.java │ │ │ │ │ ├── PrintableResult.java │ │ │ │ │ └── ResultMatchers.java │ │ │ │ ├── runners │ │ │ │ │ └── Enclosed.java │ │ │ │ └── theories │ │ │ │ │ ├── DataPoint.java │ │ │ │ │ ├── DataPoints.java │ │ │ │ │ ├── FromDataPoints.java │ │ │ │ │ ├── ParameterSignature.java │ │ │ │ │ ├── ParameterSupplier.java │ │ │ │ │ ├── ParametersSuppliedBy.java │ │ │ │ │ ├── PotentialAssignment.java │ │ │ │ │ ├── Theories.java │ │ │ │ │ ├── Theory.java │ │ │ │ │ ├── internal │ │ │ │ │ ├── AllMembersSupplier.java │ │ │ │ │ ├── Assignments.java │ │ │ │ │ ├── BooleanSupplier.java │ │ │ │ │ ├── EnumSupplier.java │ │ │ │ │ ├── ParameterizedAssertionError.java │ │ │ │ │ └── SpecificDataPointsSupplier.java │ │ │ │ │ └── suppliers │ │ │ │ │ ├── TestedOn.java │ │ │ │ │ └── TestedOnSupplier.java │ │ │ │ ├── internal │ │ │ │ ├── ArrayComparisonFailure.java │ │ │ │ ├── AssumptionViolatedException.java │ │ │ │ ├── Classes.java │ │ │ │ ├── ComparisonCriteria.java │ │ │ │ ├── ExactComparisonCriteria.java │ │ │ │ ├── InexactComparisonCriteria.java │ │ │ │ ├── JUnitSystem.java │ │ │ │ ├── MethodSorter.java │ │ │ │ ├── RealSystem.java │ │ │ │ ├── TextListener.java │ │ │ │ ├── Throwables.java │ │ │ │ ├── builders │ │ │ │ │ ├── AllDefaultPossibilitiesBuilder.java │ │ │ │ │ ├── AnnotatedBuilder.java │ │ │ │ │ ├── IgnoredBuilder.java │ │ │ │ │ ├── IgnoredClassRunner.java │ │ │ │ │ ├── JUnit3Builder.java │ │ │ │ │ ├── JUnit4Builder.java │ │ │ │ │ ├── NullBuilder.java │ │ │ │ │ └── SuiteMethodBuilder.java │ │ │ │ ├── matchers │ │ │ │ │ ├── StacktracePrintingMatcher.java │ │ │ │ │ ├── ThrowableCauseMatcher.java │ │ │ │ │ ├── ThrowableMessageMatcher.java │ │ │ │ │ └── TypeSafeMatcher.java │ │ │ │ ├── requests │ │ │ │ │ ├── ClassRequest.java │ │ │ │ │ ├── FilterRequest.java │ │ │ │ │ ├── SortingRequest.java │ │ │ │ │ └── package-info.java │ │ │ │ └── runners │ │ │ │ │ ├── ClassRoadie.java │ │ │ │ │ ├── ErrorReportingRunner.java │ │ │ │ │ ├── FailedBefore.java │ │ │ │ │ ├── InitializationError.java │ │ │ │ │ ├── JUnit38ClassRunner.java │ │ │ │ │ ├── JUnit4ClassRunner.java │ │ │ │ │ ├── MethodRoadie.java │ │ │ │ │ ├── MethodValidator.java │ │ │ │ │ ├── SuiteMethod.java │ │ │ │ │ ├── TestClass.java │ │ │ │ │ ├── TestMethod.java │ │ │ │ │ ├── model │ │ │ │ │ ├── EachTestNotifier.java │ │ │ │ │ ├── MultipleFailureException.java │ │ │ │ │ └── ReflectiveCallable.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── rules │ │ │ │ │ ├── RuleMemberValidator.java │ │ │ │ │ └── ValidationError.java │ │ │ │ │ └── statements │ │ │ │ │ ├── ExpectException.java │ │ │ │ │ ├── Fail.java │ │ │ │ │ ├── FailOnTimeout.java │ │ │ │ │ ├── InvokeMethod.java │ │ │ │ │ ├── RunAfters.java │ │ │ │ │ └── RunBefores.java │ │ │ │ ├── matchers │ │ │ │ ├── JUnitMatchers.java │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ ├── rules │ │ │ │ ├── DisableOnDebug.java │ │ │ │ ├── ErrorCollector.java │ │ │ │ ├── ExpectedException.java │ │ │ │ ├── ExpectedExceptionMatcherBuilder.java │ │ │ │ ├── ExternalResource.java │ │ │ │ ├── MethodRule.java │ │ │ │ ├── RuleChain.java │ │ │ │ ├── RunRules.java │ │ │ │ ├── Stopwatch.java │ │ │ │ ├── TemporaryFolder.java │ │ │ │ ├── TestName.java │ │ │ │ ├── TestRule.java │ │ │ │ ├── TestWatcher.java │ │ │ │ ├── TestWatchman.java │ │ │ │ ├── Timeout.java │ │ │ │ └── Verifier.java │ │ │ │ ├── runner │ │ │ │ ├── Computer.java │ │ │ │ ├── Describable.java │ │ │ │ ├── Description.java │ │ │ │ ├── FilterFactories.java │ │ │ │ ├── FilterFactory.java │ │ │ │ ├── FilterFactoryParams.java │ │ │ │ ├── JUnitCommandLineParseResult.java │ │ │ │ ├── JUnitCore.java │ │ │ │ ├── Request.java │ │ │ │ ├── Result.java │ │ │ │ ├── RunWith.java │ │ │ │ ├── Runner.java │ │ │ │ ├── manipulation │ │ │ │ │ ├── Filter.java │ │ │ │ │ ├── Filterable.java │ │ │ │ │ ├── NoTestsRemainException.java │ │ │ │ │ ├── Sortable.java │ │ │ │ │ ├── Sorter.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── notification │ │ │ │ │ ├── Failure.java │ │ │ │ │ ├── RunListener.java │ │ │ │ │ ├── RunNotifier.java │ │ │ │ │ ├── StoppedByUserException.java │ │ │ │ │ ├── SynchronizedRunListener.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ │ ├── runners │ │ │ │ ├── AllTests.java │ │ │ │ ├── BlockJUnit4ClassRunner.java │ │ │ │ ├── JUnit4.java │ │ │ │ ├── MethodSorters.java │ │ │ │ ├── Parameterized.java │ │ │ │ ├── ParentRunner.java │ │ │ │ ├── Suite.java │ │ │ │ ├── model │ │ │ │ │ ├── Annotatable.java │ │ │ │ │ ├── FrameworkField.java │ │ │ │ │ ├── FrameworkMember.java │ │ │ │ │ ├── FrameworkMethod.java │ │ │ │ │ ├── InitializationError.java │ │ │ │ │ ├── MultipleFailureException.java │ │ │ │ │ ├── NoGenericTypeParametersValidator.java │ │ │ │ │ ├── RunnerBuilder.java │ │ │ │ │ ├── RunnerScheduler.java │ │ │ │ │ ├── Statement.java │ │ │ │ │ ├── TestClass.java │ │ │ │ │ └── TestTimedOutException.java │ │ │ │ ├── package-info.java │ │ │ │ └── parameterized │ │ │ │ │ ├── BlockJUnit4ClassRunnerWithParameters.java │ │ │ │ │ ├── BlockJUnit4ClassRunnerWithParametersFactory.java │ │ │ │ │ ├── ParametersRunnerFactory.java │ │ │ │ │ └── TestWithParameters.java │ │ │ │ └── validator │ │ │ │ ├── AnnotationValidator.java │ │ │ │ ├── AnnotationValidatorFactory.java │ │ │ │ ├── AnnotationsValidator.java │ │ │ │ ├── PublicClassValidator.java │ │ │ │ ├── TestClassValidator.java │ │ │ │ └── ValidateWith.java │ │ ├── javadoc │ │ │ └── stylesheet.css │ │ └── resources │ │ │ └── junit │ │ │ └── runner │ │ │ ├── logo.gif │ │ │ └── smalllogo.gif │ ├── site │ │ ├── fml │ │ │ └── faq.fml │ │ ├── markdown │ │ │ └── cookbook.md │ │ ├── resources │ │ │ ├── css │ │ │ │ ├── hopscotch-0.1.2.min.css │ │ │ │ └── plain-links.css │ │ │ ├── images │ │ │ │ ├── junit-logo.png │ │ │ │ └── junit-logo.svg │ │ │ └── scripts │ │ │ │ ├── hopscotch-0.1.2.min.js │ │ │ │ └── index.js │ │ ├── site.xml │ │ └── xdoc │ │ │ └── index.xml │ └── test │ │ ├── java │ │ ├── junit │ │ │ ├── samples │ │ │ │ ├── AllTests.java │ │ │ │ ├── ListTest.java │ │ │ │ ├── SimpleTest.java │ │ │ │ ├── money │ │ │ │ │ ├── IMoney.java │ │ │ │ │ ├── Money.java │ │ │ │ │ ├── MoneyBag.java │ │ │ │ │ ├── MoneyTest.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ └── tests │ │ │ │ ├── AllTests.java │ │ │ │ ├── WasRun.java │ │ │ │ ├── extensions │ │ │ │ ├── ActiveTestTest.java │ │ │ │ ├── AllTests.java │ │ │ │ ├── ExtensionTest.java │ │ │ │ ├── RepeatedTestTest.java │ │ │ │ └── package-info.java │ │ │ │ ├── framework │ │ │ │ ├── AllTests.java │ │ │ │ ├── AssertTest.java │ │ │ │ ├── AssertionFailedErrorTest.java │ │ │ │ ├── ComparisonCompactorTest.java │ │ │ │ ├── ComparisonFailureTest.java │ │ │ │ ├── DoublePrecisionAssertTest.java │ │ │ │ ├── Failure.java │ │ │ │ ├── FloatAssertTest.java │ │ │ │ ├── InheritedTestCase.java │ │ │ │ ├── NoArgTestCaseTest.java │ │ │ │ ├── NoTestCaseClass.java │ │ │ │ ├── NoTestCases.java │ │ │ │ ├── NotPublicTestCase.java │ │ │ │ ├── NotVoidTestCase.java │ │ │ │ ├── OneTestCase.java │ │ │ │ ├── OverrideTestCase.java │ │ │ │ ├── Success.java │ │ │ │ ├── SuiteTest.java │ │ │ │ ├── TestCaseTest.java │ │ │ │ ├── TestImplementorTest.java │ │ │ │ ├── TestListenerTest.java │ │ │ │ ├── ThreeTestCases.java │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── runner │ │ │ │ ├── AllTests.java │ │ │ │ ├── BaseTestRunnerTest.java │ │ │ │ ├── ResultTest.java │ │ │ │ ├── StackFilterTest.java │ │ │ │ ├── TextFeedbackTest.java │ │ │ │ ├── TextRunnerSingleMethodTest.java │ │ │ │ ├── TextRunnerTest.java │ │ │ │ └── package-info.java │ │ └── org │ │ │ └── junit │ │ │ ├── AssumptionViolatedExceptionTest.java │ │ │ ├── experimental │ │ │ └── categories │ │ │ │ └── CategoryFilterFactoryTest.java │ │ │ ├── internal │ │ │ ├── MethodSorterTest.java │ │ │ ├── builders │ │ │ │ └── AnnotatedBuilderTest.java │ │ │ └── matchers │ │ │ │ ├── StacktracePrintingMatcherTest.java │ │ │ │ └── ThrowableCauseMatcherTest.java │ │ │ ├── rules │ │ │ ├── DisableOnDebugTest.java │ │ │ └── StopwatchTest.java │ │ │ ├── runner │ │ │ ├── FilterFactoriesTest.java │ │ │ ├── FilterOptionIntegrationTest.java │ │ │ ├── JUnitCommandLineParseResultTest.java │ │ │ ├── JUnitCoreTest.java │ │ │ ├── RunnerSpy.java │ │ │ └── notification │ │ │ │ ├── ConcurrentRunNotifierTest.java │ │ │ │ ├── RunNotifierTest.java │ │ │ │ └── SynchronizedRunListenerTest.java │ │ │ ├── runners │ │ │ ├── CustomBlockJUnit4ClassRunnerTest.java │ │ │ ├── model │ │ │ │ ├── FrameworkFieldTest.java │ │ │ │ ├── FrameworkMethodTest.java │ │ │ │ ├── RunnerBuilderStub.java │ │ │ │ └── TestClassTest.java │ │ │ └── parameterized │ │ │ │ ├── BlockJUnit4ClassRunnerWithParametersTest.java │ │ │ │ ├── ParameterizedNamesTest.java │ │ │ │ └── TestWithParametersTest.java │ │ │ ├── samples │ │ │ ├── ListTest.java │ │ │ ├── SimpleTest.java │ │ │ ├── money │ │ │ │ ├── MoneyTest.java │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ │ ├── tests │ │ │ ├── AllTests.java │ │ │ ├── ObjectContractTest.java │ │ │ ├── TestSystem.java │ │ │ ├── assertion │ │ │ │ ├── AssertionTest.java │ │ │ │ ├── ComparisonFailureTest.java │ │ │ │ └── MultipleFailureExceptionTest.java │ │ │ ├── deprecated │ │ │ │ └── JUnit4ClassRunnerTest.java │ │ │ ├── description │ │ │ │ ├── AnnotatedDescriptionTest.java │ │ │ │ ├── SuiteDescriptionTest.java │ │ │ │ ├── TestDescriptionMethodNameTest.java │ │ │ │ └── TestDescriptionTest.java │ │ │ ├── experimental │ │ │ │ ├── AssumptionTest.java │ │ │ │ ├── ExperimentalTests.java │ │ │ │ ├── MatcherTest.java │ │ │ │ ├── categories │ │ │ │ │ ├── CategoriesAndParameterizedTest.java │ │ │ │ │ ├── CategoryTest.java │ │ │ │ │ ├── CategoryValidatorTest.java │ │ │ │ │ ├── JavadocTest.java │ │ │ │ │ └── MultiCategoryTest.java │ │ │ │ ├── max │ │ │ │ │ ├── DescriptionTest.java │ │ │ │ │ ├── JUnit38SortingTest.java │ │ │ │ │ └── MaxStarterTest.java │ │ │ │ ├── parallel │ │ │ │ │ ├── ParallelClassTest.java │ │ │ │ │ └── ParallelMethodTest.java │ │ │ │ ├── results │ │ │ │ │ ├── PrintableResultTest.java │ │ │ │ │ └── ResultMatchersTest.java │ │ │ │ ├── rules │ │ │ │ │ ├── BlockJUnit4ClassRunnerOverrideTest.java │ │ │ │ │ ├── ClassRulesTest.java │ │ │ │ │ ├── EventCollector.java │ │ │ │ │ ├── ExpectedExceptionTest.java │ │ │ │ │ ├── ExternalResourceRuleTest.java │ │ │ │ │ ├── LoggingTestWatcher.java │ │ │ │ │ ├── MethodRulesTest.java │ │ │ │ │ ├── NameRulesTest.java │ │ │ │ │ ├── RuleChainTest.java │ │ │ │ │ ├── RuleMemberValidatorTest.java │ │ │ │ │ ├── TempFolderRuleTest.java │ │ │ │ │ ├── TemporaryFolderRuleAssuredDeletionTest.java │ │ │ │ │ ├── TemporaryFolderUsageTest.java │ │ │ │ │ ├── TestRuleTest.java │ │ │ │ │ ├── TestWatcherTest.java │ │ │ │ │ ├── TestWatchmanTest.java │ │ │ │ │ ├── TimeoutRuleTest.java │ │ │ │ │ └── VerifierRuleTest.java │ │ │ │ └── theories │ │ │ │ │ ├── AssumingInTheoriesTest.java │ │ │ │ │ ├── ParameterSignatureTest.java │ │ │ │ │ ├── PotentialAssignmentTest.java │ │ │ │ │ ├── TestedOnSupplierTest.java │ │ │ │ │ ├── TheoryTestUtils.java │ │ │ │ │ ├── extendingwithstubs │ │ │ │ │ ├── Correspondent.java │ │ │ │ │ ├── Guesser.java │ │ │ │ │ ├── GuesserQueue.java │ │ │ │ │ ├── MethodCall.java │ │ │ │ │ ├── ReguessableValue.java │ │ │ │ │ ├── StringableObject.java │ │ │ │ │ ├── Stub.java │ │ │ │ │ ├── StubbedTheories.java │ │ │ │ │ └── StubbedTheoriesTest.java │ │ │ │ │ ├── internal │ │ │ │ │ ├── AllMembersSupplierTest.java │ │ │ │ │ ├── ParameterizedAssertionErrorTest.java │ │ │ │ │ └── SpecificDataPointsSupplierTest.java │ │ │ │ │ └── runner │ │ │ │ │ ├── FailingDataPointMethods.java │ │ │ │ │ ├── SuccessfulWithDataPointFields.java │ │ │ │ │ ├── TheoriesPerformanceTest.java │ │ │ │ │ ├── TypeMatchingBetweenMultiDataPointsMethod.java │ │ │ │ │ ├── UnsuccessfulWithDataPointFields.java │ │ │ │ │ ├── WhenNoParametersMatch.java │ │ │ │ │ ├── WithAutoGeneratedDataPoints.java │ │ │ │ │ ├── WithDataPointMethod.java │ │ │ │ │ ├── WithExtendedParameterSources.java │ │ │ │ │ ├── WithNamedDataPoints.java │ │ │ │ │ ├── WithOnlyTestAnnotations.java │ │ │ │ │ ├── WithParameterSupplier.java │ │ │ │ │ └── WithUnresolvedGenericTypeVariablesOnTheoryParms.java │ │ │ ├── internal │ │ │ │ └── runners │ │ │ │ │ ├── ErrorReportingRunnerTest.java │ │ │ │ │ └── statements │ │ │ │ │ └── FailOnTimeoutTest.java │ │ │ ├── junit3compatibility │ │ │ │ ├── AllTestsTest.java │ │ │ │ ├── ClassRequestTest.java │ │ │ │ ├── ForwardCompatibilityPrintingTest.java │ │ │ │ ├── ForwardCompatibilityTest.java │ │ │ │ ├── InitializationErrorForwardCompatibilityTest.java │ │ │ │ ├── JUnit38ClassRunnerTest.java │ │ │ │ ├── OldTestClassAdaptingListenerTest.java │ │ │ │ ├── OldTests.java │ │ │ │ └── SuiteMethodTest.java │ │ │ ├── listening │ │ │ │ ├── ListenerTest.java │ │ │ │ ├── RunnerTest.java │ │ │ │ ├── TestListenerTest.java │ │ │ │ ├── TextListenerTest.java │ │ │ │ └── UserStopTest.java │ │ │ ├── manipulation │ │ │ │ ├── FilterTest.java │ │ │ │ ├── FilterableTest.java │ │ │ │ ├── SingleMethodTest.java │ │ │ │ └── SortableTest.java │ │ │ ├── package-info.java │ │ │ ├── running │ │ │ │ ├── classes │ │ │ │ │ ├── BlockJUnit4ClassRunnerTest.java │ │ │ │ │ ├── ClassLevelMethodsWithIgnoredTestsTest.java │ │ │ │ │ ├── EnclosedTest.java │ │ │ │ │ ├── IgnoreClassTest.java │ │ │ │ │ ├── ParameterizedTestTest.java │ │ │ │ │ ├── ParentRunnerFilteringTest.java │ │ │ │ │ ├── ParentRunnerTest.java │ │ │ │ │ ├── RunWithTest.java │ │ │ │ │ ├── SuiteTest.java │ │ │ │ │ └── UseSuiteAsASuperclassTest.java │ │ │ │ ├── core │ │ │ │ │ ├── CommandLineTest.java │ │ │ │ │ ├── JUnitCoreReturnsCorrectExitCodeTest.java │ │ │ │ │ ├── MainRunner.java │ │ │ │ │ └── SystemExitTest.java │ │ │ │ └── methods │ │ │ │ │ ├── AnnotationTest.java │ │ │ │ │ ├── ExpectedTest.java │ │ │ │ │ ├── InheritedTestTest.java │ │ │ │ │ ├── ParameterizedTestMethodTest.java │ │ │ │ │ ├── TestMethodTest.java │ │ │ │ │ └── TimeoutTest.java │ │ │ └── validation │ │ │ │ ├── BadlyFormedClassesTest.java │ │ │ │ ├── FailedConstructionTest.java │ │ │ │ ├── ValidationTest.java │ │ │ │ └── anotherpackage │ │ │ │ ├── Sub.java │ │ │ │ └── Super.java │ │ │ └── validator │ │ │ ├── AnnotationValidatorFactoryTest.java │ │ │ ├── AnnotationsValidatorTest.java │ │ │ └── PublicClassValidatorTest.java │ │ └── resources │ │ └── junit │ │ └── tests │ │ └── runner │ │ ├── testRunFailureResultCanBeSerialised │ │ └── testRunSuccessResultCanBeSerialised │ └── to-do.txt └── src └── main ├── java └── me │ └── tomassetti │ ├── examples │ ├── CodeGenerationExample.java │ ├── ListClassesExample.java │ ├── MethodCallsExample.java │ ├── ModifyingCode.java │ ├── ParsingForFirstTime.java │ └── StatementsLinesExample.java │ └── support │ └── DirExplorer.java └── resources └── ASimpleClass.java /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | .gradle 4 | *.ipr 5 | *.iws 6 | out 7 | build -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # analyze-java-code-examples 2 | Some examples of code extracting information from Java source files using JavaParser 3 | 4 | Read an explanation in this article: [http://tomassetti.me/getting-started-with-javaparser-analyzing-java-code-programmatically/](http://tomassetti.me/getting-started-with-javaparser-analyzing-java-code-programmatically/) 5 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | group 'tomassetti.me' 2 | version '1.0-SNAPSHOT' 3 | 4 | apply plugin: 'java' 5 | apply plugin: 'idea' 6 | 7 | sourceCompatibility = 1.8 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | implementation group: 'com.github.javaparser', name:'javaparser-core', version: '3.15.13' 15 | implementation group: 'com.google.guava', name: 'guava', version: '11.0.2' 16 | testImplementation group: 'junit', name: 'junit', version: '4.11' 17 | } 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri May 14 09:26:17 CEST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'analyze-java-code' 2 | 3 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/.gitignore: -------------------------------------------------------------------------------- 1 | MaxCore.ser 2 | bin 3 | junit4.* 4 | target 5 | MaxCore.max 6 | # IntelliJ 7 | .idea 8 | *.ipr 9 | *.iml 10 | *.iws 11 | out 12 | java.hprof.txt 13 | .gitattributes -------------------------------------------------------------------------------- /source_to_parse/junit-master/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | junit 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | org.eclipse.team.cvs.core.cvsnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | #Tue Jul 22 09:31:38 PDT 2008 2 | eclipse.preferences.version=1 3 | formatter_profile=_junit 4 | formatter_settings_version=11 5 | internal.default.compliance=default 6 | org.eclipse.jdt.ui.exception.name=e 7 | org.eclipse.jdt.ui.gettersetter.use.is=true 8 | org.eclipse.jdt.ui.ignorelowercasenames=true 9 | org.eclipse.jdt.ui.importorder=java;javax;com; 10 | org.eclipse.jdt.ui.keywordthis=false 11 | org.eclipse.jdt.ui.ondemandthreshold=99 12 | org.eclipse.jdt.ui.overrideannotation=true 13 | org.eclipse.jdt.ui.text.custom_code_templates= 14 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | script: mvn verify javadoc:javadoc site:site 3 | jdk: 4 | - oraclejdk7 5 | - oraclejdk8 6 | - openjdk7 7 | - openjdk6 8 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/BUILDING: -------------------------------------------------------------------------------- 1 | BUILDING FROM GITHUB: 2 | ===================== 3 | 4 | git clone https://github.com/junit-team/junit.git 5 | cd junit 6 | mvn install 7 | 8 | BUILDING FROM JARS OR ZIPS: 9 | =========================== 10 | 11 | The contents of the zip and jar files are largely maintained for historical 12 | reasons. We do not at this time have an official way to build from the src 13 | jar or zip. If this is an important missing feature, please let us know 14 | at http://github.com/junit-team/junit/issues 15 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/CODING_STYLE.txt: -------------------------------------------------------------------------------- 1 | JUnit project uses the Google Java Style (http://google-styleguide.googlecode.com/svn/trunk/javaguide.html) for all new 2 | code (under org.junit.*). Legacy code (under junit.*) used the legacy guide specified in LEGACY_CODING_STYLE.txt in the 3 | project root. 4 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Project License: Eclipse Public License v1.0 2 | 3 | - You will only Submit Contributions where You have authored 100% of the content. 4 | - 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. 5 | - Whatever content You Contribute will be provided under the Project License(s). 6 | 7 | --- 8 | 9 | ### How to submit a pull request 10 | 11 | We love pull requests. Here is a quick guide: 12 | 13 | 1. You need to have Maven and a JDK (at least version 1.5) installed. 14 | 2. [Fork the repo](https://help.github.com/articles/fork-a-repo). 15 | 3. [Create a new branch](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/) from master. 16 | 4. Ensure that you have a clean state by running `mvn verify`. 17 | 5. Add your change together with a test (tests are not needed for refactorings and documentation changes). 18 | 6. 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. 19 | 7. Run `mvn verify` again and ensure all tests are passing. 20 | 8. Push to your fork and [submit a pull request](https://help.github.com/articles/creating-a-pull-request/). 21 | 22 | Now you are waiting on us. We review your pull request and at least leave some comments. 23 | 24 | 25 | Note that if you are thinking of providing a fix for one of the bugs or feature requests, it's usually 26 | a good idea to add a comment to the bug to make sure that there's agreement on how we should proceed. 27 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/NOTICE.txt: -------------------------------------------------------------------------------- 1 | =================================================================================== 2 | == Notices and attributions required by libraries that the project depends on == 3 | =================================================================================== 4 | 5 | The JUnit depends on Java Hamcrest (http://hamcrest.org/JavaHamcrest/). 6 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/README.md: -------------------------------------------------------------------------------- 1 | # JUnit 4 2 | JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. 3 | 4 | For more information, please visit: 5 | * [Wiki](https://github.com/junit-team/junit/wiki) 6 | * [Download and Install guide](https://github.com/junit-team/junit/wiki/Download-and-Install) 7 | * [Getting Started](https://github.com/junit-team/junit/wiki/Getting-started) 8 | 9 | [![Latest Build Status](https://junit.ci.cloudbees.com/job/JUnit/badge/icon)](https://junit.ci.cloudbees.com/) 10 | 11 | [![Built on DEV@cloud](http://www.cloudbees.com/sites/default/files/Button-Built-on-CB-1.png)](http://www.cloudbees.com/foss/foss-dev.cb) 12 | 13 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.10.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.10.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.11.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.11.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.13.md: -------------------------------------------------------------------------------- 1 | ## Summary of changes in version 4.13 [unreleased!] 2 | 3 | We collect release notes in the wiki: 4 | https://github.com/junit-team/junit/wiki/4.13-release-notes 5 | 6 | This file will be updated right before release. 7 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.4.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.4.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.5.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.5.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.6.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.6.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.7.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.7.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.1.html: -------------------------------------------------------------------------------- 1 |

Summary of Changes in version 4.8.1

2 | 3 |

This was a quick bugfix release for an important bug

4 | 5 |

Bug fixes

6 | 7 | 10 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.1.md: -------------------------------------------------------------------------------- 1 | ## Summary of Changes in version 4.8.1 ## 2 | 3 | This was a quick bugfix release for an important bug 4 | 5 | ### Bug fixes ### 6 | 7 | - github#61: Category annotations on classes were not honored. -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.1.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.8.1.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.2.html: -------------------------------------------------------------------------------- 1 |

Summary of Changes in version 4.8.2

2 | 3 |

This was a quick bugfix release

4 | 5 |

Bug fixes

6 | 7 | 11 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.2.md: -------------------------------------------------------------------------------- 1 | ## Summary of Changes in version 4.8.2 ## 2 | 3 | This was a quick bugfix release 4 | 5 | ### Bug fixes ### 6 | 7 | - github#96: TestSuite(MyTestCase.class) should dynamically detect if MyTestCase 8 | is a TestCase 9 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.2.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.8.2.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.md: -------------------------------------------------------------------------------- 1 | ## Summary of Changes in version 4.8 ## 2 | 3 | ### Categories ### 4 | 5 | From a given set of test classes, the `Categories` runner 6 | runs only the classes and methods 7 | that are annotated with either the category given with the `@IncludeCategory` 8 | annotation, or a subtype of that category. Either classes or interfaces can be 9 | used as categories. Subtyping works, so if you say `@IncludeCategory(SuperClass.class)`, 10 | a test marked `@Category({SubClass.class})` will be run. 11 | 12 | You can also exclude categories by using the `@ExcludeCategory` annotation 13 | 14 | Example: 15 | 16 | ```java 17 | public interface FastTests { /* category marker */ } 18 | public interface SlowTests { /* category marker */ } 19 | 20 | public class A { 21 | @Test 22 | public void a() { 23 | fail(); 24 | } 25 | 26 | @Category(SlowTests.class) 27 | @Test 28 | public void b() { 29 | } 30 | } 31 | 32 | @Category({SlowTests.class, FastTests.class}) 33 | public class B { 34 | @Test 35 | public void c() { 36 | } 37 | } 38 | 39 | @RunWith(Categories.class) 40 | @IncludeCategory(SlowTests.class) 41 | @SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite 42 | public class SlowTestSuite { 43 | // Will run A.b and B.c, but not A.a 44 | } 45 | 46 | @RunWith(Categories.class) 47 | @IncludeCategory(SlowTests.class) 48 | @ExcludeCategory(FastTests.class) 49 | @SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite 50 | public class SlowTestSuite { 51 | // Will run A.b, but not A.a or B.c 52 | } 53 | ``` 54 | 55 | ### Bug fixes ### 56 | 57 | - github#16: thread safety of Result counting 58 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.8.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.8.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.9.1.md: -------------------------------------------------------------------------------- 1 | ## Summary of Changes in version 4.9.1 [unreleased!] ## 2 | 3 | ### Theories ### 4 | 5 | The `Theories` runner does not anticipate theory parameters that have generic 6 | types, as reported by github#64. Fixing this won't happen until `Theories` is 7 | moved to junit-contrib. In anticipation of this, 4.9.1 adds some of the 8 | necessary machinery to the runner classes, and deprecates a method that only 9 | the `Theories` runner uses, `FrameworkMethod`#producesType(). 10 | The Common Public License that JUnit is released under is now included 11 | in the source repository. 12 | 13 | Thanks to `@pholser` for identifying a potential resolution for github#64 14 | and initiating work on it. 15 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.9.1.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.9.1.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/ReleaseNotes4.9.txt: -------------------------------------------------------------------------------- 1 | Please see ReleaseNotes4.9.md 2 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/Image1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/Image1.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/Image2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/Image2.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/Image3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/Image3.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/Image4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/Image4.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/Image5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/Image5.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/Image6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/Image6.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/Image7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/Image7.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/cookstour/cookstour.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/cookstour/cookstour.htm -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | JUnit Documentation 7 | 8 | 9 | 10 |

11 | JUnit Documentation

12 | 13 |

14 | Kent Beck, Erich Gamma, David Saff

15 | 16 |
17 | We have just begun documenting the new JUnit 4 architecture. The cookbook has already been updated. You can find the javadoc here. 18 | The JUnit home page is here. 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/markdown.sh: -------------------------------------------------------------------------------- 1 | ~/bin/Markdown.pl ReleaseNotes4.8.txt >ReleaseNotes4.8.html -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/testinfected/IMG00001.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/testinfected/IMG00001.GIF -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/testinfected/IMG00002.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/testinfected/IMG00002.GIF -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/testinfected/IMG00003.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/testinfected/IMG00003.GIF -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/testinfected/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/testinfected/logo.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/doc/testinfected/testing.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/doc/testinfected/testing.htm -------------------------------------------------------------------------------- /source_to_parse/junit-master/lib/hamcrest-core-1.3-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/lib/hamcrest-core-1.3-sources.jar -------------------------------------------------------------------------------- /source_to_parse/junit-master/lib/hamcrest-core-1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/lib/hamcrest-core-1.3.jar -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/changes/changes.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/extensions/RepeatedTest.java: -------------------------------------------------------------------------------- 1 | package junit.extensions; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestResult; 5 | 6 | /** 7 | * A Decorator that runs a test repeatedly. 8 | */ 9 | public class RepeatedTest extends TestDecorator { 10 | private int fTimesRepeat; 11 | 12 | public RepeatedTest(Test test, int repeat) { 13 | super(test); 14 | if (repeat < 0) { 15 | throw new IllegalArgumentException("Repetition count must be >= 0"); 16 | } 17 | fTimesRepeat = repeat; 18 | } 19 | 20 | @Override 21 | public int countTestCases() { 22 | return super.countTestCases() * fTimesRepeat; 23 | } 24 | 25 | @Override 26 | public void run(TestResult result) { 27 | for (int i = 0; i < fTimesRepeat; i++) { 28 | if (result.shouldStop()) { 29 | break; 30 | } 31 | super.run(result); 32 | } 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return super.toString() + "(repeated)"; 38 | } 39 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/extensions/TestDecorator.java: -------------------------------------------------------------------------------- 1 | package junit.extensions; 2 | 3 | import junit.framework.Assert; 4 | import junit.framework.Test; 5 | import junit.framework.TestResult; 6 | 7 | /** 8 | * A Decorator for Tests. Use TestDecorator as the base class for defining new 9 | * test decorators. Test decorator subclasses can be introduced to add behaviour 10 | * before or after a test is run. 11 | */ 12 | @SuppressWarnings("deprecation") 13 | public class TestDecorator extends Assert implements Test { 14 | protected Test fTest; 15 | 16 | public TestDecorator(Test test) { 17 | fTest = test; 18 | } 19 | 20 | /** 21 | * The basic run behaviour. 22 | */ 23 | public void basicRun(TestResult result) { 24 | fTest.run(result); 25 | } 26 | 27 | public int countTestCases() { 28 | return fTest.countTestCases(); 29 | } 30 | 31 | public void run(TestResult result) { 32 | basicRun(result); 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return fTest.toString(); 38 | } 39 | 40 | public Test getTest() { 41 | return fTest; 42 | } 43 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/extensions/TestSetup.java: -------------------------------------------------------------------------------- 1 | package junit.extensions; 2 | 3 | import junit.framework.Protectable; 4 | import junit.framework.Test; 5 | import junit.framework.TestResult; 6 | 7 | /** 8 | * A Decorator to set up and tear down additional fixture state. Subclass 9 | * TestSetup and insert it into your tests when you want to set up additional 10 | * state once before the tests are run. 11 | */ 12 | public class TestSetup extends TestDecorator { 13 | 14 | public TestSetup(Test test) { 15 | super(test); 16 | } 17 | 18 | @Override 19 | public void run(final TestResult result) { 20 | Protectable p = new Protectable() { 21 | public void protect() throws Exception { 22 | setUp(); 23 | basicRun(result); 24 | tearDown(); 25 | } 26 | }; 27 | result.runProtected(this, p); 28 | } 29 | 30 | /** 31 | * Sets up the fixture. Override to set up additional fixture state. 32 | */ 33 | protected void setUp() throws Exception { 34 | } 35 | 36 | /** 37 | * Tears down the fixture. Override to tear down the additional fixture 38 | * state. 39 | */ 40 | protected void tearDown() throws Exception { 41 | } 42 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/extensions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides extended functionality for JUnit v3.x. 3 | */ 4 | package junit.extensions; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/framework/AssertionFailedError.java: -------------------------------------------------------------------------------- 1 | package junit.framework; 2 | 3 | /** 4 | * Thrown when an assertion failed. 5 | */ 6 | public class AssertionFailedError extends AssertionError { 7 | 8 | private static final long serialVersionUID = 1L; 9 | 10 | /** 11 | * Constructs a new AssertionFailedError without a detail message. 12 | */ 13 | public AssertionFailedError() { 14 | } 15 | 16 | /** 17 | * Constructs a new AssertionFailedError with the specified detail message. 18 | * A null message is replaced by an empty String. 19 | * @param message the detail message. The detail message is saved for later 20 | * retrieval by the {@code Throwable.getMessage()} method. 21 | */ 22 | public AssertionFailedError(String message) { 23 | super(defaultString(message)); 24 | } 25 | 26 | private static String defaultString(String message) { 27 | return message == null ? "" : message; 28 | } 29 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/framework/ComparisonFailure.java: -------------------------------------------------------------------------------- 1 | package junit.framework; 2 | 3 | /** 4 | * Thrown when an assert equals for Strings failed. 5 | * 6 | * Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com 7 | */ 8 | public class ComparisonFailure extends AssertionFailedError { 9 | private static final int MAX_CONTEXT_LENGTH = 20; 10 | private static final long serialVersionUID = 1L; 11 | 12 | private String fExpected; 13 | private String fActual; 14 | 15 | /** 16 | * Constructs a comparison failure. 17 | * 18 | * @param message the identifying message or null 19 | * @param expected the expected string value 20 | * @param actual the actual string value 21 | */ 22 | public ComparisonFailure(String message, String expected, String actual) { 23 | super(message); 24 | fExpected = expected; 25 | fActual = actual; 26 | } 27 | 28 | /** 29 | * Returns "..." in place of common prefix and "..." in 30 | * place of common suffix between expected and actual. 31 | * 32 | * @see Throwable#getMessage() 33 | */ 34 | @Override 35 | public String getMessage() { 36 | return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage()); 37 | } 38 | 39 | /** 40 | * Gets the actual string value 41 | * 42 | * @return the actual string value 43 | */ 44 | public String getActual() { 45 | return fActual; 46 | } 47 | 48 | /** 49 | * Gets the expected string value 50 | * 51 | * @return the expected string value 52 | */ 53 | public String getExpected() { 54 | return fExpected; 55 | } 56 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/framework/JUnit4TestCaseFacade.java: -------------------------------------------------------------------------------- 1 | package junit.framework; 2 | 3 | import org.junit.runner.Describable; 4 | import org.junit.runner.Description; 5 | 6 | public class JUnit4TestCaseFacade implements Test, Describable { 7 | private final Description fDescription; 8 | 9 | JUnit4TestCaseFacade(Description description) { 10 | fDescription = description; 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | return getDescription().toString(); 16 | } 17 | 18 | public int countTestCases() { 19 | return 1; 20 | } 21 | 22 | public void run(TestResult result) { 23 | throw new RuntimeException( 24 | "This test stub created only for informational purposes."); 25 | } 26 | 27 | public Description getDescription() { 28 | return fDescription; 29 | } 30 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/framework/Protectable.java: -------------------------------------------------------------------------------- 1 | package junit.framework; 2 | 3 | /** 4 | * A Protectable can be run and can throw a Throwable. 5 | * 6 | * @see TestResult 7 | */ 8 | public interface Protectable { 9 | 10 | /** 11 | * Run the the following method protected. 12 | */ 13 | public abstract void protect() throws Throwable; 14 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/framework/Test.java: -------------------------------------------------------------------------------- 1 | package junit.framework; 2 | 3 | /** 4 | * A Test can be run and collect its results. 5 | * 6 | * @see TestResult 7 | */ 8 | public interface Test { 9 | /** 10 | * Counts the number of test cases that will be run by this test. 11 | */ 12 | public abstract int countTestCases(); 13 | 14 | /** 15 | * Runs a test and collects its result in a TestResult instance. 16 | */ 17 | public abstract void run(TestResult result); 18 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/framework/TestListener.java: -------------------------------------------------------------------------------- 1 | package junit.framework; 2 | 3 | /** 4 | * A Listener for test progress 5 | */ 6 | public interface TestListener { 7 | /** 8 | * An error occurred. 9 | */ 10 | public void addError(Test test, Throwable e); 11 | 12 | /** 13 | * A failure occurred. 14 | */ 15 | public void addFailure(Test test, AssertionFailedError e); 16 | 17 | /** 18 | * A test ended. 19 | */ 20 | public void endTest(Test test); 21 | 22 | /** 23 | * A test started. 24 | */ 25 | public void startTest(Test test); 26 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/framework/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides JUnit v3.x core classes. 3 | */ 4 | package junit.framework; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/runner/TestRunListener.java: -------------------------------------------------------------------------------- 1 | package junit.runner; 2 | 3 | /** 4 | * A listener interface for observing the 5 | * execution of a test run. Unlike TestListener, 6 | * this interface using only primitive objects, 7 | * making it suitable for remote test execution. 8 | */ 9 | public interface TestRunListener { 10 | /* test status constants*/ 11 | public static final int STATUS_ERROR = 1; 12 | public static final int STATUS_FAILURE = 2; 13 | 14 | public void testRunStarted(String testSuiteName, int testCount); 15 | 16 | public void testRunEnded(long elapsedTime); 17 | 18 | public void testRunStopped(long elapsedTime); 19 | 20 | public void testStarted(String testName); 21 | 22 | public void testEnded(String testName); 23 | 24 | public void testFailed(int status, String testName, String trace); 25 | } 26 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/runner/Version.java: -------------------------------------------------------------------------------- 1 | package junit.runner; 2 | 3 | /** 4 | * This class defines the current version of JUnit 5 | */ 6 | public class Version { 7 | private Version() { 8 | // don't instantiate 9 | } 10 | 11 | public static String id() { 12 | return "4.13-SNAPSHOT"; 13 | } 14 | 15 | public static void main(String[] args) { 16 | System.out.println(id()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/runner/Version.java.template: -------------------------------------------------------------------------------- 1 | package junit.runner; 2 | 3 | /** 4 | * This class defines the current version of JUnit 5 | */ 6 | public class Version { 7 | private Version() { 8 | // don't instantiate 9 | } 10 | 11 | public static String id() { 12 | return "@version@"; 13 | } 14 | 15 | public static void main(String[] args) { 16 | System.out.println(id()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/runner/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides JUnit v3.x test runners. 3 | */ 4 | package junit.runner; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/junit/textui/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides JUnit v3.x command line based tool to run tests. 3 | */ 4 | package junit.textui; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/After.java: -------------------------------------------------------------------------------- 1 | package org.junit; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * If you allocate external resources in a {@link org.junit.Before} method you need to release them 10 | * after the test runs. Annotating a public void method 11 | * with @After causes that method to be run after the {@link org.junit.Test} method. All @After 12 | * methods are guaranteed to run even if a {@link org.junit.Before} or {@link org.junit.Test} method throws an 13 | * exception. The @After methods declared in superclasses will be run after those of the current 14 | * class, unless they are overridden in the current class. 15 | *

16 | * Here is a simple example: 17 | *

18 |  * public class Example {
19 |  *    File output;
20 |  *    @Before public void createOutputFile() {
21 |  *          output= new File(...);
22 |  *    }
23 |  *    @Test public void something() {
24 |  *          ...
25 |  *    }
26 |  *    @After public void deleteOutputFile() {
27 |  *          output.delete();
28 |  *    }
29 |  * }
30 |  * 
31 | * 32 | * @see org.junit.Before 33 | * @see org.junit.Test 34 | * @since 4.0 35 | */ 36 | 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @Target(ElementType.METHOD) 39 | public @interface After { 40 | } 41 | 42 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/AfterClass.java: -------------------------------------------------------------------------------- 1 | package org.junit; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * If you allocate expensive external resources in a {@link org.junit.BeforeClass} method you need to release them 10 | * after all the tests in the class have run. Annotating a public static void method 11 | * with @AfterClass causes that method to be run after all the tests in the class have been run. All @AfterClass 12 | * methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an 13 | * exception. The @AfterClass methods declared in superclasses will be run after those of the current 14 | * class, unless they are shadowed in the current class. 15 | *

16 | * Here is a simple example: 17 | *

18 |  * public class Example {
19 |  *    private static DatabaseConnection database;
20 |  *    @BeforeClass public static void login() {
21 |  *          database= ...;
22 |  *    }
23 |  *    @Test public void something() {
24 |  *          ...
25 |  *    }
26 |  *    @Test public void somethingElse() {
27 |  *          ...
28 |  *    }
29 |  *    @AfterClass public static void logout() {
30 |  *          database.logout();
31 |  *    }
32 |  * }
33 |  * 
34 | * 35 | * @see org.junit.BeforeClass 36 | * @see org.junit.Test 37 | * @since 4.0 38 | */ 39 | @Retention(RetentionPolicy.RUNTIME) 40 | @Target(ElementType.METHOD) 41 | public @interface AfterClass { 42 | } 43 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/AssumptionViolatedException.java: -------------------------------------------------------------------------------- 1 | package org.junit; 2 | 3 | import org.hamcrest.Matcher; 4 | 5 | /** 6 | * An exception class used to implement assumptions (state in which a given test 7 | * is meaningful and should or should not be executed). A test for which an assumption 8 | * fails should not generate a test case failure. 9 | * 10 | * @see org.junit.Assume 11 | * @since 4.12 12 | */ 13 | @SuppressWarnings("deprecation") 14 | public class AssumptionViolatedException extends org.junit.internal.AssumptionViolatedException { 15 | private static final long serialVersionUID = 1L; 16 | 17 | /** 18 | * An assumption exception with the given actual value and a matcher describing 19 | * the expectation that failed. 20 | */ 21 | @Deprecated 22 | public AssumptionViolatedException(T actual, Matcher matcher) { 23 | super(actual, matcher); 24 | } 25 | 26 | /** 27 | * An assumption exception with a message with the given actual value and a 28 | * matcher describing the expectation that failed. 29 | */ 30 | @Deprecated 31 | public AssumptionViolatedException(String message, T expected, Matcher matcher) { 32 | super(message, expected, matcher); 33 | } 34 | 35 | /** 36 | * An assumption exception with the given message only. 37 | */ 38 | public AssumptionViolatedException(String message) { 39 | super(message); 40 | } 41 | 42 | /** 43 | * An assumption exception with the given message and a cause. 44 | */ 45 | public AssumptionViolatedException(String assumption, Throwable t) { 46 | super(assumption, t); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/Before.java: -------------------------------------------------------------------------------- 1 | package org.junit; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * When writing tests, it is common to find that several tests need similar 10 | * objects created before they can run. Annotating a public void method 11 | * with @Before causes that method to be run before the {@link org.junit.Test} method. 12 | * The @Before methods of superclasses will be run before those of the current class, 13 | * unless they are overridden in the current class. No other ordering is defined. 14 | *

15 | * Here is a simple example: 16 | *

17 |  * public class Example {
18 |  *    List empty;
19 |  *    @Before public void initialize() {
20 |  *       empty= new ArrayList();
21 |  *    }
22 |  *    @Test public void size() {
23 |  *       ...
24 |  *    }
25 |  *    @Test public void remove() {
26 |  *       ...
27 |  *    }
28 |  * }
29 |  * 
30 | * 31 | * @see org.junit.BeforeClass 32 | * @see org.junit.After 33 | * @since 4.0 34 | */ 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Target(ElementType.METHOD) 37 | public @interface Before { 38 | } 39 | 40 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/BeforeClass.java: -------------------------------------------------------------------------------- 1 | package org.junit; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Sometimes several tests need to share computationally expensive setup 10 | * (like logging into a database). While this can compromise the independence of 11 | * tests, sometimes it is a necessary optimization. Annotating a public static void no-arg method 12 | * with @BeforeClass causes it to be run once before any of 13 | * the test methods in the class. The @BeforeClass methods of superclasses 14 | * will be run before those of the current class, unless they are shadowed in the current class. 15 | *

16 | * For example: 17 | *

18 |  * public class Example {
19 |  *    @BeforeClass public static void onlyOnce() {
20 |  *       ...
21 |  *    }
22 |  *    @Test public void one() {
23 |  *       ...
24 |  *    }
25 |  *    @Test public void two() {
26 |  *       ...
27 |  *    }
28 |  * }
29 |  * 
30 | * 31 | * @see org.junit.AfterClass 32 | * @since 4.0 33 | */ 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Target(ElementType.METHOD) 36 | public @interface BeforeClass { 37 | } 38 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/FixMethodOrder.java: -------------------------------------------------------------------------------- 1 | package org.junit; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import org.junit.runners.MethodSorters; 9 | 10 | /** 11 | * This class allows the user to choose the order of execution of the methods within a test class. 12 | * 13 | *

The default order of execution of JUnit tests within a class is deterministic but not predictable. 14 | * The order of execution is not guaranteed for Java 7 (and some previous versions), and can even change 15 | * from run to run, so the order of execution was changed to be deterministic (in JUnit 4.11) 16 | * 17 | *

It is recommended that test methods be written so that they are independent of the order that they are executed. 18 | * However, there may be a number of dependent tests either through error or by design. 19 | * This class allows the user to specify the order of execution of test methods. 20 | * 21 | *

For possibilities, see {@link MethodSorters} 22 | * 23 | * Here is an example: 24 | * 25 | *

26 |  * @FixMethodOrder(MethodSorters.NAME_ASCENDING)
27 |  * public class MyTest {
28 |  * }
29 |  * 
30 | * 31 | * @see org.junit.runners.MethodSorters 32 | * @since 4.11 33 | */ 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Target({ElementType.TYPE}) 36 | public @interface FixMethodOrder { 37 | /** 38 | * Optionally specify value to have the methods executed in a particular order 39 | */ 40 | MethodSorters value() default MethodSorters.DEFAULT; 41 | } 42 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/Ignore.java: -------------------------------------------------------------------------------- 1 | package org.junit; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Sometimes you want to temporarily disable a test or a group of tests. Methods annotated with 10 | * {@link org.junit.Test} that are also annotated with @Ignore will not be executed as tests. 11 | * Also, you can annotate a class containing test methods with @Ignore and none of the containing 12 | * tests will be executed. Native JUnit 4 test runners should report the number of ignored tests along with the 13 | * number of tests that ran and the number of tests that failed. 14 | * 15 | *

For example: 16 | *

17 |  *    @Ignore @Test public void something() { ...
18 |  * 
19 | * @Ignore takes an optional default parameter if you want to record why a test is being ignored: 20 | *
21 |  *    @Ignore("not ready yet") @Test public void something() { ...
22 |  * 
23 | * @Ignore can also be applied to the test class: 24 | *
25 |  *      @Ignore public class IgnoreMe {
26 |  *          @Test public void test1() { ... }
27 |  *          @Test public void test2() { ... }
28 |  *         }
29 |  * 
30 | * 31 | * @since 4.0 32 | */ 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Target({ElementType.METHOD, ElementType.TYPE}) 35 | public @interface Ignore { 36 | /** 37 | * The optional reason why the test is ignored. 38 | */ 39 | String value() default ""; 40 | } 41 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/categories/Category.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.categories; 2 | 3 | import java.lang.annotation.Inherited; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | 7 | import org.junit.validator.ValidateWith; 8 | 9 | /** 10 | * Marks a test class or test method as belonging to one or more categories of tests. 11 | * The value is an array of arbitrary classes. 12 | * 13 | * This annotation is only interpreted by the Categories runner (at present). 14 | * 15 | * For example: 16 | *
17 |  * public interface FastTests {}
18 |  * public interface SlowTests {}
19 |  *
20 |  * public static class A {
21 |  * @Test
22 |  * public void a() {
23 |  * fail();
24 |  * }
25 |  *
26 |  * @Category(SlowTests.class)
27 |  * @Test
28 |  * public void b() {
29 |  * }
30 |  * }
31 |  *
32 |  * @Category({SlowTests.class, FastTests.class})
33 |  * public static class B {
34 |  * @Test
35 |  * public void c() {
36 |  *
37 |  * }
38 |  * }
39 |  * 
40 | * 41 | * For more usage, see code example on {@link Categories}. 42 | */ 43 | @Retention(RetentionPolicy.RUNTIME) 44 | @Inherited 45 | @ValidateWith(CategoryValidator.class) 46 | public @interface Category { 47 | Class[] value(); 48 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/max/CouldNotReadCoreException.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.max; 2 | 3 | /** 4 | * Thrown when Max cannot read the MaxCore serialization 5 | */ 6 | public class CouldNotReadCoreException extends Exception { 7 | private static final long serialVersionUID = 1L; 8 | 9 | /** 10 | * Constructs 11 | */ 12 | public CouldNotReadCoreException(Throwable e) { 13 | super(e); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/results/FailureList.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.results; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.runner.Result; 6 | import org.junit.runner.notification.Failure; 7 | import org.junit.runner.notification.RunListener; 8 | 9 | class FailureList { 10 | private final List failures; 11 | 12 | public FailureList(List failures) { 13 | this.failures = failures; 14 | } 15 | 16 | public Result result() { 17 | Result result = new Result(); 18 | RunListener listener = result.createListener(); 19 | for (Failure failure : failures) { 20 | try { 21 | listener.testFailure(failure); 22 | } catch (Exception e) { 23 | throw new RuntimeException("I can't believe this happened"); 24 | } 25 | } 26 | return result; 27 | } 28 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/runners/Enclosed.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.runners; 2 | 3 | import java.lang.reflect.Modifier; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.junit.runners.Suite; 8 | import org.junit.runners.model.RunnerBuilder; 9 | 10 | /** 11 | * If you put tests in inner classes, Ant, for example, won't find them. By running the outer class 12 | * with Enclosed, the tests in the inner classes will be run. You might put tests in inner classes 13 | * to group them for convenience or to share constants. Abstract inner classes are ignored. 14 | *

15 | * So, for example: 16 | *

17 |  * @RunWith(Enclosed.class)
18 |  * public class ListTests {
19 |  *     ...useful shared stuff...
20 |  *     public static class OneKindOfListTest {...}
21 |  *     public static class AnotherKind {...}
22 |  *     abstract public static class Ignored {...}
23 |  * }
24 |  * 
25 | */ 26 | public class Enclosed extends Suite { 27 | /** 28 | * Only called reflectively. Do not use programmatically. 29 | */ 30 | public Enclosed(Class klass, RunnerBuilder builder) throws Throwable { 31 | super(builder, klass, filterAbstractClasses(klass.getClasses())); 32 | } 33 | 34 | private static Class[] filterAbstractClasses(final Class[] classes) { 35 | final List> filteredList= new ArrayList>(classes.length); 36 | 37 | for (final Class clazz : classes) { 38 | if (!Modifier.isAbstract(clazz.getModifiers())) { 39 | filteredList.add(clazz); 40 | } 41 | } 42 | 43 | return filteredList.toArray(new Class[filteredList.size()]); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.theories; 2 | 3 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 4 | import static java.lang.annotation.ElementType.PARAMETER; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Annotating a {@link org.junit.experimental.theories.Theory Theory} method 12 | * parameter with @ParametersSuppliedBy causes it to be supplied with 13 | * values from the named 14 | * {@link org.junit.experimental.theories.ParameterSupplier ParameterSupplier} 15 | * when run as a theory by the {@link org.junit.experimental.theories.Theories 16 | * Theories} runner. 17 | * 18 | * In addition, annotations themselves can be annotated with 19 | * @ParametersSuppliedBy, and then used similarly. ParameterSuppliedBy 20 | * annotations on parameters are detected by searching up this heirarchy such 21 | * that these act as syntactic sugar, making: 22 | * 23 | *
24 |  * @ParametersSuppliedBy(Supplier.class)
25 |  * public @interface SpecialParameter { }
26 |  * 
27 |  * @Theory
28 |  * public void theoryMethod(@SpecialParameter String param) {
29 |  *   ...
30 |  * }
31 |  * 
32 | * 33 | * equivalent to: 34 | * 35 | *
36 |  * @Theory
37 |  * public void theoryMethod(@ParametersSuppliedBy(Supplier.class) String param) {
38 |  *   ...
39 |  * }
40 |  * 
41 | */ 42 | @Retention(RetentionPolicy.RUNTIME) 43 | @Target({ ANNOTATION_TYPE, PARAMETER }) 44 | public @interface ParametersSuppliedBy { 45 | 46 | Class value(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/theories/Theory.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.theories; 2 | 3 | import static java.lang.annotation.ElementType.METHOD; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Marks test methods that should be read as theories by the {@link org.junit.experimental.theories.Theories Theories} runner. 11 | * 12 | * @see org.junit.experimental.theories.Theories 13 | */ 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target(METHOD) 16 | public @interface Theory { 17 | boolean nullsAccepted() default true; 18 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/theories/internal/BooleanSupplier.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.theories.internal; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.junit.experimental.theories.ParameterSignature; 7 | import org.junit.experimental.theories.ParameterSupplier; 8 | import org.junit.experimental.theories.PotentialAssignment; 9 | 10 | public class BooleanSupplier extends ParameterSupplier { 11 | 12 | @Override 13 | public List getValueSources(ParameterSignature sig) { 14 | return Arrays.asList(PotentialAssignment.forValue("true", true), 15 | PotentialAssignment.forValue("false", false)); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/theories/internal/EnumSupplier.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.theories.internal; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.junit.experimental.theories.ParameterSignature; 7 | import org.junit.experimental.theories.ParameterSupplier; 8 | import org.junit.experimental.theories.PotentialAssignment; 9 | 10 | public class EnumSupplier extends ParameterSupplier { 11 | 12 | private Class enumType; 13 | 14 | public EnumSupplier(Class enumType) { 15 | this.enumType = enumType; 16 | } 17 | 18 | @Override 19 | public List getValueSources(ParameterSignature sig) { 20 | Object[] enumValues = enumType.getEnumConstants(); 21 | 22 | List assignments = new ArrayList(); 23 | for (Object value : enumValues) { 24 | assignments.add(PotentialAssignment.forValue(value.toString(), value)); 25 | } 26 | 27 | return assignments; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/theories/internal/ParameterizedAssertionError.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.theories.internal; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collection; 5 | import java.util.Iterator; 6 | 7 | public class ParameterizedAssertionError extends AssertionError { 8 | private static final long serialVersionUID = 1L; 9 | 10 | public ParameterizedAssertionError(Throwable targetException, 11 | String methodName, Object... params) { 12 | super(String.format("%s(%s)", methodName, join(", ", params))); 13 | this.initCause(targetException); 14 | } 15 | 16 | @Override 17 | public boolean equals(Object obj) { 18 | return obj instanceof ParameterizedAssertionError && toString().equals(obj.toString()); 19 | } 20 | 21 | @Override 22 | public int hashCode() { 23 | return toString().hashCode(); 24 | } 25 | 26 | public static String join(String delimiter, Object... params) { 27 | return join(delimiter, Arrays.asList(params)); 28 | } 29 | 30 | public static String join(String delimiter, Collection values) { 31 | StringBuilder sb = new StringBuilder(); 32 | Iterator iter = values.iterator(); 33 | while (iter.hasNext()) { 34 | Object next = iter.next(); 35 | sb.append(stringValueOf(next)); 36 | if (iter.hasNext()) { 37 | sb.append(delimiter); 38 | } 39 | } 40 | return sb.toString(); 41 | } 42 | 43 | private static String stringValueOf(Object next) { 44 | try { 45 | return String.valueOf(next); 46 | } catch (Throwable e) { 47 | return "[toString failed]"; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/theories/suppliers/TestedOn.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.theories.suppliers; 2 | 3 | import static java.lang.annotation.ElementType.PARAMETER; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.junit.experimental.theories.ParametersSuppliedBy; 10 | 11 | /** 12 | * Annotating a {@link org.junit.experimental.theories.Theory Theory} method int 13 | * parameter with @TestedOn causes it to be supplied with values from the 14 | * ints array given when run as a theory by the 15 | * {@link org.junit.experimental.theories.Theories Theories} runner. For 16 | * example, the below method would be called three times by the Theories runner, 17 | * once with each of the int parameters specified. 18 | * 19 | *
20 |  * @Theory
21 |  * public void shouldPassForSomeInts(@TestedOn(ints={1, 2, 3}) int param) {
22 |  *     ...
23 |  * }
24 |  * 
25 | */ 26 | @ParametersSuppliedBy(TestedOnSupplier.class) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(PARAMETER) 29 | public @interface TestedOn { 30 | int[] ints(); 31 | } 32 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/experimental/theories/suppliers/TestedOnSupplier.java: -------------------------------------------------------------------------------- 1 | package org.junit.experimental.theories.suppliers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.junit.experimental.theories.ParameterSignature; 7 | import org.junit.experimental.theories.ParameterSupplier; 8 | import org.junit.experimental.theories.PotentialAssignment; 9 | 10 | /** 11 | * @see org.junit.experimental.theories.suppliers.TestedOn 12 | * @see org.junit.experimental.theories.ParameterSupplier 13 | */ 14 | public class TestedOnSupplier extends ParameterSupplier { 15 | @Override 16 | public List getValueSources(ParameterSignature sig) { 17 | List list = new ArrayList(); 18 | TestedOn testedOn = sig.getAnnotation(TestedOn.class); 19 | int[] ints = testedOn.ints(); 20 | for (final int i : ints) { 21 | list.add(PotentialAssignment.forValue("ints", i)); 22 | } 23 | return list; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/Classes.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal; 2 | 3 | import static java.lang.Thread.currentThread; 4 | 5 | /** 6 | * Miscellaneous functions dealing with classes. 7 | */ 8 | public class Classes { 9 | 10 | /** 11 | * Do not instantiate. 12 | * @deprecated will be private soon. 13 | */ 14 | @Deprecated 15 | public Classes() { 16 | } 17 | 18 | /** 19 | * Returns Class.forName for {@code className} using the current thread's class loader. 20 | * 21 | * @param className Name of the class. 22 | * @throws ClassNotFoundException 23 | */ 24 | public static Class getClass(String className) throws ClassNotFoundException { 25 | return Class.forName(className, true, currentThread().getContextClassLoader()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/ExactComparisonCriteria.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal; 2 | 3 | import org.junit.Assert; 4 | 5 | public class ExactComparisonCriteria extends ComparisonCriteria { 6 | @Override 7 | protected void assertElementsEqual(Object expected, Object actual) { 8 | Assert.assertEquals(expected, actual); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/InexactComparisonCriteria.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal; 2 | 3 | import org.junit.Assert; 4 | 5 | public class InexactComparisonCriteria extends ComparisonCriteria { 6 | public Object fDelta; 7 | 8 | public InexactComparisonCriteria(double delta) { 9 | fDelta = delta; 10 | } 11 | 12 | public InexactComparisonCriteria(float delta) { 13 | fDelta = delta; 14 | } 15 | 16 | @Override 17 | protected void assertElementsEqual(Object expected, Object actual) { 18 | if (expected instanceof Double) { 19 | Assert.assertEquals((Double) expected, (Double) actual, (Double) fDelta); 20 | } else { 21 | Assert.assertEquals((Float) expected, (Float) actual, (Float) fDelta); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/JUnitSystem.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal; 2 | 3 | import java.io.PrintStream; 4 | 5 | public interface JUnitSystem { 6 | 7 | /** 8 | * Will be removed in the next major release 9 | */ 10 | @Deprecated 11 | void exit(int code); 12 | 13 | PrintStream out(); 14 | } 15 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/RealSystem.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal; 2 | 3 | import java.io.PrintStream; 4 | 5 | public class RealSystem implements JUnitSystem { 6 | 7 | /** 8 | * Will be removed in the next major release 9 | */ 10 | @Deprecated 11 | public void exit(int code) { 12 | System.exit(code); 13 | } 14 | 15 | public PrintStream out() { 16 | return System.out; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/Throwables.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal; 2 | 3 | /** 4 | * Miscellaneous functions dealing with {@code Throwable}. 5 | * 6 | * @author kcooney@google.com (Kevin Cooney) 7 | * @since 4.12 8 | */ 9 | public final class Throwables { 10 | 11 | private Throwables() { 12 | } 13 | 14 | /** 15 | * Rethrows the given {@code Throwable}, allowing the caller to 16 | * declare that it throws {@code Exception}. This is useful when 17 | * your callers have nothing reasonable they can do when a 18 | * {@code Throwable} is thrown. This is declared to return {@code Exception} 19 | * so it can be used in a {@code throw} clause: 20 | *
21 |      * try {
22 |      *   doSomething();
23 |      * } catch (Throwable e} {
24 |      *   throw Throwables.rethrowAsException(e);
25 |      * }
26 |      * doSomethingLater();
27 |      * 
28 | * 29 | * @param e exception to rethrow 30 | * @return does not return anything 31 | * @since 4.12 32 | */ 33 | public static Exception rethrowAsException(Throwable e) throws Exception { 34 | Throwables.rethrow(e); 35 | return null; // we never get here 36 | } 37 | 38 | @SuppressWarnings("unchecked") 39 | private static void rethrow(Throwable e) throws T { 40 | throw (T) e; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.builders; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.junit.runner.Runner; 7 | import org.junit.runners.model.RunnerBuilder; 8 | 9 | public class AllDefaultPossibilitiesBuilder extends RunnerBuilder { 10 | private final boolean canUseSuiteMethod; 11 | 12 | public AllDefaultPossibilitiesBuilder(boolean canUseSuiteMethod) { 13 | this.canUseSuiteMethod = canUseSuiteMethod; 14 | } 15 | 16 | @Override 17 | public Runner runnerForClass(Class testClass) throws Throwable { 18 | List builders = Arrays.asList( 19 | ignoredBuilder(), 20 | annotatedBuilder(), 21 | suiteMethodBuilder(), 22 | junit3Builder(), 23 | junit4Builder()); 24 | 25 | for (RunnerBuilder each : builders) { 26 | Runner runner = each.safeRunnerForClass(testClass); 27 | if (runner != null) { 28 | return runner; 29 | } 30 | } 31 | return null; 32 | } 33 | 34 | protected JUnit4Builder junit4Builder() { 35 | return new JUnit4Builder(); 36 | } 37 | 38 | protected JUnit3Builder junit3Builder() { 39 | return new JUnit3Builder(); 40 | } 41 | 42 | protected AnnotatedBuilder annotatedBuilder() { 43 | return new AnnotatedBuilder(this); 44 | } 45 | 46 | protected IgnoredBuilder ignoredBuilder() { 47 | return new IgnoredBuilder(); 48 | } 49 | 50 | protected RunnerBuilder suiteMethodBuilder() { 51 | if (canUseSuiteMethod) { 52 | return new SuiteMethodBuilder(); 53 | } 54 | return new NullBuilder(); 55 | } 56 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/builders/IgnoredBuilder.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.builders; 2 | 3 | import org.junit.Ignore; 4 | import org.junit.runner.Runner; 5 | import org.junit.runners.model.RunnerBuilder; 6 | 7 | public class IgnoredBuilder extends RunnerBuilder { 8 | @Override 9 | public Runner runnerForClass(Class testClass) { 10 | if (testClass.getAnnotation(Ignore.class) != null) { 11 | return new IgnoredClassRunner(testClass); 12 | } 13 | return null; 14 | } 15 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/builders/IgnoredClassRunner.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.builders; 2 | 3 | import org.junit.runner.Description; 4 | import org.junit.runner.Runner; 5 | import org.junit.runner.notification.RunNotifier; 6 | 7 | public class IgnoredClassRunner extends Runner { 8 | private final Class clazz; 9 | 10 | public IgnoredClassRunner(Class testClass) { 11 | clazz = testClass; 12 | } 13 | 14 | @Override 15 | public void run(RunNotifier notifier) { 16 | notifier.fireTestIgnored(getDescription()); 17 | } 18 | 19 | @Override 20 | public Description getDescription() { 21 | return Description.createSuiteDescription(clazz); 22 | } 23 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/builders/JUnit3Builder.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.builders; 2 | 3 | import org.junit.internal.runners.JUnit38ClassRunner; 4 | import org.junit.runner.Runner; 5 | import org.junit.runners.model.RunnerBuilder; 6 | 7 | public class JUnit3Builder extends RunnerBuilder { 8 | @Override 9 | public Runner runnerForClass(Class testClass) throws Throwable { 10 | if (isPre4Test(testClass)) { 11 | return new JUnit38ClassRunner(testClass); 12 | } 13 | return null; 14 | } 15 | 16 | boolean isPre4Test(Class testClass) { 17 | return junit.framework.TestCase.class.isAssignableFrom(testClass); 18 | } 19 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/builders/JUnit4Builder.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.builders; 2 | 3 | import org.junit.runner.Runner; 4 | import org.junit.runners.BlockJUnit4ClassRunner; 5 | import org.junit.runners.model.RunnerBuilder; 6 | 7 | public class JUnit4Builder extends RunnerBuilder { 8 | @Override 9 | public Runner runnerForClass(Class testClass) throws Throwable { 10 | return new BlockJUnit4ClassRunner(testClass); 11 | } 12 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/builders/NullBuilder.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.builders; 2 | 3 | import org.junit.runner.Runner; 4 | import org.junit.runners.model.RunnerBuilder; 5 | 6 | public class NullBuilder extends RunnerBuilder { 7 | @Override 8 | public Runner runnerForClass(Class each) throws Throwable { 9 | return null; 10 | } 11 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/builders/SuiteMethodBuilder.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.builders; 2 | 3 | import org.junit.internal.runners.SuiteMethod; 4 | import org.junit.runner.Runner; 5 | import org.junit.runners.model.RunnerBuilder; 6 | 7 | public class SuiteMethodBuilder extends RunnerBuilder { 8 | @Override 9 | public Runner runnerForClass(Class each) throws Throwable { 10 | if (hasSuiteMethod(each)) { 11 | return new SuiteMethod(each); 12 | } 13 | return null; 14 | } 15 | 16 | public boolean hasSuiteMethod(Class testClass) { 17 | try { 18 | testClass.getMethod("suite"); 19 | } catch (NoSuchMethodException e) { 20 | return false; 21 | } 22 | return true; 23 | } 24 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/matchers/ThrowableMessageMatcher.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.matchers; 2 | 3 | import org.hamcrest.Description; 4 | import org.hamcrest.Factory; 5 | import org.hamcrest.Matcher; 6 | import org.hamcrest.TypeSafeMatcher; 7 | 8 | public class ThrowableMessageMatcher extends 9 | TypeSafeMatcher { 10 | 11 | private final Matcher matcher; 12 | 13 | public ThrowableMessageMatcher(Matcher matcher) { 14 | this.matcher = matcher; 15 | } 16 | 17 | public void describeTo(Description description) { 18 | description.appendText("exception with message "); 19 | description.appendDescriptionOf(matcher); 20 | } 21 | 22 | @Override 23 | protected boolean matchesSafely(T item) { 24 | return matcher.matches(item.getMessage()); 25 | } 26 | 27 | @Override 28 | protected void describeMismatchSafely(T item, Description description) { 29 | description.appendText("message "); 30 | matcher.describeMismatch(item.getMessage(), description); 31 | } 32 | 33 | @Factory 34 | public static Matcher hasMessage(final Matcher matcher) { 35 | return new ThrowableMessageMatcher(matcher); 36 | } 37 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/requests/ClassRequest.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.requests; 2 | 3 | import org.junit.internal.builders.AllDefaultPossibilitiesBuilder; 4 | import org.junit.runner.Request; 5 | import org.junit.runner.Runner; 6 | 7 | public class ClassRequest extends Request { 8 | private final Object runnerLock = new Object(); 9 | 10 | /* 11 | * We have to use the f prefix, because IntelliJ's JUnit4IdeaTestRunner uses 12 | * reflection to access this field. See 13 | * https://github.com/junit-team/junit/issues/960 14 | */ 15 | private final Class fTestClass; 16 | private final boolean canUseSuiteMethod; 17 | private volatile Runner runner; 18 | 19 | public ClassRequest(Class testClass, boolean canUseSuiteMethod) { 20 | this.fTestClass = testClass; 21 | this.canUseSuiteMethod = canUseSuiteMethod; 22 | } 23 | 24 | public ClassRequest(Class testClass) { 25 | this(testClass, true); 26 | } 27 | 28 | @Override 29 | public Runner getRunner() { 30 | if (runner == null) { 31 | synchronized (runnerLock) { 32 | if (runner == null) { 33 | runner = new AllDefaultPossibilitiesBuilder(canUseSuiteMethod).safeRunnerForClass(fTestClass); 34 | } 35 | } 36 | } 37 | return runner; 38 | } 39 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/requests/FilterRequest.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.requests; 2 | 3 | import org.junit.internal.runners.ErrorReportingRunner; 4 | import org.junit.runner.Request; 5 | import org.junit.runner.Runner; 6 | import org.junit.runner.manipulation.Filter; 7 | import org.junit.runner.manipulation.NoTestsRemainException; 8 | 9 | /** 10 | * A filtered {@link Request}. 11 | */ 12 | public final class FilterRequest extends Request { 13 | private final Request request; 14 | /* 15 | * We have to use the f prefix, because IntelliJ's JUnit4IdeaTestRunner uses 16 | * reflection to access this field. See 17 | * https://github.com/junit-team/junit/issues/960 18 | */ 19 | private final Filter fFilter; 20 | 21 | /** 22 | * Creates a filtered Request 23 | * 24 | * @param request a {@link Request} describing your Tests 25 | * @param filter {@link Filter} to apply to the Tests described in 26 | * request 27 | */ 28 | public FilterRequest(Request request, Filter filter) { 29 | this.request = request; 30 | this.fFilter = filter; 31 | } 32 | 33 | @Override 34 | public Runner getRunner() { 35 | try { 36 | Runner runner = request.getRunner(); 37 | fFilter.apply(runner); 38 | return runner; 39 | } catch (NoTestsRemainException e) { 40 | return new ErrorReportingRunner(Filter.class, new Exception(String 41 | .format("No tests found matching %s from %s", fFilter 42 | .describe(), request.toString()))); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/requests/SortingRequest.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.requests; 2 | 3 | import java.util.Comparator; 4 | 5 | import org.junit.runner.Description; 6 | import org.junit.runner.Request; 7 | import org.junit.runner.Runner; 8 | import org.junit.runner.manipulation.Sorter; 9 | 10 | public class SortingRequest extends Request { 11 | private final Request request; 12 | private final Comparator comparator; 13 | 14 | public SortingRequest(Request request, Comparator comparator) { 15 | this.request = request; 16 | this.comparator = comparator; 17 | } 18 | 19 | @Override 20 | public Runner getRunner() { 21 | Runner runner = request.getRunner(); 22 | new Sorter(comparator).apply(runner); 23 | return runner; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/requests/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides implementations of {@link org.junit.runner.Request}. 3 | * 4 | * @since 4.0 5 | */ 6 | package org.junit.internal.requests; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/FailedBefore.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners; 2 | 3 | import org.junit.runners.BlockJUnit4ClassRunner; 4 | 5 | /** 6 | * @deprecated Included for backwards compatibility with JUnit 4.4. Will be 7 | * removed in the next major release. Please use 8 | * {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}. 9 | */ 10 | @Deprecated 11 | class FailedBefore extends Exception { 12 | private static final long serialVersionUID = 1L; 13 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/InitializationError.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | /** 7 | * Use the published version: 8 | * {@link org.junit.runners.model.InitializationError} 9 | * This may disappear as soon as 1 April 2009 10 | */ 11 | @Deprecated 12 | public class InitializationError extends Exception { 13 | private static final long serialVersionUID = 1L; 14 | 15 | /* 16 | * We have to use the f prefix until the next major release to ensure 17 | * serialization compatibility. 18 | * See https://github.com/junit-team/junit/issues/976 19 | */ 20 | private final List fErrors; 21 | 22 | public InitializationError(List errors) { 23 | this.fErrors = errors; 24 | } 25 | 26 | public InitializationError(Throwable... errors) { 27 | this(Arrays.asList(errors)); 28 | } 29 | 30 | public InitializationError(String string) { 31 | this(new Exception(string)); 32 | } 33 | 34 | public List getCauses() { 35 | return fErrors; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/SuiteMethod.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | import java.lang.reflect.Method; 5 | import java.lang.reflect.Modifier; 6 | 7 | import junit.framework.Test; 8 | 9 | /** 10 | * Runner for use with JUnit 3.8.x-style AllTests classes 11 | * (those that only implement a static suite() 12 | * method). For example: 13 | *
14 |  * @RunWith(AllTests.class)
15 |  * public class ProductTests {
16 |  *    public static junit.framework.Test suite() {
17 |  *       ...
18 |  *    }
19 |  * }
20 |  * 
21 | */ 22 | public class SuiteMethod extends JUnit38ClassRunner { 23 | public SuiteMethod(Class klass) throws Throwable { 24 | super(testFromSuiteMethod(klass)); 25 | } 26 | 27 | public static Test testFromSuiteMethod(Class klass) throws Throwable { 28 | Method suiteMethod = null; 29 | Test suite = null; 30 | try { 31 | suiteMethod = klass.getMethod("suite"); 32 | if (!Modifier.isStatic(suiteMethod.getModifiers())) { 33 | throw new Exception(klass.getName() + ".suite() must be static"); 34 | } 35 | suite = (Test) suiteMethod.invoke(null); // static method 36 | } catch (InvocationTargetException e) { 37 | throw e.getCause(); 38 | } 39 | return suite; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/model/EachTestNotifier.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.model; 2 | 3 | import org.junit.internal.AssumptionViolatedException; 4 | import org.junit.runner.Description; 5 | import org.junit.runner.notification.Failure; 6 | import org.junit.runner.notification.RunNotifier; 7 | import org.junit.runners.model.MultipleFailureException; 8 | 9 | public class EachTestNotifier { 10 | private final RunNotifier notifier; 11 | 12 | private final Description description; 13 | 14 | public EachTestNotifier(RunNotifier notifier, Description description) { 15 | this.notifier = notifier; 16 | this.description = description; 17 | } 18 | 19 | public void addFailure(Throwable targetException) { 20 | if (targetException instanceof MultipleFailureException) { 21 | addMultipleFailureException((MultipleFailureException) targetException); 22 | } else { 23 | notifier.fireTestFailure(new Failure(description, targetException)); 24 | } 25 | } 26 | 27 | private void addMultipleFailureException(MultipleFailureException mfe) { 28 | for (Throwable each : mfe.getFailures()) { 29 | addFailure(each); 30 | } 31 | } 32 | 33 | public void addFailedAssumption(AssumptionViolatedException e) { 34 | notifier.fireTestAssumptionFailed(new Failure(description, e)); 35 | } 36 | 37 | public void fireTestFinished() { 38 | notifier.fireTestFinished(description); 39 | } 40 | 41 | public void fireTestStarted() { 42 | notifier.fireTestStarted(description); 43 | } 44 | 45 | public void fireTestIgnored() { 46 | notifier.fireTestIgnored(description); 47 | } 48 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/model/MultipleFailureException.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.model; 2 | 3 | import java.util.List; 4 | 5 | @Deprecated 6 | public class MultipleFailureException extends org.junit.runners.model.MultipleFailureException { 7 | private static final long serialVersionUID = 1L; 8 | 9 | public MultipleFailureException(List errors) { 10 | super(errors); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/model/ReflectiveCallable.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.model; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | 5 | /** 6 | * When invoked, throws the exception from the reflected method, rather than 7 | * wrapping it in an InvocationTargetException. 8 | */ 9 | public abstract class ReflectiveCallable { 10 | public Object run() throws Throwable { 11 | try { 12 | return runReflectiveCall(); 13 | } catch (InvocationTargetException e) { 14 | throw e.getTargetException(); 15 | } 16 | } 17 | 18 | protected abstract Object runReflectiveCall() throws Throwable; 19 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides implementations of {@link org.junit.runner.Runner} 3 | * 4 | * @since 4.0 5 | */ 6 | package org.junit.internal.runners; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/rules/ValidationError.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.rules; 2 | 3 | import org.junit.runners.model.FrameworkMember; 4 | 5 | import java.lang.annotation.Annotation; 6 | 7 | class ValidationError extends Exception { 8 | 9 | private static final long serialVersionUID = 3176511008672645574L; 10 | 11 | public ValidationError(FrameworkMember member, Class annotation, String suffix) { 12 | super(String.format("The @%s '%s' %s", annotation.getSimpleName(), member.getName(), suffix)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/statements/ExpectException.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.statements; 2 | 3 | import org.junit.internal.AssumptionViolatedException; 4 | import org.junit.runners.model.Statement; 5 | 6 | public class ExpectException extends Statement { 7 | private final Statement next; 8 | private final Class expected; 9 | 10 | public ExpectException(Statement next, Class expected) { 11 | this.next = next; 12 | this.expected = expected; 13 | } 14 | 15 | @Override 16 | public void evaluate() throws Exception { 17 | boolean complete = false; 18 | try { 19 | next.evaluate(); 20 | complete = true; 21 | } catch (AssumptionViolatedException e) { 22 | throw e; 23 | } catch (Throwable e) { 24 | if (!expected.isAssignableFrom(e.getClass())) { 25 | String message = "Unexpected exception, expected<" 26 | + expected.getName() + "> but was<" 27 | + e.getClass().getName() + ">"; 28 | throw new Exception(message, e); 29 | } 30 | } 31 | if (complete) { 32 | throw new AssertionError("Expected exception: " 33 | + expected.getName()); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/statements/Fail.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.statements; 2 | 3 | import org.junit.runners.model.Statement; 4 | 5 | public class Fail extends Statement { 6 | private final Throwable error; 7 | 8 | public Fail(Throwable e) { 9 | error = e; 10 | } 11 | 12 | @Override 13 | public void evaluate() throws Throwable { 14 | throw error; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/statements/InvokeMethod.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.statements; 2 | 3 | import org.junit.runners.model.FrameworkMethod; 4 | import org.junit.runners.model.Statement; 5 | 6 | public class InvokeMethod extends Statement { 7 | private final FrameworkMethod testMethod; 8 | private final Object target; 9 | 10 | public InvokeMethod(FrameworkMethod testMethod, Object target) { 11 | this.testMethod = testMethod; 12 | this.target = target; 13 | } 14 | 15 | @Override 16 | public void evaluate() throws Throwable { 17 | testMethod.invokeExplosively(target); 18 | } 19 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/statements/RunAfters.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.statements; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.junit.runners.model.FrameworkMethod; 7 | import org.junit.runners.model.MultipleFailureException; 8 | import org.junit.runners.model.Statement; 9 | 10 | public class RunAfters extends Statement { 11 | private final Statement next; 12 | 13 | private final Object target; 14 | 15 | private final List afters; 16 | 17 | public RunAfters(Statement next, List afters, Object target) { 18 | this.next = next; 19 | this.afters = afters; 20 | this.target = target; 21 | } 22 | 23 | @Override 24 | public void evaluate() throws Throwable { 25 | List errors = new ArrayList(); 26 | try { 27 | next.evaluate(); 28 | } catch (Throwable e) { 29 | errors.add(e); 30 | } finally { 31 | for (FrameworkMethod each : afters) { 32 | try { 33 | each.invokeExplosively(target); 34 | } catch (Throwable e) { 35 | errors.add(e); 36 | } 37 | } 38 | } 39 | MultipleFailureException.assertEmpty(errors); 40 | } 41 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/internal/runners/statements/RunBefores.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.runners.statements; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.runners.model.FrameworkMethod; 6 | import org.junit.runners.model.Statement; 7 | 8 | public class RunBefores extends Statement { 9 | private final Statement next; 10 | 11 | private final Object target; 12 | 13 | private final List befores; 14 | 15 | public RunBefores(Statement next, List befores, Object target) { 16 | this.next = next; 17 | this.befores = befores; 18 | this.target = target; 19 | } 20 | 21 | @Override 22 | public void evaluate() throws Throwable { 23 | for (FrameworkMethod before : befores) { 24 | before.invokeExplosively(target); 25 | } 26 | next.evaluate(); 27 | } 28 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/matchers/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides useful additional {@link org.hamcrest.Matcher}s for use with 3 | * the {@link org.junit.Assert#assertThat(Object, org.hamcrest.Matcher)} 4 | * statement 5 | * 6 | * @since 4.0 7 | * @see org.junit.matchers.JUnitMatchers 8 | */ 9 | package org.junit.matchers; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides JUnit core classes and annotations. 3 | * 4 | * Corresponds to junit.framework in Junit 3.x. 5 | * 6 | * @since 4.0 7 | */ 8 | package org.junit; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/rules/ExpectedExceptionMatcherBuilder.java: -------------------------------------------------------------------------------- 1 | package org.junit.rules; 2 | 3 | import static org.hamcrest.CoreMatchers.allOf; 4 | import static org.junit.matchers.JUnitMatchers.isThrowable; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import org.hamcrest.Matcher; 10 | 11 | /** 12 | * Builds special matcher used by {@link ExpectedException}. 13 | */ 14 | class ExpectedExceptionMatcherBuilder { 15 | 16 | private final List> matchers = new ArrayList>(); 17 | 18 | void add(Matcher matcher) { 19 | matchers.add(matcher); 20 | } 21 | 22 | boolean expectsThrowable() { 23 | return !matchers.isEmpty(); 24 | } 25 | 26 | Matcher build() { 27 | return isThrowable(allOfTheMatchers()); 28 | } 29 | 30 | private Matcher allOfTheMatchers() { 31 | if (matchers.size() == 1) { 32 | return cast(matchers.get(0)); 33 | } 34 | return allOf(castedMatchers()); 35 | } 36 | 37 | @SuppressWarnings({"unchecked", "rawtypes"}) 38 | private List> castedMatchers() { 39 | return new ArrayList>((List) matchers); 40 | } 41 | 42 | @SuppressWarnings("unchecked") 43 | private Matcher cast(Matcher singleMatcher) { 44 | return (Matcher) singleMatcher; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/rules/MethodRule.java: -------------------------------------------------------------------------------- 1 | package org.junit.rules; 2 | 3 | import org.junit.Rule; 4 | import org.junit.runners.model.FrameworkMethod; 5 | import org.junit.runners.model.Statement; 6 | 7 | /** 8 | * A MethodRule is an alteration in how a test method is run and reported. 9 | * Multiple {@link MethodRule}s can be applied to a test method. The 10 | * {@link Statement} that executes the method is passed to each annotated 11 | * {@link Rule} in turn, and each may return a substitute or modified 12 | * {@link Statement}, which is passed to the next {@link Rule}, if any. For 13 | * an example of how this can be useful, see {@link TestWatchman}. 14 | * 15 | *

Note that {@link MethodRule} has been replaced by {@link TestRule}, 16 | * which has the added benefit of supporting class rules. 17 | * 18 | * @since 4.7 19 | */ 20 | public interface MethodRule { 21 | /** 22 | * Modifies the method-running {@link Statement} to implement an additional 23 | * test-running rule. 24 | * 25 | * @param base The {@link Statement} to be modified 26 | * @param method The method to be run 27 | * @param target The object on which the method will be run. 28 | * @return a new statement, which may be the same as {@code base}, 29 | * a wrapper around {@code base}, or a completely new Statement. 30 | */ 31 | Statement apply(Statement base, FrameworkMethod method, Object target); 32 | } 33 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/rules/RunRules.java: -------------------------------------------------------------------------------- 1 | package org.junit.rules; 2 | 3 | import org.junit.runner.Description; 4 | import org.junit.runners.model.Statement; 5 | 6 | /** 7 | * Runs a collection of rules on a statement. 8 | * 9 | * @since 4.9 10 | */ 11 | public class RunRules extends Statement { 12 | private final Statement statement; 13 | 14 | public RunRules(Statement base, Iterable rules, Description description) { 15 | statement = applyAll(base, rules, description); 16 | } 17 | 18 | @Override 19 | public void evaluate() throws Throwable { 20 | statement.evaluate(); 21 | } 22 | 23 | private static Statement applyAll(Statement result, Iterable rules, 24 | Description description) { 25 | for (TestRule each : rules) { 26 | result = each.apply(result, description); 27 | } 28 | return result; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/rules/TestName.java: -------------------------------------------------------------------------------- 1 | package org.junit.rules; 2 | 3 | import org.junit.runner.Description; 4 | 5 | /** 6 | * The TestName Rule makes the current test name available inside test methods: 7 | * 8 | *

 9 |  * public class TestNameTest {
10 |  *  @Rule
11 |  *  public TestName name= new TestName();
12 |  *
13 |  *  @Test
14 |  *  public void testA() {
15 |  *      assertEquals("testA", name.getMethodName());
16 |  *     }
17 |  *
18 |  *  @Test
19 |  *  public void testB() {
20 |  *      assertEquals("testB", name.getMethodName());
21 |  *     }
22 |  * }
23 |  * 
24 | * 25 | * @since 4.7 26 | */ 27 | public class TestName extends TestWatcher { 28 | private volatile String name; 29 | 30 | @Override 31 | protected void starting(Description d) { 32 | name = d.getMethodName(); 33 | } 34 | 35 | /** 36 | * @return the name of the currently-running test method 37 | */ 38 | public String getMethodName() { 39 | return name; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/rules/Verifier.java: -------------------------------------------------------------------------------- 1 | package org.junit.rules; 2 | 3 | import org.junit.runner.Description; 4 | import org.junit.runners.model.Statement; 5 | 6 | /** 7 | * Verifier is a base class for Rules like ErrorCollector, which can turn 8 | * otherwise passing test methods into failing tests if a verification check is 9 | * failed 10 | * 11 | *
12 |  *     public static class ErrorLogVerifier {
13 |  *        private ErrorLog errorLog = new ErrorLog();
14 |  *
15 |  *        @Rule
16 |  *        public Verifier verifier = new Verifier() {
17 |  *           @Override public void verify() {
18 |  *              assertTrue(errorLog.isEmpty());
19 |  *           }
20 |  *        }
21 |  *
22 |  *        @Test public void testThatMightWriteErrorLog() {
23 |  *           // ...
24 |  *        }
25 |  *     }
26 |  * 
27 | * 28 | * @since 4.7 29 | */ 30 | public abstract class Verifier implements TestRule { 31 | public Statement apply(final Statement base, Description description) { 32 | return new Statement() { 33 | @Override 34 | public void evaluate() throws Throwable { 35 | base.evaluate(); 36 | verify(); 37 | } 38 | }; 39 | } 40 | 41 | /** 42 | * Override this to add verification logic. Overrides should throw an 43 | * exception to indicate that verification failed. 44 | */ 45 | protected void verify() throws Throwable { 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/Computer.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | import org.junit.runners.Suite; 4 | import org.junit.runners.model.InitializationError; 5 | import org.junit.runners.model.RunnerBuilder; 6 | 7 | /** 8 | * Represents a strategy for computing runners and suites. 9 | * WARNING: this class is very likely to undergo serious changes in version 4.8 and 10 | * beyond. 11 | * 12 | * @since 4.6 13 | */ 14 | public class Computer { 15 | /** 16 | * Returns a new default computer, which runs tests in serial order 17 | */ 18 | public static Computer serial() { 19 | return new Computer(); 20 | } 21 | 22 | /** 23 | * Create a suite for {@code classes}, building Runners with {@code builder}. 24 | * Throws an InitializationError if Runner construction fails 25 | */ 26 | public Runner getSuite(final RunnerBuilder builder, 27 | Class[] classes) throws InitializationError { 28 | return new Suite(new RunnerBuilder() { 29 | @Override 30 | public Runner runnerForClass(Class testClass) throws Throwable { 31 | return getRunner(builder, testClass); 32 | } 33 | }, classes); 34 | } 35 | 36 | /** 37 | * Create a single-class runner for {@code testClass}, using {@code builder} 38 | */ 39 | protected Runner getRunner(RunnerBuilder builder, Class testClass) throws Throwable { 40 | return builder.runnerForClass(testClass); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/Describable.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | 4 | /** 5 | * Represents an object that can describe itself 6 | * 7 | * @since 4.5 8 | */ 9 | public interface Describable { 10 | /** 11 | * @return a {@link Description} showing the tests to be run by the receiver 12 | */ 13 | Description getDescription(); 14 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/FilterFactory.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | import org.junit.runner.manipulation.Filter; 4 | 5 | /** 6 | * Extend this class to create a factory that creates {@link Filter}. 7 | */ 8 | public interface FilterFactory { 9 | /** 10 | * Creates a {@link Filter} given a {@link FilterFactoryParams} argument. 11 | * 12 | * @param params Parameters needed to create the {@link Filter} 13 | */ 14 | Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException; 15 | 16 | /** 17 | * Exception thrown if the {@link Filter} cannot be created. 18 | */ 19 | @SuppressWarnings("serial") 20 | class FilterNotCreatedException extends Exception { 21 | public FilterNotCreatedException(Exception exception) { 22 | super(exception.getMessage(), exception); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/FilterFactoryParams.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | public final class FilterFactoryParams { 4 | private final Description topLevelDescription; 5 | private final String args; 6 | 7 | public FilterFactoryParams(Description topLevelDescription, String args) { 8 | if (args == null || topLevelDescription == null) { 9 | throw new NullPointerException(); 10 | } 11 | 12 | this.topLevelDescription = topLevelDescription; 13 | this.args = args; 14 | } 15 | 16 | public String getArgs() { 17 | return args; 18 | } 19 | 20 | public Description getTopLevelDescription() { 21 | return topLevelDescription; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/RunWith.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * When a class is annotated with @RunWith or extends a class annotated 11 | * with @RunWith, JUnit will invoke the class it references to run the 12 | * tests in that class instead of the runner built into JUnit. We added this feature late 13 | * in development. While it seems powerful we expect the runner API to change as we learn 14 | * how people really use it. Some of the classes that are currently internal will likely 15 | * be refined and become public. 16 | * 17 | * For example, suites in JUnit 4 are built using RunWith, and a custom runner named Suite: 18 | * 19 | *
20 |  * @RunWith(Suite.class)
21 |  * @SuiteClasses({ATest.class, BTest.class, CTest.class})
22 |  * public class ABCSuite {
23 |  * }
24 |  * 
25 | * 26 | * @since 4.0 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.TYPE) 30 | @Inherited 31 | public @interface RunWith { 32 | /** 33 | * @return a Runner class (must have a constructor that takes a single Class to run) 34 | */ 35 | Class value(); 36 | } 37 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/Runner.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | import org.junit.runner.notification.RunNotifier; 4 | 5 | /** 6 | * A Runner runs tests and notifies a {@link org.junit.runner.notification.RunNotifier} 7 | * of significant events as it does so. You will need to subclass Runner 8 | * when using {@link org.junit.runner.RunWith} to invoke a custom runner. When creating 9 | * a custom runner, in addition to implementing the abstract methods here you must 10 | * also provide a constructor that takes as an argument the {@link Class} containing 11 | * the tests. 12 | * 13 | *

The default runner implementation guarantees that the instances of the test case 14 | * class will be constructed immediately before running the test and that the runner 15 | * will retain no reference to the test case instances, generally making them 16 | * available for garbage collection. 17 | * 18 | * @see org.junit.runner.Description 19 | * @see org.junit.runner.RunWith 20 | * @since 4.0 21 | */ 22 | public abstract class Runner implements Describable { 23 | /* 24 | * (non-Javadoc) 25 | * @see org.junit.runner.Describable#getDescription() 26 | */ 27 | public abstract Description getDescription(); 28 | 29 | /** 30 | * Run the tests for this runner. 31 | * 32 | * @param notifier will be notified of events while tests are being run--tests being 33 | * started, finishing, and failing 34 | */ 35 | public abstract void run(RunNotifier notifier); 36 | 37 | /** 38 | * @return the number of tests to be run by the receiver 39 | */ 40 | public int testCount() { 41 | return getDescription().testCount(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/manipulation/Filterable.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner.manipulation; 2 | 3 | /** 4 | * Runners that allow filtering should implement this interface. Implement {@link #filter(Filter)} 5 | * to remove tests that don't pass the filter. 6 | * 7 | * @since 4.0 8 | */ 9 | public interface Filterable { 10 | 11 | /** 12 | * Remove tests that don't pass the parameter filter. 13 | * 14 | * @param filter the {@link Filter} to apply 15 | * @throws NoTestsRemainException if all tests are filtered out 16 | */ 17 | void filter(Filter filter) throws NoTestsRemainException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/manipulation/NoTestsRemainException.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner.manipulation; 2 | 3 | /** 4 | * Thrown when a filter removes all tests from a runner. 5 | * 6 | * @since 4.0 7 | */ 8 | public class NoTestsRemainException extends Exception { 9 | private static final long serialVersionUID = 1L; 10 | } 11 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/manipulation/Sortable.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner.manipulation; 2 | 3 | /** 4 | * Interface for runners that allow sorting of tests. By sorting tests based on when they last failed, most recently 5 | * failed first, you can reduce the average time to the first test failing. Test sorting should not be used to 6 | * cope with order dependencies between tests. Tests that are isolated from each other are less 7 | * expensive to maintain and can be run individually. 8 | * 9 | * @since 4.0 10 | */ 11 | public interface Sortable { 12 | 13 | /** 14 | * Sorts the tests using sorter 15 | * 16 | * @param sorter the {@link Sorter} to use for sorting the tests 17 | */ 18 | void sort(Sorter sorter); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/manipulation/Sorter.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner.manipulation; 2 | 3 | import java.util.Comparator; 4 | 5 | import org.junit.runner.Description; 6 | 7 | /** 8 | * A Sorter orders tests. In general you will not need 9 | * to use a Sorter directly. Instead, use {@link org.junit.runner.Request#sortWith(Comparator)}. 10 | * 11 | * @since 4.0 12 | */ 13 | public class Sorter implements Comparator { 14 | /** 15 | * NULL is a Sorter that leaves elements in an undefined order 16 | */ 17 | public static final Sorter NULL = new Sorter(new Comparator() { 18 | public int compare(Description o1, Description o2) { 19 | return 0; 20 | } 21 | }); 22 | 23 | private final Comparator comparator; 24 | 25 | /** 26 | * Creates a Sorter that uses comparator 27 | * to sort tests 28 | * 29 | * @param comparator the {@link Comparator} to use when sorting tests 30 | */ 31 | public Sorter(Comparator comparator) { 32 | this.comparator = comparator; 33 | } 34 | 35 | /** 36 | * Sorts the test in runner using comparator 37 | */ 38 | public void apply(Object object) { 39 | if (object instanceof Sortable) { 40 | Sortable sortable = (Sortable) object; 41 | sortable.sort(this); 42 | } 43 | } 44 | 45 | public int compare(Description o1, Description o2) { 46 | return comparator.compare(o1, o2); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/manipulation/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides classes to {@link org.junit.runner.manipulation.Filter filter} or {@link org.junit.runner.manipulation.Sorter sort} tests. 3 | * 4 | * @since 4.0 5 | * @see org.junit.runner.Runner 6 | */ 7 | package org.junit.runner.manipulation; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/notification/StoppedByUserException.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner.notification; 2 | 3 | /** 4 | * Thrown when a user has requested that the test run stop. Writers of 5 | * test running GUIs should be prepared to catch a StoppedByUserException. 6 | * 7 | * @see org.junit.runner.notification.RunNotifier 8 | * @since 4.0 9 | */ 10 | public class StoppedByUserException extends RuntimeException { 11 | private static final long serialVersionUID = 1L; 12 | } 13 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/notification/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides information about a test run. 3 | * 4 | * @since 4.0 5 | */ 6 | package org.junit.runner.notification; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runner/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides classes used to describe, collect, run and analyze multiple tests. 3 | * 4 | * @since 4.0 5 | */ 6 | package org.junit.runner; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/AllTests.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners; 2 | 3 | import org.junit.internal.runners.SuiteMethod; 4 | 5 | /** 6 | * Runner for use with JUnit 3.8.x-style AllTests classes 7 | * (those that only implement a static suite() 8 | * method). For example: 9 | *

10 |  * @RunWith(AllTests.class)
11 |  * public class ProductTests {
12 |  *    public static junit.framework.Test suite() {
13 |  *       ...
14 |  *    }
15 |  * }
16 |  * 
17 | * 18 | * @since 4.0 19 | */ 20 | public class AllTests extends SuiteMethod { 21 | /** 22 | * Only called reflectively. Do not use programmatically. 23 | */ 24 | public AllTests(Class klass) throws Throwable { 25 | super(klass); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/JUnit4.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners; 2 | 3 | import org.junit.runners.model.InitializationError; 4 | 5 | /** 6 | * Aliases the current default JUnit 4 class runner, for future-proofing. If 7 | * future versions of JUnit change the default Runner class, they will also 8 | * change the definition of this class. Developers wanting to explicitly tag a 9 | * class as a JUnit 4 class should use {@code @RunWith(JUnit4.class)}, not, 10 | * for example in JUnit 4.5, {@code @RunWith(BlockJUnit4ClassRunner.class)}. 11 | * This is the only way this class should be used--any extension that 12 | * depends on the implementation details of this class is likely to break 13 | * in future versions. 14 | * 15 | * @since 4.5 16 | */ 17 | public final class JUnit4 extends BlockJUnit4ClassRunner { 18 | /** 19 | * Constructs a new instance of the default runner 20 | */ 21 | public JUnit4(Class klass) throws InitializationError { 22 | super(klass); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/MethodSorters.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.Comparator; 5 | 6 | import org.junit.internal.MethodSorter; 7 | 8 | /** 9 | * Sort the methods into a specified execution order. 10 | * Defines common {@link MethodSorter} implementations. 11 | * 12 | * @since 4.11 13 | */ 14 | public enum MethodSorters { 15 | /** 16 | * Sorts the test methods by the method name, in lexicographic order, 17 | * with {@link Method#toString()} used as a tiebreaker 18 | */ 19 | NAME_ASCENDING(MethodSorter.NAME_ASCENDING), 20 | 21 | /** 22 | * Leaves the test methods in the order returned by the JVM. 23 | * Note that the order from the JVM may vary from run to run 24 | */ 25 | JVM(null), 26 | 27 | /** 28 | * Sorts the test methods in a deterministic, but not predictable, order 29 | */ 30 | DEFAULT(MethodSorter.DEFAULT); 31 | 32 | private final Comparator comparator; 33 | 34 | private MethodSorters(Comparator comparator) { 35 | this.comparator = comparator; 36 | } 37 | 38 | public Comparator getComparator() { 39 | return comparator; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/model/Annotatable.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.model; 2 | 3 | import java.lang.annotation.Annotation; 4 | 5 | /** 6 | * A model element that may have annotations. 7 | * 8 | * @since 4.12 9 | */ 10 | public interface Annotatable { 11 | /** 12 | * Returns the model elements' annotations. 13 | */ 14 | Annotation[] getAnnotations(); 15 | 16 | /** 17 | * Returns the annotation on the model element of the given type, or @code{null} 18 | */ 19 | T getAnnotation(Class annotationType); 20 | } 21 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/model/FrameworkMember.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.model; 2 | 3 | import java.lang.reflect.Modifier; 4 | import java.util.List; 5 | 6 | /** 7 | * Parent class for {@link FrameworkField} and {@link FrameworkMethod} 8 | * 9 | * @since 4.7 10 | */ 11 | public abstract class FrameworkMember> implements 12 | Annotatable { 13 | abstract boolean isShadowedBy(T otherMember); 14 | 15 | boolean isShadowedBy(List members) { 16 | for (T each : members) { 17 | if (isShadowedBy(each)) { 18 | return true; 19 | } 20 | } 21 | return false; 22 | } 23 | 24 | protected abstract int getModifiers(); 25 | 26 | /** 27 | * Returns true if this member is static, false if not. 28 | */ 29 | public boolean isStatic() { 30 | return Modifier.isStatic(getModifiers()); 31 | } 32 | 33 | /** 34 | * Returns true if this member is public, false if not. 35 | */ 36 | public boolean isPublic() { 37 | return Modifier.isPublic(getModifiers()); 38 | } 39 | 40 | public abstract String getName(); 41 | 42 | public abstract Class getType(); 43 | 44 | public abstract Class getDeclaringClass(); 45 | } 46 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/model/InitializationError.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.model; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | /** 7 | * Represents one or more problems encountered while initializing a Runner 8 | * 9 | * @since 4.5 10 | */ 11 | public class InitializationError extends Exception { 12 | private static final long serialVersionUID = 1L; 13 | 14 | /* 15 | * We have to use the f prefix until the next major release to ensure 16 | * serialization compatibility. 17 | * See https://github.com/junit-team/junit/issues/976 18 | */ 19 | private final List fErrors; 20 | 21 | /** 22 | * Construct a new {@code InitializationError} with one or more 23 | * errors {@code errors} as causes 24 | */ 25 | public InitializationError(List errors) { 26 | this.fErrors = errors; 27 | } 28 | 29 | public InitializationError(Throwable error) { 30 | this(Arrays.asList(error)); 31 | } 32 | 33 | /** 34 | * Construct a new {@code InitializationError} with one cause 35 | * with message {@code string} 36 | */ 37 | public InitializationError(String string) { 38 | this(new Exception(string)); 39 | } 40 | 41 | /** 42 | * Returns one or more Throwables that led to this initialization error. 43 | */ 44 | public List getCauses() { 45 | return fErrors; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/model/RunnerScheduler.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.model; 2 | 3 | /** 4 | * Represents a strategy for scheduling when individual test methods 5 | * should be run (in serial or parallel) 6 | * 7 | * WARNING: still experimental, may go away. 8 | * 9 | * @since 4.7 10 | */ 11 | public interface RunnerScheduler { 12 | /** 13 | * Schedule a child statement to run 14 | */ 15 | void schedule(Runnable childStatement); 16 | 17 | /** 18 | * Override to implement any behavior that must occur 19 | * after all children have been scheduled (for example, 20 | * waiting for them all to finish) 21 | */ 22 | void finished(); 23 | } 24 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/model/Statement.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.model; 2 | 3 | 4 | /** 5 | * Represents one or more actions to be taken at runtime in the course 6 | * of running a JUnit test suite. 7 | * 8 | * @since 4.5 9 | */ 10 | public abstract class Statement { 11 | /** 12 | * Run the action, throwing a {@code Throwable} if anything goes wrong. 13 | */ 14 | public abstract void evaluate() throws Throwable; 15 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/model/TestTimedOutException.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.model; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | /** 6 | * Exception thrown when a test fails on timeout. 7 | * 8 | * @since 4.12 9 | * 10 | */ 11 | public class TestTimedOutException extends Exception { 12 | 13 | private static final long serialVersionUID = 31935685163547539L; 14 | 15 | private final TimeUnit timeUnit; 16 | private final long timeout; 17 | 18 | /** 19 | * Creates exception with a standard message "test timed out after [timeout] [timeUnit]" 20 | * 21 | * @param timeout the amount of time passed before the test was interrupted 22 | * @param timeUnit the time unit for the timeout value 23 | */ 24 | public TestTimedOutException(long timeout, TimeUnit timeUnit) { 25 | super(String.format("test timed out after %d %s", 26 | timeout, timeUnit.name().toLowerCase())); 27 | this.timeUnit = timeUnit; 28 | this.timeout = timeout; 29 | } 30 | 31 | /** 32 | * Gets the time passed before the test was interrupted 33 | */ 34 | public long getTimeout() { 35 | return timeout; 36 | } 37 | 38 | /** 39 | * Gets the time unit for the timeout value 40 | */ 41 | public TimeUnit getTimeUnit() { 42 | return timeUnit; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides standard {@link org.junit.runner.Runner Runner} implementations. 3 | * 4 | * @since 4.0 5 | * @see org.junit.runner.Runner 6 | * @see org.junit.runners.BlockJUnit4ClassRunner 7 | */ 8 | package org.junit.runners; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParametersFactory.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.parameterized; 2 | 3 | import org.junit.runner.Runner; 4 | import org.junit.runners.model.InitializationError; 5 | 6 | /** 7 | * A {@link ParametersRunnerFactory} that creates 8 | * {@link BlockJUnit4ClassRunnerWithParameters}. 9 | * 10 | * @since 4.12 11 | */ 12 | public class BlockJUnit4ClassRunnerWithParametersFactory implements 13 | ParametersRunnerFactory { 14 | public Runner createRunnerForTestWithParameters(TestWithParameters test) 15 | throws InitializationError { 16 | return new BlockJUnit4ClassRunnerWithParameters(test); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/runners/parameterized/ParametersRunnerFactory.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.parameterized; 2 | 3 | import org.junit.runner.Runner; 4 | import org.junit.runners.model.InitializationError; 5 | 6 | /** 7 | * A {@code ParametersRunnerFactory} creates a runner for a single 8 | * {@link TestWithParameters}. 9 | * 10 | * @since 4.12 11 | */ 12 | public interface ParametersRunnerFactory { 13 | /** 14 | * Returns a runner for the specified {@link TestWithParameters}. 15 | * 16 | * @throws InitializationError 17 | * if the runner could not be created. 18 | */ 19 | Runner createRunnerForTestWithParameters(TestWithParameters test) 20 | throws InitializationError; 21 | } 22 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/validator/AnnotationValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package org.junit.validator; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | 5 | /** 6 | * Creates instances of Annotation Validators. 7 | * 8 | * @since 4.12 9 | */ 10 | public class AnnotationValidatorFactory { 11 | private static final ConcurrentHashMap VALIDATORS_FOR_ANNOTATION_TYPES = 12 | new ConcurrentHashMap(); 13 | 14 | /** 15 | * Creates the AnnotationValidator specified by the value in 16 | * {@link org.junit.validator.ValidateWith}. Instances are 17 | * cached. 18 | * 19 | * @return An instance of the AnnotationValidator. 20 | * 21 | * @since 4.12 22 | */ 23 | public AnnotationValidator createAnnotationValidator(ValidateWith validateWithAnnotation) { 24 | AnnotationValidator validator = VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation); 25 | if (validator != null) { 26 | return validator; 27 | } 28 | 29 | Class clazz = validateWithAnnotation.value(); 30 | try { 31 | AnnotationValidator annotationValidator = clazz.newInstance(); 32 | VALIDATORS_FOR_ANNOTATION_TYPES.putIfAbsent(validateWithAnnotation, annotationValidator); 33 | return VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation); 34 | } catch (Exception e) { 35 | throw new RuntimeException("Exception received when creating AnnotationValidator class " + clazz.getName(), e); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/validator/PublicClassValidator.java: -------------------------------------------------------------------------------- 1 | package org.junit.validator; 2 | 3 | import static java.util.Collections.emptyList; 4 | import static java.util.Collections.singletonList; 5 | 6 | import java.util.List; 7 | 8 | import org.junit.runners.model.TestClass; 9 | 10 | /** 11 | * Validates that a {@link TestClass} is public. 12 | * 13 | * @since 4.12 14 | */ 15 | public class PublicClassValidator implements TestClassValidator { 16 | private static final List NO_VALIDATION_ERRORS = emptyList(); 17 | 18 | /** 19 | * Validate that the specified {@link TestClass} is public. 20 | * 21 | * @param testClass the {@link TestClass} that is validated. 22 | * @return an empty list if the class is public or a list with a single 23 | * exception otherwise. 24 | */ 25 | public List validateTestClass(TestClass testClass) { 26 | if (testClass.isPublic()) { 27 | return NO_VALIDATION_ERRORS; 28 | } else { 29 | return singletonList(new Exception("The class " 30 | + testClass.getName() + " is not public.")); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/validator/TestClassValidator.java: -------------------------------------------------------------------------------- 1 | package org.junit.validator; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.runners.model.TestClass; 6 | 7 | /** 8 | * Validates a single facet of a test class. 9 | * 10 | * @since 4.12 11 | */ 12 | public interface TestClassValidator { 13 | /** 14 | * Validate a single facet of a test class. 15 | * 16 | * @param testClass 17 | * the {@link TestClass} that is validated. 18 | * @return the validation errors found by the validator. 19 | */ 20 | List validateTestClass(TestClass testClass); 21 | } 22 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/java/org/junit/validator/ValidateWith.java: -------------------------------------------------------------------------------- 1 | package org.junit.validator; 2 | 3 | import java.lang.annotation.Inherited; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | 7 | /** 8 | * Allows for an {@link AnnotationValidator} to be attached to an annotation. 9 | * 10 | *

When attached to an annotation, the validator will be instantiated and invoked 11 | * by the {@link org.junit.runners.ParentRunner}.

12 | * 13 | * @since 4.12 14 | */ 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Inherited 17 | public @interface ValidateWith { 18 | Class value(); 19 | } 20 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/javadoc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ /* makes unvisited links red (red bad) */ A {color:red;} /* makes visited links the same green as the toolbar (green good) */ A:visited {color:#03A35D;} /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background-color: #FFFFFF } /* Table colors */ .TableHeadingColor { background: #03A35D} /* Green */ .TableSubHeadingColor { background: #03A35D } /* Green */ .TableRowColor { background: #FFFFFF } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: normal; font-family: normal } .FrameHeadingFont { font-size: normal; font-family: normal } .FrameItemFont { font-size: normal; font-family: normal } /* Example of smaller, sans-serif font in frames */ /* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#03A35D;}/* Green */ .NavBarCell1Rev { background-color:#006400;}/* Dark green */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/resources/junit/runner/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/src/main/resources/junit/runner/logo.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/main/resources/junit/runner/smalllogo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/src/main/resources/junit/runner/smalllogo.gif -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/site/resources/css/plain-links.css: -------------------------------------------------------------------------------- 1 | a.externalLink { 2 | background: none !important; 3 | padding-right: 0 !important; 4 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/site/resources/images/junit-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/src/site/resources/images/junit-logo.png -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/site/resources/scripts/index.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | $('#main-carousel').carousel({ 3 | interval:5000 4 | }); 5 | 6 | $('#main-carousel-prev').on("click", function () { 7 | $('#main-carousel').carousel('prev'); 8 | }); 9 | 10 | $('#main-carousel-next').on("click", function () { 11 | $('#main-carousel').carousel('next'); 12 | }); 13 | }); -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/samples/AllTests.java: -------------------------------------------------------------------------------- 1 | package junit.samples; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestSuite; 5 | 6 | /** 7 | * TestSuite that runs all the sample tests 8 | */ 9 | public class AllTests { 10 | 11 | public static void main(String[] args) { 12 | junit.textui.TestRunner.run(suite()); 13 | } 14 | 15 | public static Test suite() { 16 | TestSuite suite = new TestSuite("All JUnit Tests"); 17 | suite.addTest(ListTest.suite()); 18 | suite.addTest(new TestSuite(junit.samples.money.MoneyTest.class)); 19 | suite.addTest(junit.tests.AllTests.suite()); 20 | return suite; 21 | } 22 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/samples/money/IMoney.java: -------------------------------------------------------------------------------- 1 | package junit.samples.money; 2 | 3 | /** 4 | * The common interface for simple Monies and MoneyBags 5 | */ 6 | public interface IMoney { 7 | /** 8 | * Adds a money to this money. 9 | */ 10 | IMoney add(IMoney m); 11 | 12 | /** 13 | * Adds a simple Money to this money. This is a helper method for 14 | * implementing double dispatch 15 | */ 16 | IMoney addMoney(Money m); 17 | 18 | /** 19 | * Adds a MoneyBag to this money. This is a helper method for 20 | * implementing double dispatch 21 | */ 22 | IMoney addMoneyBag(MoneyBag s); 23 | 24 | /** 25 | * Tests whether this money is zero 26 | */ 27 | boolean isZero(); 28 | 29 | /** 30 | * Multiplies a money by the given factor. 31 | */ 32 | IMoney multiply(int factor); 33 | 34 | /** 35 | * Negates this money. 36 | */ 37 | IMoney negate(); 38 | 39 | /** 40 | * Subtracts a money from this money. 41 | */ 42 | IMoney subtract(IMoney m); 43 | 44 | /** 45 | * Append this to a MoneyBag m. 46 | * appendTo() needs to be public because it is used 47 | * polymorphically, but it should not be used by clients 48 | * because it modifies the argument m. 49 | */ 50 | void appendTo(MoneyBag m); 51 | } 52 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/samples/money/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Example "Money" for JUnit v3.x. 3 | */ 4 | package junit.samples.money; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/samples/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * JUnit v3.x examples. 3 | */ 4 | package junit.samples; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/AllTests.java: -------------------------------------------------------------------------------- 1 | package junit.tests; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestSuite; 5 | 6 | /** 7 | * TestSuite that runs all the JUnit tests 8 | */ 9 | public class AllTests { 10 | 11 | public static void main(String[] args) { 12 | junit.textui.TestRunner.run(suite()); 13 | } 14 | 15 | public static Test suite() { 16 | TestSuite suite = new TestSuite("Framework Tests"); 17 | suite.addTest(junit.tests.framework.AllTests.suite()); 18 | suite.addTest(junit.tests.runner.AllTests.suite()); 19 | suite.addTest(junit.tests.extensions.AllTests.suite()); 20 | return suite; 21 | } 22 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/WasRun.java: -------------------------------------------------------------------------------- 1 | package junit.tests; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * A helper test case for testing whether the testing method 7 | * is run. 8 | */ 9 | public class WasRun extends TestCase { 10 | public boolean fWasRun = false; 11 | 12 | @Override 13 | protected void runTest() { 14 | fWasRun = true; 15 | } 16 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/extensions/AllTests.java: -------------------------------------------------------------------------------- 1 | package junit.tests.extensions; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestSuite; 5 | 6 | /** 7 | * TestSuite that runs all the extension tests 8 | */ 9 | public class AllTests { 10 | 11 | public static void main(String[] args) { 12 | junit.textui.TestRunner.run(suite()); 13 | } 14 | 15 | public static Test suite() { // Collect tests manually because we have to test class collection code 16 | TestSuite suite = new TestSuite("Framework Tests"); 17 | suite.addTestSuite(ExtensionTest.class); 18 | suite.addTestSuite(ActiveTestTest.class); 19 | suite.addTestSuite(RepeatedTestTest.class); 20 | return suite; 21 | } 22 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/extensions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests for the JUnit v3.x extension functionality. 3 | */ 4 | package junit.tests.extensions; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/AllTests.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestSuite; 5 | 6 | /** 7 | * TestSuite that runs all the sample tests 8 | */ 9 | public class AllTests { 10 | 11 | public static void main(String[] args) { 12 | junit.textui.TestRunner.run(suite()); 13 | } 14 | 15 | public static Test suite() { 16 | TestSuite suite = new TestSuite("Framework Tests"); 17 | suite.addTestSuite(TestCaseTest.class); 18 | suite.addTest(SuiteTest.suite()); // Tests suite building, so can't use automatic test extraction 19 | suite.addTestSuite(TestListenerTest.class); 20 | suite.addTestSuite(AssertionFailedErrorTest.class); 21 | suite.addTestSuite(AssertTest.class); 22 | suite.addTestSuite(TestImplementorTest.class); 23 | suite.addTestSuite(NoArgTestCaseTest.class); 24 | suite.addTestSuite(ComparisonCompactorTest.class); 25 | suite.addTestSuite(ComparisonFailureTest.class); 26 | suite.addTestSuite(DoublePrecisionAssertTest.class); 27 | suite.addTestSuite(FloatAssertTest.class); 28 | return suite; 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/AssertionFailedErrorTest.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.AssertionFailedError; 4 | import junit.framework.TestCase; 5 | 6 | public class AssertionFailedErrorTest extends TestCase { 7 | private static final String ARBITRARY_MESSAGE = "arbitrary message"; 8 | 9 | public void testCreateErrorWithoutMessage() throws Exception { 10 | AssertionFailedError error = new AssertionFailedError(); 11 | assertNull(error.getMessage()); 12 | } 13 | 14 | public void testCreateErrorWithMessage() throws Exception { 15 | AssertionFailedError error = new AssertionFailedError(ARBITRARY_MESSAGE); 16 | assertEquals(ARBITRARY_MESSAGE, error.getMessage()); 17 | } 18 | 19 | public void testCreateErrorWithoutMessageInsteadOfNull() throws Exception { 20 | AssertionFailedError error = new AssertionFailedError(null); 21 | assertEquals("", error.getMessage()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/ComparisonFailureTest.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.ComparisonFailure; 4 | import junit.framework.TestCase; 5 | 6 | public class ComparisonFailureTest extends TestCase { 7 | 8 | // Most of the tests are in ComparisonCompactorTest 9 | public void testConnection() { 10 | ComparisonFailure failure = new ComparisonFailure("warning", "Mary had a little lamb", "Mary had the little lamb"); 11 | assertEquals("warning expected: but was:", failure.getMessage()); 12 | } 13 | 14 | // This is like an instanceof test. 15 | public void testThrowing() { 16 | try { 17 | assertEquals("a", "b"); 18 | } catch (ComparisonFailure e) { 19 | return; 20 | } 21 | fail(); 22 | } 23 | 24 | public void testExceptionToStringWithMessage() { 25 | try { 26 | assertEquals("woops!", "a", "b"); 27 | } catch (ComparisonFailure e) { 28 | if (!e.toString().startsWith("junit.framework.ComparisonFailure: woops! expected:<")) { 29 | fail("Unexpected message: " + e); 30 | } 31 | return; 32 | } 33 | fail(); 34 | } 35 | 36 | public void testExceptionToStringWithoutMessage() { 37 | try { 38 | assertEquals("a", "b"); 39 | } catch (ComparisonFailure e) { 40 | if (!e.toString().startsWith("junit.framework.ComparisonFailure: expected:<")) { 41 | fail("Unexpected message: " + e); 42 | } 43 | return; 44 | } 45 | fail(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/DoublePrecisionAssertTest.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.AssertionFailedError; 4 | import junit.framework.TestCase; 5 | 6 | public class DoublePrecisionAssertTest extends TestCase { 7 | 8 | /** 9 | * Test for the special Double.NaN value. 10 | */ 11 | public void testAssertEqualsNaNFails() { 12 | try { 13 | assertEquals(1.234, Double.NaN, 0.0); 14 | fail(); 15 | } catch (AssertionFailedError e) { 16 | } 17 | } 18 | 19 | public void testAssertNaNEqualsFails() { 20 | try { 21 | assertEquals(Double.NaN, 1.234, 0.0); 22 | fail(); 23 | } catch (AssertionFailedError e) { 24 | } 25 | } 26 | 27 | public void testAssertNaNEqualsNaN() { 28 | assertEquals(Double.NaN, Double.NaN, 0.0); 29 | } 30 | 31 | public void testAssertPosInfinityNotEqualsNegInfinity() { 32 | try { 33 | assertEquals(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0); 34 | fail(); 35 | } catch (AssertionFailedError e) { 36 | } 37 | } 38 | 39 | public void testAssertPosInfinityNotEquals() { 40 | try { 41 | assertEquals(Double.POSITIVE_INFINITY, 1.23, 0.0); 42 | fail(); 43 | } catch (AssertionFailedError e) { 44 | } 45 | } 46 | 47 | public void testAssertPosInfinityEqualsInfinity() { 48 | assertEquals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 0.0); 49 | } 50 | 51 | public void testAssertNegInfinityEqualsInfinity() { 52 | assertEquals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/Failure.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * A test case testing the testing framework. 7 | */ 8 | public class Failure extends TestCase { 9 | @Override 10 | public void runTest() { 11 | fail(); 12 | } 13 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/InheritedTestCase.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | /** 4 | * Test class used in SuiteTest 5 | */ 6 | public class InheritedTestCase extends OneTestCase { 7 | public void test2() { 8 | } 9 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/NoArgTestCaseTest.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | public class NoArgTestCaseTest extends TestCase { 6 | public void testNothing() { // If this compiles, the no arg ctor is there 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/NoTestCaseClass.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | /** 4 | * Test class used in SuiteTest 5 | */ 6 | public class NoTestCaseClass extends Object { 7 | public void testSuccess() { 8 | } 9 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/NoTestCases.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Test class used in SuiteTest 7 | */ 8 | public class NoTestCases extends TestCase { 9 | public void noTestCase() { 10 | } 11 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/NotPublicTestCase.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Test class used in SuiteTest 7 | */ 8 | public class NotPublicTestCase extends TestCase { 9 | protected void testNotPublic() { 10 | } 11 | 12 | public void testPublic() { 13 | } 14 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/NotVoidTestCase.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Test class used in SuiteTest 7 | */ 8 | public class NotVoidTestCase extends TestCase { 9 | public int testNotVoid() { 10 | return 1; 11 | } 12 | 13 | public void testVoid() { 14 | } 15 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/OneTestCase.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Test class used in SuiteTest 7 | */ 8 | public class OneTestCase extends TestCase { 9 | public void noTestCase() { 10 | } 11 | 12 | public void testCase() { 13 | } 14 | 15 | public void testCase(int arg) { 16 | } 17 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/OverrideTestCase.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | /** 4 | * Test class used in SuiteTest 5 | */ 6 | public class OverrideTestCase extends OneTestCase { 7 | @Override 8 | public void testCase() { 9 | } 10 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/Success.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * A test case testing the testing framework. 7 | */ 8 | public class Success extends TestCase { 9 | 10 | @Override 11 | public void runTest() { 12 | } 13 | 14 | public void testSuccess() { 15 | } 16 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/TestImplementorTest.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.Protectable; 4 | import junit.framework.Test; 5 | import junit.framework.TestCase; 6 | import junit.framework.TestResult; 7 | 8 | /** 9 | * Test an implementor of junit.framework.Test other than TestCase or TestSuite 10 | */ 11 | public class TestImplementorTest extends TestCase { 12 | public static class DoubleTestCase implements Test { 13 | private TestCase fTestCase; 14 | 15 | public DoubleTestCase(TestCase testCase) { 16 | fTestCase = testCase; 17 | } 18 | 19 | public int countTestCases() { 20 | return 2; 21 | } 22 | 23 | public void run(TestResult result) { 24 | result.startTest(this); 25 | Protectable p = new Protectable() { 26 | public void protect() throws Throwable { 27 | fTestCase.runBare(); 28 | fTestCase.runBare(); 29 | } 30 | }; 31 | result.runProtected(this, p); 32 | result.endTest(this); 33 | } 34 | } 35 | 36 | private DoubleTestCase fTest; 37 | 38 | public TestImplementorTest() { 39 | TestCase testCase = new TestCase() { 40 | @Override 41 | public void runTest() { 42 | } 43 | }; 44 | fTest = new DoubleTestCase(testCase); 45 | } 46 | 47 | public void testSuccessfulRun() { 48 | TestResult result = new TestResult(); 49 | fTest.run(result); 50 | assertEquals(fTest.countTestCases(), result.runCount()); 51 | assertEquals(0, result.errorCount()); 52 | assertEquals(0, result.failureCount()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/ThreeTestCases.java: -------------------------------------------------------------------------------- 1 | package junit.tests.framework; 2 | 3 | import junit.framework.TestCase; 4 | 5 | /** 6 | * Test class used in SuiteTest 7 | */ 8 | public class ThreeTestCases extends TestCase { 9 | public void testCase() { 10 | } 11 | 12 | public void testCase2() { 13 | } 14 | 15 | public void testCase3thisTimeItsPersonal() { 16 | } 17 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/framework/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests the JUnit v3.x core classes. 3 | */ 4 | package junit.tests.framework; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests the JUnit v3.x framework. 3 | */ 4 | package junit.tests; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/runner/AllTests.java: -------------------------------------------------------------------------------- 1 | package junit.tests.runner; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestSuite; 5 | 6 | /** 7 | * TestSuite that runs all the sample tests 8 | */ 9 | public class AllTests { 10 | 11 | public static void main(String[] args) { 12 | junit.textui.TestRunner.run(suite()); 13 | } 14 | 15 | public static Test suite() { // Collect tests manually because we have to test class collection code 16 | TestSuite suite = new TestSuite("Framework Tests"); 17 | suite.addTestSuite(StackFilterTest.class); 18 | suite.addTestSuite(ResultTest.class); 19 | suite.addTestSuite(BaseTestRunnerTest.class); 20 | suite.addTestSuite(TextFeedbackTest.class); 21 | suite.addTestSuite(TextRunnerSingleMethodTest.class); 22 | suite.addTestSuite(TextRunnerTest.class); 23 | return suite; 24 | } 25 | 26 | static boolean isJDK11() { 27 | String version = System.getProperty("java.version"); 28 | return version.startsWith("1.1"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/runner/BaseTestRunnerTest.java: -------------------------------------------------------------------------------- 1 | package junit.tests.runner; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | import junit.runner.BaseTestRunner; 7 | 8 | public class BaseTestRunnerTest extends TestCase { 9 | public static class MockRunner extends BaseTestRunner { 10 | private boolean fRunFailed = false; 11 | 12 | @Override 13 | protected void runFailed(String message) { 14 | fRunFailed = true; 15 | } 16 | 17 | @Override 18 | public void testEnded(String testName) { 19 | } 20 | 21 | @Override 22 | public void testFailed(int status, Test test, Throwable e) { 23 | } 24 | 25 | @Override 26 | public void testStarted(String testName) { 27 | } 28 | } 29 | 30 | public static class NonStatic { 31 | public Test suite() { 32 | return null; 33 | } 34 | } 35 | 36 | public void testInvokeNonStaticSuite() { 37 | BaseTestRunner runner = new MockRunner(); 38 | runner.getTest("junit.tests.runner.BaseTestRunnerTest$NonStatic"); // Used to throw NullPointerException 39 | } 40 | 41 | public static class DoesntExtendTestCase { 42 | public static Test suite() { 43 | return new TestSuite(); 44 | } 45 | } 46 | 47 | public void testInvokeSuiteOnNonSubclassOfTestCase() { 48 | MockRunner runner = new MockRunner(); 49 | runner.getTest(DoesntExtendTestCase.class.getName()); 50 | assertFalse(runner.fRunFailed); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/runner/TextRunnerSingleMethodTest.java: -------------------------------------------------------------------------------- 1 | package junit.tests.runner; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.PrintStream; 5 | 6 | import junit.framework.TestCase; 7 | import junit.textui.ResultPrinter; 8 | import junit.textui.TestRunner; 9 | 10 | /** 11 | * Test invoking a single test method of a TestCase. 12 | */ 13 | public class TextRunnerSingleMethodTest extends TestCase { 14 | 15 | static boolean fgWasInvoked; 16 | 17 | public static class InvocationTest extends TestCase { 18 | 19 | public void testWasInvoked() { 20 | TextRunnerSingleMethodTest.fgWasInvoked = true; 21 | } 22 | 23 | public void testNotInvoked() { 24 | fail("Shouldn't get here."); 25 | } 26 | } 27 | 28 | public void testSingle() throws Exception { 29 | TestRunner t = new TestRunner(); 30 | t.setPrinter(new ResultPrinter(new PrintStream(new ByteArrayOutputStream()))); 31 | String[] args = { 32 | "-m", "junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest.testWasInvoked" 33 | }; 34 | fgWasInvoked = false; 35 | t.start(args); 36 | assertTrue(fgWasInvoked); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/junit/tests/runner/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests for the JUnit v3.x runner functionality. 3 | */ 4 | package junit.tests.runner; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/internal/matchers/StacktracePrintingMatcherTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.matchers; 2 | 3 | import static org.hamcrest.CoreMatchers.any; 4 | import static org.hamcrest.CoreMatchers.containsString; 5 | import static org.hamcrest.CoreMatchers.equalTo; 6 | import static org.hamcrest.CoreMatchers.notNullValue; 7 | import static org.junit.Assert.assertFalse; 8 | import static org.junit.Assert.assertThat; 9 | import static org.junit.Assert.assertTrue; 10 | import static org.junit.internal.matchers.StacktracePrintingMatcher.isException; 11 | import static org.junit.internal.matchers.StacktracePrintingMatcher.isThrowable; 12 | 13 | import org.junit.Test; 14 | 15 | public class StacktracePrintingMatcherTest { 16 | 17 | @Test 18 | public void succeedsWhenInnerMatcherSucceeds() throws Exception { 19 | assertTrue(isThrowable(any(Throwable.class)).matches(new Exception())); 20 | } 21 | 22 | @Test 23 | public void failsWhenInnerMatcherFails() throws Exception { 24 | assertFalse(isException(notNullValue(Exception.class)).matches(null)); 25 | } 26 | 27 | @Test 28 | public void assertThatIncludesStacktrace() { 29 | Exception actual = new IllegalArgumentException("my message"); 30 | Exception expected = new NullPointerException(); 31 | 32 | try { 33 | assertThat(actual, isThrowable(equalTo(expected))); 34 | } catch (AssertionError e) { 35 | assertThat(e.getMessage(), containsString("Stacktrace was: java.lang.IllegalArgumentException: my message")); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/internal/matchers/ThrowableCauseMatcherTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.internal.matchers; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.CoreMatchers.is; 6 | import static org.junit.Assert.assertThat; 7 | import static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause; 8 | 9 | public class ThrowableCauseMatcherTest { 10 | 11 | @Test 12 | public void shouldAllowCauseOfDifferentClassFromRoot() throws Exception { 13 | NullPointerException expectedCause = new NullPointerException("expected"); 14 | Exception actual = new Exception(expectedCause); 15 | 16 | assertThat(actual, hasCause(is(expectedCause))); 17 | } 18 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/runner/JUnitCoreTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | import org.junit.Test; 4 | import org.junit.tests.TestSystem; 5 | 6 | import static org.hamcrest.CoreMatchers.instanceOf; 7 | import static org.hamcrest.CoreMatchers.is; 8 | import static org.hamcrest.MatcherAssert.assertThat; 9 | 10 | public class JUnitCoreTest { 11 | @Test 12 | public void shouldAddFailuresToResult() { 13 | JUnitCore jUnitCore = new JUnitCore(); 14 | 15 | Result result = jUnitCore.runMain(new TestSystem(), "NonExistentTest"); 16 | 17 | assertThat(result.getFailureCount(), is(1)); 18 | assertThat(result.getFailures().get(0).getException(), instanceOf(IllegalArgumentException.class)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/runner/RunnerSpy.java: -------------------------------------------------------------------------------- 1 | package org.junit.runner; 2 | 3 | import org.junit.runner.notification.RunNotifier; 4 | import org.junit.runners.model.RunnerBuilder; 5 | 6 | public class RunnerSpy extends Runner { 7 | public static final Description DESCRIPTION = Description.TEST_MECHANISM; 8 | 9 | private RunnerBuilder invokedRunnerBuilder; 10 | private Class invokedTestClass; 11 | 12 | public RunnerSpy(Class testClass) { 13 | invokedTestClass = testClass; 14 | } 15 | 16 | public RunnerSpy(Class testClass, RunnerBuilder runnerBuilder) { 17 | invokedTestClass = testClass; 18 | invokedRunnerBuilder = runnerBuilder; 19 | } 20 | 21 | @Override 22 | public Description getDescription() { 23 | return DESCRIPTION; 24 | } 25 | 26 | @Override 27 | public void run(RunNotifier runNotifier) { 28 | } 29 | 30 | public RunnerBuilder getInvokedRunnerBuilder() { 31 | return invokedRunnerBuilder; 32 | } 33 | 34 | public Class getInvokedTestClass() { 35 | return invokedTestClass; 36 | } 37 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/runners/model/RunnerBuilderStub.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.model; 2 | 3 | import org.junit.runner.Runner; 4 | import org.junit.runner.RunnerSpy; 5 | 6 | public class RunnerBuilderStub extends RunnerBuilder { 7 | @Override 8 | public Runner runnerForClass(Class testClass) throws Throwable { 9 | return new RunnerSpy(testClass, this); 10 | } 11 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParametersTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.parameterized; 2 | 3 | import static java.util.Collections.emptyList; 4 | import static org.junit.Assert.assertEquals; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | import java.util.List; 12 | 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import org.junit.runners.Parameterized; 16 | import org.junit.runners.model.TestClass; 17 | 18 | public class BlockJUnit4ClassRunnerWithParametersTest { 19 | private static final List NO_PARAMETERS = emptyList(); 20 | 21 | @RunWith(Parameterized.class) 22 | @DummyAnnotation 23 | public static class ClassWithParameterizedAnnotation { 24 | @Test 25 | public void dummyTest() { 26 | } 27 | } 28 | 29 | @Test 30 | public void hasAllAnnotationsExceptRunWith() throws Exception { 31 | TestWithParameters testWithParameters = new TestWithParameters( 32 | "dummy name", new TestClass( 33 | ClassWithParameterizedAnnotation.class), NO_PARAMETERS); 34 | BlockJUnit4ClassRunnerWithParameters runner = new BlockJUnit4ClassRunnerWithParameters( 35 | testWithParameters); 36 | Annotation[] annotations = runner.getRunnerAnnotations(); 37 | assertEquals(1, annotations.length); 38 | assertEquals(annotations[0].annotationType(), DummyAnnotation.class); 39 | } 40 | 41 | @Retention(RetentionPolicy.RUNTIME) 42 | @Target(ElementType.TYPE) 43 | private static @interface DummyAnnotation { 44 | } 45 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/runners/parameterized/ParameterizedNamesTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.runners.parameterized; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.Description; 5 | import org.junit.runner.Request; 6 | import org.junit.runner.RunWith; 7 | import org.junit.runners.Parameterized; 8 | 9 | import java.util.Arrays; 10 | import java.util.Collection; 11 | 12 | import static org.junit.Assert.assertEquals; 13 | 14 | /** 15 | * @author Dmitry Baev charlie@yandex-team.ru 16 | * Date: 03.05.14 17 | */ 18 | public class ParameterizedNamesTest { 19 | @RunWith(Parameterized.class) 20 | public static class ParametrizedWithSpecialCharsInName { 21 | 22 | public ParametrizedWithSpecialCharsInName(String s) { 23 | } 24 | 25 | @Parameterized.Parameters(name = "{0}") 26 | public static Collection data() { 27 | return Arrays.asList( 28 | new Object[]{"\n"}, 29 | new Object[]{"\r\n"}, 30 | new Object[]{"\r"}, 31 | new Object[]{"\u0085"}, 32 | new Object[]{"\u2028"}, 33 | new Object[]{"\u2029"} 34 | ); 35 | } 36 | 37 | @Test 38 | public void test() { 39 | } 40 | } 41 | 42 | @Test 43 | public void parameterizedTestsWithSpecialCharsInName() { 44 | Request request = Request.aClass(ParametrizedWithSpecialCharsInName.class); 45 | for (Description parent : request.getRunner().getDescription().getChildren()) { 46 | for (Description description : parent.getChildren()) { 47 | assertEquals("test" + parent.getDisplayName(), description.getMethodName()); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/samples/SimpleTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.samples; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import junit.framework.JUnit4TestAdapter; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | /** 10 | * Some simple tests. 11 | */ 12 | public class SimpleTest { 13 | protected int fValue1; 14 | protected int fValue2; 15 | 16 | @Before 17 | public void setUp() { 18 | fValue1 = 2; 19 | fValue2 = 3; 20 | } 21 | 22 | public static junit.framework.Test suite() { 23 | return new JUnit4TestAdapter(SimpleTest.class); 24 | } 25 | 26 | public int unused; 27 | 28 | @Test 29 | public void divideByZero() { 30 | int zero = 0; 31 | int result = 8 / zero; 32 | unused = result; // avoid warning for not using result 33 | } 34 | 35 | @Test 36 | public void testEquals() { 37 | assertEquals(12, 12); 38 | assertEquals(12L, 12L); 39 | assertEquals(new Long(12), new Long(12)); 40 | 41 | assertEquals("Size", 12, 13); 42 | assertEquals("Capacity", 12.0, 11.99, 0.0); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/samples/money/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * JUnit v4.x Test for the Money example. 3 | * 4 | * @since 4.0 5 | * @see junit.samples.money.Money 6 | */ 7 | package org.junit.samples.money; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/samples/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides examples on how to use JUnit 4. 3 | * 4 | * @since 4.0 5 | */ 6 | package org.junit.samples; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/ObjectContractTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests; 2 | 3 | import static org.hamcrest.CoreMatchers.is; 4 | import static org.junit.Assert.assertThat; 5 | import static org.junit.Assume.assumeNotNull; 6 | import static org.junit.Assume.assumeThat; 7 | 8 | import java.lang.reflect.Method; 9 | 10 | import org.junit.Test; 11 | import org.junit.Test.None; 12 | import org.junit.experimental.theories.DataPoints; 13 | import org.junit.experimental.theories.Theories; 14 | import org.junit.experimental.theories.Theory; 15 | import org.junit.runner.RunWith; 16 | import org.junit.runners.model.FrameworkMethod; 17 | 18 | @RunWith(Theories.class) 19 | public class ObjectContractTest { 20 | @DataPoints 21 | public static Object[] objects = {new FrameworkMethod(toStringMethod()), 22 | new FrameworkMethod(toStringMethod()), 3, null}; 23 | 24 | @Theory 25 | @Test(expected = None.class) 26 | public void equalsThrowsNoException(Object a, Object b) { 27 | assumeNotNull(a); 28 | a.equals(b); 29 | } 30 | 31 | @Theory 32 | public void equalsMeansEqualHashCodes(Object a, Object b) { 33 | assumeNotNull(a, b); 34 | assumeThat(a, is(b)); 35 | assertThat(a.hashCode(), is(b.hashCode())); 36 | } 37 | 38 | private static Method toStringMethod() { 39 | try { 40 | return Object.class.getMethod("toString"); 41 | } catch (SecurityException e) { 42 | } catch (NoSuchMethodException e) { 43 | } 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/TestSystem.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.OutputStream; 5 | import java.io.PrintStream; 6 | 7 | import org.junit.internal.JUnitSystem; 8 | 9 | public class TestSystem implements JUnitSystem { 10 | private PrintStream out; 11 | public int fCode; 12 | private ByteArrayOutputStream fOutContents; 13 | 14 | public TestSystem() { 15 | fOutContents = new ByteArrayOutputStream(); 16 | out = new PrintStream(fOutContents); 17 | } 18 | 19 | /** 20 | * Will be removed in the next major release 21 | */ 22 | @Deprecated 23 | public void exit(int code) { 24 | fCode = code; 25 | } 26 | 27 | public PrintStream out() { 28 | return out; 29 | } 30 | 31 | public OutputStream outContents() { 32 | return fOutContents; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/description/SuiteDescriptionTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.description; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.Description; 8 | 9 | public class SuiteDescriptionTest { 10 | Description childless = Description.createSuiteDescription("a"); 11 | Description anotherChildless = Description.createSuiteDescription("a"); 12 | Description namedB = Description.createSuiteDescription("b"); 13 | 14 | Description twoKids = descriptionWithTwoKids("foo", "bar"); 15 | Description anotherTwoKids = descriptionWithTwoKids("foo", "baz"); 16 | 17 | @Test 18 | public void equalsIsCorrect() { 19 | assertEquals(childless, anotherChildless); 20 | assertFalse(childless.equals(namedB)); 21 | assertEquals(childless, twoKids); 22 | assertEquals(twoKids, anotherTwoKids); 23 | assertFalse(twoKids.equals(new Integer(5))); 24 | } 25 | 26 | @Test 27 | public void hashCodeIsReasonable() { 28 | assertEquals(childless.hashCode(), anotherChildless.hashCode()); 29 | assertFalse(childless.hashCode() == namedB.hashCode()); 30 | } 31 | 32 | private Description descriptionWithTwoKids(String first, String second) { 33 | Description twoKids = Description.createSuiteDescription("a"); 34 | twoKids.addChild(Description.createTestDescription(getClass(), first)); 35 | twoKids.addChild(Description.createTestDescription(getClass(), second)); 36 | return twoKids; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/description/TestDescriptionMethodNameTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.description; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.Description; 5 | import org.junit.runner.RunWith; 6 | import org.junit.runners.Parameterized; 7 | 8 | import java.util.Arrays; 9 | import java.util.Collection; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertNotNull; 13 | 14 | /** 15 | * @author Dmitry Baev charlie@yandex-team.ru 16 | * Date: 03.05.14 17 | */ 18 | @RunWith(Parameterized.class) 19 | public class TestDescriptionMethodNameTest { 20 | 21 | private String methodName; 22 | 23 | public TestDescriptionMethodNameTest(String methodName) { 24 | this.methodName = methodName; 25 | } 26 | 27 | @Parameterized.Parameters 28 | public static Collection getMethodNames() { 29 | return Arrays.asList( 30 | new Object[]{"simple"}, 31 | new Object[]{"with space"}, 32 | new Object[]{"[]!@#$%^&*()"}, 33 | new Object[]{""}, 34 | new Object[]{"\t"}, 35 | new Object[]{"\n"}, 36 | new Object[]{"\r\n"}, 37 | new Object[]{"\r"}, 38 | new Object[]{"\u0085"}, 39 | new Object[]{"\u2028"}, 40 | new Object[]{"\u2029"} 41 | ); 42 | } 43 | 44 | @Test 45 | public void methodNameTest() throws Exception { 46 | Description description = Description.createTestDescription("some-class-name", methodName); 47 | assertNotNull("Method name should be not null", description.getMethodName()); 48 | assertEquals(methodName, description.getMethodName()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/description/TestDescriptionTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.description; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.Description; 8 | 9 | public class TestDescriptionTest { 10 | @Test 11 | public void equalsIsFalseForNonTestDescription() { 12 | assertFalse(Description.createTestDescription(getClass(), "a").equals(new Integer(5))); 13 | } 14 | 15 | @Test 16 | public void equalsIsTrueForSameNameAndNoExplicitUniqueId() { 17 | assertTrue(Description.createSuiteDescription("Hello").equals(Description.createSuiteDescription("Hello"))); 18 | } 19 | 20 | @Test 21 | public void equalsIsFalseForSameNameAndDifferentUniqueId() { 22 | assertFalse(Description.createSuiteDescription("Hello", 2).equals(Description.createSuiteDescription("Hello", 3))); 23 | } 24 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/max/JUnit38SortingTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.max; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.File; 6 | import java.util.List; 7 | 8 | import junit.framework.TestCase; 9 | import org.junit.After; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.experimental.max.MaxCore; 13 | import org.junit.runner.Description; 14 | import org.junit.runner.Request; 15 | 16 | public class JUnit38SortingTest { 17 | private MaxCore fMax; 18 | private File fMaxFile; 19 | 20 | @Before 21 | public void createMax() { 22 | fMaxFile = new File("MaxCore.ser"); 23 | if (fMaxFile.exists()) { 24 | fMaxFile.delete(); 25 | } 26 | fMax = MaxCore.storedLocally(fMaxFile); 27 | } 28 | 29 | @After 30 | public void forgetMax() { 31 | fMaxFile.delete(); 32 | } 33 | 34 | public static class JUnit4Test { 35 | @Test 36 | public void pass() { 37 | } 38 | } 39 | 40 | public static class JUnit38Test extends TestCase { 41 | public void testFails() { 42 | fail(); 43 | } 44 | 45 | public void testSucceeds() { 46 | } 47 | 48 | public void testSucceedsToo() { 49 | } 50 | } 51 | 52 | @Test 53 | public void preferRecentlyFailed38Test() { 54 | Request request = Request.classes(JUnit4Test.class, JUnit38Test.class); 55 | fMax.run(request); 56 | List tests = fMax.sortedLeavesForTest(request); 57 | Description dontSucceed = Description.createTestDescription( 58 | JUnit38Test.class, "testFails"); 59 | assertEquals(dontSucceed, tests.get(0)); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/results/ResultMatchersTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.results; 2 | 3 | import static org.hamcrest.CoreMatchers.containsString; 4 | import static org.hamcrest.CoreMatchers.is; 5 | import static org.junit.Assert.assertThat; 6 | 7 | import org.junit.Test; 8 | import org.junit.experimental.results.ResultMatchers; 9 | import org.junit.experimental.theories.Theory; 10 | 11 | public class ResultMatchersTest { 12 | @Test 13 | public void hasFailuresHasGoodDescription() { 14 | assertThat(ResultMatchers.failureCountIs(3).toString(), 15 | is("has 3 failures")); 16 | } 17 | 18 | @Theory 19 | public void hasFailuresDescriptionReflectsInput(int i) { 20 | assertThat(ResultMatchers.failureCountIs(i).toString(), 21 | containsString("" + i)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/rules/ExternalResourceRuleTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.rules; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertThat; 5 | import static org.junit.experimental.results.PrintableResult.testResult; 6 | import static org.junit.experimental.results.ResultMatchers.isSuccessful; 7 | 8 | import org.junit.Rule; 9 | import org.junit.Test; 10 | import org.junit.rules.ExternalResource; 11 | 12 | public class ExternalResourceRuleTest { 13 | private static String callSequence; 14 | 15 | public static class UsesExternalResource { 16 | @Rule 17 | public ExternalResource resource = new ExternalResource() { 18 | @Override 19 | protected void before() throws Throwable { 20 | callSequence += "before "; 21 | } 22 | 23 | ; 24 | 25 | @Override 26 | protected void after() { 27 | callSequence += "after "; 28 | } 29 | 30 | ; 31 | }; 32 | 33 | @Test 34 | public void testFoo() { 35 | callSequence += "test "; 36 | } 37 | } 38 | 39 | @Test 40 | public void externalResourceGeneratesCorrectSequence() { 41 | callSequence = ""; 42 | assertThat(testResult(UsesExternalResource.class), isSuccessful()); 43 | assertEquals("before test after ", callSequence); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/rules/LoggingTestWatcher.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.rules; 2 | 3 | import org.junit.AssumptionViolatedException; 4 | import org.junit.rules.TestWatcher; 5 | import org.junit.runner.Description; 6 | 7 | class LoggingTestWatcher extends TestWatcher { 8 | private final StringBuilder log; 9 | 10 | LoggingTestWatcher(StringBuilder log) { 11 | this.log = log; 12 | } 13 | 14 | @Override 15 | protected void succeeded(Description description) { 16 | log.append("succeeded "); 17 | } 18 | 19 | @Override 20 | protected void failed(Throwable e, Description description) { 21 | log.append("failed "); 22 | } 23 | 24 | @Override 25 | protected void skipped(AssumptionViolatedException e, Description description) { 26 | log.append("skipped "); 27 | } 28 | 29 | @Override 30 | protected void starting(Description description) { 31 | log.append("starting "); 32 | } 33 | 34 | @Override 35 | protected void finished(Description description) { 36 | log.append("finished "); 37 | } 38 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/rules/NameRulesTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.rules; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Rule; 8 | import org.junit.Test; 9 | import org.junit.experimental.runners.Enclosed; 10 | import org.junit.rules.TestName; 11 | import org.junit.runner.RunWith; 12 | 13 | @RunWith(Enclosed.class) 14 | public class NameRulesTest { 15 | public static class TestNames { 16 | @Rule 17 | public TestName name = new TestName(); 18 | 19 | @Test 20 | public void testA() { 21 | assertEquals("testA", name.getMethodName()); 22 | } 23 | 24 | @Test 25 | public void testB() { 26 | assertEquals("testB", name.getMethodName()); 27 | } 28 | } 29 | 30 | public static class BeforeAndAfterTest { 31 | @Rule 32 | public TestName name = new TestName(); 33 | 34 | private final String expectedName = "x"; 35 | 36 | @Before 37 | public void setUp() { 38 | assertEquals(expectedName, name.getMethodName()); 39 | } 40 | 41 | @Test 42 | public void x() { 43 | assertEquals(expectedName, name.getMethodName()); 44 | } 45 | 46 | @After 47 | public void tearDown() { 48 | assertEquals(expectedName, name.getMethodName()); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/AssumingInTheoriesTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories; 2 | 3 | import static org.junit.tests.experimental.theories.TheoryTestUtils.runTheoryClass; 4 | import org.junit.Assert; 5 | import org.junit.Assume; 6 | import org.junit.Test; 7 | import org.junit.experimental.theories.DataPoint; 8 | import org.junit.experimental.theories.Theories; 9 | import org.junit.experimental.theories.Theory; 10 | import org.junit.runner.Result; 11 | import org.junit.runner.RunWith; 12 | import org.junit.runners.model.InitializationError; 13 | 14 | @RunWith(Theories.class) 15 | public class AssumingInTheoriesTest { 16 | 17 | @Test 18 | public void noTheoryAnnotationMeansAssumeShouldIgnore() { 19 | Assume.assumeTrue(false); 20 | } 21 | 22 | @Test 23 | public void theoryMeansOnlyAssumeShouldFail() throws InitializationError { 24 | Result result = runTheoryClass(TheoryWithNoUnassumedParameters.class); 25 | Assert.assertEquals(1, result.getFailureCount()); 26 | } 27 | 28 | /** 29 | * Simple class that SHOULD fail because no parameters are met. 30 | */ 31 | public static class TheoryWithNoUnassumedParameters { 32 | 33 | @DataPoint 34 | public final static boolean FALSE = false; 35 | 36 | @Theory 37 | public void theoryWithNoUnassumedParameters(boolean value) { 38 | Assume.assumeTrue(value); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/TestedOnSupplierTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories; 2 | 3 | import static org.hamcrest.CoreMatchers.is; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import java.lang.reflect.Method; 7 | import java.util.List; 8 | 9 | import org.junit.Test; 10 | import org.junit.experimental.theories.ParameterSignature; 11 | import org.junit.experimental.theories.PotentialAssignment; 12 | import org.junit.experimental.theories.suppliers.TestedOn; 13 | import org.junit.experimental.theories.suppliers.TestedOnSupplier; 14 | 15 | public class TestedOnSupplierTest { 16 | 17 | public void foo(@TestedOn(ints = {1}) int x) { 18 | } 19 | 20 | @Test 21 | public void descriptionStatesParameterName() throws Exception { 22 | TestedOnSupplier supplier = new TestedOnSupplier(); 23 | List assignments = supplier.getValueSources(signatureOfFoo()); 24 | assertThat(assignments.get(0).getDescription(), is("\"1\" ")); 25 | } 26 | 27 | private ParameterSignature signatureOfFoo() throws NoSuchMethodException { 28 | Method method = getClass().getMethod("foo", int.class); 29 | return ParameterSignature.signatures(method).get(0); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/TheoryTestUtils.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.List; 5 | 6 | import org.junit.experimental.theories.PotentialAssignment; 7 | import org.junit.experimental.theories.Theories; 8 | import org.junit.experimental.theories.internal.Assignments; 9 | import org.junit.runner.JUnitCore; 10 | import org.junit.runner.Request; 11 | import org.junit.runner.Result; 12 | import org.junit.runner.Runner; 13 | import org.junit.runners.model.InitializationError; 14 | import org.junit.runners.model.TestClass; 15 | 16 | public final class TheoryTestUtils { 17 | 18 | private TheoryTestUtils() { } 19 | 20 | public static List potentialAssignments(Method method) 21 | throws Throwable { 22 | return Assignments.allUnassigned(method, 23 | new TestClass(method.getDeclaringClass())) 24 | .potentialsForNextUnassigned(); 25 | } 26 | 27 | public static Result runTheoryClass(Class testClass) throws InitializationError { 28 | Runner theoryRunner = new Theories(testClass); 29 | Request request = Request.runner(theoryRunner); 30 | return new JUnitCore().run(request); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/Correspondent.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories.extendingwithstubs; 2 | 3 | public interface Correspondent { 4 | 5 | String getAnswer(String question, String... bucket); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/MethodCall.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories.extendingwithstubs; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | public class MethodCall { 9 | private final Method method; 10 | private final Object[] args; 11 | 12 | public MethodCall(Method method, Object... args) { 13 | this.method = method; 14 | this.args = args; 15 | } 16 | 17 | @Override 18 | public boolean equals(Object obj) { 19 | MethodCall call = (MethodCall) obj; 20 | return call.method.equals(method) && Arrays.deepEquals(call.args, args); 21 | } 22 | 23 | @Override 24 | public int hashCode() { 25 | return 1; 26 | } 27 | 28 | public Class getReturnType() { 29 | return method.getReturnType(); 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return String.format("%s(%s)", method.getName(), argListString()); 35 | } 36 | 37 | private String argListString() { 38 | if (args == null) { 39 | return null; 40 | } 41 | return argList().toString().substring(1, argList().toString().length() - 1); 42 | } 43 | 44 | private List argList() { 45 | ArrayList list = new ArrayList(); 46 | for (Object arg : args) { 47 | list.add(new StringableObject(arg)); 48 | } 49 | return list; 50 | } 51 | 52 | public Object stringableObject(Object arg) { 53 | return new StringableObject(arg).stringableObject(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/ReguessableValue.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories.extendingwithstubs; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.experimental.theories.PotentialAssignment; 6 | import org.junit.internal.AssumptionViolatedException; 7 | 8 | public abstract class ReguessableValue extends PotentialAssignment { 9 | 10 | public ReguessableValue() { 11 | super(); 12 | } 13 | 14 | public abstract List reguesses( 15 | AssumptionViolatedException e); 16 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/StringableObject.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories.extendingwithstubs; 2 | 3 | import java.util.Arrays; 4 | 5 | public class StringableObject { 6 | public Object obj; 7 | 8 | public StringableObject(Object obj) { 9 | this.obj = obj; 10 | } 11 | 12 | public Object stringableObject() { 13 | if (isListableArray()) { 14 | return Arrays.asList((Object[]) obj); 15 | } else { 16 | return obj; 17 | } 18 | } 19 | 20 | private boolean isListableArray() { 21 | Class type = obj.getClass(); 22 | return type.isArray() && !type.getComponentType().isPrimitive(); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return stringableObject().toString(); 28 | } 29 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/Stub.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories.extendingwithstubs; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.RUNTIME) 7 | public @interface Stub { 8 | } 9 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/extendingwithstubs/StubbedTheoriesTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories.extendingwithstubs; 2 | 3 | import static org.hamcrest.CoreMatchers.is; 4 | import static org.junit.Assume.assumeThat; 5 | 6 | import org.junit.experimental.theories.Theory; 7 | import org.junit.runner.RunWith; 8 | 9 | @RunWith(StubbedTheories.class) 10 | public class StubbedTheoriesTest { 11 | @Theory 12 | public void ask(@Stub Correspondent correspondent) { 13 | assumeThat(correspondent.getAnswer("What is five?", "four", "five"), 14 | is("five")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/experimental/theories/runner/TheoriesPerformanceTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.experimental.theories.runner; 2 | 3 | import static org.junit.Assert.assertThat; 4 | import static org.junit.Assume.assumeTrue; 5 | import static org.junit.experimental.results.PrintableResult.testResult; 6 | import static org.junit.experimental.results.ResultMatchers.isSuccessful; 7 | 8 | import org.junit.Test; 9 | import org.junit.experimental.theories.DataPoints; 10 | import org.junit.experimental.theories.Theories; 11 | import org.junit.experimental.theories.Theory; 12 | import org.junit.runner.RunWith; 13 | 14 | public class TheoriesPerformanceTest { 15 | @RunWith(Theories.class) 16 | public static class UpToTen { 17 | @DataPoints 18 | public static int[] ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 19 | 20 | @Theory 21 | public void threeInts(int x, int y, int z) { 22 | // pass always 23 | } 24 | } 25 | 26 | private static final boolean TESTING_PERFORMANCE = false; 27 | 28 | // If we do not share the same instance of TestClass, repeatedly parsing the 29 | // class's annotations looking for @Befores and @Afters gets really costly. 30 | // 31 | // Likewise, the TestClass must be passed into AllMembersSupplier, or the 32 | // annotation parsing is again costly. 33 | @Test 34 | public void tryCombinationsQuickly() { 35 | assumeTrue(TESTING_PERFORMANCE); 36 | assertThat(testResult(UpToTen.class), isSuccessful()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/internal/runners/ErrorReportingRunnerTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.internal.runners; 2 | 3 | import org.junit.Test; 4 | import org.junit.internal.runners.ErrorReportingRunner; 5 | 6 | public class ErrorReportingRunnerTest { 7 | 8 | @Test(expected = NullPointerException.class) 9 | public void cannotCreateWithNullClass() { 10 | new ErrorReportingRunner(null, new RuntimeException()); 11 | } 12 | 13 | @Test(expected = NullPointerException.class) 14 | public void cannotCreateWithNullClass2() { 15 | new ErrorReportingRunner(new RuntimeException(), (Class) null); 16 | } 17 | 18 | @Test(expected = NullPointerException.class) 19 | public void cannotCreateWithNullClasses() { 20 | new ErrorReportingRunner(new RuntimeException(), (Class[]) null); 21 | } 22 | 23 | @Test(expected = NullPointerException.class) 24 | public void cannotCreateWithoutClass() { 25 | new ErrorReportingRunner(new RuntimeException()); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/junit3compatibility/ClassRequestTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.junit3compatibility; 2 | 3 | import static org.junit.Assert.assertNull; 4 | 5 | import org.junit.Test; 6 | import org.junit.internal.builders.SuiteMethodBuilder; 7 | 8 | public class ClassRequestTest { 9 | public static class PrivateSuiteMethod { 10 | static junit.framework.Test suite() { 11 | return null; 12 | } 13 | } 14 | 15 | @Test 16 | public void noSuiteMethodIfMethodPrivate() throws Throwable { 17 | assertNull(new SuiteMethodBuilder() 18 | .runnerForClass(PrivateSuiteMethod.class)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/junit3compatibility/OldTestClassAdaptingListenerTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.junit3compatibility; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import junit.framework.AssertionFailedError; 6 | import junit.framework.TestCase; 7 | import junit.framework.TestListener; 8 | import org.junit.Test; 9 | import org.junit.internal.runners.JUnit38ClassRunner; 10 | import org.junit.runner.Result; 11 | import org.junit.runner.notification.RunListener; 12 | import org.junit.runner.notification.RunNotifier; 13 | 14 | public class OldTestClassAdaptingListenerTest { 15 | @Test 16 | public void addFailureDelegatesToNotifier() { 17 | Result result = new Result(); 18 | RunListener listener = result.createListener(); 19 | RunNotifier notifier = new RunNotifier(); 20 | notifier.addFirstListener(listener); 21 | TestCase testCase = new TestCase() { 22 | }; 23 | TestListener adaptingListener = new JUnit38ClassRunner(testCase) 24 | .createAdaptingListener(notifier); 25 | adaptingListener.addFailure(testCase, new AssertionFailedError()); 26 | assertEquals(1, result.getFailureCount()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/junit3compatibility/OldTests.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.junit3compatibility; 2 | 3 | import junit.framework.Test; 4 | import org.junit.runner.RunWith; 5 | import org.junit.runners.AllTests; 6 | 7 | @RunWith(AllTests.class) 8 | public class OldTests { 9 | static public Test suite() { 10 | return junit.tests.AllTests.suite(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/listening/ListenerTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.listening; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.Description; 7 | import org.junit.runner.JUnitCore; 8 | import org.junit.runner.notification.RunListener; 9 | 10 | public class ListenerTest { 11 | static private String log; 12 | 13 | public static class OneTest { 14 | @Test 15 | public void nothing() { 16 | } 17 | } 18 | 19 | @Test 20 | public void notifyListenersInTheOrderInWhichTheyAreAdded() { 21 | JUnitCore core = new JUnitCore(); 22 | log = ""; 23 | core.addListener(new RunListener() { 24 | @Override 25 | public void testRunStarted(Description description) throws Exception { 26 | log += "first "; 27 | } 28 | }); 29 | core.addListener(new RunListener() { 30 | @Override 31 | public void testRunStarted(Description description) throws Exception { 32 | log += "second "; 33 | } 34 | }); 35 | core.run(OneTest.class); 36 | assertEquals("first second ", log); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/listening/UserStopTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.listening; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.junit.runner.Request; 6 | import org.junit.runner.notification.RunNotifier; 7 | import org.junit.runner.notification.StoppedByUserException; 8 | 9 | public class UserStopTest { 10 | private RunNotifier fNotifier; 11 | 12 | @Before 13 | public void createNotifier() { 14 | fNotifier = new RunNotifier(); 15 | fNotifier.pleaseStop(); 16 | } 17 | 18 | @Test(expected = StoppedByUserException.class) 19 | public void userStop() { 20 | fNotifier.fireTestStarted(null); 21 | } 22 | 23 | public static class OneTest { 24 | @Test 25 | public void foo() { 26 | } 27 | } 28 | 29 | @Test(expected = StoppedByUserException.class) 30 | public void stopClassRunner() throws Exception { 31 | Request.aClass(OneTest.class).getRunner().run(fNotifier); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/manipulation/FilterTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.manipulation; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertSame; 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.Description; 8 | import org.junit.runner.manipulation.Filter; 9 | 10 | public class FilterTest { 11 | public static class NamedFilter extends Filter { 12 | private final String fName; 13 | 14 | public NamedFilter(String name) { 15 | fName = name; 16 | } 17 | 18 | @Override 19 | public boolean shouldRun(Description description) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public String describe() { 25 | return fName; 26 | } 27 | } 28 | 29 | @Test 30 | public void intersectionText() { 31 | NamedFilter a = new NamedFilter("a"); 32 | NamedFilter b = new NamedFilter("b"); 33 | assertEquals("a and b", a.intersect(b).describe()); 34 | assertEquals("b and a", b.intersect(a).describe()); 35 | } 36 | 37 | @Test 38 | public void intersectSelf() { 39 | NamedFilter a = new NamedFilter("a"); 40 | assertSame(a, a.intersect(a)); 41 | } 42 | 43 | @Test 44 | public void intersectAll() { 45 | NamedFilter a = new NamedFilter("a"); 46 | assertSame(a, a.intersect(Filter.ALL)); 47 | assertSame(a, Filter.ALL.intersect(a)); 48 | assertSame(Filter.ALL, Filter.ALL.intersect(Filter.ALL)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests the JUnit functionality. 3 | * 4 | * Corresponds to {@link junit.tests.AllTests} in Junit 3.x. 5 | * 6 | * @since 4.0 7 | */ 8 | package org.junit.tests; -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/running/classes/BlockJUnit4ClassRunnerTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.running.classes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.List; 6 | 7 | import org.junit.Test; 8 | import org.junit.runners.BlockJUnit4ClassRunner; 9 | import org.junit.runners.model.InitializationError; 10 | 11 | public class BlockJUnit4ClassRunnerTest { 12 | public static class OuterClass { 13 | public class Enclosed { 14 | @Test 15 | public void test() { 16 | } 17 | } 18 | } 19 | 20 | @Test 21 | public void detectNonStaticEnclosedClass() throws Exception { 22 | try { 23 | new BlockJUnit4ClassRunner(OuterClass.Enclosed.class); 24 | } catch (InitializationError e) { 25 | List causes = e.getCauses(); 26 | assertEquals("Wrong number of causes.", 1, causes.size()); 27 | assertEquals( 28 | "Wrong exception.", 29 | "The inner class org.junit.tests.running.classes.BlockJUnit4ClassRunnerTest$OuterClass$Enclosed is not static.", 30 | causes.get(0).getMessage()); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/running/classes/EnclosedTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.running.classes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.junit.experimental.runners.Enclosed; 7 | import org.junit.runner.JUnitCore; 8 | import org.junit.runner.Request; 9 | import org.junit.runner.Result; 10 | import org.junit.runner.RunWith; 11 | import org.junit.runner.Runner; 12 | 13 | public class EnclosedTest { 14 | @RunWith(Enclosed.class) 15 | public static class Enclosing { 16 | public static class A { 17 | @Test 18 | public void a() {} 19 | 20 | @Test 21 | public void b() {} 22 | } 23 | public static class B { 24 | @Test 25 | public void a() {} 26 | 27 | @Test 28 | public void b() {} 29 | 30 | @Test 31 | public void c() {} 32 | } 33 | abstract public static class C { 34 | @Test public void a() {} 35 | } 36 | } 37 | 38 | @Test 39 | public void enclosedRunnerPlansConcreteEnclosedClasses() throws Exception { 40 | Runner runner= Request.aClass(Enclosing.class).getRunner(); 41 | assertEquals(5, runner.testCount()); 42 | } 43 | 44 | @Test 45 | public void enclosedRunnerRunsConcreteEnclosedClasses() throws Exception { 46 | Result result= JUnitCore.runClasses(Enclosing.class); 47 | assertEquals(5, result.getRunCount()); 48 | } 49 | 50 | @Test 51 | public void enclosedRunnerIsNamedForEnclosingClass() throws Exception { 52 | assertEquals(Enclosing.class.getName(), Request.aClass(Enclosing.class) 53 | .getRunner().getDescription().getDisplayName()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/running/classes/IgnoreClassTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.running.classes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.fail; 5 | 6 | import org.junit.Ignore; 7 | import org.junit.Test; 8 | import org.junit.runner.JUnitCore; 9 | import org.junit.runner.Result; 10 | 11 | public class IgnoreClassTest { 12 | @Ignore("For a good reason") 13 | public static class IgnoreMe { 14 | @Test 15 | public void iFail() { 16 | fail(); 17 | } 18 | 19 | @Test 20 | public void iFailToo() { 21 | fail(); 22 | } 23 | } 24 | 25 | @Test 26 | public void ignoreClass() { 27 | Result result = JUnitCore.runClasses(IgnoreMe.class); 28 | assertEquals(0, result.getFailureCount()); 29 | assertEquals(1, result.getIgnoreCount()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/running/classes/UseSuiteAsASuperclassTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.running.classes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.fail; 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.JUnitCore; 8 | import org.junit.runner.Result; 9 | import org.junit.runner.RunWith; 10 | import org.junit.runners.Suite; 11 | import org.junit.runners.model.InitializationError; 12 | 13 | public class UseSuiteAsASuperclassTest { 14 | 15 | public static class TestA { 16 | @Test 17 | public void pass() { 18 | } 19 | } 20 | 21 | public static class TestB { 22 | @Test 23 | public void dontPass() { 24 | fail(); 25 | } 26 | } 27 | 28 | public static class MySuite extends Suite { 29 | public MySuite(Class klass) throws InitializationError { 30 | super(klass, new Class[]{TestA.class, TestB.class}); 31 | } 32 | } 33 | 34 | @RunWith(MySuite.class) 35 | public static class AllWithMySuite { 36 | } 37 | 38 | @Test 39 | public void ensureTestsAreRun() { 40 | JUnitCore core = new JUnitCore(); 41 | Result result = core.run(AllWithMySuite.class); 42 | assertEquals(2, result.getRunCount()); 43 | assertEquals(1, result.getFailureCount()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/running/core/JUnitCoreReturnsCorrectExitCodeTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.running.core; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.fail; 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.JUnitCore; 8 | 9 | public class JUnitCoreReturnsCorrectExitCodeTest { 10 | 11 | static public class Fail { 12 | @Test 13 | public void kaboom() { 14 | fail(); 15 | } 16 | } 17 | 18 | @Test 19 | public void failureCausesExitCodeOf1() throws Exception { 20 | runClass(getClass().getName() + "$Fail", 1); 21 | } 22 | 23 | @Test 24 | public void missingClassCausesExitCodeOf1() throws Exception { 25 | runClass("Foo", 1); 26 | } 27 | 28 | static public class Succeed { 29 | @Test 30 | public void peacefulSilence() { 31 | } 32 | } 33 | 34 | @Test 35 | public void successCausesExitCodeOf0() throws Exception { 36 | runClass(getClass().getName() + "$Succeed", 0); 37 | } 38 | 39 | private void runClass(final String className, int returnCode) { 40 | Integer exitValue = new MainRunner().runWithCheckForSystemExit(new Runnable() { 41 | public void run() { 42 | JUnitCore.main(className); 43 | } 44 | }); 45 | assertEquals(Integer.valueOf(returnCode), exitValue); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/running/core/SystemExitTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.running.core; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.File; 6 | import java.io.InputStream; 7 | 8 | import org.junit.Test; 9 | 10 | // Make sure System.exit works as expected. We've had problems with this on some platforms. 11 | public class SystemExitTest { 12 | 13 | private static final int EXIT_CODE = 5; 14 | 15 | static public class Exit { 16 | public static void main(String[] args) { 17 | System.exit(EXIT_CODE); 18 | } 19 | } 20 | 21 | @Test 22 | public void failureCausesExitCodeOf1() throws Exception { 23 | String java = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; 24 | String classPath = getClass().getClassLoader().getResource(".").getFile() + File.pathSeparator + System.getProperty("java.class.path"); 25 | String[] cmd = {java, "-cp", classPath, getClass().getName() + "$Exit"}; 26 | Process process = Runtime.getRuntime().exec(cmd); 27 | InputStream input = process.getInputStream(); 28 | while ((input.read()) != -1) ; 29 | assertEquals(EXIT_CODE, process.waitFor()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/running/methods/InheritedTestTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.running.methods; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | import static org.junit.Assert.fail; 6 | 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.JUnitCore; 10 | import org.junit.runner.Result; 11 | 12 | public class InheritedTestTest { 13 | public abstract static class Super { 14 | @Test 15 | public void nothing() { 16 | } 17 | } 18 | 19 | public static class Sub extends Super { 20 | } 21 | 22 | @Test 23 | public void subclassWithOnlyInheritedTestsRuns() { 24 | Result result = JUnitCore.runClasses(Sub.class); 25 | assertTrue(result.wasSuccessful()); 26 | } 27 | 28 | public static class SubWithBefore extends Super { 29 | @Before 30 | public void gack() { 31 | fail(); 32 | } 33 | } 34 | 35 | @Test 36 | public void subclassWithInheritedTestAndOwnBeforeRunsBefore() { 37 | assertFalse(JUnitCore.runClasses(SubWithBefore.class).wasSuccessful()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/validation/FailedConstructionTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.validation; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.junit.runner.Description; 6 | import org.junit.runner.JUnitCore; 7 | import org.junit.runner.Result; 8 | import org.junit.runner.notification.Failure; 9 | 10 | public class FailedConstructionTest { 11 | public static class CantConstruct { 12 | public CantConstruct() { 13 | throw new RuntimeException(); 14 | } 15 | 16 | @Test 17 | public void foo() { 18 | } 19 | } 20 | 21 | @Test 22 | public void failedConstructionIsTestFailure() { 23 | Result result = JUnitCore.runClasses(CantConstruct.class); 24 | Failure failure = result.getFailures().get(0); 25 | Description expected = Description.createTestDescription(CantConstruct.class, "foo"); 26 | Assert.assertEquals(expected, failure.getDescription()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/validation/ValidationTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.validation; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.BeforeClass; 6 | import org.junit.Test; 7 | import org.junit.runner.JUnitCore; 8 | import org.junit.runner.Request; 9 | import org.junit.runner.Result; 10 | 11 | public class ValidationTest { 12 | public static class WrongBeforeClass { 13 | @BeforeClass 14 | protected int a() { 15 | return 0; 16 | } 17 | } 18 | 19 | @Test 20 | public void initializationErrorIsOnCorrectClass() { 21 | assertEquals(WrongBeforeClass.class.getName(), 22 | Request.aClass(WrongBeforeClass.class).getRunner().getDescription().getDisplayName()); 23 | } 24 | 25 | public static class NonStaticBeforeClass { 26 | @BeforeClass 27 | public void before() { 28 | } 29 | 30 | @Test 31 | public void hereBecauseEveryTestClassNeedsATest() { 32 | } 33 | } 34 | 35 | @Test 36 | public void nonStaticBeforeClass() { 37 | Result result = JUnitCore.runClasses(NonStaticBeforeClass.class); 38 | assertEquals("Method before() should be static", result.getFailures().get(0).getMessage()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/validation/anotherpackage/Sub.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.validation.anotherpackage; 2 | 3 | public class Sub extends Super { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/tests/validation/anotherpackage/Super.java: -------------------------------------------------------------------------------- 1 | package org.junit.tests.validation.anotherpackage; 2 | 3 | import org.junit.Test; 4 | 5 | class Super { 6 | @Test 7 | public void a() { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/java/org/junit/validator/PublicClassValidatorTest.java: -------------------------------------------------------------------------------- 1 | package org.junit.validator; 2 | 3 | import static org.hamcrest.CoreMatchers.equalTo; 4 | import static org.hamcrest.CoreMatchers.is; 5 | import static org.hamcrest.MatcherAssert.assertThat; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | import org.junit.Test; 11 | import org.junit.runners.model.TestClass; 12 | 13 | public class PublicClassValidatorTest { 14 | private final PublicClassValidator validator = new PublicClassValidator(); 15 | 16 | public static class PublicClass { 17 | 18 | } 19 | 20 | @Test 21 | public void acceptsPublicClass() { 22 | TestClass testClass = new TestClass(PublicClass.class); 23 | List validationErrors = validator 24 | .validateTestClass(testClass); 25 | assertThat(validationErrors, 26 | is(equalTo(Collections. emptyList()))); 27 | } 28 | 29 | static class NonPublicClass { 30 | 31 | } 32 | 33 | @Test 34 | public void rejectsNonPublicClass() { 35 | TestClass testClass = new TestClass(NonPublicClass.class); 36 | List validationErrors = validator 37 | .validateTestClass(testClass); 38 | assertThat("Wrong number of errors.", validationErrors.size(), 39 | is(equalTo(1))); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/resources/junit/tests/runner/testRunFailureResultCanBeSerialised: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/src/test/resources/junit/tests/runner/testRunFailureResultCanBeSerialised -------------------------------------------------------------------------------- /source_to_parse/junit-master/src/test/resources/junit/tests/runner/testRunSuccessResultCanBeSerialised: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftomassetti/analyze-java-code-examples/927e75173277cf0f3ac0001ddc6929cf3b72abdf/source_to_parse/junit-master/src/test/resources/junit/tests/runner/testRunSuccessResultCanBeSerialised -------------------------------------------------------------------------------- /source_to_parse/junit-master/to-do.txt: -------------------------------------------------------------------------------- 1 | * update documentation 2 | * new cook's tour 3 | * update Test Infected 4 | * Should there be a "prefix" annotation for Suites? 5 | * This would allow two Suites with different BeforeClass/AfterClass behaviors, 6 | but the same component tests, to co-exist 7 | 8 | * update the build process 9 | * update site for plug-in version? 10 | * Ant 11 | * Basic task 12 | * support testing run once initialization code e.g. class Foo {{...}} 13 | * Automatically add failing tests to the Known Defects section of the README.html 14 | 15 | * Create assume(that()) and assert(that()) 16 | (what is a better name for the second one?) 17 | 18 | * Simplify implementation of equality, and organize AssertionTest 19 | 20 | * Theories class validation should be much better 21 | 22 | * Find a way to make Parameterized a single-class extension 23 | 24 | * If a suite() returns a JUnit4TestAdapter, allow Filters and Sorters to operate on 25 | the adapted Runner. 26 | 27 | * Every time I add a Filter feature, I have to add an equivalent Sorter feature. Suspicious. 28 | -------------------------------------------------------------------------------- /src/main/java/me/tomassetti/examples/ListClassesExample.java: -------------------------------------------------------------------------------- 1 | package me.tomassetti.examples; 2 | 3 | import com.github.javaparser.StaticJavaParser; 4 | import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; 5 | import com.github.javaparser.ast.visitor.VoidVisitorAdapter; 6 | import com.google.common.base.Strings; 7 | import me.tomassetti.support.DirExplorer; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | public class ListClassesExample { 13 | 14 | public static void listClasses(File projectDir) { 15 | new DirExplorer((level, path, file) -> path.endsWith(".java"), (level, path, file) -> { 16 | System.out.println(path); 17 | System.out.println(Strings.repeat("=", path.length())); 18 | try { 19 | new VoidVisitorAdapter() { 20 | @Override 21 | public void visit(ClassOrInterfaceDeclaration n, Object arg) { 22 | super.visit(n, arg); 23 | System.out.println(" * " + n.getName()); 24 | } 25 | }.visit(StaticJavaParser.parse(file), null); 26 | System.out.println(); // empty line 27 | } catch (IOException e) { 28 | throw new RuntimeException(e); 29 | } 30 | }).explore(projectDir); 31 | } 32 | 33 | public static void main(String[] args) { 34 | File projectDir = new File("source_to_parse/junit-master"); 35 | listClasses(projectDir); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/tomassetti/examples/MethodCallsExample.java: -------------------------------------------------------------------------------- 1 | package me.tomassetti.examples; 2 | 3 | import com.github.javaparser.StaticJavaParser; 4 | import com.github.javaparser.ast.expr.MethodCallExpr; 5 | import com.github.javaparser.ast.visitor.VoidVisitorAdapter; 6 | import com.google.common.base.Strings; 7 | import me.tomassetti.support.DirExplorer; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | public class MethodCallsExample { 13 | 14 | public static void listMethodCalls(File projectDir) { 15 | new DirExplorer((level, path, file) -> path.endsWith(".java"), (level, path, file) -> { 16 | System.out.println(path); 17 | System.out.println(Strings.repeat("=", path.length())); 18 | try { 19 | new VoidVisitorAdapter() { 20 | @Override 21 | public void visit(MethodCallExpr n, Object arg) { 22 | super.visit(n, arg); 23 | System.out.println(" [L " + n.getBegin().get().line + "] " + n); 24 | } 25 | }.visit(StaticJavaParser.parse(file), null); 26 | System.out.println(); // empty line 27 | } catch (IOException e) { 28 | throw new RuntimeException(e); 29 | } 30 | }).explore(projectDir); 31 | } 32 | 33 | public static void main(String[] args) { 34 | File projectDir = new File("source_to_parse/junit-master"); 35 | listMethodCalls(projectDir); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/tomassetti/examples/StatementsLinesExample.java: -------------------------------------------------------------------------------- 1 | package me.tomassetti.examples; 2 | 3 | import com.github.javaparser.StaticJavaParser; 4 | import com.github.javaparser.ast.stmt.Statement; 5 | import com.google.common.base.Strings; 6 | import me.tomassetti.support.DirExplorer; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | public class StatementsLinesExample { 12 | 13 | public static void statementsByLine(File projectDir) { 14 | new DirExplorer((level, path, file) -> path.endsWith(".java"), (level, path, file) -> { 15 | System.out.println(path); 16 | System.out.println(Strings.repeat("=", path.length())); 17 | try { 18 | StaticJavaParser.parse(file) 19 | .findAll(Statement.class) 20 | .forEach(statement -> System.out.println(" [Lines " + statement.getBegin().get().line 21 | + " - " + statement.getEnd().get().line + " ] " + statement)); 22 | System.out.println(); // empty line 23 | } catch (IOException e) { 24 | throw new RuntimeException(e); 25 | } 26 | }).explore(projectDir); 27 | } 28 | 29 | public static void main(String[] args) { 30 | File projectDir = new File("source_to_parse/junit-master"); 31 | statementsByLine(projectDir); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/tomassetti/support/DirExplorer.java: -------------------------------------------------------------------------------- 1 | package me.tomassetti.support; 2 | 3 | import java.io.File; 4 | 5 | public class DirExplorer { 6 | public interface FileHandler { 7 | void handle(int level, String path, File file); 8 | } 9 | 10 | public interface Filter { 11 | boolean interested(int level, String path, File file); 12 | } 13 | 14 | private FileHandler fileHandler; 15 | private Filter filter; 16 | 17 | public DirExplorer(Filter filter, FileHandler fileHandler) { 18 | this.filter = filter; 19 | this.fileHandler = fileHandler; 20 | } 21 | 22 | public void explore(File root) { 23 | explore(0, "", root); 24 | } 25 | 26 | private void explore(int level, String path, File file) { 27 | if (file.isDirectory()) { 28 | for (File child : file.listFiles()) { 29 | explore(level + 1, path + "/" + child.getName(), child); 30 | } 31 | } else { 32 | if (filter.interested(level, path, file)) { 33 | fileHandler.handle(level, path, file); 34 | } 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/ASimpleClass.java: -------------------------------------------------------------------------------- 1 | package me.tomassetti.examples; 2 | 3 | public class ASimpleClass { 4 | 5 | boolean aField; 6 | 7 | public ASimpleClass(boolean aField) { 8 | this.aField = aField; 9 | } 10 | 11 | public boolean getAField() { 12 | return aField; 13 | } 14 | } 15 | --------------------------------------------------------------------------------