From f6ebe062939d7a92d59d0225cb0db3f2846acaf6 Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 29 Jul 2015 13:43:55 +0100 Subject: [PATCH] Apply eclipse cleanup to add java 6 compliant override annotations --- .../commandline/MutationCoverageReport.java | 21 +- .../commandline/OptionsParser.java | 37 ++- .../mutationtest/commandline/ParseResult.java | 6 +- .../commandline/PluginFilter.java | 2 + .../commandline/OptionsParserTest.java | 97 +++---- .../commandline/PluginFilterTest.java | 22 +- .../report/html/AnnotatedLineFactory.java | 10 +- .../report/html/ConfidenceMap.java | 8 +- .../report/html/HtmlReportFactory.java | 9 +- .../pitest/mutationtest/report/html/Line.java | 6 +- .../mutationtest/report/html/LineStatus.java | 22 +- .../mutationtest/report/html/LineStyle.java | 22 +- .../report/html/MutationGrouping.java | 22 +- .../html/MutationHtmlReportListener.java | 40 +-- .../report/html/MutationResultList.java | 14 +- .../report/html/MutationTestSummaryData.java | 8 +- ...tionTestSummaryDataFileNameComparator.java | 4 +- .../report/html/PackageSummaryData.java | 2 +- .../report/html/PackageSummaryMap.java | 1 - .../report/html/ResultComparator.java | 9 +- .../mutationtest/report/html/SourceFile.java | 23 +- .../org/pitest/maven/DependencyFilter.java | 8 +- .../java/org/pitest/maven/GoalStrategy.java | 13 +- .../maven/MojoToReportOptionsConverter.java | 30 ++- .../maven/PathToJavaClassConverter.java | 5 +- .../main/java/org/pitest/maven/PitMojo.java | 1 + .../java/org/pitest/maven/RunPitStrategy.java | 28 +- .../main/java/org/pitest/maven/ScmMojo.java | 1 + .../main/java/org/pitest/maven/ScmStatus.java | 2 +- .../pitest/maven/SurefireConfigConverter.java | 16 +- .../pitest/maven/report/PitReportMojo.java | 3 + .../report/generator/HTMLReportGenerator.java | 59 +++-- .../generator/ReportGenerationContext.java | 149 ++++++----- .../generator/ReportGenerationManager.java | 107 ++++---- .../generator/ReportGenerationResultEnum.java | 4 +- .../generator/ReportGenerationStrategy.java | 16 +- .../report/generator/XMLReportGenerator.java | 34 +-- .../org/pitest/maven/BasePitMojoTest.java | 26 +- .../org/pitest/maven/DependencyFilterIT.java | 6 +- .../MojoToReportOptionsConverterTest.java | 91 ++++--- .../maven/PathToJavaClassConverterTest.java | 3 +- .../java/org/pitest/maven/PitMojoTest.java | 44 ++-- .../java/org/pitest/maven/ScmMojoTest.java | 36 +-- .../maven/SurefireConfigConverterTest.java | 117 +++++---- .../maven/report/PitReportMojoTest.java | 137 +++++----- .../ReportSourceLocatorParamaterizedTest.java | 87 +++--- .../maven/report/ReportSourceLocatorTest.java | 178 +++++++------ .../generator/HTMLReportGeneratorTest.java | 139 +++++----- .../ReportGenerationManagerTest.java | 207 ++++++++------- .../generator/XMLReportGeneratorTest.java | 61 +++-- .../java/org/pitest/boot/HotSwapAgent.java | 22 +- .../org/pitest/bytecode/FrameOptions.java | 7 +- .../java/org/pitest/bytecode/NullVisitor.java | 22 +- .../java/org/pitest/classinfo/AddlerHash.java | 1 + .../pitest/classinfo/BridgeMethodFilter.java | 25 +- .../classinfo/ClassByteArraySource.java | 24 +- .../java/org/pitest/classinfo/ClassInfo.java | 23 +- .../pitest/classinfo/ClassInfoBuilder.java | 28 +- .../pitest/classinfo/ClassInfoVisitor.java | 24 +- .../java/org/pitest/classinfo/ClassName.java | 17 +- .../org/pitest/classinfo/ClassPointer.java | 8 +- .../pitest/classinfo/ComputeClassWriter.java | 12 +- .../classinfo/MethodFilteringAdapter.java | 22 +- .../org/pitest/classinfo/NameToClassInfo.java | 1 + .../java/org/pitest/classinfo/Repository.java | 9 +- .../pitest/classinfo/TestToClassMapper.java | 22 +- .../classpath/ArchiveClassPathRoot.java | 26 +- .../org/pitest/classpath/ClassFilter.java | 22 +- .../java/org/pitest/classpath/ClassPath.java | 40 +-- .../classpath/ClassPathByteArraySource.java | 29 +- .../org/pitest/classpath/ClassPathRoot.java | 22 +- .../classpath/ClassloaderByteArraySource.java | 23 +- .../java/org/pitest/classpath/CodeSource.java | 12 +- .../classpath/CompoundClassPathRoot.java | 11 +- .../classpath/DirectoryClassPathRoot.java | 28 +- .../OtherClassLoaderClassPathRoot.java | 26 +- .../java/org/pitest/classpath/PathFilter.java | 22 +- .../pitest/classpath/ProjectClassPaths.java | 28 +- .../org/pitest/coverage/BlockCoverage.java | 2 +- .../java/org/pitest/coverage/ClassLine.java | 22 +- .../pitest/coverage/CoverageClassVisitor.java | 36 +-- .../org/pitest/coverage/CoverageData.java | 52 ++-- .../pitest/coverage/CoverageGenerator.java | 6 +- .../org/pitest/coverage/CoverageResult.java | 8 +- .../pitest/coverage/CoverageTransformer.java | 3 +- .../java/org/pitest/coverage/TestInfo.java | 10 +- .../coverage/TestInfoNameComparator.java | 23 +- .../analysis/AbstractCoverageStrategy.java | 39 ++- .../ArrayProbeCoverageMethodVisitor.java | 14 +- .../coverage/analysis/CoverageAnalyser.java | 6 +- .../pitest/coverage/analysis/LineMapper.java | 1 + .../LocalVariableCoverageMethodVisitor.java | 2 +- .../analysis/SimpleBlockCoverageVisitor.java | 38 ++- .../coverage/execute/CoverageDecorator.java | 6 +- .../coverage/execute/CoverageOptions.java | 6 +- .../pitest/coverage/execute/CoveragePipe.java | 9 +- .../coverage/execute/CoverageProcess.java | 2 +- .../coverage/execute/CoverageSlave.java | 5 +- .../coverage/execute/CoverageWorker.java | 10 +- .../execute/DefaultCoverageGenerator.java | 17 +- .../coverage/execute/DependencyFilter.java | 1 + .../coverage/execute/ErrorListener.java | 6 + .../org/pitest/coverage/execute/Receive.java | 18 +- .../org/pitest/coverage/execute/SendData.java | 1 + .../export/DefaultCoverageExporter.java | 10 +- .../coverage/export/NullCoverageExporter.java | 3 +- .../pitest/dependency/DependencyAccess.java | 23 +- .../dependency/DependencyClassVisitor.java | 23 +- .../dependency/DependencyExtractor.java | 15 +- .../pitest/dependency/IgnoreCoreClasses.java | 15 +- .../common/CompoundTestSuiteFinder.java | 1 + .../extension/common/NoTestSuiteFinder.java | 1 + .../extension/common/TestUnitDecorator.java | 24 +- .../main/java/org/pitest/functional/F.java | 22 +- .../main/java/org/pitest/functional/F2.java | 22 +- .../main/java/org/pitest/functional/F3.java | 22 +- .../main/java/org/pitest/functional/F4.java | 22 +- .../main/java/org/pitest/functional/F5.java | 22 +- .../main/java/org/pitest/functional/F6.java | 25 +- .../java/org/pitest/functional/FArray.java | 22 +- .../org/pitest/functional/FCollection.java | 22 +- .../functional/FunctionalCollection.java | 24 +- .../pitest/functional/FunctionalIterable.java | 22 +- .../org/pitest/functional/FunctionalList.java | 22 +- .../org/pitest/functional/MutableList.java | 51 +++- .../java/org/pitest/functional/Option.java | 18 +- .../org/pitest/functional/SideEffect.java | 24 +- .../org/pitest/functional/SideEffect1.java | 22 +- .../org/pitest/functional/SideEffect2.java | 24 +- .../org/pitest/functional/predicate/And.java | 25 +- .../pitest/functional/predicate/False.java | 25 +- .../org/pitest/functional/predicate/Not.java | 25 +- .../org/pitest/functional/predicate/Or.java | 25 +- .../functional/predicate/Predicate.java | 24 +- .../org/pitest/functional/predicate/True.java | 9 +- .../pitest/functional/prelude/Prelude.java | 19 +- .../src/main/java/org/pitest/help/Help.java | 38 +-- .../java/org/pitest/help/PitHelpError.java | 6 +- .../pitest/junit/CompoundTestUnitFinder.java | 1 + .../org/pitest/junit/DescriptionFilter.java | 22 +- .../org/pitest/junit/JUnit4SuiteFinder.java | 7 +- .../junit/JUnitCompatibleConfiguration.java | 16 +- .../JUnitCustomRunnerTestUnitFinder.java | 5 +- .../junit/JUnitTestClassIdentifier.java | 38 +-- .../junit/ParameterisedJUnitTestFinder.java | 24 +- .../pitest/junit/ParameterisedTestFilter.java | 22 +- .../org/pitest/junit/RunnerSuiteFinder.java | 26 +- .../main/java/org/pitest/junit/TestInfo.java | 7 +- .../junit/adapter/AdaptedJUnitTestUnit.java | 13 +- .../junit/adapter/CustomRunnerExecutor.java | 22 +- ...ForeignClassLoaderAdaptingRunListener.java | 22 +- ...oreignClassLoaderCustomRunnerExecutor.java | 27 +- .../mutationtest/ClassMutationResults.java | 2 +- .../pitest/mutationtest/DetectionStatus.java | 12 +- .../pitest/mutationtest/MutationConfig.java | 22 +- .../pitest/mutationtest/MutationMetaData.java | 9 +- .../pitest/mutationtest/MutationResult.java | 6 +- .../MutationResultListenerFactory.java | 6 +- .../mutationtest/MutationStatusMap.java | 26 +- .../mutationtest/MutationStatusTestPair.java | 6 +- .../pitest/mutationtest/SourceLocator.java | 22 +- .../mutationtest/TimeoutLengthStrategy.java | 22 +- .../build/AnalysisPriorityComparator.java | 7 +- .../mutationtest/build/DefaultGrouper.java | 5 +- .../build/DefaultMutationGrouperFactory.java | 2 + .../build/DefaultTestPrioritiser.java | 39 +-- .../build/DefaultTestPrioritiserFactory.java | 2 + .../build/KnownStatusMutationTestUnit.java | 8 +- .../build/MutationAnalysisUnit.java | 2 +- .../mutationtest/build/MutationGrouper.java | 5 +- .../build/MutationGrouperFactory.java | 3 +- .../mutationtest/build/MutationSource.java | 28 +- .../build/MutationTestBuilder.java | 33 ++- .../mutationtest/build/MutationTestUnit.java | 2 + .../PercentAndConstantTimeoutStrategy.java | 7 +- .../build/TestInfoPriorisationComparator.java | 9 +- .../mutationtest/build/TestPrioritiser.java | 9 +- .../build/TestPrioritiserFactory.java | 5 +- .../config/CompoundConfiguration.java | 30 ++- .../config/CompoundListenerFactory.java | 4 + .../config/CompoundTestClassIdentifier.java | 30 ++- .../config/CompoundTestListener.java | 9 +- .../mutationtest/config/ConfigOption.java | 247 +++++++++--------- .../config/ConfigurationFactory.java | 28 +- ...tedDirectoryReportDirCreationStrategy.java | 9 +- .../config/DefaultCodePathPredicate.java | 23 +- .../DefaultDependencyPathPredicate.java | 23 +- .../config/DirectoryResultOutputStrategy.java | 7 +- .../config/LegacyTestFrameworkPlugin.java | 20 +- .../config/PathNamePredicate.java | 23 +- .../mutationtest/config/PluginServices.java | 16 +- .../config/ReportDirCreationStrategy.java | 6 +- .../mutationtest/config/ReportOptions.java | 56 ++-- .../mutationtest/config/SettingsFactory.java | 4 +- .../UndatedReportDirCreationStrategy.java | 3 +- .../pitest/mutationtest/engine/Location.java | 27 +- .../pitest/mutationtest/engine/Mutant.java | 24 +- .../pitest/mutationtest/engine/Mutater.java | 32 ++- .../mutationtest/engine/MutationDetails.java | 71 +++-- .../mutationtest/engine/MutationEngine.java | 35 +-- .../engine/MutationIdentifier.java | 38 +-- .../engine/gregor/AbstractInsnMutator.java | 24 +- .../engine/gregor/AbstractJumpMutator.java | 24 +- .../gregor/AvoidAssertsMethodAdapter.java | 32 +-- .../engine/gregor/ClassContext.java | 27 +- .../mutationtest/engine/gregor/ClassInfo.java | 1 + .../engine/gregor/GregorMutater.java | 33 ++- .../engine/gregor/GregorMutationEngine.java | 11 +- .../engine/gregor/InsnSubstitution.java | 24 +- .../gregor/LineFilterMethodAdapter.java | 2 +- .../gregor/LineTrackingMethodVisitor.java | 22 +- .../engine/gregor/MethodInfo.java | 22 +- .../engine/gregor/MethodMutationContext.java | 11 + .../engine/gregor/MethodMutatorFactory.java | 16 +- .../engine/gregor/MutatingClassVisitor.java | 46 ++-- .../gregor/MutationEngineConfiguration.java | 22 +- .../gregor/PreMutationMethodAnalyzer.java | 1 + .../gregor/TryWithResourcesMethodVisitor.java | 161 ++++++++---- .../engine/gregor/ZeroOperandMutation.java | 22 +- .../analysis/DefaultInstructionCounter.java | 3 +- .../InstructionTrackingMethodVisitor.java | 3 - .../engine/gregor/blocks/BlockCounter.java | 2 +- .../blocks/BlockTrackingMethodDecorator.java | 6 +- .../gregor/blocks/ConcreteBlockCounter.java | 3 + .../DefaultMutationEngineConfiguration.java | 29 +- .../gregor/config/GregorEngineFactory.java | 27 +- .../engine/gregor/config/Mutator.java | 37 ++- .../InlinedFinallyBlockDetector.java | 14 +- .../inlinedcode/NoInlinedCodeDetection.java | 1 + .../mutators/ArgumentPropagationMutator.java | 45 ++-- .../mutators/ArgumentPropagationVisitor.java | 2 +- .../mutators/ConditionalsBoundaryMutator.java | 9 +- .../mutators/ConstructorCallMutator.java | 10 +- .../gregor/mutators/IncrementsMutator.java | 11 +- .../mutators/InlineConstantMutator.java | 21 +- .../gregor/mutators/InvertNegsMutator.java | 9 +- .../engine/gregor/mutators/MathMutator.java | 9 +- .../mutators/MethodCallMethodVisitor.java | 8 +- .../mutators/NegateConditionalsMutator.java | 3 + .../mutators/NonVoidMethodCallMutator.java | 10 +- .../mutators/RemoveConditionalMutator.java | 16 +- .../gregor/mutators/ReturnValsMutator.java | 19 +- .../mutators/VoidMethodCallMutator.java | 10 +- .../experimental/MemberVariableMutator.java | 31 ++- .../experimental/RemoveIncrementsMutator.java | 3 + .../experimental/RemoveSwitchMutator.java | 36 +-- .../experimental/ReturnValuesMutator.java | 29 +- .../mutators/experimental/SwitchMutator.java | 3 + .../CheckTestHasFailedResultListener.java | 13 +- .../execute/DefaultPITClassloader.java | 8 +- .../mutationtest/execute/DefaultReporter.java | 9 +- .../pitest/mutationtest/execute/HotSwap.java | 15 +- .../execute/MutationAnalysisExecutor.java | 49 ++-- .../MutationTestCommunicationThread.java | 8 +- .../execute/MutationTestProcess.java | 3 +- .../execute/MutationTestSlave.java | 7 +- .../execute/MutationTestWorker.java | 6 +- .../execute/MutationTimeoutDecorator.java | 4 +- .../pitest/mutationtest/execute/Reporter.java | 6 +- .../mutationtest/execute/SlaveArguments.java | 6 +- .../execute/TimeOutDecoratedTestSource.java | 9 +- .../execute/TimeOutSystemExitSideEffect.java | 1 + .../filter/CompoundFilterFactory.java | 25 +- .../filter/CompoundMutationFilter.java | 3 +- .../LimitNumberOfMutationPerClassFilter.java | 24 +- ...umberOfMutationsPerClassFilterFactory.java | 14 +- .../mutationtest/filter/MutationFilter.java | 22 +- .../filter/MutationFilterFactory.java | 27 +- .../filter/UnfilteredMutationFilter.java | 23 +- .../incremental/DefaultCodeHistory.java | 3 + .../incremental/FileWriterFactory.java | 2 + .../incremental/HistoryListener.java | 3 + .../incremental/IncrementalAnalyser.java | 4 +- .../incremental/NullWriterFactory.java | 2 + .../incremental/XStreamHistoryStore.java | 7 +- .../BendJavassistToMyWillTransformer.java | 9 +- ...vassistInputStreamInterceptorAdapater.java | 6 +- .../mocksupport/JavassistInterceptor.java | 8 +- .../report/csv/CSVReportFactory.java | 9 +- .../report/csv/CSVReportListener.java | 11 +- .../report/xml/XMLReportFactory.java | 9 +- .../report/xml/XMLReportListener.java | 12 +- .../statistics/MutationStatistics.java | 29 +- .../MutationStatisticsListener.java | 28 +- .../pitest/mutationtest/statistics/Score.java | 24 +- .../mutationtest/statistics/StatusCount.java | 22 +- .../tooling/DirectorySourceLocator.java | 9 +- .../mutationtest/tooling/EntryPoint.java | 30 +-- .../tooling/JarCreatingJarFinder.java | 13 +- .../tooling/KnownLocationJavaAgentFinder.java | 2 + .../tooling/MutationCoverage.java | 58 ++-- .../tooling/SmartSourceLocator.java | 26 +- .../mutationtest/tooling/SpinnerListener.java | 5 +- .../verify/DefaultBuildVerifier.java | 9 +- .../pitest/plugin/ClientClasspathPlugin.java | 4 +- .../pitest/plugin/ToolClasspathPlugin.java | 2 +- .../process/DefaultJavaExecutableLocator.java | 1 + .../java/org/pitest/process/JavaAgent.java | 6 +- .../java/org/pitest/process/JavaProcess.java | 23 +- .../KnownLocationJavaExecutableLocator.java | 3 +- .../org/pitest/process/LaunchOptions.java | 12 +- .../java/org/pitest/process/ProcessArgs.java | 10 +- .../org/pitest/process/WrappingProcess.java | 71 +++-- .../pitest/reflection/IsAnnotatedWith.java | 25 +- .../org/pitest/reflection/Reflection.java | 9 +- .../org/pitest/testapi/AbstractTestUnit.java | 26 +- .../testapi/BaseTestClassIdentifier.java | 3 +- .../org/pitest/testapi/Configuration.java | 6 +- .../java/org/pitest/testapi/Description.java | 11 +- .../org/pitest/testapi/ResultCollector.java | 22 +- .../pitest/testapi/TestClassIdentifier.java | 6 +- .../org/pitest/testapi/TestGroupConfig.java | 22 +- .../java/org/pitest/testapi/TestListener.java | 24 +- .../java/org/pitest/testapi/TestResult.java | 25 +- .../org/pitest/testapi/TestSuiteFinder.java | 22 +- .../java/org/pitest/testapi/TestUnit.java | 24 +- .../org/pitest/testapi/TestUnitFinder.java | 6 +- .../org/pitest/testapi/TestUnitState.java | 22 +- .../org/pitest/testapi/execute/Container.java | 22 +- .../execute/ExitingResultCollector.java | 27 +- .../testapi/execute/MultipleTestGroup.java | 6 +- .../org/pitest/testapi/execute/Pitest.java | 6 +- .../pitest/testapi/execute/ResultType.java | 34 ++- .../containers/ConcreteResultCollector.java | 29 +- .../execute/containers/UnContainer.java | 23 +- .../testapi/foreignclassloader/Events.java | 4 +- .../testapi/foreignclassloader/Fail.java | 23 +- .../testapi/foreignclassloader/Skipped.java | 23 +- .../testapi/foreignclassloader/Start.java | 23 +- .../testapi/foreignclassloader/Success.java | 23 +- .../ForeignClassLoaderAdaptingListener.java | 77 +++--- .../ForeignClassLoaderTestNGExecutor.java | 16 +- .../java/org/pitest/testng/TestNGAdapter.java | 29 +- .../pitest/testng/TestNGConfiguration.java | 28 +- .../testng/TestNGTestClassIdentifier.java | 25 +- .../org/pitest/testng/TestNGTestUnit.java | 36 +-- .../pitest/testng/TestNGTestUnitFinder.java | 25 +- .../org/pitest/util/CommandLineMessage.java | 22 +- .../org/pitest/util/CommunicationThread.java | 6 +- .../main/java/org/pitest/util/ExitCode.java | 22 +- .../main/java/org/pitest/util/Functions.java | 11 +- .../src/main/java/org/pitest/util/Glob.java | 24 +- pitest/src/main/java/org/pitest/util/Id.java | 8 +- .../pitest/util/InputStreamLineIterable.java | 32 ++- .../java/org/pitest/util/IsolationUtils.java | 27 +- pitest/src/main/java/org/pitest/util/Log.java | 2 +- .../java/org/pitest/util/MemoryWatchdog.java | 22 +- .../main/java/org/pitest/util/PitError.java | 39 +-- .../java/org/pitest/util/PitXmlDriver.java | 22 +- .../java/org/pitest/util/ReceiveStrategy.java | 6 +- .../org/pitest/util/ResultOutputStrategy.java | 6 +- .../org/pitest/util/SafeDataInputStream.java | 6 +- .../org/pitest/util/SafeDataOutputStream.java | 6 +- .../java/org/pitest/util/ServiceLoader.java | 2 +- .../java/org/pitest/util/SocketFinder.java | 6 +- .../pitest/util/SocketReadingCallable.java | 1 + .../java/org/pitest/util/StreamMonitor.java | 24 +- .../main/java/org/pitest/util/StringUtil.java | 22 +- .../main/java/org/pitest/util/TimeSpan.java | 22 +- .../main/java/org/pitest/util/Timings.java | 24 +- .../main/java/org/pitest/util/Unchecked.java | 6 +- .../java/sun/pitest/CodeCoverageStore.java | 43 +-- .../main/java/sun/pitest/InvokeReceiver.java | 8 +- .../CoveredButOnlyPartiallyTested.java | 6 +- .../CoveredButOnlyPartiallyTestedTest.java | 6 +- .../java/com/example/CoveredByEasyMock.java | 6 +- .../java/com/example/CoveredByJMockit.java | 6 +- .../test/java/com/example/EasyMockTest.java | 6 +- .../java/com/example/FullyCoveredTestee.java | 22 +- .../com/example/HasExcludedMethodsTestee.java | 22 +- .../example/HasExcludedMethodsTesteeTest.java | 22 +- .../example/HasMutableStaticInitializer.java | 22 +- .../HasMutableStaticInitializerTest.java | 22 +- .../java/com/example/KeepAliveThread.java | 29 +- .../java/com/example/KeepAliveThreadTest.java | 28 +- .../com/example/LineNumbersSpanBlocks.java | 23 +- .../example/LoadsResourcesFromClassPath.java | 2 +- .../java/com/example/MockitoRunnerTest.java | 6 +- .../java/com/example/MultipleMutations.java | 22 +- .../com/example/PartiallyCoveredTestee.java | 22 +- .../example/PartiallyCoveredTesteeTest.java | 22 +- .../src/test/java/com/example/TheoryTest.java | 22 +- .../TestThrowsExceptionInFinallyBlock.java | 2 +- .../ThrowsExceptionFromLargeMethodTestee.java | 64 ++--- .../execute/samples/simple/Testee.java | 1 + .../simple/TesteeWithComplexConstructors.java | 8 +- .../TesteeWithComplexConstructorsTest.java | 7 +- .../simple/TestsForMultiBlockCoverage.java | 16 +- .../com/example/testhasignores/MuteeTest.java | 14 +- .../com/example/testng/AbstractClass.java | 22 +- .../example/testng/AnnotatedAtClassLevel.java | 22 +- .../testng/AnnotatedAtMethodLevel.java | 22 +- .../com/example/testng/AnnotatedBase.java | 22 +- .../test/java/com/example/testng/Fails.java | 26 +- .../testng/FullyCoveredByTestNGTestee.java | 44 ++-- .../FullyCoveredByTestNGTesteeTest.java | 22 +- .../java/com/example/testng/HasGroups.java | 22 +- .../HasOnePassingAndOneFailingMethod.java | 22 +- .../testng/InheritsFromAnnotatedBase.java | 22 +- .../test/java/com/example/testng/Passes.java | 22 +- .../test/java/com/example/testng/Skips.java | 1 - .../com/example/testng/StaticMethods.java | 22 +- .../java/org/pitest/DescriptionMother.java | 6 +- .../org/pitest/TestJUnitConfiguration.java | 29 +- .../org/pitest/bytecode/FrameOptionsTest.java | 22 +- .../pitest/bytecode/MethodDecoratorTest.java | 22 +- .../pitest/classinfo/ClassIdentifierTest.java | 2 +- .../org/pitest/classinfo/ClassInfoMother.java | 8 +- .../org/pitest/classinfo/ClassInfoTest.java | 10 +- .../classinfo/ClassInfoVisitorTest.java | 73 ++++-- .../org/pitest/classinfo/ClassNameTest.java | 12 +- .../classinfo/ComputeClassWriterTest.java | 10 +- .../classinfo/HierarchicalClassIdTest.java | 2 +- .../org/pitest/classinfo/RepositoryTest.java | 7 +- .../classinfo/TestToClassMapperTest.java | 31 ++- .../classpath/ArchiveClassPathRootTest.java | 23 +- .../org/pitest/classpath/ClassPathTest.java | 25 +- .../org/pitest/classpath/CodeSourceTest.java | 23 +- .../classpath/CompoundClassPathRootTest.java | 7 +- .../classpath/DirectoryClassPathRootTest.java | 1 - .../OtherClassLoaderClassPathRootTest.java | 23 +- ...estContainersSendCorrectNotifications.java | 9 +- .../pitest/coverage/BlockLocationTest.java | 2 +- .../org/pitest/coverage/ClassLineTest.java | 3 +- .../org/pitest/coverage/CoverageDataTest.java | 146 ++++++----- .../org/pitest/coverage/CoverageMother.java | 29 +- .../pitest/coverage/CoverageResultTest.java | 5 +- .../coverage/CoverageTransformerTest.java | 29 +- .../org/pitest/coverage/TestInfoTest.java | 2 +- .../pitest/coverage/analysis/BlockTest.java | 2 +- .../coverage/codeassist/ClassUtils.java | 2 +- .../codeassist/CoverageClassVisitorTest.java | 4 +- .../coverage/codeassist/LineMapperTest.java | 43 ++- .../coverage/codeassist/samples/Bridge.java | 22 +- .../codeassist/samples/ClassWithAMethod.java | 22 +- .../samples/ClassWithInitialisedField.java | 22 +- .../samples/HasDefaultConstructor.java | 22 +- .../samples/NoDefaultConstructor.java | 22 +- .../execute/CoverageProcessSystemTest.java | 51 ++-- .../execute/DependencyFilterTest.java | 6 +- .../pitest/coverage/execute/ReceiveTest.java | 4 +- .../pitest/coverage/execute/SendDataTest.java | 2 - .../export/DefaultCoverageExporterTest.java | 25 +- .../dependency/DependencyAccessTest.java | 2 +- .../DependencyClassVisitorTest.java | 24 +- .../dependency/DependencyExtractorTest.java | 9 +- .../dependency/IgnoreCoreClassesTest.java | 6 +- .../org/pitest/functional/FArrayTest.java | 8 +- .../pitest/functional/FCollectionTest.java | 13 +- .../pitest/functional/MutableListTest.java | 26 +- .../org/pitest/functional/OptionTest.java | 13 +- .../functional/predicate/FalseTest.java | 2 +- .../pitest/functional/predicate/NotTest.java | 4 +- .../pitest/functional/predicate/TrueTest.java | 2 +- .../functional/prelude/PreludeTest.java | 23 +- .../org/pitest/help/PitHelpErrorTest.java | 6 +- .../pitest/junit/JUnit4SuiteFinderTest.java | 24 +- .../JUnitCustomRunnerTestUnitFinderTest.java | 24 +- .../junit/JUnitTestClassIdentifierTest.java | 58 ++-- .../ParameterisedJUnitTestFinderTest.java | 22 +- .../pitest/junit/RunnerSuiteFinderTest.java | 16 +- .../java/org/pitest/junit/TestInfoTest.java | 8 +- .../adapter/AdaptedJUnitTestUnitTest.java | 23 +- .../adapter/AdaptingRunListenerTest.java | 30 +-- .../adapter/CustomRunnerExecutorTest.java | 22 +- ...ignClassLoaderAdaptingRunListenerTest.java | 27 +- .../mutationtest/DetectionStatusTest.java | 15 +- .../pitest/mutationtest/LocationMother.java | 7 +- .../mutationtest/MetaDataExtractor.java | 10 +- .../java/org/pitest/mutationtest/Mutable.java | 22 +- .../pitest/mutationtest/MutableIncrement.java | 22 +- .../MutationCoverageReportSystemTest.java | 51 ++-- .../mutationtest/MutationMetaDataTest.java | 37 +-- .../mutationtest/MutationResultTest.java | 9 +- .../mutationtest/MutationStatusMapTest.java | 21 +- .../org/pitest/mutationtest/NullAnalyser.java | 4 +- .../pitest/mutationtest/ReportTestBase.java | 31 ++- .../mutationtest/TestMutationTesting.java | 42 ++- .../mutationtest/UnviableClassMutator.java | 9 +- .../build/AnalyisPriorityComparatorTest.java | 2 + .../build/DefaultGrouperTest.java | 3 +- .../build/DefaultTestPrioritiserTest.java | 23 +- .../KnownStatusMutationTestUnitTest.java | 2 +- .../build/MutationSourceTest.java | 7 +- .../build/MutationTestBuilderTest.java | 4 +- .../build/MutationTestUnitTest.java | 12 +- ...PercentAndConstantTimeoutStrategyTest.java | 23 +- .../TestInfoPriorisationComparatorTest.java | 7 +- .../MutationCoverageReportTest.java | 30 +-- .../config/CompoundConfigurationTest.java | 24 +- .../config/CompoundListenerFactoryTest.java | 20 +- .../CompoundTestClassIdentifierTest.java | 25 +- .../config/CompoundTestListenerTest.java | 6 +- .../config/ConfigurationFactoryTest.java | 24 +- .../config/DefaultCodePathPredicateTest.java | 23 +- .../DefaultDependencyPathPredicateTest.java | 23 +- .../config/PathNamePredicateTest.java | 23 +- .../config/PluginServicesTest.java | 19 +- .../config/ReportOptionsTest.java | 22 +- .../config/SettingsFactoryTest.java | 33 ++- .../mutationtest/engine/LocationTest.java | 18 +- .../engine/MutationDetailsMother.java | 32 ++- .../engine/MutationIdentifierTest.java | 62 +++-- .../gregor/AvoidAssertsMethodAdapterTest.java | 10 +- .../engine/gregor/ClassInfoTest.java | 22 +- .../gregor/GregorMutationEngineTest.java | 10 +- .../gregor/LineFilterMethodAdapterTest.java | 2 +- .../engine/gregor/MethodInfoTest.java | 28 +- .../engine/gregor/MutatorTestBase.java | 33 ++- .../engine/gregor/TestGregorMutater.java | 35 +-- .../engine/gregor/TestTryWithResources.java | 74 +++--- .../InstructionTrackingMethodVisitorTest.java | 17 +- .../engine/gregor/config/MutatorTest.java | 26 +- .../ArgumentPropagationMutatorTest.java | 151 ++++++----- .../ConditionalsBoundaryMutatorTest.java | 14 +- .../mutators/ConstructorCallMutatorTest.java | 25 +- .../mutators/IncrementsMutatorTest.java | 23 +- .../mutators/InlineConstantMutatorTest.java | 37 ++- .../mutators/InvertNegsMutatorTest.java | 32 +-- .../gregor/mutators/MathMutatorTest.java | 54 +++- .../NegateConditionalsMutatorTest.java | 22 +- .../NonVoidMethodCallMutatorTest.java | 34 ++- .../RemoveConditionalMutatorTest.java | 52 ++-- .../mutators/ReturnValsMutatorTest.java | 28 +- .../mutators/VoidMethodCallMutatorTest.java | 27 +- .../MemberVariableMutatorTest.java | 45 ++-- .../mutators/experimental/MutantStarter.java | 31 +-- .../experimental/MutantStarterTest.java | 28 +- .../RemoveIncrementsMutatorTest.java | 26 +- .../experimental/RemoveSwitchMutatorTest.java | 64 +++-- .../experimental/ReturnValuesMutatorTest.java | 17 +- .../experimental/SwitchMutatorTest.java | 19 +- .../CheckTestHasFailedResultListenerTest.java | 8 +- .../execute/DefaultReporterTest.java | 7 +- .../execute/MutationTestSlaveTest.java | 5 +- .../execute/MutationTestWorkerTest.java | 14 +- .../execute/MutationTimeoutDecoratorTest.java | 23 +- .../TimeOutDecoratedTestSourceTest.java | 26 +- .../TimeOutSystemExitSideEffectTest.java | 6 +- ...mitNumberOfMutationPerClassFilterTest.java | 24 +- ...rOfMutationsPerClassFilterFactoryTest.java | 14 +- .../incremental/DefaultCodeHistoryTest.java | 5 +- .../incremental/FileWriterFactoryTest.java | 70 ++--- .../incremental/IncrementalAnalyserTest.java | 16 +- .../incremental/NullHistoryStore.java | 5 + .../incremental/XStreamHistoryStoreTest.java | 16 +- .../InstrumentedMutationTestUnitTest.java | 22 +- ...istInputStreamInterceptorAdapaterTest.java | 11 +- .../report/MutationTestResultMother.java | 14 +- .../report/csv/CSVReportListenerTest.java | 6 +- .../report/xml/XMLReportListenerTest.java | 6 +- .../MutationStatisticsListenerTest.java | 23 +- .../statistics/MutationStatisticsTest.java | 23 +- .../mutationtest/statistics/ScoreTest.java | 23 +- .../tooling/DirectorySourceLocatorTest.java | 11 +- .../tooling/JarCreatingJarFinderTest.java | 17 +- .../tooling/SpinnerListenerTest.java | 1 - .../verify/DefaultBuildVerifierTest.java | 6 +- ...nownLocationJavaExecutableLocatorTest.java | 5 +- .../pitest/process/WrappingProcessTest.java | 30 +-- .../org/pitest/reflection/ReflectionTest.java | 9 +- .../simpletest/BasicTestUnitFinder.java | 15 +- .../CanNotCreateTestClassException.java | 8 +- .../simpletest/ConfigurationForTesting.java | 18 +- .../org/pitest/simpletest/EqualitySet.java | 25 +- .../pitest/simpletest/EqualitySetTest.java | 1 + .../pitest/simpletest/EqualityStrategy.java | 22 +- .../ExcludedPrefixIsolationStrategy.java | 23 +- .../simpletest/InstantiationStrategy.java | 22 +- .../pitest/simpletest/IsolationStrategy.java | 24 +- .../org/pitest/simpletest/MethodFinder.java | 22 +- ...oArgsConstructorInstantiationStrategy.java | 26 +- ...sConstructorInstantiationStrategyTest.java | 24 +- .../simpletest/SignatureEqualityStrategy.java | 23 +- .../SignatureEqualityStrategyTest.java | 3 + .../pitest/simpletest/SteppedTestUnit.java | 24 +- .../simpletest/TestExecutionException.java | 22 +- .../org/pitest/simpletest/TestMethod.java | 22 +- .../java/org/pitest/simpletest/TestStep.java | 22 +- .../org/pitest/simpletest/Transformation.java | 22 +- .../simpletest/TransformingClassLoader.java | 6 +- .../org/pitest/simpletest/steps/CallStep.java | 25 +- .../steps/NoArgsInstantiateStep.java | 25 +- .../steps/NoArgsInstantiateStepTest.java | 6 +- .../org/pitest/testapi/DescriptionTest.java | 1 - .../execute/ExitingResultCollectorTest.java | 7 +- .../execute/MultipleTestGroupTest.java | 11 +- .../testapi/execute/ResultTypeTest.java | 27 +- .../pitest/testapi/execute/TestPitest.java | 30 +-- .../org/pitest/testng/TestNGAdapterTest.java | 26 +- .../testng/TestNGConfigurationTest.java | 22 +- .../testng/TestNGTestClassIdentifierTest.java | 22 +- .../testng/TestNGTestUnitFinderTest.java | 24 +- .../org/pitest/testng/TestNGTestUnitTest.java | 54 ++-- .../java/org/pitest/util/FunctionsTest.java | 6 +- .../util/InputStreamLineIterableTest.java | 23 +- .../org/pitest/util/IsolationUtilsTest.java | 52 ++-- .../java/org/pitest/util/NullJavaAgent.java | 8 +- .../util/ResourceFolderByteArraySource.java | 5 + .../pitest/util/SafeDataInputStreamTest.java | 6 +- .../org/pitest/util/ServiceLoaderTest.java | 2 +- .../org/pitest/util/SocketFinderTest.java | 6 +- .../java/org/pitest/util/StringUtilTest.java | 33 +-- .../java/org/pitest/util/TimeSpanTest.java | 22 +- .../sun/pitest/CodeCoverageStoreTest.java | 43 ++- 605 files changed, 6948 insertions(+), 5732 deletions(-) diff --git a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/MutationCoverageReport.java b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/MutationCoverageReport.java index db238cbe2..fb850a992 100644 --- a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/MutationCoverageReport.java +++ b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/MutationCoverageReport.java @@ -14,6 +14,8 @@ */ package org.pitest.mutationtest.commandline; +import java.util.HashMap; + import org.pitest.coverage.CoverageSummary; import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.config.ReportOptions; @@ -23,8 +25,6 @@ import org.pitest.mutationtest.tooling.EntryPoint; import org.pitest.util.Unchecked; -import java.util.HashMap; - /** * Entry point for command line interface */ @@ -44,8 +44,10 @@ public static void main(final String[] args) { final CombinedStatistics stats = runReport(data, plugins); - throwErrorIfScoreBelowCoverageThreshold(stats.getCoverageSummary(), data.getCoverageThreshold()); - throwErrorIfScoreBelowMutationThreshold(stats.getMutationStatistics(), data.getMutationThreshold()); + throwErrorIfScoreBelowCoverageThreshold(stats.getCoverageSummary(), + data.getCoverageThreshold()); + throwErrorIfScoreBelowMutationThreshold(stats.getMutationStatistics(), + data.getMutationThreshold()); } } @@ -53,9 +55,8 @@ public static void main(final String[] args) { private static void throwErrorIfScoreBelowCoverageThreshold( CoverageSummary stats, int threshold) { if ((threshold != 0) && (stats.getCoverage() < threshold)) { - throw new RuntimeException("Line coverage of " - + stats.getCoverage() + " is below threshold of " - + threshold); + throw new RuntimeException("Line coverage of " + stats.getCoverage() + + " is below threshold of " + threshold); } } @@ -68,10 +69,12 @@ private static void throwErrorIfScoreBelowMutationThreshold( } } - private static CombinedStatistics runReport(ReportOptions data, PluginServices plugins) { + private static CombinedStatistics runReport(ReportOptions data, + PluginServices plugins) { EntryPoint e = new EntryPoint(); - AnalysisResult result = e.execute(null, data, plugins,new HashMap()); + AnalysisResult result = e.execute(null, data, plugins, + new HashMap()); if (result.getError().hasSome()) { throw Unchecked.translateCheckedException(result.getError().value()); } diff --git a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/OptionsParser.java b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/OptionsParser.java index 1200d44dc..c14e65aac 100644 --- a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/OptionsParser.java +++ b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/OptionsParser.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -111,7 +111,7 @@ public class OptionsParser { private final ArgumentAcceptingOptionSpec exportLineCoverageSpec; private final OptionSpec javaExecutable; private final OptionSpec pluginPropertiesSpec; - + private final ArgumentAcceptingOptionSpec includeLaunchClasspathSpec; public OptionsParser(Predicate dependencyFilter) { @@ -124,14 +124,13 @@ public OptionsParser(Predicate dependencyFilter) { this.reportDirSpec = parserAccepts(REPORT_DIR).withRequiredArg() .describedAs("directory to create report folder in").required(); - this.targetClassesSpec = parserAccepts(TARGET_CLASSES) .withRequiredArg() .ofType(String.class) .withValuesSeparatedBy(',') .describedAs( "comma separated list of filters to match against classes to test") - .required(); + .required(); this.avoidCallsSpec = parserAccepts(AVOID_CALLS) .withRequiredArg() @@ -236,7 +235,7 @@ public OptionsParser(Predicate dependencyFilter) { .withValuesSeparatedBy(',') .describedAs( "comma separated list of listeners to receive mutation results") - .defaultsTo("HTML"); + .defaultsTo("HTML"); this.additionalClassPathSpec = parserAccepts(CLASSPATH).withRequiredArg() .ofType(String.class).withValuesSeparatedBy(',') @@ -266,7 +265,7 @@ public OptionsParser(Predicate dependencyFilter) { .ofType(Integer.class) .describedAs( "Maximum number of mutations to include within a single unit of analysis") - .defaultsTo(MUTATION_UNIT_SIZE.getDefault(Integer.class)); + .defaultsTo(MUTATION_UNIT_SIZE.getDefault(Integer.class)); this.historyInputSpec = parserAccepts(HISTORY_INPUT_LOCATION) .withRequiredArg().ofType(File.class) @@ -292,9 +291,9 @@ public OptionsParser(Predicate dependencyFilter) { this.javaExecutable = parserAccepts(JVM_PATH).withRequiredArg() .ofType(String.class).describedAs("path to java executable"); - - this.pluginPropertiesSpec = parserAccepts(PLUGIN_CONFIGURATION).withRequiredArg() - .ofType(KeyValuePair.class) + + this.pluginPropertiesSpec = parserAccepts(PLUGIN_CONFIGURATION) + .withRequiredArg().ofType(KeyValuePair.class) .describedAs("custom plugin properties"); } @@ -316,7 +315,7 @@ public ParseResult parse(final String[] args) { /** * Creates a new ParseResult object using the command line arguments. - * + * * @param data * the ReportOptions to populate. * @param userArgs @@ -369,7 +368,8 @@ private ParseResult parseCommandLine(final ReportOptions data, data.setMutationThreshold(this.mutationThreshHoldSpec.value(userArgs)); data.setCoverageThreshold(this.coverageThreshHoldSpec.value(userArgs)); data.setMutationEngine(this.mutationEngine.value(userArgs)); - data.setFreeFormProperties(listToProperties(this.pluginPropertiesSpec.values(userArgs))); + data.setFreeFormProperties(listToProperties(this.pluginPropertiesSpec + .values(userArgs))); data.setExportLineCoverage(userArgs.has(this.exportLineCoverageSpec) && userArgs.valueOf(this.exportLineCoverageSpec)); @@ -392,25 +392,24 @@ private void setClassPath(final OptionSet userArgs, final ReportOptions data) { if (data.isIncludeLaunchClasspath()) { elements.addAll(ClassPath.getClassPathElementsAsPaths()); } else { - elements.addAll(FCollection.filter(ClassPath.getClassPathElementsAsPaths(), - dependencyFilter)); + elements.addAll(FCollection.filter( + ClassPath.getClassPathElementsAsPaths(), this.dependencyFilter)); } elements.addAll(userArgs.valuesOf(this.additionalClassPathSpec)); data.setClassPathElements(elements); } - private void setTestGroups(final OptionSet userArgs, - final ReportOptions data) { + private void setTestGroups(final OptionSet userArgs, final ReportOptions data) { final TestGroupConfig conf = new TestGroupConfig( this.excludedGroupsSpec.values(userArgs), this.includedGroupsSpec.values(userArgs)); data.setGroupConfig(conf); } - + private Properties listToProperties(List kvps) { Properties p = new Properties(); - for ( KeyValuePair kvp : kvps) { + for (KeyValuePair kvp : kvps) { p.put(kvp.key, kvp.value); } return p; diff --git a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/ParseResult.java b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/ParseResult.java index 371d2791b..0449ea2e0 100644 --- a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/ParseResult.java +++ b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/ParseResult.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/PluginFilter.java b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/PluginFilter.java index d47f58a78..9d191eeda 100644 --- a/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/PluginFilter.java +++ b/pitest-command-line/src/main/java/org/pitest/mutationtest/commandline/PluginFilter.java @@ -24,6 +24,7 @@ public PluginFilter(final PluginServices plugin) { private static F classToLocation() { return new F() { + @Override public String apply(final ClientClasspathPlugin a) { try { return new File(a.getClass().getProtectionDomain().getCodeSource() @@ -42,6 +43,7 @@ private PitError createPitErrorForExceptionOnClass(final Exception ex, }; } + @Override public Boolean apply(final String a) { return this.includedClassPathElement.contains(a); } diff --git a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java index 369656916..dd428e88e 100644 --- a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java +++ b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -45,21 +45,20 @@ public class OptionsParserTest { - private static final String JAVA_PATH_SEPARATOR = "/"; + private static final String JAVA_PATH_SEPARATOR = "/"; private static final String JAVA_CLASS_PATH_PROPERTY = "java.class.path"; - private OptionsParser testee; - - @Mock - private Predicate filter; + private OptionsParser testee; + @Mock + private Predicate filter; @Before public void setUp() { MockitoAnnotations.initMocks(this); - when(filter.apply(any(String.class))).thenReturn(true); - this.testee = new OptionsParser(filter); + when(this.filter.apply(any(String.class))).thenReturn(true); + this.testee = new OptionsParser(this.filter); } @Test @@ -103,8 +102,10 @@ public void shouldParseCommaSeparatedListOfJVMArgs() { @Test public void shouldParseCommaSeparatedListOfMutationOperators() { final ReportOptions actual = parseAddingRequiredArgs("--mutators", - ConditionalsBoundaryMutator.CONDITIONALS_BOUNDARY_MUTATOR.name() + "," + MathMutator.MATH_MUTATOR.name()); - assertEquals(Arrays.asList(ConditionalsBoundaryMutator.CONDITIONALS_BOUNDARY_MUTATOR.name(), + ConditionalsBoundaryMutator.CONDITIONALS_BOUNDARY_MUTATOR.name() + "," + + MathMutator.MATH_MUTATOR.name()); + assertEquals(Arrays.asList( + ConditionalsBoundaryMutator.CONDITIONALS_BOUNDARY_MUTATOR.name(), MathMutator.MATH_MUTATOR.name()), actual.getMutators()); } @@ -270,9 +271,8 @@ public void shouldDefaultToHtmlReportWhenNoOutputFormatsSpecified() { public void shouldParseCommaSeparatedListOfOutputFormatsWhenSupplied() { final ReportOptions actual = parseAddingRequiredArgs("--outputFormats", "HTML,CSV"); - assertEquals( - new HashSet(Arrays.asList("HTML", - "CSV")), actual.getOutputFormats()); + assertEquals(new HashSet(Arrays.asList("HTML", "CSV")), + actual.getOutputFormats()); } @Test @@ -306,16 +306,16 @@ public void shouldParseCommaSeparatedListOfMutableCodePaths() { @Test public void shouldParseCommaSeparatedListOfExcludedTestGroups() { - final ReportOptions actual = parseAddingRequiredArgs( - "--excludedGroups", "foo,bar"); + final ReportOptions actual = parseAddingRequiredArgs("--excludedGroups", + "foo,bar"); assertEquals(Arrays.asList("foo", "bar"), actual.getGroupConfig() .getExcludedGroups()); } @Test public void shouldParseCommaSeparatedListOfIncludedTestGroups() { - final ReportOptions actual = parseAddingRequiredArgs( - "--includedGroups", "foo,bar"); + final ReportOptions actual = parseAddingRequiredArgs("--includedGroups", + "foo,bar"); assertEquals(Arrays.asList("foo", "bar"), actual.getGroupConfig() .getIncludedGroups()); } @@ -362,7 +362,7 @@ public void shouldParseMutationThreshold() { "42"); assertEquals(42, actual.getMutationThreshold()); } - + @Test public void shouldParseCoverageThreshold() { final ReportOptions actual = parseAddingRequiredArgs("--coverageThreshold", @@ -376,28 +376,25 @@ public void shouldDefaultToGregorEngineWhenNoOptionSupplied() { assertEquals("gregor", actual.getMutationEngine()); } - @Test public void shouldParseMutationEnigne() { final ReportOptions actual = parseAddingRequiredArgs("--mutationEngine", "foo"); assertEquals("foo", actual.getMutationEngine()); } - - + @Test public void shouldDefaultJVMToNull() { final ReportOptions actual = parseAddingRequiredArgs(); assertEquals(null, actual.getJavaExecutable()); } - + @Test public void shouldParseJVM() { - final ReportOptions actual = parseAddingRequiredArgs("--jvmPath", - "foo"); + final ReportOptions actual = parseAddingRequiredArgs("--jvmPath", "foo"); assertEquals("foo", actual.getJavaExecutable()); } - + @Test public void shouldParseExportLineCoverageFlag() { final ReportOptions actual = parseAddingRequiredArgs("--exportLineCoverage"); @@ -409,20 +406,19 @@ public void shouldNotExportLineCoverageWhenFlagNotSet() { final ReportOptions actual = parseAddingRequiredArgs(""); assertFalse(actual.shouldExportLineCoverage()); } - + @Test public void shouldIncludeLaunchClasspathByDefault() { final ReportOptions actual = parseAddingRequiredArgs(""); assertTrue(actual.isIncludeLaunchClasspath()); } - + @Test public void shouldNotIncludeLaunchClasspathWhenFlagUnset() { final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=false"); assertFalse(actual.isIncludeLaunchClasspath()); } - - + @Test public void shouldIncludeLaunchClasspathWhenFlag() { final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=true"); @@ -433,49 +429,54 @@ public void shouldIncludeLaunchClasspathWhenFlag() { public void shouldHandleNotCanonicalLaunchClasspathElements() { final String oldClasspath = System.getProperty(JAVA_CLASS_PATH_PROPERTY); try { - //given + // given final PluginServices plugins = PluginServices.makeForContextLoader(); this.testee = new OptionsParser(new PluginFilter(plugins)); - //and - System.setProperty(JAVA_CLASS_PATH_PROPERTY, getNonCanonicalGregorEngineClassPath()); - //when + // and + System.setProperty(JAVA_CLASS_PATH_PROPERTY, + getNonCanonicalGregorEngineClassPath()); + // when final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=false"); - //then + // then assertThat(actual.getClassPath().findClasses(gregorClass())).hasSize(1); } finally { System.setProperty(JAVA_CLASS_PATH_PROPERTY, oldClasspath); } } - + @Test public void shouldCreateEmptyPluginPropertiesWhenNoneSupplied() { final ReportOptions actual = parseAddingRequiredArgs(""); assertNotNull(actual.getFreeFormProperties()); } - + @Test public void shouldIncludePluginPropertyValuesWhenSingleKey() { final ReportOptions actual = parseAddingRequiredArgs("-pluginConfiguration=foo=1"); - assertEquals("1",actual.getFreeFormProperties().getProperty("foo")); + assertEquals("1", actual.getFreeFormProperties().getProperty("foo")); } @Test public void shouldIncludePluginPropertyValuesWhenMultipleKeys() { - final ReportOptions actual = parseAddingRequiredArgs("-pluginConfiguration=foo=1", "-pluginConfiguration=bar=2"); - assertEquals("1",actual.getFreeFormProperties().getProperty("foo")); - assertEquals("2",actual.getFreeFormProperties().getProperty("bar")); + final ReportOptions actual = parseAddingRequiredArgs( + "-pluginConfiguration=foo=1", "-pluginConfiguration=bar=2"); + assertEquals("1", actual.getFreeFormProperties().getProperty("foo")); + assertEquals("2", actual.getFreeFormProperties().getProperty("bar")); } - + private String getNonCanonicalGregorEngineClassPath() { - final String gregorEngineClassPath = GregorMutationEngine.class.getProtectionDomain() - .getCodeSource().getLocation().getFile(); - final int lastOccurrenceOfFileSeparator = gregorEngineClassPath.lastIndexOf(JAVA_PATH_SEPARATOR); - return new StringBuilder(gregorEngineClassPath).replace(lastOccurrenceOfFileSeparator, - lastOccurrenceOfFileSeparator + 1, JAVA_PATH_SEPARATOR + "." + JAVA_PATH_SEPARATOR).toString(); + final String gregorEngineClassPath = GregorMutationEngine.class + .getProtectionDomain().getCodeSource().getLocation().getFile(); + final int lastOccurrenceOfFileSeparator = gregorEngineClassPath + .lastIndexOf(JAVA_PATH_SEPARATOR); + return new StringBuilder(gregorEngineClassPath).replace( + lastOccurrenceOfFileSeparator, lastOccurrenceOfFileSeparator + 1, + JAVA_PATH_SEPARATOR + "." + JAVA_PATH_SEPARATOR).toString(); } private Predicate gregorClass() { return new Predicate() { + @Override public Boolean apply(String s) { return GregorMutationEngine.class.getName().equals(s); } diff --git a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/PluginFilterTest.java b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/PluginFilterTest.java index e7aa1b27d..044d7729e 100644 --- a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/PluginFilterTest.java +++ b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/PluginFilterTest.java @@ -3,34 +3,36 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; + import org.junit.Test; import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.engine.gregor.GregorMutationEngine; import org.pitest.mutationtest.report.html.HtmlReportFactory; import org.pitest.util.IsolationUtils; -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; - public class PluginFilterTest { - private PluginFilter testee = new PluginFilter(new PluginServices( - IsolationUtils.getContextClassLoader())); + private final PluginFilter testee = new PluginFilter(new PluginServices( + IsolationUtils.getContextClassLoader())); @Test public void shouldExcludeHtmlReportPlugin() throws Exception { String pluginLocation = getClassLocationAsCanonicalPath(HtmlReportFactory.class); - assertFalse(testee.apply(pluginLocation)); + assertFalse(this.testee.apply(pluginLocation)); } @Test public void shouldIncludeMutationEngine() throws Exception { String pluginLocation = getClassLocationAsCanonicalPath(GregorMutationEngine.class); - assertTrue(testee.apply(pluginLocation)); + assertTrue(this.testee.apply(pluginLocation)); } - private String getClassLocationAsCanonicalPath(Class clazz) throws URISyntaxException, IOException { - return new File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI()).getCanonicalPath(); + private String getClassLocationAsCanonicalPath(Class clazz) + throws URISyntaxException, IOException { + return new File(clazz.getProtectionDomain().getCodeSource().getLocation() + .toURI()).getCanonicalPath(); } } diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/AnnotatedLineFactory.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/AnnotatedLineFactory.java index 7923fb114..c1c8433b2 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/AnnotatedLineFactory.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/AnnotatedLineFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -58,6 +58,7 @@ private F stringToAnnotatedLine() { return new F() { private int lineNumber = 1; + @Override public Line apply(final String a) { final Line l = new Line(this.lineNumber, StringUtil.escapeBasicHtmlChars(a), lineCovered(this.lineNumber), @@ -76,6 +77,7 @@ private List getMutationsForLine(final int lineNumber) { private F isAtLineNumber(final int lineNumber) { return new F() { + @Override public Boolean apply(final MutationResult result) { return result.getDetails().getLineNumber() == lineNumber; } @@ -98,6 +100,7 @@ private LineStatus lineCovered(final int line) { private boolean isCodeLine(final int line) { final F predicate = new F() { + @Override public Boolean apply(final ClassInfo a) { return a.isCodeLine(line); } @@ -107,6 +110,7 @@ public Boolean apply(final ClassInfo a) { private boolean isLineCovered(final int line) { final F predicate = new F() { + @Override public Boolean apply(final ClassInfo a) { return !AnnotatedLineFactory.this.statistics.getTestsForClassLine( new ClassLine(a.getName().asInternalName(), line)).isEmpty(); diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ConfidenceMap.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ConfidenceMap.java index 21b108c5f..5534907f8 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ConfidenceMap.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ConfidenceMap.java @@ -7,10 +7,10 @@ class ConfidenceMap { private static final EnumSet HIGH = EnumSet - .of(DetectionStatus.KILLED, - DetectionStatus.SURVIVED, - DetectionStatus.NO_COVERAGE, - DetectionStatus.NON_VIABLE); + .of(DetectionStatus.KILLED, + DetectionStatus.SURVIVED, + DetectionStatus.NO_COVERAGE, + DetectionStatus.NON_VIABLE); public static boolean hasHighConfidence(final DetectionStatus status) { return HIGH.contains(status); diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/HtmlReportFactory.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/HtmlReportFactory.java index 5e9022f6c..f7d2b13b3 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/HtmlReportFactory.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/HtmlReportFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,6 +23,7 @@ public class HtmlReportFactory implements MutationResultListenerFactory { + @Override public MutationResultListener getListener(Properties props, ListenerArguments args) { return new MutationHtmlReportListener(args.getCoverage(), @@ -30,10 +31,12 @@ public MutationResultListener getListener(Properties props, args.getLocator()); } + @Override public String name() { return "HTML"; } + @Override public String description() { return "Default html report plugin"; } diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/Line.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/Line.java index 40f31878a..b2f776ccf 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/Line.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/Line.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStatus.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStatus.java index 939ad58ff..17b66f77e 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStatus.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStatus.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.report.html; diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStyle.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStyle.java index 79d4a2972..929d486ad 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStyle.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/LineStyle.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.report.html; diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationGrouping.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationGrouping.java index bc00f2d78..772c35ae6 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationGrouping.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationGrouping.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.report.html; diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationHtmlReportListener.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationHtmlReportListener.java index 159298b34..ed6fce7b3 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationHtmlReportListener.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationHtmlReportListener.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,11 +52,11 @@ public class MutationHtmlReportListener implements MutationResultListener { private final CoverageDatabase coverage; private final Set mutatorNames; - private final String css; + private final String css; public MutationHtmlReportListener(final CoverageDatabase coverage, - final ResultOutputStrategy outputStrategy, Collection mutatorNames, - final SourceLocator... locators) { + final ResultOutputStrategy outputStrategy, + Collection mutatorNames, final SourceLocator... locators) { this.coverage = coverage; this.outputStrategy = outputStrategy; this.sourceRoots = new HashSet(Arrays.asList(locators)); @@ -66,9 +66,8 @@ public MutationHtmlReportListener(final CoverageDatabase coverage, private String loadCss() { try { - return FileUtil.readToString(IsolationUtils - .getContextClassLoader().getResourceAsStream( - "templates/mutation/style.css")); + return FileUtil.readToString(IsolationUtils.getContextClassLoader() + .getResourceAsStream("templates/mutation/style.css")); } catch (IOException e) { Log.getLogger().log(Level.SEVERE, "Error while loading css", e); } @@ -87,7 +86,7 @@ private void generateAnnotatedSourceFile( final StringTemplateGroup group = new StringTemplateGroup("mutation_test"); final StringTemplate st = group .getInstanceOf("templates/mutation/mutation_report"); - st.setAttribute("css", css); + st.setAttribute("css", this.css); st.setAttribute("tests", mutationMetaData.getTests()); @@ -109,16 +108,17 @@ private void generateAnnotatedSourceFile( private PackageSummaryData collectPackageSummaries( final ClassMutationResults mutationMetaData) { final String packageName = mutationMetaData.getPackageName(); - + return this.packageSummaryData.update(packageName, - createSummaryData(this.coverage,mutationMetaData)); + createSummaryData(this.coverage, mutationMetaData)); } - + public MutationTestSummaryData createSummaryData( final CoverageDatabase coverage, final ClassMutationResults data) { return new MutationTestSummaryData(data.getFileName(), data.getMutations(), - mutatorNames, coverage.getClassInfo(Collections.singleton(data.getMutatedClass())), - coverage.getNumberOfCoveredLines(Collections.singleton(data.getMutatedClass()))); + this.mutatorNames, coverage.getClassInfo(Collections.singleton(data + .getMutatedClass())), coverage.getNumberOfCoveredLines(Collections + .singleton(data.getMutatedClass()))); } private SourceFile createAnnotatedSourceFile( @@ -139,9 +139,9 @@ private SourceFile createAnnotatedSourceFile( private List createAnnotatedSourceCodeLines(final String sourceFile, final String packageName, final MutationResultList mutationsForThisFile) - throws IOException { - final Collection classes = this.coverage - .getClassesForFile(sourceFile, packageName); + throws IOException { + final Collection classes = this.coverage.getClassesForFile( + sourceFile, packageName); final Option reader = findSourceFile(classInfoToNames(classes), sourceFile); if (reader.hasSome()) { @@ -160,6 +160,7 @@ private Collection classInfoToNames( private F classInfoToJavaName() { return new F() { + @Override public String apply(final ClassInfo a) { return a.getName().asJavaName(); } @@ -227,15 +228,18 @@ private void createPackageIndexPage(final PackageSummaryData psData) { } + @Override public void runStart() { // TODO Auto-generated method stub } + @Override public void runEnd() { createIndexPages(); } + @Override public void handleMutationResult(final ClassMutationResults metaData) { final PackageSummaryData packageData = collectPackageSummaries(metaData); diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationResultList.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationResultList.java index c8a566ae1..e89982c8a 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationResultList.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationResultList.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -61,6 +61,7 @@ public List groupMutationsByLine() { private void sortMutationsIntoLineOrder() { final Comparator c = new Comparator() { + @Override public int compare(final MutationResult o1, final MutationResult o2) { return o1.getDetails().getLineNumber() - o2.getDetails().getLineNumber(); @@ -70,32 +71,39 @@ public int compare(final MutationResult o1, final MutationResult o2) { Collections.sort(this.impl, c); } + @Override public boolean contains(final F predicate) { return FCollection.contains(this.impl, predicate); } + @Override public FunctionalList filter( final F predicate) { return FCollection.filter(this, predicate); } + @Override public FunctionalList flatMap( final F> f) { return FCollection.flatMap(this, f); } + @Override public void forEach(final SideEffect1 e) { FCollection.forEach(this, e); } + @Override public Iterator iterator() { return this.impl.iterator(); } + @Override public FunctionalList map(final F f) { return FCollection.map(this, f); } + @Override public void mapTo(final F f, final Collection bs) { FCollection.mapTo(this, f, bs); diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java index 9613cf812..6e7e0fb50 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -107,6 +107,7 @@ private int getNumberOfLines() { private F2 accumulateCodeLines() { return new F2() { + @Override public Integer apply(final Integer a, final ClassInfo b) { return a + b.getNumberOfCodeLines(); } @@ -131,6 +132,7 @@ private long getNumberOfMutationsDetected() { private F> mutationToTargettedTests() { return new F>() { + @Override public Iterable apply(final MutationResult a) { return a.getDetails().getTestsInOrder(); } diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryDataFileNameComparator.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryDataFileNameComparator.java index 5ee6ee489..a3df47a9a 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryDataFileNameComparator.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryDataFileNameComparator.java @@ -3,12 +3,12 @@ import java.io.Serializable; import java.util.Comparator; - public class MutationTestSummaryDataFileNameComparator implements - Comparator, Serializable { +Comparator, Serializable { private static final long serialVersionUID = 1L; + @Override public int compare(final MutationTestSummaryData arg0, final MutationTestSummaryData arg1) { return arg0.getFileName().compareTo(arg1.getFileName()); diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryData.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryData.java index d0a92f9a6..23faf51ca 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryData.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryData.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Map; - public class PackageSummaryData implements Comparable { private final String packageName; @@ -86,6 +85,7 @@ public boolean equals(final Object obj) { return true; } + @Override public int compareTo(final PackageSummaryData arg0) { return this.packageName.compareTo(arg0.packageName); } diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryMap.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryMap.java index 448679c82..8d3d67d07 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryMap.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/PackageSummaryMap.java @@ -4,7 +4,6 @@ import java.util.Map; import java.util.TreeMap; - public class PackageSummaryMap { private final Map packageSummaryData = new TreeMap(); diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ResultComparator.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ResultComparator.java index d6c2f7340..35cf18f6c 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ResultComparator.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/ResultComparator.java @@ -19,9 +19,10 @@ class ResultComparator implements Comparator, Serializable { - private static final long serialVersionUID = 1L; - private static final EnumMap RANK = new EnumMap(DetectionStatus.class); - + private static final long serialVersionUID = 1L; + private static final EnumMap RANK = new EnumMap( + DetectionStatus.class); + static { RANK.put(KILLED, 4); RANK.put(SURVIVED, 0); @@ -34,7 +35,7 @@ class ResultComparator implements Comparator, Serializable { RANK.put(NO_COVERAGE, 0); } - + @Override public int compare(MutationResult o1, MutationResult o2) { return getRanking(o1.getStatus()) - getRanking(o2.getStatus()); diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/SourceFile.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/SourceFile.java index 0b39c73b7..890de28b0 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/SourceFile.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/SourceFile.java @@ -1,22 +1,21 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.report.html; import java.util.List; - public class SourceFile { private final String fileName; diff --git a/pitest-maven/src/main/java/org/pitest/maven/DependencyFilter.java b/pitest-maven/src/main/java/org/pitest/maven/DependencyFilter.java index 31211f28b..75b8ea261 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/DependencyFilter.java +++ b/pitest-maven/src/main/java/org/pitest/maven/DependencyFilter.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,6 +38,7 @@ public DependencyFilter(PluginServices plugins) { private static F artifactToPair() { return new F() { + @Override public GroupIdPair apply(final ClientClasspathPlugin a) { final Package p = a.getClass().getPackage(); @@ -67,6 +68,7 @@ private void reportBadPlugin(final String missingProperty, }; } + @Override public Boolean apply(final Artifact a) { final GroupIdPair p = new GroupIdPair(a.getGroupId(), a.getArtifactId()); return this.groups.contains(p); diff --git a/pitest-maven/src/main/java/org/pitest/maven/GoalStrategy.java b/pitest-maven/src/main/java/org/pitest/maven/GoalStrategy.java index 250403a3a..5cab06d8d 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/GoalStrategy.java +++ b/pitest-maven/src/main/java/org/pitest/maven/GoalStrategy.java @@ -14,18 +14,17 @@ */ package org.pitest.maven; +import java.io.File; +import java.util.Map; + import org.apache.maven.plugin.MojoExecutionException; import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.config.ReportOptions; import org.pitest.mutationtest.tooling.CombinedStatistics; -import java.io.File; -import java.util.Map; - public interface GoalStrategy { - CombinedStatistics execute(File baseDir, - ReportOptions options, - PluginServices plugins, - Map environmentVariables) throws MojoExecutionException; + CombinedStatistics execute(File baseDir, ReportOptions options, + PluginServices plugins, Map environmentVariables) + throws MojoExecutionException; } diff --git a/pitest-maven/src/main/java/org/pitest/maven/MojoToReportOptionsConverter.java b/pitest-maven/src/main/java/org/pitest/maven/MojoToReportOptionsConverter.java index 3d8dbb897..ea599dccf 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/MojoToReportOptionsConverter.java +++ b/pitest-maven/src/main/java/org/pitest/maven/MojoToReportOptionsConverter.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -58,7 +58,7 @@ public ReportOptions convert() { try { classPath.addAll(this.mojo.getProject().getTestClasspathElements()); } catch (final DependencyResolutionRequiredException e1) { - log.info(e1); + this.log.info(e1); } addOwnDependenciesToClassPath(classPath); @@ -84,7 +84,7 @@ private ReportOptions parseReportOptions(final List classPath) { final ReportOptions data = new ReportOptions(); if (this.mojo.getProject().getBuild() != null) { - log.info("Mutating from " + this.log.info("Mutating from " + this.mojo.getProject().getBuild().getOutputDirectory()); data.setCodePaths(Collections.singleton(this.mojo.getProject().getBuild() .getOutputDirectory())); @@ -147,13 +147,13 @@ private ReportOptions updateFromSurefire(ReportOptions option) { if (!this.mojo.isParseSurefireConfig()) { return option; } else if (plugins.isEmpty()) { - log.warn("Could not find surefire configuration in pom"); + this.log.warn("Could not find surefire configuration in pom"); return option; } Plugin surefire = plugins.iterator().next(); if (surefire != null) { - return surefireConverter.update(option, + return this.surefireConverter.update(option, (Xpp3Dom) surefire.getConfiguration()); } else { return option; @@ -163,12 +163,13 @@ private ReportOptions updateFromSurefire(ReportOptions option) { private Collection lookupPlugin(String key) { @SuppressWarnings("unchecked") - List plugins = mojo.getProject().getBuildPlugins(); + List plugins = this.mojo.getProject().getBuildPlugins(); return FCollection.filter(plugins, hasKey(key)); } private static F hasKey(final String key) { return new F() { + @Override public Boolean apply(Plugin a) { return a.getKey().equals(key); } @@ -187,7 +188,8 @@ private void setTestGroups(final ReportOptions data) { private void addOwnDependenciesToClassPath(final List classPath) { for (final Artifact dependency : filteredDependencies()) { - log.info("Adding " + dependency.getGroupId() + ":" + dependency.getArtifactId() + " to SUT classpath"); + this.log.info("Adding " + dependency.getGroupId() + ":" + + dependency.getArtifactId() + " to SUT classpath"); classPath.add(dependency.getFile().getAbsolutePath()); } } @@ -203,7 +205,7 @@ private Collection> determineTargetTests() { private Collection filteredDependencies() { return FCollection.filter(this.mojo.getPluginArtifactMap().values(), - dependencyFilter); + this.dependencyFilter); } private Collection determineMutators() { @@ -235,6 +237,7 @@ private Collection stringsTofiles(final List sourceRoots) { private F stringToFile() { return new F() { + @Override public File apply(final String a) { return new File(a); } @@ -253,14 +256,13 @@ private Collection determineOutputFormats() { private boolean hasValue(final Collection collection) { return (collection != null) && !collection.isEmpty(); } - + private Properties createPluginProperties() { Properties p = new Properties(); - if (mojo.getPluginProperties() != null) { - p.putAll(mojo.getPluginProperties()); + if (this.mojo.getPluginProperties() != null) { + p.putAll(this.mojo.getPluginProperties()); } return p; } - } diff --git a/pitest-maven/src/main/java/org/pitest/maven/PathToJavaClassConverter.java b/pitest-maven/src/main/java/org/pitest/maven/PathToJavaClassConverter.java index de0ccb3e8..50d1993ec 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/PathToJavaClassConverter.java +++ b/pitest-maven/src/main/java/org/pitest/maven/PathToJavaClassConverter.java @@ -8,12 +8,12 @@ /** * Converts paths to java class names globs if they are within the supplied * source root. Globs include wildcards to catch any inner classes. - * + * * This conversion will not pick up non public, non inner classes defined in a * source file not matching the class name. To cover this corner case would need * to instead scan the byte code on the classpath and see if it had been tagged * with the supplied filenames. - * + * */ class PathToJavaClassConverter implements F> { @@ -23,6 +23,7 @@ class PathToJavaClassConverter implements F> { this.sourceRoot = sourceRoot; } + @Override public Iterable apply(final String a) { final File f = new File(a); final String modifiedFilePath = f.getAbsolutePath(); diff --git a/pitest-maven/src/main/java/org/pitest/maven/PitMojo.java b/pitest-maven/src/main/java/org/pitest/maven/PitMojo.java index 165224f7e..2d00d8637 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/PitMojo.java +++ b/pitest-maven/src/main/java/org/pitest/maven/PitMojo.java @@ -351,6 +351,7 @@ public PitMojo(final GoalStrategy strategy, final Predicate filter, this.plugins = plugins; } + @Override public final void execute() throws MojoExecutionException, MojoFailureException { diff --git a/pitest-maven/src/main/java/org/pitest/maven/RunPitStrategy.java b/pitest-maven/src/main/java/org/pitest/maven/RunPitStrategy.java index 4c55a809f..af5cfc003 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/RunPitStrategy.java +++ b/pitest-maven/src/main/java/org/pitest/maven/RunPitStrategy.java @@ -14,6 +14,9 @@ */ package org.pitest.maven; +import java.io.File; +import java.util.Map; + import org.apache.maven.plugin.MojoExecutionException; import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.config.ReportOptions; @@ -21,23 +24,20 @@ import org.pitest.mutationtest.tooling.CombinedStatistics; import org.pitest.mutationtest.tooling.EntryPoint; -import java.io.File; -import java.util.Map; - public class RunPitStrategy implements GoalStrategy { - public CombinedStatistics execute(File baseDir, - ReportOptions data, - PluginServices plugins, - Map environmentVariables) - throws MojoExecutionException { + @Override + public CombinedStatistics execute(File baseDir, ReportOptions data, + PluginServices plugins, Map environmentVariables) + throws MojoExecutionException { - EntryPoint e = new EntryPoint(); - AnalysisResult result = e.execute(baseDir, data, plugins,environmentVariables); - if ( result.getError().hasSome() ) { - throw new MojoExecutionException("fail", result.getError().value()); - } - return result.getStatistics().value(); + EntryPoint e = new EntryPoint(); + AnalysisResult result = e.execute(baseDir, data, plugins, + environmentVariables); + if (result.getError().hasSome()) { + throw new MojoExecutionException("fail", result.getError().value()); + } + return result.getStatistics().value(); } } diff --git a/pitest-maven/src/main/java/org/pitest/maven/ScmMojo.java b/pitest-maven/src/main/java/org/pitest/maven/ScmMojo.java index a33c68dcd..462fcb219 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/ScmMojo.java +++ b/pitest-maven/src/main/java/org/pitest/maven/ScmMojo.java @@ -168,6 +168,7 @@ private Set makeStatusSet() { private static F stringToMavenScmStatus() { return new F() { + @Override public ScmFileStatus apply(final String a) { return ScmStatus.valueOf(a.toUpperCase()).getStatus(); } diff --git a/pitest-maven/src/main/java/org/pitest/maven/ScmStatus.java b/pitest-maven/src/main/java/org/pitest/maven/ScmStatus.java index de5215870..3929a9e96 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/ScmStatus.java +++ b/pitest-maven/src/main/java/org/pitest/maven/ScmStatus.java @@ -4,7 +4,7 @@ /** * Maps string to maven ScmFileStatus constants. - * + * * Descriptions copied from maven scm source. */ public enum ScmStatus { diff --git a/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java b/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java index 8469c4b21..0bd10cf91 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java +++ b/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java @@ -1,5 +1,10 @@ package org.pitest.maven; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + import org.codehaus.plexus.util.xml.Xpp3Dom; import org.pitest.functional.F; import org.pitest.functional.FCollection; @@ -8,11 +13,6 @@ import org.pitest.testapi.TestGroupConfig; import org.pitest.util.Glob; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - /** * Extracts configuration from surefire plugin and create pitest equivalents */ @@ -29,8 +29,9 @@ public ReportOptions update(ReportOptions option, Xpp3Dom configuration) { private void convertGroups(ReportOptions option, Xpp3Dom configuration) { TestGroupConfig existing = option.getGroupConfig(); - if (existing == null || (existing.getExcludedGroups().isEmpty() - && existing.getIncludedGroups().isEmpty())) { + if ((existing == null) + || (existing.getExcludedGroups().isEmpty() && existing + .getIncludedGroups().isEmpty())) { List groups = extractStrings("groups", configuration); List excluded = extractStrings("excludedGroups", configuration); TestGroupConfig gc = new TestGroupConfig(excluded, groups); @@ -57,6 +58,7 @@ private void convertExcludes(ReportOptions option, Xpp3Dom configuration) { private F> filenameToClassFilter() { return new F>() { + @Override public Predicate apply(String a) { return new Glob(a.replace(".java", "").replace("/", ".")); } diff --git a/pitest-maven/src/main/java/org/pitest/maven/report/PitReportMojo.java b/pitest-maven/src/main/java/org/pitest/maven/report/PitReportMojo.java index 87fed3990..cc1aee065 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/report/PitReportMojo.java +++ b/pitest-maven/src/main/java/org/pitest/maven/report/PitReportMojo.java @@ -115,14 +115,17 @@ public PitReportMojo() { this.reportGenerationManager = new ReportGenerationManager(); } + @Override public String getOutputName() { return this.siteReportDirectory + File.separator + "index"; } + @Override public String getName(Locale locale) { return this.siteReportName; } + @Override public String getDescription(Locale locale) { return this.siteReportDescription; } diff --git a/pitest-maven/src/main/java/org/pitest/maven/report/generator/HTMLReportGenerator.java b/pitest-maven/src/main/java/org/pitest/maven/report/generator/HTMLReportGenerator.java index b6fbc3562..3a562e330 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/report/generator/HTMLReportGenerator.java +++ b/pitest-maven/src/main/java/org/pitest/maven/report/generator/HTMLReportGenerator.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,27 +23,38 @@ public class HTMLReportGenerator implements ReportGenerationStrategy { - protected static final FileFilter EXCLUDE_TIMESTAMPED_REPORTS_DIRECTORIES = new NotFileFilter(new RegexFileFilter("^\\d+$")); - - public ReportGenerationResultEnum generate(ReportGenerationContext context) { - try { - context.getLogger().debug("HTMLReportGenerator using directory [" + context.getReportsDataDirectory() + "] as directory containing the html report"); - context.getLogger().debug("HTMLReportGenerator using directory [" + context.getSiteDirectory() + "] as directory that is the destination of the site report"); - FileUtils.copyDirectory(context.getReportsDataDirectory(), context.getSiteDirectory(), EXCLUDE_TIMESTAMPED_REPORTS_DIRECTORIES); - } catch (IOException e) { - context.getLogger().warn(e); - return ReportGenerationResultEnum.FAILURE; - } - - return ReportGenerationResultEnum.SUCCESS; - } - - public String getGeneratorName() { - return "HTMLReportGenerator"; - } - - public String getGeneratorDataFormat() { - return "HTML"; + protected static final FileFilter EXCLUDE_TIMESTAMPED_REPORTS_DIRECTORIES = new NotFileFilter( + new RegexFileFilter( + "^\\d+$")); + + @Override + public ReportGenerationResultEnum generate(ReportGenerationContext context) { + try { + context.getLogger().debug( + "HTMLReportGenerator using directory [" + + context.getReportsDataDirectory() + + "] as directory containing the html report"); + context.getLogger().debug( + "HTMLReportGenerator using directory [" + context.getSiteDirectory() + + "] as directory that is the destination of the site report"); + FileUtils.copyDirectory(context.getReportsDataDirectory(), + context.getSiteDirectory(), EXCLUDE_TIMESTAMPED_REPORTS_DIRECTORIES); + } catch (IOException e) { + context.getLogger().warn(e); + return ReportGenerationResultEnum.FAILURE; } + return ReportGenerationResultEnum.SUCCESS; + } + + @Override + public String getGeneratorName() { + return "HTMLReportGenerator"; + } + + @Override + public String getGeneratorDataFormat() { + return "HTML"; + } + } diff --git a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationContext.java b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationContext.java index 525cabff1..61714455a 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationContext.java +++ b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationContext.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,71 +25,80 @@ public class ReportGenerationContext { - private Locale locale; - private Sink sink; - private File reportsDataDirectory; - private File siteDirectory; - private Log logger; - private List sourceDataFormats; - - public ReportGenerationContext() { - - } - - public ReportGenerationContext(Locale locale, Sink sink, File reportsDataDirectory, File siteDirectory, Log logger, List sourceDataFormats) { - this.locale = locale; - this.sink = sink; - this.reportsDataDirectory = reportsDataDirectory; - this.siteDirectory = siteDirectory; - this.logger = logger; - this.sourceDataFormats = sourceDataFormats; - } - - public Locale getLocale() { - return locale; - } - public void setLocale(Locale locale) { - this.locale = locale; - } - - public Sink getSink() { - return sink; - } - public void setSink(Sink sink) { - this.sink = sink; - } - - public File getReportsDataDirectory() { - return reportsDataDirectory; - } - public void setReportsDataDirectory(File reportsDataDirectory) { - this.reportsDataDirectory = reportsDataDirectory; - } - - public File getSiteDirectory() { - return siteDirectory; - } - public void setSiteDirectory(File siteDirectory) { - this.siteDirectory = siteDirectory; - } - - public Log getLogger() { - return this.logger; - } - public void setLogger(Log logger) { - this.logger = logger; - } - - public List getSourceDataFormats() { - return sourceDataFormats; - } - public void setSourceDataFormats(List sourceDataFormats) { - this.sourceDataFormats = sourceDataFormats; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); - } - + private Locale locale; + private Sink sink; + private File reportsDataDirectory; + private File siteDirectory; + private Log logger; + private List sourceDataFormats; + + public ReportGenerationContext() { + + } + + public ReportGenerationContext(Locale locale, Sink sink, + File reportsDataDirectory, File siteDirectory, Log logger, + List sourceDataFormats) { + this.locale = locale; + this.sink = sink; + this.reportsDataDirectory = reportsDataDirectory; + this.siteDirectory = siteDirectory; + this.logger = logger; + this.sourceDataFormats = sourceDataFormats; + } + + public Locale getLocale() { + return this.locale; + } + + public void setLocale(Locale locale) { + this.locale = locale; + } + + public Sink getSink() { + return this.sink; + } + + public void setSink(Sink sink) { + this.sink = sink; + } + + public File getReportsDataDirectory() { + return this.reportsDataDirectory; + } + + public void setReportsDataDirectory(File reportsDataDirectory) { + this.reportsDataDirectory = reportsDataDirectory; + } + + public File getSiteDirectory() { + return this.siteDirectory; + } + + public void setSiteDirectory(File siteDirectory) { + this.siteDirectory = siteDirectory; + } + + public Log getLogger() { + return this.logger; + } + + public void setLogger(Log logger) { + this.logger = logger; + } + + public List getSourceDataFormats() { + return this.sourceDataFormats; + } + + public void setSourceDataFormats(List sourceDataFormats) { + this.sourceDataFormats = sourceDataFormats; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, + ToStringStyle.MULTI_LINE_STYLE); + } + } diff --git a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationManager.java b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationManager.java index abea5249d..61ff95866 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationManager.java +++ b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationManager.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,55 +20,64 @@ import org.pitest.maven.report.ReportSourceLocator; import org.pitest.util.PitError; - public class ReportGenerationManager { - private final ReportSourceLocator reportLocator; - private final List reportGenerationStrategyList; - - public ReportGenerationManager() { - this(new ReportSourceLocator(), Arrays.asList(new XMLReportGenerator(), new HTMLReportGenerator())); - } - - public ReportGenerationManager(final ReportSourceLocator reportLocator, final List reportGenerationStrategyList) { - this.reportLocator = reportLocator; - this.reportGenerationStrategyList = reportGenerationStrategyList; + private final ReportSourceLocator reportLocator; + private final List reportGenerationStrategyList; + + public ReportGenerationManager() { + this(new ReportSourceLocator(), Arrays.asList(new XMLReportGenerator(), + new HTMLReportGenerator())); + } + + public ReportGenerationManager(final ReportSourceLocator reportLocator, + final List reportGenerationStrategyList) { + this.reportLocator = reportLocator; + this.reportGenerationStrategyList = reportGenerationStrategyList; + } + + public void generateSiteReport(ReportGenerationContext context) { + ReportGenerationResultEnum result; + boolean successfulExecution = false; + + context.setReportsDataDirectory(this.reportLocator.locate( + context.getReportsDataDirectory(), context.getLogger())); + + context.getLogger().debug("starting execution of report generators"); + context.getLogger().debug("using report generation context: " + context); + + for (String dataFormat : context.getSourceDataFormats()) { + context.getLogger().debug( + "starting report generator for source data format [" + dataFormat + + "]"); + result = this.locateReportGenerationStrategy(dataFormat) + .generate(context); + context.getLogger().debug( + "result of report generator for source data format [" + dataFormat + + "] was [" + result.toString() + "]"); + if (result == ReportGenerationResultEnum.SUCCESS) { + successfulExecution = true; + break; + } } - - public void generateSiteReport(ReportGenerationContext context) { - ReportGenerationResultEnum result; - boolean successfulExecution = false; - - context.setReportsDataDirectory(this.reportLocator.locate(context.getReportsDataDirectory(), context.getLogger())); - - context.getLogger().debug("starting execution of report generators"); - context.getLogger().debug("using report generation context: " + context); - - for (String dataFormat : context.getSourceDataFormats()) { - context.getLogger().debug("starting report generator for source data format [" + dataFormat + "]"); - result = this.locateReportGenerationStrategy(dataFormat).generate(context); - context.getLogger().debug("result of report generator for source data format [" + dataFormat + "] was [" + result.toString() + "]"); - if (result == ReportGenerationResultEnum.SUCCESS) { - successfulExecution = true; - break; - } - } - - if (!successfulExecution) { - throw new PitError("no report generators executed successfully"); - } - - context.getLogger().debug("finished execution of report generators"); + + if (!successfulExecution) { + throw new PitError("no report generators executed successfully"); } - - private ReportGenerationStrategy locateReportGenerationStrategy(String sourceDataFormat) { - for (ReportGenerationStrategy strategy : this.reportGenerationStrategyList) { - if (sourceDataFormat.equalsIgnoreCase(strategy.getGeneratorDataFormat())) { - return strategy; - } - } - - throw new PitError("Could not locate report generator for data source [" + sourceDataFormat + "]"); + + context.getLogger().debug("finished execution of report generators"); + } + + private ReportGenerationStrategy locateReportGenerationStrategy( + String sourceDataFormat) { + for (ReportGenerationStrategy strategy : this.reportGenerationStrategyList) { + if (sourceDataFormat.equalsIgnoreCase(strategy.getGeneratorDataFormat())) { + return strategy; + } } - + + throw new PitError("Could not locate report generator for data source [" + + sourceDataFormat + "]"); + } + } diff --git a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationResultEnum.java b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationResultEnum.java index e0a8ee7d1..f5d064e59 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationResultEnum.java +++ b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationResultEnum.java @@ -16,8 +16,6 @@ public enum ReportGenerationResultEnum { - SUCCESS, - FAILURE, - NOT_EXECUTED + SUCCESS, FAILURE, NOT_EXECUTED } diff --git a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationStrategy.java b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationStrategy.java index 6b037bff8..e0d3bd6ef 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationStrategy.java +++ b/pitest-maven/src/main/java/org/pitest/maven/report/generator/ReportGenerationStrategy.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,12 +14,12 @@ */ package org.pitest.maven.report.generator; +public interface ReportGenerationStrategy { + ReportGenerationResultEnum generate(ReportGenerationContext context); -public interface ReportGenerationStrategy { + String getGeneratorName(); + + String getGeneratorDataFormat(); - ReportGenerationResultEnum generate(ReportGenerationContext context); - String getGeneratorName(); - String getGeneratorDataFormat(); - } diff --git a/pitest-maven/src/main/java/org/pitest/maven/report/generator/XMLReportGenerator.java b/pitest-maven/src/main/java/org/pitest/maven/report/generator/XMLReportGenerator.java index 2f1785e71..9e5c65e2d 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/report/generator/XMLReportGenerator.java +++ b/pitest-maven/src/main/java/org/pitest/maven/report/generator/XMLReportGenerator.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,20 +14,22 @@ */ package org.pitest.maven.report.generator; - public class XMLReportGenerator implements ReportGenerationStrategy { - public ReportGenerationResultEnum generate(ReportGenerationContext context) { - context.getLogger().debug("XMLReportGenerator not yet implemented"); - return ReportGenerationResultEnum.NOT_EXECUTED; - } - - public String getGeneratorName() { - return "XMLReportGenerator"; - } - - public String getGeneratorDataFormat() { - return "XML"; - } + @Override + public ReportGenerationResultEnum generate(ReportGenerationContext context) { + context.getLogger().debug("XMLReportGenerator not yet implemented"); + return ReportGenerationResultEnum.NOT_EXECUTED; + } + + @Override + public String getGeneratorName() { + return "XMLReportGenerator"; + } + + @Override + public String getGeneratorDataFormat() { + return "XML"; + } } diff --git a/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java index 4f98181fd..15d7d99ec 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,18 +42,18 @@ public abstract class BasePitMojoTest extends AbstractMojoTestCase { @Mock - protected MavenProject project; + protected MavenProject project; @Mock - protected RunPitStrategy executionStrategy; + protected RunPitStrategy executionStrategy; - protected List classPath; + protected List classPath; @Mock protected Predicate filter; - + @Mock - protected PluginServices plugins; + protected PluginServices plugins; @SuppressWarnings("unchecked") @Override @@ -64,13 +64,16 @@ protected void setUp() throws Exception { ClassPath.getClassPathElementsAsFiles(), fileToString())); when(this.project.getTestClasspathElements()).thenReturn(this.classPath); when(this.project.getPackaging()).thenReturn("jar"); - when(this.plugins.findToolClasspathPlugins()).thenReturn(Collections.emptyList()); - when(this.plugins.findClientClasspathPlugins()).thenReturn(Collections.emptyList()); + when(this.plugins.findToolClasspathPlugins()).thenReturn( + Collections.emptyList()); + when(this.plugins.findClientClasspathPlugins()).thenReturn( + Collections.emptyList()); } private F fileToString() { return new F() { + @Override public String apply(final File a) { return a.getAbsolutePath(); } @@ -95,7 +98,8 @@ protected String createPomWithConfiguration(final String config) { } protected PitMojo createPITMojo(final String config) throws Exception { - final PitMojo pitMojo = new PitMojo(this.executionStrategy, filter, plugins); + final PitMojo pitMojo = new PitMojo(this.executionStrategy, this.filter, + this.plugins); configurePitMojo(pitMojo, config); return pitMojo; } diff --git a/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java b/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java index 97a0f6651..acf07635c 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java +++ b/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java b/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java index 79921104c..bc1866dff 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,9 +15,10 @@ package org.pitest.maven; import static org.mockito.AdditionalAnswers.returnsFirstArg; -import static org.mockito.Matchers.*; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; import java.io.File; import java.util.Arrays; @@ -41,20 +42,19 @@ public class MojoToReportOptionsConverterTest extends BasePitMojoTest { private MojoToReportOptionsConverter testee; - private SurefireConfigConverter surefireConverter; - + private SurefireConfigConverter surefireConverter; + @Override public void setUp() throws Exception { super.setUp(); Plugin surefire = new Plugin(); surefire.setGroupId("org.apache.maven.plugins"); surefire.setArtifactId("maven-surefire-plugin"); - surefireConverter = Mockito.mock(SurefireConfigConverter.class); + this.surefireConverter = Mockito.mock(SurefireConfigConverter.class); List mavenPlugins = Collections.singletonList(surefire); when(this.project.getBuildPlugins()).thenReturn(mavenPlugins); } - public void testsParsesReportDir() { final ReportOptions actual = parseConfig("Foo"); assertEquals(new File("Foo").getAbsolutePath(), actual.getReportDir()); @@ -102,7 +102,7 @@ public void testParsesListOfMutationOperators() { " bar" + // " "; final ReportOptions actual = parseConfig(xml); - assertEquals(Arrays.asList("foo","bar"), actual.getMutators()); + assertEquals(Arrays.asList("foo", "bar"), actual.getMutators()); } public void testParsersMutateStaticInitializersFlag() { @@ -224,9 +224,8 @@ public void testParsesListOfOutputFormatsWhenSupplied() { " CSV" + // " "; final ReportOptions actual = parseConfig(xml); - assertEquals( - new HashSet(Arrays.asList("HTML", - "CSV")), actual.getOutputFormats()); + assertEquals(new HashSet(Arrays.asList("HTML", "CSV")), + actual.getOutputFormats()); } public void testObeysFailWhenNoMutationsFlagWhenPackagingTypeIsNotPOM() { @@ -295,45 +294,54 @@ public void testParsesEngineWhenSet() { final ReportOptions actual = parseConfig("foo"); assertEquals("foo", actual.getMutationEngine()); } - + public void testDefaultsJavaExecutableToNull() { final ReportOptions actual = parseConfig(""); assertEquals(null, actual.getJavaExecutable()); } - + public void testParsesJavaExecutable() { final ReportOptions actual = parseConfig("foo"); assertEquals("foo", actual.getJavaExecutable()); } - - public void testParsesExcludedClasspathElements() throws DependencyResolutionRequiredException { - final String sep = File.pathSeparator; - - final Set artifacts = new HashSet(); - final Artifact dependency = Mockito.mock(Artifact.class); - when(dependency.getGroupId()).thenReturn("group"); - when(dependency.getArtifactId()).thenReturn("artifact"); - when(dependency.getFile()).thenReturn(new File("group" + sep + "artifact" + sep + "1.0.0" + sep + "group-artifact-1.0.0.jar")); - artifacts.add(dependency); - when(this.project.getArtifacts()).thenReturn(artifacts); - when(this.project.getTestClasspathElements()).thenReturn(Arrays.asList("group" + sep + "artifact" + sep + "1.0.0" + sep + "group-artifact-1.0.0.jar")); - - final ReportOptions actual = parseConfig("" - + " group:artifact" - + " "); - assertFalse(actual.getClassPathElements().contains("group" + sep + "artifact" + sep + "1.0.0" + sep + "group-artifact-1.0.0.jar")); - } - + + public void testParsesExcludedClasspathElements() + throws DependencyResolutionRequiredException { + final String sep = File.pathSeparator; + + final Set artifacts = new HashSet(); + final Artifact dependency = Mockito.mock(Artifact.class); + when(dependency.getGroupId()).thenReturn("group"); + when(dependency.getArtifactId()).thenReturn("artifact"); + when(dependency.getFile()).thenReturn( + new File("group" + sep + "artifact" + sep + "1.0.0" + sep + + "group-artifact-1.0.0.jar")); + artifacts.add(dependency); + when(this.project.getArtifacts()).thenReturn(artifacts); + when(this.project.getTestClasspathElements()).thenReturn( + Arrays.asList("group" + sep + "artifact" + sep + "1.0.0" + sep + + "group-artifact-1.0.0.jar")); + + final ReportOptions actual = parseConfig("" + + " group:artifact" + + " "); + assertFalse(actual.getClassPathElements().contains( + "group" + sep + "artifact" + sep + "1.0.0" + sep + + "group-artifact-1.0.0.jar")); + } + public void testParsesSurefireConfigWhenFlagSet() { parseConfig("true"); - verify(surefireConverter).update(any(ReportOptions.class), any(Xpp3Dom.class)); + verify(this.surefireConverter).update(any(ReportOptions.class), + any(Xpp3Dom.class)); } - + public void testIgnoreSurefireConfigWhenFlagNotSet() { parseConfig("false"); - verify(surefireConverter, never()).update(any(ReportOptions.class), any(Xpp3Dom.class)); + verify(this.surefireConverter, never()).update(any(ReportOptions.class), + any(Xpp3Dom.class)); } - + public void testParsesCustomProperties() { final ReportOptions actual = parseConfig("foobar"); assertEquals("foo", actual.getFreeFormProperties().get("foo")); @@ -346,8 +354,11 @@ private ReportOptions parseConfig(final String xml) { final PitMojo mojo = createPITMojo(pom); @SuppressWarnings("unchecked") Predicate filter = Mockito.mock(Predicate.class); - when(surefireConverter.update(any(ReportOptions.class), any(Xpp3Dom.class))).then(returnsFirstArg()); - this.testee = new MojoToReportOptionsConverter(mojo, surefireConverter,filter); + when( + this.surefireConverter.update(any(ReportOptions.class), + any(Xpp3Dom.class))).then(returnsFirstArg()); + this.testee = new MojoToReportOptionsConverter(mojo, + this.surefireConverter, filter); final ReportOptions actual = this.testee.convert(); return actual; } catch (final Exception ex) { diff --git a/pitest-maven/src/test/java/org/pitest/maven/PathToJavaClassConverterTest.java b/pitest-maven/src/test/java/org/pitest/maven/PathToJavaClassConverterTest.java index 2e52d13ed..6819c0fc2 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/PathToJavaClassConverterTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/PathToJavaClassConverterTest.java @@ -43,7 +43,8 @@ public void shouldNotConvertFilesWithoutExtension() { @Test public void shouldConvertFilesWithDotInPath() { - assertTrue(this.testee.apply(SRC + "/foo.bar/File.java").iterator().hasNext()); + assertTrue(this.testee.apply(SRC + "/foo.bar/File.java").iterator() + .hasNext()); } @Test diff --git a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java index 6e9310c23..792b97b13 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java @@ -1,5 +1,13 @@ package org.pitest.maven; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.Map; + import org.apache.maven.model.Build; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -11,12 +19,6 @@ import org.pitest.mutationtest.statistics.MutationStatistics; import org.pitest.mutationtest.tooling.CombinedStatistics; -import java.io.File; -import java.util.Map; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - public class PitMojoTest extends BasePitMojoTest { private PitMojo testee; @@ -34,7 +36,7 @@ public void testRunsAMutationReportWhenMutationCoverageGoalTrigered() this.testee.getProject().setBuild(build); this.testee.execute(); verify(this.executionStrategy).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } public void testDoesNotAnalysePomProjects() throws Exception { @@ -42,14 +44,14 @@ public void testDoesNotAnalysePomProjects() throws Exception { this.testee = createPITMojo(createPomWithConfiguration("")); this.testee.execute(); verify(this.executionStrategy, never()).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } public void testDoesNotAnalyseProjectsWithSkipFlagSet() throws Exception { this.testee = createPITMojo(createPomWithConfiguration("true")); this.testee.execute(); verify(this.executionStrategy, never()).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } public void testThrowsMojoFailureExceptionWhenMutationScoreBelowThreshold() @@ -102,26 +104,28 @@ public void testDoesNotThrowMojoFailureExceptionWhenCoverageOnThreshold() public void testConfigureEnvironmentVariable() throws Exception { - PitMojo mojo = createPITMojo(createPomWithConfiguration("\n" + - " \n" + - " :20\n" + - " ")); + PitMojo mojo = createPITMojo(createPomWithConfiguration("\n" + + " \n" + + " :20\n" + + " ")); - assertEquals(mojo.getEnvironmentVariables().get("DISPLAY"),":20"); + assertEquals(mojo.getEnvironmentVariables().get("DISPLAY"), ":20"); } - private void setupCoverage(long mutationScore, int lines, int linesCovered) throws MojoExecutionException { + private void setupCoverage(long mutationScore, int lines, int linesCovered) + throws MojoExecutionException { final MutationStatistics stats = Mockito.mock(MutationStatistics.class); when(stats.getPercentageDetected()).thenReturn(mutationScore); - CoverageSummary sum = new CoverageSummary(lines,linesCovered); - final CombinedStatistics cs = new CombinedStatistics(stats,sum); + CoverageSummary sum = new CoverageSummary(lines, linesCovered); + final CombinedStatistics cs = new CombinedStatistics(stats, sum); when( this.executionStrategy.execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap())).thenReturn(cs); + any(ReportOptions.class), any(PluginServices.class), anyMap())) + .thenReturn(cs); } - + private Map anyMap() { - return Matchers.>any(); + return Matchers.> any(); } } diff --git a/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java index a3599bb81..1b03dc8cd 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java @@ -1,5 +1,16 @@ package org.pitest.maven; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + import org.apache.maven.model.Build; import org.apache.maven.model.Scm; import org.apache.maven.plugin.MojoExecutionException; @@ -15,14 +26,6 @@ import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.config.ReportOptions; -import java.io.File; -import java.util.Arrays; -import java.util.Collections; -import java.util.Map; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - public class ScmMojoTest extends BasePitMojoTest { private ScmMojo testee; @@ -42,7 +45,8 @@ public class ScmMojoTest extends BasePitMojoTest { @Override public void setUp() throws Exception { super.setUp(); - this.testee = new ScmMojo(this.executionStrategy, this.manager, filter, plugins); + this.testee = new ScmMojo(this.executionStrategy, this.manager, + this.filter, this.plugins); this.testee.setScmRootDir(new File("foo")); when(this.project.getBuild()).thenReturn(this.build); when(this.build.getSourceDirectory()).thenReturn("foo"); @@ -90,7 +94,7 @@ public void testClassesAddedToScmAreMutationTested() throws Exception { setFileWithStatus(ScmFileStatus.ADDED); this.testee.execute(); verify(this.executionStrategy).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } private void setFileWithStatus(final ScmFileStatus status) @@ -106,7 +110,7 @@ public void testModifiedClassesAreMutationTested() throws Exception { setFileWithStatus(ScmFileStatus.MODIFIED); this.testee.execute(); verify(this.executionStrategy).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } public void testUnknownAndDeletedClassesAreNotMutationTested() @@ -119,7 +123,7 @@ public void testUnknownAndDeletedClassesAreNotMutationTested() "foo/bar/Bar.java", ScmFileStatus.UNKNOWN)))); this.testee.execute(); verify(this.executionStrategy, never()).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } public void testCanOverrideInspectedStatus() throws Exception { @@ -130,7 +134,7 @@ public void testCanOverrideInspectedStatus() throws Exception { createPomWithConfiguration("DELETEDUNKNOWN")); this.testee.execute(); verify(this.executionStrategy, times(1)).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } public void testDoesNotAnalysePomProjects() throws Exception { @@ -139,7 +143,7 @@ public void testDoesNotAnalysePomProjects() throws Exception { when(this.project.getPackaging()).thenReturn("pom"); this.testee.execute(); verify(this.executionStrategy, never()).execute(any(File.class), - any(ReportOptions.class), any(PluginServices.class),anyMap()); + any(ReportOptions.class), any(PluginServices.class), anyMap()); } private void setupConnection() { @@ -151,8 +155,8 @@ private void setupToReturnNoModifiedFiles() throws ScmException { when(this.manager.status(any(ScmRepository.class), any(ScmFileSet.class))) .thenReturn(new StatusScmResult("", Collections. emptyList())); } - + private Map anyMap() { - return Matchers.>any(); + return Matchers.> any(); } } \ No newline at end of file diff --git a/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java b/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java index 076a4ccc9..84c1b6398 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java @@ -17,91 +17,108 @@ public class SurefireConfigConverterTest { - SurefireConfigConverter testee = new SurefireConfigConverter(); - ReportOptions options = new ReportOptions(); - Xpp3Dom surefireConfig; - + SurefireConfigConverter testee = new SurefireConfigConverter(); + ReportOptions options = new ReportOptions(); + Xpp3Dom surefireConfig; + @Test public void shouldIgnoreNullSurefireConfiguration() { - assertThat(testee.update(options, null)).isSameAs(options); + assertThat(this.testee.update(this.options, null)).isSameAs(this.options); } - + @Test public void shouldCreatePredicateForEachExclude() throws Exception { - surefireConfig = makeConfig("AB"); - - ReportOptions actual = testee.update(options, surefireConfig); + this.surefireConfig = makeConfig("AB"); + + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); assertThat(actual.getExcludedClasses()).hasSize(2); } - + @Test - public void shouldConvertSurefireExclusionsToPackagePredicates() throws Exception { - surefireConfig = makeConfig("**/FailingTest.java"); - - ReportOptions actual = testee.update(options, surefireConfig); + public void shouldConvertSurefireExclusionsToPackagePredicates() + throws Exception { + this.surefireConfig = makeConfig("**/FailingTest.java"); + + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); Predicate predicate = actual.getExcludedClasses().iterator().next(); assertThat(predicate.apply("com.example.FailingTest")).isTrue(); assertThat(predicate.apply("com.example.Test")).isFalse(); } - + @Test public void shouldKeepExistingExclusions() throws Exception { - surefireConfig = makeConfig("AB"); - options.setExcludedClasses(Collections.>singletonList(new Glob("Foo"))); - ReportOptions actual = testee.update(options, surefireConfig); - + this.surefireConfig = makeConfig("AB"); + this.options.setExcludedClasses(Collections + .> singletonList(new Glob("Foo"))); + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + assertThat(actual.getExcludedClasses()).hasSize(3); } - + @Test public void shouldConvertSingleSurefireGroups() throws Exception { - surefireConfig = makeConfig("com.example.Unit"); - ReportOptions actual = testee.update(options, surefireConfig); - - assertThat(actual.getGroupConfig().getIncludedGroups()).containsOnly("com.example.Unit"); + this.surefireConfig = makeConfig("com.example.Unit"); + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + + assertThat(actual.getGroupConfig().getIncludedGroups()).containsOnly( + "com.example.Unit"); } @Test public void shouldConvertMultipleSurefireGroups() throws Exception { - surefireConfig = makeConfig("com.example.Unit com.example.Fast"); - ReportOptions actual = testee.update(options, surefireConfig); - - assertThat(actual.getGroupConfig().getIncludedGroups()).containsOnly("com.example.Unit", "com.example.Fast"); + this.surefireConfig = makeConfig("com.example.Unit com.example.Fast"); + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + + assertThat(actual.getGroupConfig().getIncludedGroups()).containsOnly( + "com.example.Unit", "com.example.Fast"); } - + @Test public void shouldConvertMultipleSurefireGroupExcludes() throws Exception { - surefireConfig = makeConfig("com.example.Unit com.example.Fast"); - ReportOptions actual = testee.update(options, surefireConfig); - - assertThat(actual.getGroupConfig().getExcludedGroups()).containsOnly("com.example.Unit", "com.example.Fast"); + this.surefireConfig = makeConfig("com.example.Unit com.example.Fast"); + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + + assertThat(actual.getGroupConfig().getExcludedGroups()).containsOnly( + "com.example.Unit", "com.example.Fast"); } - + @Test - public void shouldNotUseSurefireGroupsWhenPitestIncludesSpecified() throws Exception { - TestGroupConfig gc = new TestGroupConfig(Collections.emptyList(), Arrays.asList("bar")); - options.setGroupConfig(gc); - surefireConfig = makeConfig("com.example.Unit com.example.Fast"); - ReportOptions actual = testee.update(options, surefireConfig); - + public void shouldNotUseSurefireGroupsWhenPitestIncludesSpecified() + throws Exception { + TestGroupConfig gc = new TestGroupConfig(Collections. emptyList(), + Arrays.asList("bar")); + this.options.setGroupConfig(gc); + this.surefireConfig = makeConfig("com.example.Unit com.example.Fast"); + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + assertThat(actual.getGroupConfig().getIncludedGroups()).containsOnly("bar"); } - - + @Test - public void shouldNotUseSurefireGroupsWhenPitestExcludesSpecified() throws Exception { - TestGroupConfig gc = new TestGroupConfig(Arrays.asList("bar"),Collections.emptyList()); - options.setGroupConfig(gc); - surefireConfig = makeConfig("com.example.Unit com.example.Fast"); - - ReportOptions actual = testee.update(options, surefireConfig); - + public void shouldNotUseSurefireGroupsWhenPitestExcludesSpecified() + throws Exception { + TestGroupConfig gc = new TestGroupConfig(Arrays.asList("bar"), + Collections. emptyList()); + this.options.setGroupConfig(gc); + this.surefireConfig = makeConfig("com.example.Unit com.example.Fast"); + + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + assertThat(actual.getGroupConfig().getExcludedGroups()).containsOnly("bar"); } + private Xpp3Dom makeConfig(String s) throws Exception { String xml = "" + s + ""; InputStream stream = new ByteArrayInputStream(xml.getBytes("UTF-8")); return Xpp3DomBuilder.build(stream, "UTF-8"); } - + } diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java index 1f1457544..5c6f44e62 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,64 +40,75 @@ @RunWith(MockitoJUnitRunner.class) public class PitReportMojoTest { - @Captor private ArgumentCaptor contextCaptor; - - @Mock private Log log; - @Mock private File reportsDirectory; - @Mock private ReportGenerationManager reportGenerationManager; - @Mock private Sink sink; - - @InjectMocks private PitReportMojo fixture; - - @Test(expected = PitError.class) - public void testNonExistantReportsDirectory() throws Exception { - this.setupMocks(false, true, true); - this.fixture.executeReport(Locale.ENGLISH); - } - - @Test(expected = PitError.class) - public void testNonReadableReportsDirectory() throws Exception { - this.setupMocks(true, false, true); - this.fixture.executeReport(Locale.ENGLISH); - } - - @Test(expected = PitError.class) - public void testFileReportsDirectory() throws Exception { - this.setupMocks(true, true, false); - this.fixture.executeReport(Locale.ENGLISH); - } - - @Test - public void testGenerateReport() throws Exception { - ReportGenerationContext actualContext; - - this.reflectionSetSiteReportDir("pit-reports"); - - setupMocks(true, true, true); - when(this.reportsDirectory.getAbsolutePath()).thenReturn("abspath"); - - this.fixture.executeReport(Locale.ENGLISH); - - verify(this.reportGenerationManager).generateSiteReport(contextCaptor.capture()); - actualContext = this.contextCaptor.getValue(); - - assertThat(actualContext.getLocale(), sameInstance(Locale.ENGLISH)); - assertThat(actualContext.getLogger(), sameInstance(this.log)); - assertThat(actualContext.getReportsDataDirectory(), sameInstance(this.reportsDirectory)); - assertThat(actualContext.getSink(), sameInstance(this.sink)); - assertThat(actualContext.getSiteDirectory().getPath(), is("abspath" + File.separator + "pit-reports")); - } - - private void setupMocks(boolean reportsDirectoryExists, boolean reportsDirectoryReadable, boolean reportsDirectoryIsDirectory) { - when(this.reportsDirectory.exists()).thenReturn(reportsDirectoryExists); - when(this.reportsDirectory.canRead()).thenReturn(reportsDirectoryReadable); - when(this.reportsDirectory.isDirectory()).thenReturn(reportsDirectoryIsDirectory); - } - - private void reflectionSetSiteReportDir(String value) throws Exception { - Field f = this.fixture.getClass().getDeclaredField("siteReportDirectory"); - f.setAccessible(true); - f.set(this.fixture, value); - } - + @Captor + private ArgumentCaptor contextCaptor; + + @Mock + private Log log; + @Mock + private File reportsDirectory; + @Mock + private ReportGenerationManager reportGenerationManager; + @Mock + private Sink sink; + + @InjectMocks + private PitReportMojo fixture; + + @Test(expected = PitError.class) + public void testNonExistantReportsDirectory() throws Exception { + this.setupMocks(false, true, true); + this.fixture.executeReport(Locale.ENGLISH); + } + + @Test(expected = PitError.class) + public void testNonReadableReportsDirectory() throws Exception { + this.setupMocks(true, false, true); + this.fixture.executeReport(Locale.ENGLISH); + } + + @Test(expected = PitError.class) + public void testFileReportsDirectory() throws Exception { + this.setupMocks(true, true, false); + this.fixture.executeReport(Locale.ENGLISH); + } + + @Test + public void testGenerateReport() throws Exception { + ReportGenerationContext actualContext; + + this.reflectionSetSiteReportDir("pit-reports"); + + setupMocks(true, true, true); + when(this.reportsDirectory.getAbsolutePath()).thenReturn("abspath"); + + this.fixture.executeReport(Locale.ENGLISH); + + verify(this.reportGenerationManager).generateSiteReport( + this.contextCaptor.capture()); + actualContext = this.contextCaptor.getValue(); + + assertThat(actualContext.getLocale(), sameInstance(Locale.ENGLISH)); + assertThat(actualContext.getLogger(), sameInstance(this.log)); + assertThat(actualContext.getReportsDataDirectory(), + sameInstance(this.reportsDirectory)); + assertThat(actualContext.getSink(), sameInstance(this.sink)); + assertThat(actualContext.getSiteDirectory().getPath(), is("abspath" + + File.separator + "pit-reports")); + } + + private void setupMocks(boolean reportsDirectoryExists, + boolean reportsDirectoryReadable, boolean reportsDirectoryIsDirectory) { + when(this.reportsDirectory.exists()).thenReturn(reportsDirectoryExists); + when(this.reportsDirectory.canRead()).thenReturn(reportsDirectoryReadable); + when(this.reportsDirectory.isDirectory()).thenReturn( + reportsDirectoryIsDirectory); + } + + private void reflectionSetSiteReportDir(String value) throws Exception { + Field f = this.fixture.getClass().getDeclaredField("siteReportDirectory"); + f.setAccessible(true); + f.set(this.fixture, value); + } + } diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorParamaterizedTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorParamaterizedTest.java index a7a350819..af238d77c 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorParamaterizedTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorParamaterizedTest.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,45 +31,46 @@ @RunWith(Parameterized.class) public class ReportSourceLocatorParamaterizedTest { - private static final String VALID_DIRECTORY_NAME = "20150304"; - private static final String INVALID_DIRECTORY_NAME = "abc2015def0304gh"; - - @Parameters(name = "{index}: reportSourceLocator(isDirectory: {0}, directoryName: \"{1}\", canWrite: {2}, shouldBeValid: {3})") - public static final Iterable data() { - return Arrays.asList(new Object[][] { - {true, VALID_DIRECTORY_NAME, true, true}, - {true, VALID_DIRECTORY_NAME, false, false}, - {true, INVALID_DIRECTORY_NAME, true, false}, - {true, INVALID_DIRECTORY_NAME, false, false}, - {false, VALID_DIRECTORY_NAME, true, false}, - {false, VALID_DIRECTORY_NAME, false, false}, - {false, INVALID_DIRECTORY_NAME, true, false}, - {false, INVALID_DIRECTORY_NAME, false, false} - }); - } - - @Parameter - public boolean isDirectory; - - @Parameter(value=1) - public String directoryName; - - @Parameter(value=2) - public boolean canWrite; - - @Parameter(value=3) - public boolean expectedResult; - - @Test - public void test() { - File mockDir = mock(File.class); - - when(mockDir.isDirectory()).thenReturn(isDirectory); - when(mockDir.getParentFile()).thenReturn(null); - when(mockDir.getName()).thenReturn(directoryName); - when(mockDir.canWrite()).thenReturn(canWrite); + private static final String VALID_DIRECTORY_NAME = "20150304"; + private static final String INVALID_DIRECTORY_NAME = "abc2015def0304gh"; + + @Parameters(name = "{index}: reportSourceLocator(isDirectory: {0}, directoryName: \"{1}\", canWrite: {2}, shouldBeValid: {3})") + public static final Iterable data() { + return Arrays.asList(new Object[][] { + { true, VALID_DIRECTORY_NAME, true, true }, + { true, VALID_DIRECTORY_NAME, false, false }, + { true, INVALID_DIRECTORY_NAME, true, false }, + { true, INVALID_DIRECTORY_NAME, false, false }, + { false, VALID_DIRECTORY_NAME, true, false }, + { false, VALID_DIRECTORY_NAME, false, false }, + { false, INVALID_DIRECTORY_NAME, true, false }, + { false, INVALID_DIRECTORY_NAME, false, false } }); + } + + @Parameter + public boolean isDirectory; + + @Parameter(value = 1) + public String directoryName; + + @Parameter(value = 2) + public boolean canWrite; + + @Parameter(value = 3) + public boolean expectedResult; + + @Test + public void test() { + File mockDir = mock(File.class); + + when(mockDir.isDirectory()).thenReturn(this.isDirectory); + when(mockDir.getParentFile()).thenReturn(null); + when(mockDir.getName()).thenReturn(this.directoryName); + when(mockDir.canWrite()).thenReturn(this.canWrite); + + assertThat( + ReportSourceLocator.TIMESTAMPED_REPORTS_FILE_FILTER.accept(mockDir), + is(this.expectedResult)); + } - assertThat(ReportSourceLocator.TIMESTAMPED_REPORTS_FILE_FILTER.accept(mockDir), is(expectedResult)); - } - } diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java index 6fb4404b8..909cf7f44 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,86 +30,96 @@ public class ReportSourceLocatorTest { - private ReportSourceLocator fixture; - private Log mockLog; - - @Before - public void setUp() { - fixture = new ReportSourceLocator(); - mockLog = mock(Log.class); - } - - @Test(expected = PitError.class) - public void testCouldNotListdirectories() { - File mockReportsDir = this.buildMockReportsDirectory(); - - when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn(null); - fixture.locate(mockReportsDir, mockLog); - } - - @Test - public void testNoSubdirectories() { - File mockReportsDir = this.buildMockReportsDirectory(); - - when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn(new File[0]); - assertThat(fixture.locate(mockReportsDir, mockLog), sameInstance(mockReportsDir)); - } - - @Test - public void testOneSubdirectory() { - File mockReportsDir = this.buildMockReportsDirectory(); - File dummySubDir = mock(File.class); - - when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn(new File[]{ dummySubDir }); - when(mockReportsDir.lastModified()).thenReturn(1L); - when(dummySubDir.lastModified()).thenReturn(2L); - assertThat(fixture.locate(mockReportsDir, mockLog), sameInstance(dummySubDir)); - } - - @Test - public void testMultipleSubdirectories() { - File mockReportsDir = this.buildMockReportsDirectory(); - File mockSubDir0 = mock(File.class); - File mockSubDir1 = mock(File.class); - File mockSubDir2 = mock(File.class); - File mockSubDir3 = mock(File.class); - - when(mockSubDir0.lastModified()).thenReturn(2L); - when(mockSubDir1.lastModified()).thenReturn(3L); - when(mockSubDir2.lastModified()).thenReturn(1L); - when(mockSubDir3.lastModified()).thenReturn(3L); - - when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn(new File[]{ mockSubDir0, mockSubDir1, mockSubDir2, mockSubDir3 }); - assertThat(fixture.locate(mockReportsDir, mockLog), sameInstance(mockSubDir1)); - } - - @Test(expected = PitError.class) - public void testNotDirectory() { - fixture.locate(this.buildMockReportsDirectory(true, true, false), mockLog); - } - - @Test(expected = PitError.class) - public void testNotReadable() { - fixture.locate(this.buildMockReportsDirectory(true, false, true), mockLog); - } - - @Test(expected = PitError.class) - public void testNotExists() { - fixture.locate(this.buildMockReportsDirectory(false, true, true), mockLog); - } - - private File buildMockReportsDirectory() { - return this.buildMockReportsDirectory(true, true, true); - } - - private File buildMockReportsDirectory(boolean exists, boolean canRead, boolean isDirectory) { - File testFile = mock(File.class); - - when(testFile.exists()).thenReturn(exists); - when(testFile.canRead()).thenReturn(canRead); - when(testFile.isDirectory()).thenReturn(isDirectory); - - return testFile; - } + private ReportSourceLocator fixture; + private Log mockLog; + + @Before + public void setUp() { + this.fixture = new ReportSourceLocator(); + this.mockLog = mock(Log.class); + } + + @Test(expected = PitError.class) + public void testCouldNotListdirectories() { + File mockReportsDir = this.buildMockReportsDirectory(); + + when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn(null); + this.fixture.locate(mockReportsDir, this.mockLog); + } + + @Test + public void testNoSubdirectories() { + File mockReportsDir = this.buildMockReportsDirectory(); + + when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn( + new File[0]); + assertThat(this.fixture.locate(mockReportsDir, this.mockLog), + sameInstance(mockReportsDir)); + } + + @Test + public void testOneSubdirectory() { + File mockReportsDir = this.buildMockReportsDirectory(); + File dummySubDir = mock(File.class); + + when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn( + new File[] { dummySubDir }); + when(mockReportsDir.lastModified()).thenReturn(1L); + when(dummySubDir.lastModified()).thenReturn(2L); + assertThat(this.fixture.locate(mockReportsDir, this.mockLog), + sameInstance(dummySubDir)); + } + + @Test + public void testMultipleSubdirectories() { + File mockReportsDir = this.buildMockReportsDirectory(); + File mockSubDir0 = mock(File.class); + File mockSubDir1 = mock(File.class); + File mockSubDir2 = mock(File.class); + File mockSubDir3 = mock(File.class); + + when(mockSubDir0.lastModified()).thenReturn(2L); + when(mockSubDir1.lastModified()).thenReturn(3L); + when(mockSubDir2.lastModified()).thenReturn(1L); + when(mockSubDir3.lastModified()).thenReturn(3L); + + when(mockReportsDir.listFiles(isA(FileFilter.class))).thenReturn( + new File[] { mockSubDir0, mockSubDir1, mockSubDir2, mockSubDir3 }); + assertThat(this.fixture.locate(mockReportsDir, this.mockLog), + sameInstance(mockSubDir1)); + } + + @Test(expected = PitError.class) + public void testNotDirectory() { + this.fixture.locate(this.buildMockReportsDirectory(true, true, false), + this.mockLog); + } + + @Test(expected = PitError.class) + public void testNotReadable() { + this.fixture.locate(this.buildMockReportsDirectory(true, false, true), + this.mockLog); + } + + @Test(expected = PitError.class) + public void testNotExists() { + this.fixture.locate(this.buildMockReportsDirectory(false, true, true), + this.mockLog); + } + + private File buildMockReportsDirectory() { + return this.buildMockReportsDirectory(true, true, true); + } + + private File buildMockReportsDirectory(boolean exists, boolean canRead, + boolean isDirectory) { + File testFile = mock(File.class); + + when(testFile.exists()).thenReturn(exists); + when(testFile.canRead()).thenReturn(canRead); + when(testFile.isDirectory()).thenReturn(isDirectory); + + return testFile; + } } diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/generator/HTMLReportGeneratorTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/generator/HTMLReportGeneratorTest.java index 97a63edce..d0e93b9e5 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/generator/HTMLReportGeneratorTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/generator/HTMLReportGeneratorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,65 +32,76 @@ public class HTMLReportGeneratorTest { - private static final String HTML_SOURCE_DATA_FORMAT = "HTML"; - - @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); - - private Log mockLogger; - private HTMLReportGenerator fixture; - - @Before - public void setUp() { - mockLogger = mock(Log.class); - fixture = new HTMLReportGenerator(); - } - - @Test - public void testName() { - assertThat(fixture.getGeneratorName(), is("HTMLReportGenerator")); - } - - @Test - public void testCopySuccess() throws Exception { - File sourceFolder = tempFolder.newFolder("reportsFolder"); - File destFolder = tempFolder.newFolder("siteFolder"); - - new File(sourceFolder, "file0.txt").createNewFile(); - new File(sourceFolder, "file1.txt").createNewFile(); - - assertThat(fixture.generate(new ReportGenerationContext(null, null, sourceFolder, destFolder, mockLogger, Arrays.asList(HTML_SOURCE_DATA_FORMAT))), sameInstance(ReportGenerationResultEnum.SUCCESS)); - assertThat(sourceFolder.listFiles().length, is(2)); - assertThat(destFolder.listFiles().length, is(2)); - } - - @Test - public void testCopySkipsTimestampedReportsSubDirectories() throws Exception { - File sourceFolder = tempFolder.newFolder("reportsFolder"); - File destFolder = tempFolder.newFolder("siteFolder"); - String[] destinationFiles; - - new File(sourceFolder, "file0.txt").createNewFile(); - new File(sourceFolder, "file1.txt").createNewFile(); - new File(sourceFolder, "0123456789").createNewFile(); - - assertThat(fixture.generate(new ReportGenerationContext(null, null, sourceFolder, destFolder, mockLogger, Arrays.asList(HTML_SOURCE_DATA_FORMAT))), sameInstance(ReportGenerationResultEnum.SUCCESS)); - assertThat(sourceFolder.list().length, is(3)); - - destinationFiles = destFolder.list(); - assertThat(destFolder.listFiles().length, is(2)); - for(String f : destinationFiles){ - assertThat(f, startsWith("file")); - } - } - - @Test - public void testCopyFails() { - assertThat(fixture.generate(new ReportGenerationContext(null, null, new File("foo"), new File("bar"), mockLogger, Arrays.asList(HTML_SOURCE_DATA_FORMAT))), sameInstance(ReportGenerationResultEnum.FAILURE)); - } - - @Test - public void testSourceDataFormat() { - assertThat(fixture.getGeneratorDataFormat(), equalTo(HTML_SOURCE_DATA_FORMAT)); - } - + private static final String HTML_SOURCE_DATA_FORMAT = "HTML"; + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + private Log mockLogger; + private HTMLReportGenerator fixture; + + @Before + public void setUp() { + this.mockLogger = mock(Log.class); + this.fixture = new HTMLReportGenerator(); + } + + @Test + public void testName() { + assertThat(this.fixture.getGeneratorName(), is("HTMLReportGenerator")); + } + + @Test + public void testCopySuccess() throws Exception { + File sourceFolder = this.tempFolder.newFolder("reportsFolder"); + File destFolder = this.tempFolder.newFolder("siteFolder"); + + new File(sourceFolder, "file0.txt").createNewFile(); + new File(sourceFolder, "file1.txt").createNewFile(); + + assertThat(this.fixture.generate(new ReportGenerationContext(null, null, + sourceFolder, destFolder, this.mockLogger, Arrays + .asList(HTML_SOURCE_DATA_FORMAT))), + sameInstance(ReportGenerationResultEnum.SUCCESS)); + assertThat(sourceFolder.listFiles().length, is(2)); + assertThat(destFolder.listFiles().length, is(2)); + } + + @Test + public void testCopySkipsTimestampedReportsSubDirectories() throws Exception { + File sourceFolder = this.tempFolder.newFolder("reportsFolder"); + File destFolder = this.tempFolder.newFolder("siteFolder"); + String[] destinationFiles; + + new File(sourceFolder, "file0.txt").createNewFile(); + new File(sourceFolder, "file1.txt").createNewFile(); + new File(sourceFolder, "0123456789").createNewFile(); + + assertThat(this.fixture.generate(new ReportGenerationContext(null, null, + sourceFolder, destFolder, this.mockLogger, Arrays + .asList(HTML_SOURCE_DATA_FORMAT))), + sameInstance(ReportGenerationResultEnum.SUCCESS)); + assertThat(sourceFolder.list().length, is(3)); + + destinationFiles = destFolder.list(); + assertThat(destFolder.listFiles().length, is(2)); + for (String f : destinationFiles) { + assertThat(f, startsWith("file")); + } + } + + @Test + public void testCopyFails() { + assertThat(this.fixture.generate(new ReportGenerationContext(null, null, + new File("foo"), new File("bar"), this.mockLogger, Arrays + .asList(HTML_SOURCE_DATA_FORMAT))), + sameInstance(ReportGenerationResultEnum.FAILURE)); + } + + @Test + public void testSourceDataFormat() { + assertThat(this.fixture.getGeneratorDataFormat(), + equalTo(HTML_SOURCE_DATA_FORMAT)); + } + } diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java index 464758d0a..16e32085a 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,95 +38,116 @@ @RunWith(MockitoJUnitRunner.class) public class ReportGenerationManagerTest { - private ReportGenerationContext generationContext; - private List reportGenerationStrategyList; - - @Mock private ReportSourceLocator reportLocator; - @Mock private XMLReportGenerator xmlGenerator; - @Mock private HTMLReportGenerator htmlGenerator; - @Mock private Log log; - @Mock private File reportsDataDirectory; - @Mock private File siteDirectory; - @Mock private File locatedReportsDataDirectory; - - private ReportGenerationManager fixture; - - @Before - public void setUp() { - this.reportGenerationStrategyList = new LinkedList(); - this.reportGenerationStrategyList.add(this.xmlGenerator); - this.reportGenerationStrategyList.add(this.htmlGenerator); - - fixture = new ReportGenerationManager(this.reportLocator, this.reportGenerationStrategyList); - - this.generationContext = new ReportGenerationContext(Locale.ENGLISH, null, this.reportsDataDirectory, this.siteDirectory, this.log, Arrays.asList("XML", "HTML")); - - when(this.reportLocator.locate(this.reportsDataDirectory, this.log)).thenReturn(this.locatedReportsDataDirectory); - when(this.xmlGenerator.getGeneratorDataFormat()).thenReturn("XML"); - when(this.htmlGenerator.getGeneratorDataFormat()).thenReturn("HTML"); - } - - @Test - public void testFirstGeneratorSuccess() { - when(this.xmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.SUCCESS); - - this.fixture.generateSiteReport(this.generationContext); - - verify(this.xmlGenerator).generate(this.generationContext); - verifyZeroInteractions(this.htmlGenerator); - this.assertLocatedReportsDirectory(); - } - - @Test - public void testFirstGeneratorNotRunSecondGeneratorSuccess() { - when(this.xmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.NOT_EXECUTED); - when(this.htmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.SUCCESS); - - this.fixture.generateSiteReport(this.generationContext); - - verify(this.xmlGenerator).generate(this.generationContext); - verify(this.htmlGenerator).generate(this.generationContext); - this.assertLocatedReportsDirectory(); - } - - @Test(expected = PitError.class) - public void testFirstGeneratorNotRunSecondGeneratorNotRun() { - when(this.xmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.NOT_EXECUTED); - when(this.htmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.NOT_EXECUTED); - - this.fixture.generateSiteReport(this.generationContext); - this.assertLocatedReportsDirectory(); - } - - @Test - public void testFirstGeneratorFailSecondGeneratorSuccess() { - when(this.xmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.FAILURE); - when(this.htmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.SUCCESS); - - this.fixture.generateSiteReport(this.generationContext); - - verify(this.xmlGenerator).generate(this.generationContext); - verify(this.htmlGenerator).generate(this.generationContext); - this.assertLocatedReportsDirectory(); - } - - @Test(expected = PitError.class) - public void testFirstGeneratorFailSecondGeneratorFail() { - when(this.xmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.FAILURE); - when(this.htmlGenerator.generate(this.generationContext)).thenReturn(ReportGenerationResultEnum.FAILURE); - - this.fixture.generateSiteReport(this.generationContext); - this.assertLocatedReportsDirectory(); - } - - @Test(expected = PitError.class) - public void testNoGeneratorsFound() { - this.generationContext.setSourceDataFormats(Arrays.asList("foo")); - this.fixture.generateSiteReport(this.generationContext); - } - - private void assertLocatedReportsDirectory() { - assertThat(this.generationContext.getReportsDataDirectory(), sameInstance(this.locatedReportsDataDirectory)); - } + private ReportGenerationContext generationContext; + private List reportGenerationStrategyList; + + @Mock + private ReportSourceLocator reportLocator; + @Mock + private XMLReportGenerator xmlGenerator; + @Mock + private HTMLReportGenerator htmlGenerator; + @Mock + private Log log; + @Mock + private File reportsDataDirectory; + @Mock + private File siteDirectory; + @Mock + private File locatedReportsDataDirectory; + + private ReportGenerationManager fixture; + + @Before + public void setUp() { + this.reportGenerationStrategyList = new LinkedList(); + this.reportGenerationStrategyList.add(this.xmlGenerator); + this.reportGenerationStrategyList.add(this.htmlGenerator); + + this.fixture = new ReportGenerationManager(this.reportLocator, + this.reportGenerationStrategyList); + + this.generationContext = new ReportGenerationContext(Locale.ENGLISH, null, + this.reportsDataDirectory, this.siteDirectory, this.log, Arrays.asList( + "XML", "HTML")); + + when(this.reportLocator.locate(this.reportsDataDirectory, this.log)) + .thenReturn(this.locatedReportsDataDirectory); + when(this.xmlGenerator.getGeneratorDataFormat()).thenReturn("XML"); + when(this.htmlGenerator.getGeneratorDataFormat()).thenReturn("HTML"); + } + + @Test + public void testFirstGeneratorSuccess() { + when(this.xmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.SUCCESS); + + this.fixture.generateSiteReport(this.generationContext); + + verify(this.xmlGenerator).generate(this.generationContext); + verifyZeroInteractions(this.htmlGenerator); + this.assertLocatedReportsDirectory(); + } + + @Test + public void testFirstGeneratorNotRunSecondGeneratorSuccess() { + when(this.xmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.NOT_EXECUTED); + when(this.htmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.SUCCESS); + + this.fixture.generateSiteReport(this.generationContext); + + verify(this.xmlGenerator).generate(this.generationContext); + verify(this.htmlGenerator).generate(this.generationContext); + this.assertLocatedReportsDirectory(); + } + + @Test(expected = PitError.class) + public void testFirstGeneratorNotRunSecondGeneratorNotRun() { + when(this.xmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.NOT_EXECUTED); + when(this.htmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.NOT_EXECUTED); + + this.fixture.generateSiteReport(this.generationContext); + this.assertLocatedReportsDirectory(); + } + + @Test + public void testFirstGeneratorFailSecondGeneratorSuccess() { + when(this.xmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.FAILURE); + when(this.htmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.SUCCESS); + + this.fixture.generateSiteReport(this.generationContext); + + verify(this.xmlGenerator).generate(this.generationContext); + verify(this.htmlGenerator).generate(this.generationContext); + this.assertLocatedReportsDirectory(); + } + + @Test(expected = PitError.class) + public void testFirstGeneratorFailSecondGeneratorFail() { + when(this.xmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.FAILURE); + when(this.htmlGenerator.generate(this.generationContext)).thenReturn( + ReportGenerationResultEnum.FAILURE); + + this.fixture.generateSiteReport(this.generationContext); + this.assertLocatedReportsDirectory(); + } + + @Test(expected = PitError.class) + public void testNoGeneratorsFound() { + this.generationContext.setSourceDataFormats(Arrays.asList("foo")); + this.fixture.generateSiteReport(this.generationContext); + } + + private void assertLocatedReportsDirectory() { + assertThat(this.generationContext.getReportsDataDirectory(), + sameInstance(this.locatedReportsDataDirectory)); + } } diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/generator/XMLReportGeneratorTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/generator/XMLReportGeneratorTest.java index 04626a03d..84ec215c8 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/generator/XMLReportGeneratorTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/generator/XMLReportGeneratorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Jason Fehr - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.sameInstance; -import static org.junit.Assert.*; +import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import java.util.Arrays; @@ -28,30 +28,33 @@ public class XMLReportGeneratorTest { - private static final String XML_SOURCE_DATA_FORMAT = "XML"; - - private Log mockLogger; - private XMLReportGenerator fixture; - - @Before - public void setUp() { - mockLogger = mock(Log.class); - fixture = new XMLReportGenerator(); - } - - @Test - public void testName() { - assertThat(fixture.getGeneratorName(), is("XMLReportGenerator")); - } - - @Test - public void testNotExecuted() { - assertThat(fixture.generate(new ReportGenerationContext(null, null, null, null, this.mockLogger, Arrays.asList(XML_SOURCE_DATA_FORMAT))), sameInstance(ReportGenerationResultEnum.NOT_EXECUTED)); - } - - @Test - public void testSourceDataFormat() { - assertThat(fixture.getGeneratorDataFormat(), equalTo(XML_SOURCE_DATA_FORMAT)); - } + private static final String XML_SOURCE_DATA_FORMAT = "XML"; + + private Log mockLogger; + private XMLReportGenerator fixture; + + @Before + public void setUp() { + this.mockLogger = mock(Log.class); + this.fixture = new XMLReportGenerator(); + } + + @Test + public void testName() { + assertThat(this.fixture.getGeneratorName(), is("XMLReportGenerator")); + } + + @Test + public void testNotExecuted() { + assertThat(this.fixture.generate(new ReportGenerationContext(null, null, + null, null, this.mockLogger, Arrays.asList(XML_SOURCE_DATA_FORMAT))), + sameInstance(ReportGenerationResultEnum.NOT_EXECUTED)); + } + + @Test + public void testSourceDataFormat() { + assertThat(this.fixture.getGeneratorDataFormat(), + equalTo(XML_SOURCE_DATA_FORMAT)); + } } diff --git a/pitest/src/main/java/org/pitest/boot/HotSwapAgent.java b/pitest/src/main/java/org/pitest/boot/HotSwapAgent.java index 84677e428..b4204c1cc 100644 --- a/pitest/src/main/java/org/pitest/boot/HotSwapAgent.java +++ b/pitest/src/main/java/org/pitest/boot/HotSwapAgent.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.boot; diff --git a/pitest/src/main/java/org/pitest/bytecode/FrameOptions.java b/pitest/src/main/java/org/pitest/bytecode/FrameOptions.java index 39904afc9..ad184278a 100644 --- a/pitest/src/main/java/org/pitest/bytecode/FrameOptions.java +++ b/pitest/src/main/java/org/pitest/bytecode/FrameOptions.java @@ -10,11 +10,12 @@ public class FrameOptions { * Java 7 and above require frame info for class version above 7. The ASM * compute frame options does not support the JSR opcode used by some pre 7 * compilers when generating java 5 bytecode. - * + * * We dodge this issue by only computing frames for classes with a version * above 6. - * - * @param bs a class + * + * @param bs + * a class * @return appropriate flags */ public static int pickFlags(byte[] bs) { diff --git a/pitest/src/main/java/org/pitest/bytecode/NullVisitor.java b/pitest/src/main/java/org/pitest/bytecode/NullVisitor.java index f15e8f0e5..dae8e3b75 100644 --- a/pitest/src/main/java/org/pitest/bytecode/NullVisitor.java +++ b/pitest/src/main/java/org/pitest/bytecode/NullVisitor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.bytecode; diff --git a/pitest/src/main/java/org/pitest/classinfo/AddlerHash.java b/pitest/src/main/java/org/pitest/classinfo/AddlerHash.java index 83d208f7c..a48510b71 100644 --- a/pitest/src/main/java/org/pitest/classinfo/AddlerHash.java +++ b/pitest/src/main/java/org/pitest/classinfo/AddlerHash.java @@ -4,6 +4,7 @@ public class AddlerHash implements HashFunction { + @Override public long hash(final byte[] value) { final Adler32 adler = new Adler32(); adler.update(value); diff --git a/pitest/src/main/java/org/pitest/classinfo/BridgeMethodFilter.java b/pitest/src/main/java/org/pitest/classinfo/BridgeMethodFilter.java index d9586c307..c85edb84d 100644 --- a/pitest/src/main/java/org/pitest/classinfo/BridgeMethodFilter.java +++ b/pitest/src/main/java/org/pitest/classinfo/BridgeMethodFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classinfo; @@ -18,10 +18,11 @@ import org.pitest.functional.F5; public enum BridgeMethodFilter implements - F5 { +F5 { INSTANCE; + @Override public Boolean apply(final Integer access, final String name, final String desc, final String signature, final String[] exceptions) { return (isSynthetic(access) || isBridge(access)); diff --git a/pitest/src/main/java/org/pitest/classinfo/ClassByteArraySource.java b/pitest/src/main/java/org/pitest/classinfo/ClassByteArraySource.java index d158aea2f..c97b7b54d 100644 --- a/pitest/src/main/java/org/pitest/classinfo/ClassByteArraySource.java +++ b/pitest/src/main/java/org/pitest/classinfo/ClassByteArraySource.java @@ -1,23 +1,23 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classinfo; import org.pitest.functional.Option; public interface ClassByteArraySource { - + Option getBytes(String clazz); } diff --git a/pitest/src/main/java/org/pitest/classinfo/ClassInfo.java b/pitest/src/main/java/org/pitest/classinfo/ClassInfo.java index 56c2c0be1..c4c16b4e3 100644 --- a/pitest/src/main/java/org/pitest/classinfo/ClassInfo.java +++ b/pitest/src/main/java/org/pitest/classinfo/ClassInfo.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,14 +27,14 @@ public class ClassInfo { - private final ClassIdentifier id; + private final ClassIdentifier id; - private final int access; - private final Set codeLines; - private final ClassPointer outerClass; - private final ClassPointer superClass; - private final Collection annotations; - private final String sourceFile; + private final int access; + private final Set codeLines; + private final ClassPointer outerClass; + private final ClassPointer superClass; + private final Collection annotations; + private final String sourceFile; private final Map classAnnotationValues; public ClassInfo(final ClassPointer superClass, @@ -149,6 +149,7 @@ private boolean descendsFrom(final ClassName clazz) { public static F matchIfAbstract() { return new F() { + @Override public Boolean apply(final ClassInfo a) { return a.isAbstract(); } @@ -163,6 +164,7 @@ public String toString() { public static F toClassName() { return new F() { + @Override public ClassName apply(final ClassInfo a) { return a.getName(); } @@ -172,6 +174,7 @@ public ClassName apply(final ClassInfo a) { public static F toFullClassId() { return new F() { + @Override public HierarchicalClassId apply(final ClassInfo a) { return a.getHierarchicalId(); } diff --git a/pitest/src/main/java/org/pitest/classinfo/ClassInfoBuilder.java b/pitest/src/main/java/org/pitest/classinfo/ClassInfoBuilder.java index b04943542..ef8bea1b8 100644 --- a/pitest/src/main/java/org/pitest/classinfo/ClassInfoBuilder.java +++ b/pitest/src/main/java/org/pitest/classinfo/ClassInfoBuilder.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,14 +21,15 @@ class ClassInfoBuilder { - int access; - ClassIdentifier id; - String outerClass; - String superClass; - String sourceFile; - final Set codeLines = new HashSet(); - final Set annotations = new HashSet(0); - final Map classAnnotationValues = new HashMap(0); + int access; + ClassIdentifier id; + String outerClass; + String superClass; + String sourceFile; + final Set codeLines = new HashSet(); + final Set annotations = new HashSet(0); + final Map classAnnotationValues = new HashMap( + 0); public void registerCodeLine(final int line) { this.codeLines.add(line); @@ -38,8 +39,9 @@ public void registerAnnotation(final String annotation) { this.annotations.add(annotation); } - public void registerClassAnnotationValue(final ClassName annotation, final Object value) { - classAnnotationValues.put(annotation, value); + public void registerClassAnnotationValue(final ClassName annotation, + final Object value) { + this.classAnnotationValues.put(annotation, value); } } diff --git a/pitest/src/main/java/org/pitest/classinfo/ClassInfoVisitor.java b/pitest/src/main/java/org/pitest/classinfo/ClassInfoVisitor.java index 9713971e6..87ecc45ac 100644 --- a/pitest/src/main/java/org/pitest/classinfo/ClassInfoVisitor.java +++ b/pitest/src/main/java/org/pitest/classinfo/ClassInfoVisitor.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -96,10 +96,11 @@ public MethodVisitor visitMethodIfRequired(final int access, } private static class ClassAnnotationValueVisitor extends AnnotationVisitor { - private ClassInfoBuilder classInfo; - private ClassName annotation; + private final ClassInfoBuilder classInfo; + private final ClassName annotation; - public ClassAnnotationValueVisitor(ClassInfoBuilder classInfo, ClassName annotation) { + public ClassAnnotationValueVisitor(ClassInfoBuilder classInfo, + ClassName annotation) { super(Opcodes.ASM5, null); this.classInfo = classInfo; this.annotation = annotation; @@ -108,7 +109,8 @@ public ClassAnnotationValueVisitor(ClassInfoBuilder classInfo, ClassName annotat @Override public void visit(String name, Object value) { if (name.equals("value")) { - classInfo.registerClassAnnotationValue(annotation, simplify(value)); + this.classInfo.registerClassAnnotationValue(this.annotation, + simplify(value)); } super.visit(name, value); } @@ -127,7 +129,10 @@ public void visit(String name, Object value) { @Override public void visitEnd() { - classInfo.registerClassAnnotationValue(annotation, arrayValue.toArray()); + ClassAnnotationValueVisitor.this.classInfo + .registerClassAnnotationValue( + ClassAnnotationValueVisitor.this.annotation, + arrayValue.toArray()); } }; } @@ -147,7 +152,8 @@ private Object simplify(Object value) { class InfoMethodVisitor extends MethodVisitor { private final ClassInfoBuilder classInfo; - public InfoMethodVisitor(final ClassInfoBuilder classInfo, final MethodVisitor writer) { + public InfoMethodVisitor(final ClassInfoBuilder classInfo, + final MethodVisitor writer) { super(Opcodes.ASM5, writer); this.classInfo = classInfo; } diff --git a/pitest/src/main/java/org/pitest/classinfo/ClassName.java b/pitest/src/main/java/org/pitest/classinfo/ClassName.java index cffdb7a4a..b5802c32a 100644 --- a/pitest/src/main/java/org/pitest/classinfo/ClassName.java +++ b/pitest/src/main/java/org/pitest/classinfo/ClassName.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,10 +22,10 @@ import org.pitest.util.Log; public final class ClassName implements Comparable { - + private static final Logger LOG = Log.getLogger(); - private final String name; + private final String name; public ClassName(final String name) { this.name = name.replace('.', '/').intern(); @@ -86,6 +86,7 @@ public ClassName withoutSuffixChars(final int suffixLength) { public static F stringToClassName() { return new F() { + @Override public ClassName apply(final String clazz) { return ClassName.fromString(clazz); } @@ -95,11 +96,12 @@ public ClassName apply(final String clazz) { public static F>> nameToClass() { return nameToClass(IsolationUtils.getContextClassLoader()); } - + public static F>> nameToClass( final ClassLoader loader) { return new F>>() { + @Override public Option> apply(final ClassName className) { try { final Class clazz = Class.forName(className.asJavaName(), false, @@ -124,7 +126,7 @@ public Option> apply(final ClassName className) { }; } - + @Override public int hashCode() { final int prime = 31; @@ -161,6 +163,7 @@ public String toString() { return asJavaName(); } + @Override public int compareTo(final ClassName o) { return this.asJavaName().compareTo(o.asJavaName()); } diff --git a/pitest/src/main/java/org/pitest/classinfo/ClassPointer.java b/pitest/src/main/java/org/pitest/classinfo/ClassPointer.java index c0e90853a..10209c4a5 100644 --- a/pitest/src/main/java/org/pitest/classinfo/ClassPointer.java +++ b/pitest/src/main/java/org/pitest/classinfo/ClassPointer.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,6 +28,7 @@ class DefaultClassPointer implements ClassPointer { this.clazz = clazz; } + @Override public Option fetch() { return Option.some(this.clazz); } @@ -43,6 +44,7 @@ class DeferredClassPointer implements ClassPointer { this.name = name; } + @Override public Option fetch() { return this.repository.fetchClass(this.name); } diff --git a/pitest/src/main/java/org/pitest/classinfo/ComputeClassWriter.java b/pitest/src/main/java/org/pitest/classinfo/ComputeClassWriter.java index 2c804b6b6..707a0c557 100644 --- a/pitest/src/main/java/org/pitest/classinfo/ComputeClassWriter.java +++ b/pitest/src/main/java/org/pitest/classinfo/ComputeClassWriter.java @@ -1,6 +1,6 @@ /*** * Extracted and modified from ASM 4 test suite. Original copyright notice preserved below - * + * * ASM tests * Copyright (c) 2000-2011 INRIA, France Telecom * All rights reserved. @@ -40,9 +40,9 @@ /** * A ClassWriter that computes the common super class of two classes without * actually loading them with a ClassLoader. - * + * * @author Eric Bruneton - * + * * Modified to match behaviour of default ClassWriter and cache already * calculated values */ @@ -123,7 +123,7 @@ private boolean isInterface(final ClassReader info1) { /** * Returns the internal names of the ancestor classes of the given type. - * + * * @param type * the internal name of a class or interface. * @param info @@ -146,7 +146,7 @@ private StringBuilder typeAncestors(String type, ClassReader info) { /** * Returns true if the given type implements the given interface. - * + * * @param type * the internal name of a class or interface. * @param info @@ -177,7 +177,7 @@ private boolean typeImplements(String type, ClassReader info, final String itf) /** * Returns a ClassReader corresponding to the given class or interface. - * + * * @param type * the internal name of a class or interface. * @return the ClassReader corresponding to 'type'. diff --git a/pitest/src/main/java/org/pitest/classinfo/MethodFilteringAdapter.java b/pitest/src/main/java/org/pitest/classinfo/MethodFilteringAdapter.java index fcf9a0f45..0ee58ec00 100644 --- a/pitest/src/main/java/org/pitest/classinfo/MethodFilteringAdapter.java +++ b/pitest/src/main/java/org/pitest/classinfo/MethodFilteringAdapter.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classinfo; diff --git a/pitest/src/main/java/org/pitest/classinfo/NameToClassInfo.java b/pitest/src/main/java/org/pitest/classinfo/NameToClassInfo.java index b1e8d10e7..20504e68d 100644 --- a/pitest/src/main/java/org/pitest/classinfo/NameToClassInfo.java +++ b/pitest/src/main/java/org/pitest/classinfo/NameToClassInfo.java @@ -11,6 +11,7 @@ public NameToClassInfo(final ClassInfoSource repository) { this.repository = repository; } + @Override public Option apply(final ClassName a) { return this.repository.fetchClass(a); } diff --git a/pitest/src/main/java/org/pitest/classinfo/Repository.java b/pitest/src/main/java/org/pitest/classinfo/Repository.java index d91c9ed76..86f6029fd 100644 --- a/pitest/src/main/java/org/pitest/classinfo/Repository.java +++ b/pitest/src/main/java/org/pitest/classinfo/Repository.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ public boolean hasClass(final ClassName name) { } public Option fetchClass(final Class clazz) { // NO_UCD (test - // only) + // only) return fetchClass(clazz.getName()); } @@ -50,6 +50,7 @@ private Option fetchClass(final String name) { return fetchClass(new ClassName(name)); } + @Override public Option fetchClass(final ClassName name) { final ClassInfo info = this.knownClasses.get(name); if (info != null) { diff --git a/pitest/src/main/java/org/pitest/classinfo/TestToClassMapper.java b/pitest/src/main/java/org/pitest/classinfo/TestToClassMapper.java index 689e7681f..60da54a49 100644 --- a/pitest/src/main/java/org/pitest/classinfo/TestToClassMapper.java +++ b/pitest/src/main/java/org/pitest/classinfo/TestToClassMapper.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classinfo; diff --git a/pitest/src/main/java/org/pitest/classpath/ArchiveClassPathRoot.java b/pitest/src/main/java/org/pitest/classpath/ArchiveClassPathRoot.java index f12b662c1..4cbd02853 100644 --- a/pitest/src/main/java/org/pitest/classpath/ArchiveClassPathRoot.java +++ b/pitest/src/main/java/org/pitest/classpath/ArchiveClassPathRoot.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -41,6 +41,7 @@ public ArchiveClassPathRoot(final File file) { this.file = file; } + @Override public InputStream getData(final String name) throws IOException { final ZipFile zip = getRoot(); try { @@ -54,6 +55,7 @@ public InputStream getData(final String name) throws IOException { } } + @Override public URL getResource(final String name) throws MalformedURLException { final ZipFile zip = getRoot(); try { @@ -82,6 +84,7 @@ public String toString() { return "ArchiveClassPathRoot [file=" + this.file.getName() + "]"; } + @Override public Collection classNames() { final List names = new ArrayList(); final ZipFile root = getRoot(); @@ -105,6 +108,7 @@ private String stringToClassName(final String name) { '.'); } + @Override public Option cacheLocation() { return Option.some(this.file.getAbsolutePath()); } diff --git a/pitest/src/main/java/org/pitest/classpath/ClassFilter.java b/pitest/src/main/java/org/pitest/classpath/ClassFilter.java index d85595e2e..6dad68059 100644 --- a/pitest/src/main/java/org/pitest/classpath/ClassFilter.java +++ b/pitest/src/main/java/org/pitest/classpath/ClassFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; diff --git a/pitest/src/main/java/org/pitest/classpath/ClassPath.java b/pitest/src/main/java/org/pitest/classpath/ClassPath.java index 3cad9a186..94535ba81 100644 --- a/pitest/src/main/java/org/pitest/classpath/ClassPath.java +++ b/pitest/src/main/java/org/pitest/classpath/ClassPath.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,7 +37,7 @@ public class ClassPath { - private static final Logger LOG = Log.getLogger(); + private static final Logger LOG = Log.getLogger(); private final CompoundClassPathRoot root; @@ -48,7 +48,7 @@ public ClassPath() { public ClassPath(final ClassPathRoot... roots) { this(Arrays.asList(roots)); } - + public ClassPath(List roots) { this.root = new CompoundClassPathRoot(roots); } @@ -59,6 +59,7 @@ public ClassPath(final Collection files) { private static F exists() { return new F() { + @Override public Boolean apply(final File a) { return a.exists() && a.canRead(); } @@ -66,7 +67,7 @@ public Boolean apply(final File a) { } public Collection classNames() { - return root.classNames(); + return this.root.classNames(); } // fixme should not be determining type here @@ -97,20 +98,20 @@ private static List createRoots(final Collection files) { } public byte[] getClassData(final String classname) throws IOException { - InputStream is = root.getData(classname); - if ( is != null ) { + InputStream is = this.root.getData(classname); + if (is != null) { try { - return StreamUtil.streamToByteArray(is); + return StreamUtil.streamToByteArray(is); } finally { is.close(); } } - return null; + return null; } public URL findResource(final String name) { try { - return root.getResource(name); + return this.root.getResource(name); } catch (final IOException exception) { return null; } @@ -118,14 +119,16 @@ public URL findResource(final String name) { public static Collection getClassPathElementsAsPaths() { final Set filesAsString = new LinkedHashSet(); - FCollection.mapTo(getClassPathElementsAsFiles(), fileToString(), filesAsString); + FCollection.mapTo(getClassPathElementsAsFiles(), fileToString(), + filesAsString); return filesAsString; } private static F fileToString() { return new F() { + @Override public String apply(File file) { - return file.getPath(); + return file.getPath(); } }; } @@ -138,11 +141,13 @@ public static Collection getClassPathElementsAsFiles() { private static F stringToCanonicalFile() { return new F() { + @Override public File apply(String fileAsString) { try { return new File(fileAsString).getCanonicalFile(); } catch (final IOException ex) { - throw new PitError("Error transforming classpath element " + fileAsString, ex); + throw new PitError("Error transforming classpath element " + + fileAsString, ex); } } }; @@ -160,18 +165,17 @@ private static List getClassPathElementsAsAre() { } - public Collection findClasses(final Predicate nameFilter) { return FCollection.filter(classNames(), nameFilter); } public String getLocalClassPath() { - return root.cacheLocation().value(); + return this.root.cacheLocation().value(); } - + public ClassPath getComponent(final Predicate predicate) { return new ClassPath(FCollection.filter(this.root, predicate).toArray( new ClassPathRoot[0])); } - + } diff --git a/pitest/src/main/java/org/pitest/classpath/ClassPathByteArraySource.java b/pitest/src/main/java/org/pitest/classpath/ClassPathByteArraySource.java index 343ddbeb6..c28d8f4db 100644 --- a/pitest/src/main/java/org/pitest/classpath/ClassPathByteArraySource.java +++ b/pitest/src/main/java/org/pitest/classpath/ClassPathByteArraySource.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -23,9 +23,9 @@ public class ClassPathByteArraySource implements ClassByteArraySource { - private static final Logger LOG = Log.getLogger(); + private static final Logger LOG = Log.getLogger(); - private final ClassPath classPath; + private final ClassPath classPath; public ClassPathByteArraySource() { this(new ClassPath()); @@ -35,11 +35,12 @@ public ClassPathByteArraySource(final ClassPath classPath) { this.classPath = classPath; } + @Override public Option getBytes(final String classname) { try { return Option.some(this.classPath.getClassData(classname)); } catch (final IOException e) { - LOG.fine("Could not read class " + classname + ":" + e.getMessage()); + LOG.fine("Could not read class " + classname + ":" + e.getMessage()); return Option.none(); } } diff --git a/pitest/src/main/java/org/pitest/classpath/ClassPathRoot.java b/pitest/src/main/java/org/pitest/classpath/ClassPathRoot.java index 49e82e528..2339a0700 100644 --- a/pitest/src/main/java/org/pitest/classpath/ClassPathRoot.java +++ b/pitest/src/main/java/org/pitest/classpath/ClassPathRoot.java @@ -2,17 +2,17 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ import java.io.IOException; import java.io.InputStream; diff --git a/pitest/src/main/java/org/pitest/classpath/ClassloaderByteArraySource.java b/pitest/src/main/java/org/pitest/classpath/ClassloaderByteArraySource.java index fba2ca52b..362e1a5c1 100644 --- a/pitest/src/main/java/org/pitest/classpath/ClassloaderByteArraySource.java +++ b/pitest/src/main/java/org/pitest/classpath/ClassloaderByteArraySource.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -28,6 +28,7 @@ public ClassloaderByteArraySource(final ClassLoader loader) { this.cp = new ClassPath(new OtherClassLoaderClassPathRoot(loader)); } + @Override public Option getBytes(final String classname) { try { return Option.some(this.cp.getClassData(classname)); diff --git a/pitest/src/main/java/org/pitest/classpath/CodeSource.java b/pitest/src/main/java/org/pitest/classpath/CodeSource.java index 3a40e003e..15e71fdc3 100644 --- a/pitest/src/main/java/org/pitest/classpath/CodeSource.java +++ b/pitest/src/main/java/org/pitest/classpath/CodeSource.java @@ -56,13 +56,14 @@ public Set getCodeUnderTestNames() { @SuppressWarnings("unchecked") public List getTests() { return flatMap(this.classPath.test(), nameToClassInfo()).filter( - and(isWithinATestClass(), isIncludedClass(), not(ClassInfo.matchIfAbstract()))); + and(isWithinATestClass(), isIncludedClass(), + not(ClassInfo.matchIfAbstract()))); } public ClassPath getClassPath() { return this.classPath.getClassPath(); } - + public ProjectClassPaths getProjectPaths() { return this.classPath; } @@ -80,7 +81,8 @@ public Collection getClassInfo(final Collection classes) { public Option fetchClassBytes(final ClassName clazz) { return this.classRepository.querySource(clazz); } - + + @Override public Option fetchClass(final ClassName clazz) { return this.classRepository.fetchClass(clazz); } @@ -92,6 +94,7 @@ private F> nameToClassInfo() { private F isWithinATestClass() { return new F() { + @Override public Boolean apply(final ClassInfo a) { return CodeSource.this.testIdentifier.isATestClass(a); } @@ -102,6 +105,7 @@ public Boolean apply(final ClassInfo a) { private F isIncludedClass() { return new F() { + @Override public Boolean apply(final ClassInfo a) { return CodeSource.this.testIdentifier.isIncluded(a); } @@ -109,5 +113,5 @@ public Boolean apply(final ClassInfo a) { }; } - + } diff --git a/pitest/src/main/java/org/pitest/classpath/CompoundClassPathRoot.java b/pitest/src/main/java/org/pitest/classpath/CompoundClassPathRoot.java index 4ed71ebe3..c65695a90 100644 --- a/pitest/src/main/java/org/pitest/classpath/CompoundClassPathRoot.java +++ b/pitest/src/main/java/org/pitest/classpath/CompoundClassPathRoot.java @@ -12,7 +12,8 @@ import org.pitest.functional.Option; -public class CompoundClassPathRoot implements ClassPathRoot, Iterable { +public class CompoundClassPathRoot implements ClassPathRoot, + Iterable { private final List roots = new ArrayList(); @@ -20,6 +21,7 @@ public CompoundClassPathRoot(final List roots) { this.roots.addAll(roots); } + @Override public InputStream getData(final String name) throws IOException { for (final ClassPathRoot each : this.roots) { final InputStream is = each.getData(name); @@ -30,6 +32,7 @@ public InputStream getData(final String name) throws IOException { return null; } + @Override public Collection classNames() { final List arrayList = new ArrayList(); for (final ClassPathRoot root : this.roots) { @@ -38,6 +41,7 @@ public Collection classNames() { return arrayList; } + @Override public URL getResource(String name) throws MalformedURLException { try { return findRootForResource(name); @@ -56,7 +60,7 @@ private URL findRootForResource(final String name) throws IOException { return null; } - + @Override public Option cacheLocation() { StringBuilder classpath = new StringBuilder(); for (final ClassPathRoot each : this.roots) { @@ -69,8 +73,9 @@ public Option cacheLocation() { return Option.some(classpath.toString()); } + @Override public Iterator iterator() { return this.roots.iterator(); } - + } \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/classpath/DirectoryClassPathRoot.java b/pitest/src/main/java/org/pitest/classpath/DirectoryClassPathRoot.java index 9ed27563a..3dd3ba96c 100644 --- a/pitest/src/main/java/org/pitest/classpath/DirectoryClassPathRoot.java +++ b/pitest/src/main/java/org/pitest/classpath/DirectoryClassPathRoot.java @@ -14,17 +14,17 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ public class DirectoryClassPathRoot implements ClassPathRoot { @@ -34,6 +34,7 @@ public DirectoryClassPathRoot(final File root) { this.root = root; } + @Override public InputStream getData(final String classname) throws IOException { final String filename = classname.replace('.', File.separatorChar).concat( ".class"); @@ -45,6 +46,7 @@ public InputStream getData(final String classname) throws IOException { } } + @Override public URL getResource(final String name) throws MalformedURLException { final File f = new File(this.root, name); if (f.canRead()) { @@ -55,6 +57,7 @@ public URL getResource(final String name) throws MalformedURLException { } } + @Override public Collection classNames() { return classNames(this.root); } @@ -76,9 +79,10 @@ private String fileToClassName(final File f) { .getAbsolutePath() .substring(this.root.getAbsolutePath().length() + 1, (f.getAbsolutePath().length() - ".class".length())) - .replace(File.separatorChar, '.'); + .replace(File.separatorChar, '.'); } + @Override public Option cacheLocation() { return Option.some(this.root.getAbsolutePath()); } diff --git a/pitest/src/main/java/org/pitest/classpath/OtherClassLoaderClassPathRoot.java b/pitest/src/main/java/org/pitest/classpath/OtherClassLoaderClassPathRoot.java index 02192b4ed..143f657e5 100644 --- a/pitest/src/main/java/org/pitest/classpath/OtherClassLoaderClassPathRoot.java +++ b/pitest/src/main/java/org/pitest/classpath/OtherClassLoaderClassPathRoot.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -30,19 +30,23 @@ public OtherClassLoaderClassPathRoot(final ClassLoader loader) { this.loader = loader; } + @Override public Collection classNames() { throw new UnsupportedOperationException(); } + @Override public InputStream getData(final String name) throws IOException { // TODO will this work for archives? Need to consider remote hetrogenous os return this.loader.getResourceAsStream(name.replace(".", "/") + ".class"); } + @Override public URL getResource(final String name) throws MalformedURLException { return this.loader.getResource(name); } + @Override public Option cacheLocation() { return Option.none(); } diff --git a/pitest/src/main/java/org/pitest/classpath/PathFilter.java b/pitest/src/main/java/org/pitest/classpath/PathFilter.java index 5548dcde4..174a7d823 100644 --- a/pitest/src/main/java/org/pitest/classpath/PathFilter.java +++ b/pitest/src/main/java/org/pitest/classpath/PathFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; diff --git a/pitest/src/main/java/org/pitest/classpath/ProjectClassPaths.java b/pitest/src/main/java/org/pitest/classpath/ProjectClassPaths.java index a5c7c38ed..03fe6c2e7 100644 --- a/pitest/src/main/java/org/pitest/classpath/ProjectClassPaths.java +++ b/pitest/src/main/java/org/pitest/classpath/ProjectClassPaths.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -33,21 +33,21 @@ public ProjectClassPaths(final ClassPath classPath, public Iterable code() { return FCollection.filter( this.classPath.getComponent(this.pathFilter.getCodeFilter()) - .findClasses(this.classFilter.getCode()), + .findClasses(this.classFilter.getCode()), this.classFilter.getCode()).map(ClassName.stringToClassName()); } public Iterable test() { return FCollection.filter( this.classPath.getComponent(this.pathFilter.getTestFilter()) - .findClasses(this.classFilter.getTest()), + .findClasses(this.classFilter.getTest()), this.classFilter.getTest()).map(ClassName.stringToClassName()); } public ClassPath getClassPath() { return this.classPath; } - + public ClassFilter getFilter() { return this.classFilter; } diff --git a/pitest/src/main/java/org/pitest/coverage/BlockCoverage.java b/pitest/src/main/java/org/pitest/coverage/BlockCoverage.java index 79fed6e44..4da8e64d0 100644 --- a/pitest/src/main/java/org/pitest/coverage/BlockCoverage.java +++ b/pitest/src/main/java/org/pitest/coverage/BlockCoverage.java @@ -4,7 +4,7 @@ public class BlockCoverage { - private final BlockLocation block; + private final BlockLocation block; private final Collection tests; public BlockCoverage(final BlockLocation block, final Collection tests) { diff --git a/pitest/src/main/java/org/pitest/coverage/ClassLine.java b/pitest/src/main/java/org/pitest/coverage/ClassLine.java index 86d675b8b..3809eb0f8 100644 --- a/pitest/src/main/java/org/pitest/coverage/ClassLine.java +++ b/pitest/src/main/java/org/pitest/coverage/ClassLine.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage; diff --git a/pitest/src/main/java/org/pitest/coverage/CoverageClassVisitor.java b/pitest/src/main/java/org/pitest/coverage/CoverageClassVisitor.java index e1f5a26a3..fb0e686d7 100644 --- a/pitest/src/main/java/org/pitest/coverage/CoverageClassVisitor.java +++ b/pitest/src/main/java/org/pitest/coverage/CoverageClassVisitor.java @@ -1,18 +1,18 @@ /* * Based on http://code.google.com/p/javacoveragent/ by * "alex.mq0" and "dmitry.kandalov" - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage; @@ -28,10 +28,10 @@ /** * Instruments a class with probes on each line */ -public class CoverageClassVisitor extends MethodFilteringAdapter { - private final int classId; +public class CoverageClassVisitor extends MethodFilteringAdapter { + private final int classId; - private int probeCount = 0; + private int probeCount = 0; public CoverageClassVisitor(final int classId, final ClassWriter writer) { super(writer, BridgeMethodFilter.INSTANCE); @@ -39,7 +39,7 @@ public CoverageClassVisitor(final int classId, final ClassWriter writer) { } public void registerProbes(final int number) { - this.probeCount = probeCount + number; + this.probeCount = this.probeCount + number; } @Override @@ -47,14 +47,14 @@ public MethodVisitor visitMethodIfRequired(final int access, final String name, final String desc, final String signature, final String[] exceptions, final MethodVisitor methodVisitor) { - return new CoverageAnalyser(this,this.classId, probeCount, + return new CoverageAnalyser(this, this.classId, this.probeCount, methodVisitor, access, name, desc, signature, exceptions); } @Override public void visitEnd() { - CodeCoverageStore.registerClassProbes(this.classId,this.probeCount); + CodeCoverageStore.registerClassProbes(this.classId, this.probeCount); } } diff --git a/pitest/src/main/java/org/pitest/coverage/CoverageData.java b/pitest/src/main/java/org/pitest/coverage/CoverageData.java index 6a687c299..8bb2466ca 100644 --- a/pitest/src/main/java/org/pitest/coverage/CoverageData.java +++ b/pitest/src/main/java/org/pitest/coverage/CoverageData.java @@ -1,12 +1,12 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,7 +41,7 @@ public class CoverageData implements CoverageDatabase { private static final Logger LOG = Log - .getLogger(); + .getLogger(); // We calculate block coverage, but everything currently runs on line // coverage. Ugly mess of maps below should go when @@ -60,9 +60,11 @@ public class CoverageData implements CoverageDatabase { public CoverageData(final CodeSource code, final LineMap lm) { this.code = code; this.lm = lm; - this.classesForFile = FCollection.bucket(this.code.getCode(), keyFromClassInfo()); + this.classesForFile = FCollection.bucket(this.code.getCode(), + keyFromClassInfo()); } - + + @Override public Collection getTestsForClassLine(final ClassLine classLine) { final Collection result = getTestsForClassName( classLine.getClassName()).get(classLine); @@ -77,14 +79,17 @@ public boolean allTestsGreen() { return !this.hasFailedTest; } + @Override public Collection getClassInfo(final Collection classes) { return this.code.getClassInfo(classes); } + @Override public int getNumberOfCoveredLines(final Collection mutatedClass) { return FCollection.fold(numberCoveredLines(), 0, mutatedClass); } + @Override public Collection getTestsForClass(final ClassName clazz) { final Set tis = new TreeSet( new TestInfoNameComparator()); @@ -107,11 +112,12 @@ private void addTestsToBlockMap(final TestInfo ti, BlockLocation each) { Set tests = this.blockCoverage.get(each); if (tests == null) { tests = new TreeSet(new TestInfoNameComparator()); - blockCoverage.put(each, tests); + this.blockCoverage.put(each, tests); } tests.add(ti); } + @Override public BigInteger getCoverageIdForClass(final ClassName clazz) { final Map> coverage = getTestsForClassName(clazz); if (coverage.isEmpty()) { @@ -127,6 +133,7 @@ public List createCoverage() { private static F>, BlockCoverage> toBlockCoverage() { return new F>, BlockCoverage>() { + @Override public BlockCoverage apply(Entry> a) { return new BlockCoverage(a.getKey(), FCollection.map(a.getValue(), TestInfo.toName())); @@ -134,21 +141,23 @@ public BlockCoverage apply(Entry> a) { }; } + @Override public Collection getClassesForFile(final String sourceFile, String packageName) { Collection value = this.getClassesForFileCache().get( - keyFromSourceAndPackage(sourceFile, packageName)); + keyFromSourceAndPackage(sourceFile, packageName)); if (value == null) { - return Collections.emptyList(); + return Collections. emptyList(); } else { return value; } } - + private Map> getClassesForFileCache() { return this.classesForFile; } + @Override public CoverageSummary createSummary() { return new CoverageSummary(numberOfLines(), coveredLines()); } @@ -168,6 +177,7 @@ private BigInteger generateCoverageNumber( private F, Iterable> testsToClassName() { return new F, Iterable>() { + @Override public Iterable apply(final Set a) { return FCollection.map(a, TestInfo.toDefiningClassName()); } @@ -175,17 +185,19 @@ public Iterable apply(final Set a) { } private static F keyFromClassInfo() { - + return new F() { + @Override public String apply(final ClassInfo c) { - return keyFromSourceAndPackage(c.getSourceFileName(), c.getName().getPackage().asJavaName()); + return keyFromSourceAndPackage(c.getSourceFileName(), c.getName() + .getPackage().asJavaName()); } }; } - private static String keyFromSourceAndPackage( - final String sourceFile, final String packageName) { - + private static String keyFromSourceAndPackage(final String sourceFile, + final String packageName) { + return packageName + " " + sourceFile; } @@ -205,6 +217,7 @@ private int coveredLines() { private F2 numberLines() { return new F2() { + @Override public Integer apply(final Integer a, final ClassInfo clazz) { return a + clazz.getNumberOfCodeLines(); } @@ -231,6 +244,7 @@ private TestInfo createTestInfo(final Description description, private F2 numberCoveredLines() { return new F2() { + @Override public Integer apply(final Integer a, final ClassName clazz) { return a + getNumberOfCoveredLines(clazz); } @@ -277,7 +291,7 @@ private Map> convertBlockCoverageToLineCoverageForClass } } - lineCoverage.put(clazz, linesToTests); + this.lineCoverage.put(clazz, linesToTests); return linesToTests; } @@ -308,8 +322,8 @@ private Set getLinesForBlock(BlockLocation bl) { } private void calculateLinesForBlocks(ClassName className) { - Map> lines = lm.mapLines(className); - blocksToLines.putAll(lines); + Map> lines = this.lm.mapLines(className); + this.blocksToLines.putAll(lines); } private void recordTestFailure() { @@ -318,6 +332,7 @@ private void recordTestFailure() { private F>, Iterable> toTests() { return new F>, Iterable>() { + @Override public Iterable apply(Entry> a) { return a.getValue(); } @@ -327,6 +342,7 @@ public Iterable apply(Entry> a) { private Predicate>> isFor( final ClassName clazz) { return new Predicate>>() { + @Override public Boolean apply(Entry> a) { return a.getKey().isFor(clazz); } diff --git a/pitest/src/main/java/org/pitest/coverage/CoverageGenerator.java b/pitest/src/main/java/org/pitest/coverage/CoverageGenerator.java index 6e7a467e3..3f7937154 100644 --- a/pitest/src/main/java/org/pitest/coverage/CoverageGenerator.java +++ b/pitest/src/main/java/org/pitest/coverage/CoverageGenerator.java @@ -1,12 +1,12 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/coverage/CoverageResult.java b/pitest/src/main/java/org/pitest/coverage/CoverageResult.java index 28df5f278..4558846ae 100644 --- a/pitest/src/main/java/org/pitest/coverage/CoverageResult.java +++ b/pitest/src/main/java/org/pitest/coverage/CoverageResult.java @@ -6,10 +6,10 @@ public class CoverageResult { - private final Description testUnitDescription; - private final int executionTime; + private final Description testUnitDescription; + private final int executionTime; private final Collection visitedBlocks; - private final boolean greenSuite; + private final boolean greenSuite; public CoverageResult(final Description testUnitDescription, final int executionTime, final boolean greenSuite, @@ -35,7 +35,7 @@ public Collection getCoverage() { public boolean isGreenTest() { return this.greenSuite; } - + public int getNumberOfCoveredBlocks() { return this.visitedBlocks.size(); } diff --git a/pitest/src/main/java/org/pitest/coverage/CoverageTransformer.java b/pitest/src/main/java/org/pitest/coverage/CoverageTransformer.java index ad2ec37f2..680a210d8 100644 --- a/pitest/src/main/java/org/pitest/coverage/CoverageTransformer.java +++ b/pitest/src/main/java/org/pitest/coverage/CoverageTransformer.java @@ -24,10 +24,11 @@ public CoverageTransformer(final Predicate filter) { this.filter = filter; } + @Override public byte[] transform(final ClassLoader loader, final String className, final Class classBeingRedefined, final ProtectionDomain protectionDomain, final byte[] classfileBuffer) - throws IllegalClassFormatException { + throws IllegalClassFormatException { final boolean include = shouldInclude(className); if (include) { try { diff --git a/pitest/src/main/java/org/pitest/coverage/TestInfo.java b/pitest/src/main/java/org/pitest/coverage/TestInfo.java index 7a4c11a50..62f19577a 100644 --- a/pitest/src/main/java/org/pitest/coverage/TestInfo.java +++ b/pitest/src/main/java/org/pitest/coverage/TestInfo.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ public final class TestInfo { private final String name; private final String definingClass; - + private final int time; private final int blocks; private final Option testee; @@ -62,6 +62,7 @@ public String toString() { public static F toName() { return new F() { + @Override public String apply(final TestInfo a) { return a.getName(); } @@ -72,6 +73,7 @@ public String apply(final TestInfo a) { public static F toDefiningClassName() { return new F() { + @Override public ClassName apply(final TestInfo a) { return new ClassName(a.definingClass); } diff --git a/pitest/src/main/java/org/pitest/coverage/TestInfoNameComparator.java b/pitest/src/main/java/org/pitest/coverage/TestInfoNameComparator.java index 1a3a64856..4725300f0 100644 --- a/pitest/src/main/java/org/pitest/coverage/TestInfoNameComparator.java +++ b/pitest/src/main/java/org/pitest/coverage/TestInfoNameComparator.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage; @@ -22,6 +22,7 @@ class TestInfoNameComparator implements Comparator, Serializable { private static final long serialVersionUID = 1L; + @Override public int compare(final TestInfo lhs, final TestInfo rhs) { // NO_UCD return lhs.getName().compareTo(rhs.getName()); } diff --git a/pitest/src/main/java/org/pitest/coverage/analysis/AbstractCoverageStrategy.java b/pitest/src/main/java/org/pitest/coverage/analysis/AbstractCoverageStrategy.java index a8876fd09..49d12e1b8 100644 --- a/pitest/src/main/java/org/pitest/coverage/analysis/AbstractCoverageStrategy.java +++ b/pitest/src/main/java/org/pitest/coverage/analysis/AbstractCoverageStrategy.java @@ -11,27 +11,25 @@ abstract class AbstractCoverageStrategy extends AdviceAdapter { + protected final MethodVisitor methodVisitor; + protected final int classId; + protected final int probeOffset; + protected final List blocks; - protected final MethodVisitor methodVisitor; - protected final int classId; - protected final int probeOffset; - protected final List blocks; - private final InstructionCounter counter; - + /** * label to mark start of try finally block that is added to each method */ - private final Label before = new Label(); + private final Label before = new Label(); /** * label to mark handler block of try finally */ - private final Label handler = new Label(); + private final Label handler = new Label(); - protected int probeCount = 0; + protected int probeCount = 0; - AbstractCoverageStrategy(List blocks, InstructionCounter counter, final int classId, final MethodVisitor writer, final int access, final String name, final String desc, final int probeOffset) { @@ -45,12 +43,11 @@ abstract class AbstractCoverageStrategy extends AdviceAdapter { } abstract void prepare(); - + abstract void generateProbeReportCode(); - + abstract void insertProbe(); - @Override public void visitCode() { super.visitCode(); @@ -112,8 +109,7 @@ protected void pushConstant(final int value) { } } } - - + @Override public void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) { @@ -210,24 +206,23 @@ public void visitMultiANewArrayInsn(final String desc, final int dims) { insertProbeIfAppropriate(); super.visitMultiANewArrayInsn(desc, dims); } - @Override public void visitLineNumber(final int line, final Label start) { insertProbeIfAppropriate(); super.visitLineNumber(line, start); } - + private void insertProbeIfAppropriate() { - if ( needsProbe(counter.currentInstructionCount()) ) { - insertProbe(); - this.probeCount++; + if (needsProbe(this.counter.currentInstructionCount())) { + insertProbe(); + this.probeCount++; } } private boolean needsProbe(int currentInstructionCount) { - for ( Block each : this.blocks) { - if ( each.firstInstructionIs(currentInstructionCount - 1)) { + for (Block each : this.blocks) { + if (each.firstInstructionIs(currentInstructionCount - 1)) { return true; } } diff --git a/pitest/src/main/java/org/pitest/coverage/analysis/ArrayProbeCoverageMethodVisitor.java b/pitest/src/main/java/org/pitest/coverage/analysis/ArrayProbeCoverageMethodVisitor.java index 198ee1af9..7a4d057f6 100644 --- a/pitest/src/main/java/org/pitest/coverage/analysis/ArrayProbeCoverageMethodVisitor.java +++ b/pitest/src/main/java/org/pitest/coverage/analysis/ArrayProbeCoverageMethodVisitor.java @@ -1,14 +1,14 @@ /* * Based on http://code.google.com/p/javacoveragent/ by * "alex.mq0" and "dmitry.kandalov" - * - * + * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,16 +29,16 @@ /** * Instruments a method adding probes at each line. The strategy requires the * compiler to be configured to add line number debug information. - * + * * Probes are implemented by adding an array to each method. Lines hits are * registered by a write to this local array. Each method exit point is then * augmented with a call that passes this array to the coverage store class that * handles communication of this data back to the parent process on the * completion of each test. - * + * * All methods are wrapped in a try finally block to ensure that coverage data * is sent in the event of a runtime exception. - * + * * Creating a new array on each method entry is not cheap - other coverage * systems add a static field used across all methods. We must clear down all * coverage history for each test however. Resetting static fields in all loaded diff --git a/pitest/src/main/java/org/pitest/coverage/analysis/CoverageAnalyser.java b/pitest/src/main/java/org/pitest/coverage/analysis/CoverageAnalyser.java index 0ed1264f4..03b11b871 100644 --- a/pitest/src/main/java/org/pitest/coverage/analysis/CoverageAnalyser.java +++ b/pitest/src/main/java/org/pitest/coverage/analysis/CoverageAnalyser.java @@ -58,19 +58,19 @@ public void visitEnd() { accept(new InstructionTrackingMethodVisitor( new SimpleBlockCoverageVisitor(blocks, counter, this.classId, this.mv, this.access, this.name, this.desc, this.probeOffset), - counter)); + counter)); } else if ((blockCount <= MAX_SUPPORTED_LOCAL_PROBES) && (blockCount >= 1)) { accept(new InstructionTrackingMethodVisitor( new LocalVariableCoverageMethodVisitor(blocks, counter, this.classId, this.mv, this.access, this.name, this.desc, this.probeOffset), - counter)); + counter)); } else { // for now fall back to the naive implementation - could instead use array // passing version accept(new InstructionTrackingMethodVisitor( new ArrayProbeCoverageMethodVisitor(blocks, counter, this.classId, this.mv, this.access, this.name, this.desc, this.probeOffset), - counter)); + counter)); } } diff --git a/pitest/src/main/java/org/pitest/coverage/analysis/LineMapper.java b/pitest/src/main/java/org/pitest/coverage/analysis/LineMapper.java index c44c5606c..d7a5cb098 100644 --- a/pitest/src/main/java/org/pitest/coverage/analysis/LineMapper.java +++ b/pitest/src/main/java/org/pitest/coverage/analysis/LineMapper.java @@ -24,6 +24,7 @@ public LineMapper(final CodeSource source) { this.source = source; } + @Override public Map> mapLines(final ClassName clazz) { final ControlFlowAnalyser cfa = new ControlFlowAnalyser(); diff --git a/pitest/src/main/java/org/pitest/coverage/analysis/LocalVariableCoverageMethodVisitor.java b/pitest/src/main/java/org/pitest/coverage/analysis/LocalVariableCoverageMethodVisitor.java index 31eaf02f9..171d3a477 100644 --- a/pitest/src/main/java/org/pitest/coverage/analysis/LocalVariableCoverageMethodVisitor.java +++ b/pitest/src/main/java/org/pitest/coverage/analysis/LocalVariableCoverageMethodVisitor.java @@ -59,7 +59,7 @@ protected void generateProbeReportCode() { CodeCoverageStore.CLASS_NAME, CodeCoverageStore.PROBE_METHOD_NAME, "(II" + String.format(String.format("%%0%dd", this.blocks.size()), 0) - .replace("0", "Z") + ")V", false); + .replace("0", "Z") + ")V", false); } } diff --git a/pitest/src/main/java/org/pitest/coverage/analysis/SimpleBlockCoverageVisitor.java b/pitest/src/main/java/org/pitest/coverage/analysis/SimpleBlockCoverageVisitor.java index f01172fa2..b4fefd62d 100644 --- a/pitest/src/main/java/org/pitest/coverage/analysis/SimpleBlockCoverageVisitor.java +++ b/pitest/src/main/java/org/pitest/coverage/analysis/SimpleBlockCoverageVisitor.java @@ -1,6 +1,5 @@ package org.pitest.coverage.analysis; - import java.util.List; import org.objectweb.asm.Handle; @@ -13,28 +12,28 @@ /** * Instruments via a method call at each line. - * + * * This simplistic approach is generally slow, but does not require finally * blocks that are difficult to generate correctly for constructors. - * + * * This simple approach should however provide better performance for single * line methods. */ public class SimpleBlockCoverageVisitor extends MethodVisitor { - private final MethodVisitor methodVisitor; - private final int classId; + private final MethodVisitor methodVisitor; + private final int classId; - private final int probeOffset; + private final int probeOffset; private final InstructionCounter counter; - private final List blocks; - - private int probeCount = 0; - - - public SimpleBlockCoverageVisitor(List blocks, InstructionCounter counter, - final int classId, final MethodVisitor writer, final int access, - final String name, final String desc, final int probeOffset) { + private final List blocks; + + private int probeCount = 0; + + public SimpleBlockCoverageVisitor(List blocks, + InstructionCounter counter, final int classId, + final MethodVisitor writer, final int access, final String name, + final String desc, final int probeOffset) { super(Opcodes.ASM5, writer); this.counter = counter; @@ -44,7 +43,7 @@ public SimpleBlockCoverageVisitor(List blocks, InstructionCounter counter this.probeOffset = probeOffset; } - + @Override public void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) { @@ -141,16 +140,15 @@ public void visitMultiANewArrayInsn(final String desc, final int dims) { insertProbeIfAppropriate(); super.visitMultiANewArrayInsn(desc, dims); } - @Override public void visitLineNumber(final int line, final Label start) { insertProbeIfAppropriate(); super.visitLineNumber(line, start); } - + private void insertProbeIfAppropriate() { - if ( needsProbe(counter.currentInstructionCount()) ) { + if (needsProbe(this.counter.currentInstructionCount())) { this.methodVisitor.visitLdcInsn(this.classId); this.methodVisitor.visitLdcInsn(this.probeCount + this.probeOffset); @@ -162,8 +160,8 @@ private void insertProbeIfAppropriate() { } private boolean needsProbe(int currentInstructionCount) { - for ( Block each : this.blocks) { - if ( each.firstInstructionIs(currentInstructionCount - 1)) { + for (Block each : this.blocks) { + if (each.firstInstructionIs(currentInstructionCount - 1)) { return true; } } diff --git a/pitest/src/main/java/org/pitest/coverage/execute/CoverageDecorator.java b/pitest/src/main/java/org/pitest/coverage/execute/CoverageDecorator.java index ec21693f4..2f4f986e3 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/CoverageDecorator.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/CoverageDecorator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/coverage/execute/CoverageOptions.java b/pitest/src/main/java/org/pitest/coverage/execute/CoverageOptions.java index ee5f1d5d1..7301abdaf 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/CoverageOptions.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/CoverageOptions.java @@ -2,13 +2,13 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/coverage/execute/CoveragePipe.java b/pitest/src/main/java/org/pitest/coverage/execute/CoveragePipe.java index 712e320a5..2834bec1a 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/CoveragePipe.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/CoveragePipe.java @@ -19,10 +19,12 @@ public CoveragePipe(final OutputStream dos) { this.dos = new SafeDataOutputStream(dos); } + @Override public synchronized void newTest() { CodeCoverageStore.reset(); } + @Override public synchronized void recordTestOutcome(final Description description, final boolean wasGreen, final int executionTime) { final Collection hits = CodeCoverageStore.getHits(); @@ -44,6 +46,7 @@ public synchronized void end(final ExitCode exitCode) { this.dos.flush(); } + @Override public synchronized void registerClass(final int id, final String className) { this.dos.writeByte(Id.CLAZZ); @@ -52,8 +55,9 @@ public synchronized void registerClass(final int id, final String className) { } - public synchronized void registerProbes(int classId, String methodName, String methodDesc, - int firstProbe, int lastProbe) { + @Override + public synchronized void registerProbes(int classId, String methodName, + String methodDesc, int firstProbe, int lastProbe) { this.dos.writeByte(Id.PROBES); this.dos.writeInt(classId); this.dos.writeString(methodName); @@ -62,5 +66,4 @@ public synchronized void registerProbes(int classId, String methodName, String m this.dos.writeInt(lastProbe); } - } diff --git a/pitest/src/main/java/org/pitest/coverage/execute/CoverageProcess.java b/pitest/src/main/java/org/pitest/coverage/execute/CoverageProcess.java index 5760e92ea..cfd375bd5 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/CoverageProcess.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/CoverageProcess.java @@ -18,7 +18,7 @@ public class CoverageProcess { public CoverageProcess(final ProcessArgs processArgs, final CoverageOptions arguments, final ServerSocket socket, final List testClases, final SideEffect1 handler) - throws IOException { + throws IOException { this.process = new WrappingProcess(socket.getLocalPort(), processArgs, CoverageSlave.class); this.crt = new CoverageCommunicationThread(socket, arguments, testClases, diff --git a/pitest/src/main/java/org/pitest/coverage/execute/CoverageSlave.java b/pitest/src/main/java/org/pitest/coverage/execute/CoverageSlave.java index 6b66cbef6..c65872bda 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/CoverageSlave.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/CoverageSlave.java @@ -111,6 +111,7 @@ public static void main(final String[] args) { private static Predicate convertToJVMClassFilter( final Predicate child) { return new Predicate() { + @Override public Boolean apply(final String a) { return child.apply(a.replace("/", ".")); } @@ -120,7 +121,7 @@ public Boolean apply(final String a) { private static List getTestsFromParent( final SafeDataInputStream dis, final CoverageOptions paramsFromParent) - throws IOException { + throws IOException { final List classes = receiveTestClassesFromParent(dis); Collections.sort(classes); // ensure classes loaded in a consistent order @@ -129,7 +130,7 @@ private static List getTestsFromParent( final DependencyFilter filter = new DependencyFilter( new DependencyExtractor(new ClassPathByteArraySource(), paramsFromParent.getDependencyAnalysisMaxDistance()), - paramsFromParent.getFilter()); + paramsFromParent.getFilter()); final List filteredTus = filter .filterTestsByDependencyAnalysis(tus); diff --git a/pitest/src/main/java/org/pitest/coverage/execute/CoverageWorker.java b/pitest/src/main/java/org/pitest/coverage/execute/CoverageWorker.java index 783acad60..3b3a29c99 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/CoverageWorker.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/CoverageWorker.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -48,7 +48,8 @@ public void run() { final Container c = new UnContainer(); - final Pitest pit = new Pitest(Collections.singletonList(new ErrorListener())); + final Pitest pit = new Pitest( + Collections.singletonList(new ErrorListener())); pit.run(c, decoratedTests); } catch (final Exception ex) { @@ -59,6 +60,7 @@ public void run() { private Comparator testComparator() { return new Comparator() { + @Override public int compare(final TestUnit o1, final TestUnit o2) { return o1.getDescription().getQualifiedName() .compareTo(o2.getDescription().getQualifiedName()); diff --git a/pitest/src/main/java/org/pitest/coverage/execute/DefaultCoverageGenerator.java b/pitest/src/main/java/org/pitest/coverage/execute/DefaultCoverageGenerator.java index d53016e31..e5fddf94c 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/DefaultCoverageGenerator.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/DefaultCoverageGenerator.java @@ -1,12 +1,12 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -71,6 +71,7 @@ public DefaultCoverageGenerator(final File workingDir, this.showProgress = showProgress; } + @Override public CoverageData calculateCoverage() { try { final long t0 = System.currentTimeMillis(); @@ -80,7 +81,7 @@ public CoverageData calculateCoverage() { this.timings.registerEnd(Timings.Stage.SCAN_CLASS_PATH); final CoverageData coverage = new CoverageData(this.code, new LineMapper( - code)); + this.code)); this.timings.registerStart(Timings.Stage.COVERAGE); gatherCoverageData(tests, coverage); @@ -146,6 +147,7 @@ private void gatherCoverageData(final Collection tests, private static F classInfoToName() { return new F() { + @Override public String apply(final ClassInfo a) { return a.getName().asInternalName(); } @@ -163,6 +165,7 @@ private SideEffect1 captureStandardOutIfVerbose() { private SideEffect1 logInfo() { return new SideEffect1() { + @Override public void apply(final String a) { LOG.info("SLAVE : " + a); } @@ -171,6 +174,7 @@ public void apply(final String a) { private SideEffect1 log() { return new SideEffect1() { + @Override public void apply(final String a) { LOG.fine("SLAVE : " + a); } @@ -181,9 +185,10 @@ private SideEffect1 resultProcessor( final CoverageData coverage) { return new SideEffect1() { private final String[] spinner = new String[] { "\u0008/", "\u0008-", - "\u0008\\", "\u0008|" }; + "\u0008\\", "\u0008|" }; int i = 0; + @Override public void apply(final CoverageResult cr) { coverage.calculateClassCoverage(cr); if (DefaultCoverageGenerator.this.showProgress) { @@ -195,10 +200,12 @@ public void apply(final CoverageResult cr) { }; } + @Override public Configuration getConfiguration() { return this.coverageOptions.getPitConfig(); } + @Override public LaunchOptions getLaunchOptions() { return this.launchOptions; } diff --git a/pitest/src/main/java/org/pitest/coverage/execute/DependencyFilter.java b/pitest/src/main/java/org/pitest/coverage/execute/DependencyFilter.java index 5ea27f0e8..bd5c4c660 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/DependencyFilter.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/DependencyFilter.java @@ -36,6 +36,7 @@ private F isWithinReach() { return new F() { private final Map cache = new HashMap(); + @Override public Boolean apply(final TestUnit testUnit) { final String testClass = testUnit.getDescription().getFirstTestClass(); try { diff --git a/pitest/src/main/java/org/pitest/coverage/execute/ErrorListener.java b/pitest/src/main/java/org/pitest/coverage/execute/ErrorListener.java index d4eaa2409..03d6ebe75 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/ErrorListener.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/ErrorListener.java @@ -6,24 +6,30 @@ public class ErrorListener implements TestListener { + @Override public void onRunStart() { } + @Override public void onTestStart(final Description d) { } + @Override public void onTestFailure(final TestResult tr) { System.out.println("FAIL " + tr.getDescription() + " -> " + tr.getThrowable()); } + @Override public void onTestSkipped(final TestResult tr) { } + @Override public void onTestSuccess(final TestResult tr) { } + @Override public void onRunEnd() { } diff --git a/pitest/src/main/java/org/pitest/coverage/execute/Receive.java b/pitest/src/main/java/org/pitest/coverage/execute/Receive.java index 611b3163a..a37c5a1a7 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/Receive.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/Receive.java @@ -22,14 +22,15 @@ final class Receive implements ReceiveStrategy { private final Map classIdToName = new ConcurrentHashMap(); - private final Map probeToBlock = new ConcurrentHashMap(); - + private final Map probeToBlock = new ConcurrentHashMap(); + private final SideEffect1 handler; Receive(final SideEffect1 handler) { this.handler = handler; } + @Override public void apply(final byte control, final SafeDataInputStream is) { switch (control) { case Id.CLAZZ: @@ -39,7 +40,7 @@ public void apply(final byte control, final SafeDataInputStream is) { break; case Id.PROBES: handleProbes(is); - break; + break; case Id.OUTCOME: handleTestEnd(is); break; @@ -54,10 +55,13 @@ private void handleProbes(final SafeDataInputStream is) { final String methodSig = is.readString(); final int first = is.readInt(); final int last = is.readInt(); - Location loc = Location.location(classIdToName.get(classId), MethodName.fromString(methodName), methodSig); - for (int i = first; i != last + 1; i++) { - // nb, convert from classwide id to method scoped index within BlockLocation - probeToBlock.put(CodeCoverageStore.encode(classId, i), new BlockLocation(loc,i - first)); + Location loc = Location.location(this.classIdToName.get(classId), + MethodName.fromString(methodName), methodSig); + for (int i = first; i != (last + 1); i++) { + // nb, convert from classwide id to method scoped index within + // BlockLocation + this.probeToBlock.put(CodeCoverageStore.encode(classId, i), + new BlockLocation(loc, i - first)); } } diff --git a/pitest/src/main/java/org/pitest/coverage/execute/SendData.java b/pitest/src/main/java/org/pitest/coverage/execute/SendData.java index 4b42692b0..c551012a3 100644 --- a/pitest/src/main/java/org/pitest/coverage/execute/SendData.java +++ b/pitest/src/main/java/org/pitest/coverage/execute/SendData.java @@ -17,6 +17,7 @@ final class SendData implements SideEffect1 { this.testClasses = testClasses; } + @Override public void apply(final SafeDataOutputStream dos) { sendArguments(dos); sendTests(dos); diff --git a/pitest/src/main/java/org/pitest/coverage/export/DefaultCoverageExporter.java b/pitest/src/main/java/org/pitest/coverage/export/DefaultCoverageExporter.java index a67be9605..bfbd69358 100644 --- a/pitest/src/main/java/org/pitest/coverage/export/DefaultCoverageExporter.java +++ b/pitest/src/main/java/org/pitest/coverage/export/DefaultCoverageExporter.java @@ -25,6 +25,7 @@ public DefaultCoverageExporter(final ResultOutputStrategy outputStrategy) { this.outputStrategy = outputStrategy; } + @Override public void recordCoverage(final Collection coverage) { final Writer out = this.outputStrategy .createWriterForFile("linecoverage.xml"); @@ -43,9 +44,12 @@ private void writeHeader(final Writer out) { private void writeLineCoverage(final BlockCoverage each, final Writer out) { Location l = each.getBlock().getLocation(); - write(out, ""); + write( + out, + ""); write(out, "\n"); final List ts = new ArrayList(each.getTests()); Collections.sort(ts); diff --git a/pitest/src/main/java/org/pitest/coverage/export/NullCoverageExporter.java b/pitest/src/main/java/org/pitest/coverage/export/NullCoverageExporter.java index 1f76b4581..f8f06ee86 100644 --- a/pitest/src/main/java/org/pitest/coverage/export/NullCoverageExporter.java +++ b/pitest/src/main/java/org/pitest/coverage/export/NullCoverageExporter.java @@ -2,11 +2,12 @@ import java.util.Collection; -import org.pitest.coverage.CoverageExporter; import org.pitest.coverage.BlockCoverage; +import org.pitest.coverage.CoverageExporter; public class NullCoverageExporter implements CoverageExporter { + @Override public void recordCoverage(final Collection coverage) { } diff --git a/pitest/src/main/java/org/pitest/dependency/DependencyAccess.java b/pitest/src/main/java/org/pitest/dependency/DependencyAccess.java index 919a2a0c1..950db36a1 100644 --- a/pitest/src/main/java/org/pitest/dependency/DependencyAccess.java +++ b/pitest/src/main/java/org/pitest/dependency/DependencyAccess.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.dependency; @@ -73,6 +73,7 @@ public boolean equals(final Object obj) { return true; } + @Override public int compareTo(final Member other) { return (other.name.compareTo(this.name) * 100) + (other.owner.compareTo(this.owner) * 1000); diff --git a/pitest/src/main/java/org/pitest/dependency/DependencyClassVisitor.java b/pitest/src/main/java/org/pitest/dependency/DependencyClassVisitor.java index 788c58fe2..a8278c36d 100644 --- a/pitest/src/main/java/org/pitest/dependency/DependencyClassVisitor.java +++ b/pitest/src/main/java/org/pitest/dependency/DependencyClassVisitor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.dependency; @@ -34,6 +34,7 @@ protected DependencyClassVisitor(final ClassVisitor visitor, private SideEffect1 filterOutJavaLangObject( final SideEffect1 child) { return new SideEffect1() { + @Override public void apply(final DependencyAccess a) { if (!a.getDest().getOwner().equals("java/lang/Object")) { child.apply(a); diff --git a/pitest/src/main/java/org/pitest/dependency/DependencyExtractor.java b/pitest/src/main/java/org/pitest/dependency/DependencyExtractor.java index c71053127..8cc892eb2 100644 --- a/pitest/src/main/java/org/pitest/dependency/DependencyExtractor.java +++ b/pitest/src/main/java/org/pitest/dependency/DependencyExtractor.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -56,7 +56,7 @@ public DependencyExtractor(final ClassByteArraySource classToBytes, @SuppressWarnings("unchecked") public Collection extractCallDependenciesForPackages( final String clazz, final Predicate targetPackages) - throws IOException { + throws IOException { final Set allDependencies = extractCallDependencies(clazz, new IgnoreCoreClasses()); return FCollection.filter(allDependencies, @@ -66,6 +66,7 @@ public Collection extractCallDependenciesForPackages( private static F notSuppliedClass(final String clazz) { return new F() { + @Override public Boolean apply(final String a) { return !Functions.jvmClassToClassName().apply(a).equals(clazz); } @@ -77,6 +78,7 @@ private static F asJVMNamePredicate( final Predicate predicate) { return new F() { + @Override public Boolean apply(final String a) { return predicate.apply(Functions.jvmClassToClassName().apply(a)); } @@ -150,6 +152,7 @@ private Set extractRelevantDependencies(final String clazz, private static Comparator equalDestinationComparator() { return new Comparator() { + @Override public int compare(final DependencyAccess o1, final DependencyAccess o2) { return o1.getDest().compareTo(o2.getDest()); } @@ -190,6 +193,7 @@ private Map> groupDependenciesByClass( private static F2>, DependencyAccess, Map>> addDependenciesToMap() { return new F2>, DependencyAccess, Map>>() { + @Override public Map> apply( final Map> map, final DependencyAccess access) { @@ -208,6 +212,7 @@ public Map> apply( private static Comparator classNameComparator() { return new Comparator() { + @Override public int compare(final DependencyAccess lhs, final DependencyAccess rhs) { return lhs.getDest().getOwner().compareTo(rhs.getDest().getOwner()); } @@ -216,6 +221,7 @@ public int compare(final DependencyAccess lhs, final DependencyAccess rhs) { private static Predicate nameIsEqual(final String clazz) { return new Predicate() { + @Override public Boolean apply(final DependencyAccess a) { return a.getDest().getOwner().equals(clazz); } @@ -226,6 +232,7 @@ private static SideEffect1 constructCollectingSideEffectForVis final List dependencies, final Predicate predicate) { final SideEffect1 se = new SideEffect1() { + @Override public void apply(final DependencyAccess a) { if (predicate.apply(a)) { dependencies.add(a); diff --git a/pitest/src/main/java/org/pitest/dependency/IgnoreCoreClasses.java b/pitest/src/main/java/org/pitest/dependency/IgnoreCoreClasses.java index 53fdad867..7d7eeda59 100644 --- a/pitest/src/main/java/org/pitest/dependency/IgnoreCoreClasses.java +++ b/pitest/src/main/java/org/pitest/dependency/IgnoreCoreClasses.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,15 +25,16 @@ public class IgnoreCoreClasses implements Predicate { private final Predicate impl; private final Collection filtered = Arrays.asList("java.*", "sun.*", - "javax.*", "org.junit.*", - "junit.*", "org.mockito.*", - "org.powermock.*", - "org.jmock.*", "com.sun.*"); + "javax.*", "org.junit.*", + "junit.*", "org.mockito.*", + "org.powermock.*", + "org.jmock.*", "com.sun.*"); IgnoreCoreClasses() { this.impl = Prelude.not(Prelude.or(Glob.toGlobPredicates(this.filtered))); } + @Override public Boolean apply(final DependencyAccess a) { final String owner = a.getDest().getOwner().replace("/", "."); return this.impl.apply(owner); diff --git a/pitest/src/main/java/org/pitest/extension/common/CompoundTestSuiteFinder.java b/pitest/src/main/java/org/pitest/extension/common/CompoundTestSuiteFinder.java index 478dad24d..2b0c3a728 100644 --- a/pitest/src/main/java/org/pitest/extension/common/CompoundTestSuiteFinder.java +++ b/pitest/src/main/java/org/pitest/extension/common/CompoundTestSuiteFinder.java @@ -14,6 +14,7 @@ public CompoundTestSuiteFinder(final Collection children) { this.children = children; } + @Override public List> apply(final Class a) { for (final TestSuiteFinder i : this.children) { final List> found = i.apply(a); diff --git a/pitest/src/main/java/org/pitest/extension/common/NoTestSuiteFinder.java b/pitest/src/main/java/org/pitest/extension/common/NoTestSuiteFinder.java index 4ead83abd..ee4d9ab5a 100644 --- a/pitest/src/main/java/org/pitest/extension/common/NoTestSuiteFinder.java +++ b/pitest/src/main/java/org/pitest/extension/common/NoTestSuiteFinder.java @@ -7,6 +7,7 @@ public class NoTestSuiteFinder implements TestSuiteFinder { + @Override public List> apply(final Class a) { return Collections.emptyList(); } diff --git a/pitest/src/main/java/org/pitest/extension/common/TestUnitDecorator.java b/pitest/src/main/java/org/pitest/extension/common/TestUnitDecorator.java index f97aaaa0a..07863b295 100644 --- a/pitest/src/main/java/org/pitest/extension/common/TestUnitDecorator.java +++ b/pitest/src/main/java/org/pitest/extension/common/TestUnitDecorator.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.extension.common; @@ -26,6 +26,7 @@ protected TestUnitDecorator(final TestUnit child) { this.child = child; } + @Override public Description getDescription() { return this.child.getDescription(); } @@ -34,6 +35,7 @@ public TestUnit child() { return this.child; } + @Override public abstract void execute(ClassLoader loader, ResultCollector rc); } diff --git a/pitest/src/main/java/org/pitest/functional/F.java b/pitest/src/main/java/org/pitest/functional/F.java index a6fa91517..9b358e8bf 100644 --- a/pitest/src/main/java/org/pitest/functional/F.java +++ b/pitest/src/main/java/org/pitest/functional/F.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/F2.java b/pitest/src/main/java/org/pitest/functional/F2.java index 88eaab391..7bf3cd28f 100644 --- a/pitest/src/main/java/org/pitest/functional/F2.java +++ b/pitest/src/main/java/org/pitest/functional/F2.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/F3.java b/pitest/src/main/java/org/pitest/functional/F3.java index bd6ff6a92..4bc8a2b63 100644 --- a/pitest/src/main/java/org/pitest/functional/F3.java +++ b/pitest/src/main/java/org/pitest/functional/F3.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/F4.java b/pitest/src/main/java/org/pitest/functional/F4.java index f3f19b711..ad62aa0a4 100644 --- a/pitest/src/main/java/org/pitest/functional/F4.java +++ b/pitest/src/main/java/org/pitest/functional/F4.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/F5.java b/pitest/src/main/java/org/pitest/functional/F5.java index efefd1122..a22f49404 100644 --- a/pitest/src/main/java/org/pitest/functional/F5.java +++ b/pitest/src/main/java/org/pitest/functional/F5.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/F6.java b/pitest/src/main/java/org/pitest/functional/F6.java index c979d9df9..7b581489e 100644 --- a/pitest/src/main/java/org/pitest/functional/F6.java +++ b/pitest/src/main/java/org/pitest/functional/F6.java @@ -1,22 +1,21 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; public interface F6 { // NO_UCD - G apply(final A a, final B b, final C c, final D d, final E e, - final FF f); + G apply(final A a, final B b, final C c, final D d, final E e, final FF f); } diff --git a/pitest/src/main/java/org/pitest/functional/FArray.java b/pitest/src/main/java/org/pitest/functional/FArray.java index e4c10020b..539daa63d 100644 --- a/pitest/src/main/java/org/pitest/functional/FArray.java +++ b/pitest/src/main/java/org/pitest/functional/FArray.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/FCollection.java b/pitest/src/main/java/org/pitest/functional/FCollection.java index 3ba4ccd54..8e798f043 100644 --- a/pitest/src/main/java/org/pitest/functional/FCollection.java +++ b/pitest/src/main/java/org/pitest/functional/FCollection.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/FunctionalCollection.java b/pitest/src/main/java/org/pitest/functional/FunctionalCollection.java index 75382c167..4fa32bff1 100644 --- a/pitest/src/main/java/org/pitest/functional/FunctionalCollection.java +++ b/pitest/src/main/java/org/pitest/functional/FunctionalCollection.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; import java.util.Collection; public interface FunctionalCollection extends Collection, - FunctionalIterable { +FunctionalIterable { } diff --git a/pitest/src/main/java/org/pitest/functional/FunctionalIterable.java b/pitest/src/main/java/org/pitest/functional/FunctionalIterable.java index e3c88be9c..4cd069b9d 100644 --- a/pitest/src/main/java/org/pitest/functional/FunctionalIterable.java +++ b/pitest/src/main/java/org/pitest/functional/FunctionalIterable.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/FunctionalList.java b/pitest/src/main/java/org/pitest/functional/FunctionalList.java index 2bd7412f6..e0b455c35 100644 --- a/pitest/src/main/java/org/pitest/functional/FunctionalList.java +++ b/pitest/src/main/java/org/pitest/functional/FunctionalList.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/MutableList.java b/pitest/src/main/java/org/pitest/functional/MutableList.java index 0635c833b..5630d9b2b 100644 --- a/pitest/src/main/java/org/pitest/functional/MutableList.java +++ b/pitest/src/main/java/org/pitest/functional/MutableList.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; @@ -37,118 +37,147 @@ public MutableList() { this(new ArrayList()); } + @Override public boolean add(final A o) { return this.impl.add(o); } + @Override public boolean addAll(final Collection c) { return this.impl.addAll(c); } + @Override public void clear() { this.impl.clear(); } + @Override public boolean contains(final Object o) { return this.impl.contains(o); } + @Override public boolean containsAll(final Collection c) { return this.impl.containsAll(c); } + @Override public boolean isEmpty() { return this.impl.isEmpty(); } + @Override public Iterator iterator() { return this.impl.iterator(); } + @Override public boolean remove(final Object o) { return this.impl.remove(o); } + @Override public boolean removeAll(final Collection c) { return this.impl.removeAll(c); } + @Override public boolean retainAll(final Collection c) { return this.impl.retainAll(c); } + @Override public int size() { return this.impl.size(); } + @Override public Object[] toArray() { return this.impl.toArray(); } + @Override public T[] toArray(final T[] a) { return this.impl.toArray(a); } + @Override public boolean contains(final F predicate) { return FCollection.contains(this, predicate); } + @Override public FunctionalList filter(final F predicate) { return FCollection.filter(this, predicate); } + @Override public FunctionalList flatMap(final F> f) { return FCollection.flatMap(this, f); } + @Override public void forEach(final SideEffect1 e) { FCollection.forEach(this, e); } + @Override public FunctionalList map(final F f) { return FCollection.map(this, f); } + @Override public void mapTo(final F f, final Collection bs) { FCollection.mapTo(this, f, bs); } + @Override public void add(final int arg0, final A arg1) { this.impl.add(arg0, arg1); } + @Override public boolean addAll(final int arg0, final Collection arg1) { return this.impl.addAll(arg0, arg1); } + @Override public A get(final int index) { return this.impl.get(index); } + @Override public int indexOf(final Object arg0) { return this.impl.indexOf(arg0); } + @Override public int lastIndexOf(final Object arg0) { return this.impl.lastIndexOf(arg0); } + @Override public ListIterator listIterator() { return this.impl.listIterator(); } + @Override public ListIterator listIterator(final int index) { return this.impl.listIterator(index); } + @Override public A remove(final int index) { return this.impl.remove(index); } + @Override public A set(final int index, final A element) { return this.impl.set(index, element); } + @Override public List subList(final int fromIndex, final int toIndex) { return this.impl.subList(fromIndex, toIndex); } diff --git a/pitest/src/main/java/org/pitest/functional/Option.java b/pitest/src/main/java/org/pitest/functional/Option.java index 95ca64159..858878b0c 100644 --- a/pitest/src/main/java/org/pitest/functional/Option.java +++ b/pitest/src/main/java/org/pitest/functional/Option.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,7 @@ public abstract class Option implements FunctionalIterable { @SuppressWarnings({ "rawtypes" }) - private static final None NONE = new None(); + private static final None NONE = new None(); private Option() { } @@ -32,26 +32,32 @@ private Option() { public abstract boolean hasSome(); + @Override public boolean contains(final F predicate) { return FCollection.contains(this, predicate); } + @Override public FunctionalList filter(final F predicate) { return FCollection.filter(this, predicate); } + @Override public FunctionalList flatMap(final F> f) { return FCollection.flatMap(this, f); } + @Override public void forEach(final SideEffect1 e) { FCollection.forEach(this, e); } + @Override public FunctionalList map(final F f) { return FCollection.map(this, f); } + @Override public void mapTo(final F f, final Collection bs) { FCollection.mapTo(this, f, bs); } @@ -80,6 +86,7 @@ private None() { } + @Override public Iterator iterator() { return Collections. emptySet().iterator(); } @@ -104,7 +111,7 @@ public boolean hasSome() { public static final class Some extends Option { - private final T value; + private final T value; private Some(final T value) { this.value = value; @@ -115,6 +122,7 @@ public T value() { return this.value; } + @Override public Iterator iterator() { return Collections.singleton(this.value).iterator(); diff --git a/pitest/src/main/java/org/pitest/functional/SideEffect.java b/pitest/src/main/java/org/pitest/functional/SideEffect.java index 8b61e9fa4..710b6beaf 100644 --- a/pitest/src/main/java/org/pitest/functional/SideEffect.java +++ b/pitest/src/main/java/org/pitest/functional/SideEffect.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; /** * @author henry - * + * */ public interface SideEffect { diff --git a/pitest/src/main/java/org/pitest/functional/SideEffect1.java b/pitest/src/main/java/org/pitest/functional/SideEffect1.java index 1595eff57..88f47efe5 100644 --- a/pitest/src/main/java/org/pitest/functional/SideEffect1.java +++ b/pitest/src/main/java/org/pitest/functional/SideEffect1.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; diff --git a/pitest/src/main/java/org/pitest/functional/SideEffect2.java b/pitest/src/main/java/org/pitest/functional/SideEffect2.java index 3b799755a..8d6287b36 100644 --- a/pitest/src/main/java/org/pitest/functional/SideEffect2.java +++ b/pitest/src/main/java/org/pitest/functional/SideEffect2.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; /** * @author henry - * + * */ public interface SideEffect2 { diff --git a/pitest/src/main/java/org/pitest/functional/predicate/And.java b/pitest/src/main/java/org/pitest/functional/predicate/And.java index c9039bf8a..37ade154b 100644 --- a/pitest/src/main/java/org/pitest/functional/predicate/And.java +++ b/pitest/src/main/java/org/pitest/functional/predicate/And.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional.predicate; @@ -21,7 +21,7 @@ /** * @author henry - * + * */ public class And implements Predicate { @@ -33,6 +33,7 @@ public And(final Iterable> ps) { } } + @Override public Boolean apply(final A a) { for (final F each : this.ps) { if (!each.apply(a)) { diff --git a/pitest/src/main/java/org/pitest/functional/predicate/False.java b/pitest/src/main/java/org/pitest/functional/predicate/False.java index f2bc1d6bd..3ba371e72 100644 --- a/pitest/src/main/java/org/pitest/functional/predicate/False.java +++ b/pitest/src/main/java/org/pitest/functional/predicate/False.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional.predicate; /** * @author henry - * + * */ public class False implements Predicate { @@ -27,6 +27,7 @@ public static False instance() { return (False) INSTANCE; } + @Override public Boolean apply(final A a) { return false; } diff --git a/pitest/src/main/java/org/pitest/functional/predicate/Not.java b/pitest/src/main/java/org/pitest/functional/predicate/Not.java index d8c77eea1..a65a00b33 100644 --- a/pitest/src/main/java/org/pitest/functional/predicate/Not.java +++ b/pitest/src/main/java/org/pitest/functional/predicate/Not.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional.predicate; @@ -18,7 +18,7 @@ /** * @author henry - * + * */ public final class Not implements Predicate { @@ -28,6 +28,7 @@ public Not(final F p) { this.p = p; } + @Override public Boolean apply(final A a) { return !this.p.apply(a); } diff --git a/pitest/src/main/java/org/pitest/functional/predicate/Or.java b/pitest/src/main/java/org/pitest/functional/predicate/Or.java index 45cf1c485..cb316ef70 100644 --- a/pitest/src/main/java/org/pitest/functional/predicate/Or.java +++ b/pitest/src/main/java/org/pitest/functional/predicate/Or.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional.predicate; @@ -19,7 +19,7 @@ /** * @author henry - * + * */ public class Or implements Predicate { @@ -31,6 +31,7 @@ public Or(final Iterable> ps) { } } + @Override public Boolean apply(final A a) { for (final Predicate each : this.ps) { if (each.apply(a)) { diff --git a/pitest/src/main/java/org/pitest/functional/predicate/Predicate.java b/pitest/src/main/java/org/pitest/functional/predicate/Predicate.java index 6b8fe820d..04b80aacf 100644 --- a/pitest/src/main/java/org/pitest/functional/predicate/Predicate.java +++ b/pitest/src/main/java/org/pitest/functional/predicate/Predicate.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional.predicate; @@ -18,7 +18,7 @@ /** * @author henry - * + * */ public interface Predicate extends F { diff --git a/pitest/src/main/java/org/pitest/functional/predicate/True.java b/pitest/src/main/java/org/pitest/functional/predicate/True.java index c14fbc067..63ea4ed2c 100644 --- a/pitest/src/main/java/org/pitest/functional/predicate/True.java +++ b/pitest/src/main/java/org/pitest/functional/predicate/True.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ /** * @author henry - * + * */ public class True implements Predicate { @@ -27,6 +27,7 @@ public static Predicate all() { return (True) INSTANCE; } + @Override public Boolean apply(final A a) { return true; } diff --git a/pitest/src/main/java/org/pitest/functional/prelude/Prelude.java b/pitest/src/main/java/org/pitest/functional/prelude/Prelude.java index d34b0fc67..37b7a2c26 100644 --- a/pitest/src/main/java/org/pitest/functional/prelude/Prelude.java +++ b/pitest/src/main/java/org/pitest/functional/prelude/Prelude.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ /** * @author henry - * + * */ public abstract class Prelude { @@ -57,6 +57,7 @@ public static final SideEffect1 accumulateTo( final Collection collection) { return new SideEffect1() { + @Override public void apply(final A a) { collection.add(a); } @@ -68,6 +69,7 @@ public void apply(final A a) { public static SideEffect1 putToMap(final Map map, final B value) { return new SideEffect1() { + @Override public void apply(final A key) { map.put(key, value); } @@ -76,6 +78,7 @@ public void apply(final A key) { public static final F id() { return new F() { + @Override public A apply(final A a) { return a; } @@ -101,6 +104,7 @@ public static final SideEffect1 printTo(final Class type, public static final SideEffect1 printTo(final PrintStream stream) { return new SideEffect1() { + @Override public void apply(final T a) { stream.print(a); } @@ -109,6 +113,7 @@ public void apply(final T a) { public static SideEffect1 printWith(final T t) { return new SideEffect1() { + @Override public void apply(final T a) { System.out.print(t + " : " + a); } @@ -117,6 +122,7 @@ public void apply(final T a) { public static Predicate isGreaterThan(final T value) { return new Predicate() { + @Override public Boolean apply(final T o) { return o.longValue() > value.longValue(); } @@ -125,6 +131,7 @@ public Boolean apply(final T o) { public static Predicate isEqualTo(final T value) { return new Predicate() { + @Override public Boolean apply(final T o) { return o.equals(value); } @@ -133,6 +140,7 @@ public Boolean apply(final T o) { public static Predicate isNotNull() { return new Predicate() { + @Override public Boolean apply(final T o) { return (o != null); } @@ -141,6 +149,7 @@ public Boolean apply(final T o) { public static Predicate isNull() { return new Predicate() { + @Override public Boolean apply(final T o) { return (o == null); } @@ -150,6 +159,7 @@ public Boolean apply(final T o) { public static F> asList(final Class type) { return new F>() { + @Override public Iterable apply(final T a) { return Collections.singletonList(a); } @@ -160,6 +170,7 @@ public Iterable apply(final T a) { public static SideEffect1 noSideEffect(final Class clazz) { return new SideEffect1() { + @Override public void apply(final T a) { } diff --git a/pitest/src/main/java/org/pitest/help/Help.java b/pitest/src/main/java/org/pitest/help/Help.java index 8b9f31b5e..2a1f08a5b 100644 --- a/pitest/src/main/java/org/pitest/help/Help.java +++ b/pitest/src/main/java/org/pitest/help/Help.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,22 +18,22 @@ public enum Help { NO_MUTATIONS_FOUND( "No mutations found. This probably means there is an issue with either the supplied classpath or filters."), // - WRONG_JUNIT_VERSION( - "Unsupported JUnit version %s. PIT requires JUnit 4.6 or above."), // - FAILING_TESTS( - "All tests did not pass without mutation when calculating line coverage. Mutation testing requires a green suite."), // - NO_JUNIT( - "JUnit was not found on the classpath. PIT requires JUnit 4.6 or above."), // - NO_SOURCE_FILE( - "The class %s does not contain a source debug information. All classes must be compiled with source and line number debug information."), // - NO_LINE_NUMBERS( - "No classes found with line number debug information. All classes must be compiled with source and line number debug information."), // - NO_TEST_LIBRARY( - "No test library found on classpath. PIT requires either JUnit 4 (but can run JUnit 3 tests) or TestNG"), // - BAD_FILTER( - "The supplied filter would cause PIT to try and mutate itself. This will lead to many wasted hours of confusion and debugging. You have better things to do with your life so please don't do this again."), // - UNKNOWN_MUTATOR( - "Mutator or group %s is unknown. Check PIT configuration and try again."); + WRONG_JUNIT_VERSION( + "Unsupported JUnit version %s. PIT requires JUnit 4.6 or above."), // + FAILING_TESTS( + "All tests did not pass without mutation when calculating line coverage. Mutation testing requires a green suite."), // + NO_JUNIT( + "JUnit was not found on the classpath. PIT requires JUnit 4.6 or above."), // + NO_SOURCE_FILE( + "The class %s does not contain a source debug information. All classes must be compiled with source and line number debug information."), // + NO_LINE_NUMBERS( + "No classes found with line number debug information. All classes must be compiled with source and line number debug information."), // + NO_TEST_LIBRARY( + "No test library found on classpath. PIT requires either JUnit 4 (but can run JUnit 3 tests) or TestNG"), // + BAD_FILTER( + "The supplied filter would cause PIT to try and mutate itself. This will lead to many wasted hours of confusion and debugging. You have better things to do with your life so please don't do this again."), // + UNKNOWN_MUTATOR( + "Mutator or group %s is unknown. Check PIT configuration and try again."); private static final String URL = "http://pitest.org"; private final String text; diff --git a/pitest/src/main/java/org/pitest/help/PitHelpError.java b/pitest/src/main/java/org/pitest/help/PitHelpError.java index b61c81563..79d9a6f58 100644 --- a/pitest/src/main/java/org/pitest/help/PitHelpError.java +++ b/pitest/src/main/java/org/pitest/help/PitHelpError.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/junit/CompoundTestUnitFinder.java b/pitest/src/main/java/org/pitest/junit/CompoundTestUnitFinder.java index 7f2b9776b..762ea0e91 100644 --- a/pitest/src/main/java/org/pitest/junit/CompoundTestUnitFinder.java +++ b/pitest/src/main/java/org/pitest/junit/CompoundTestUnitFinder.java @@ -14,6 +14,7 @@ public CompoundTestUnitFinder(final List tufs) { this.tufs = tufs; } + @Override public List findTestUnits(final Class clazz) { for (final TestUnitFinder each : this.tufs) { final List tus = each.findTestUnits(clazz); diff --git a/pitest/src/main/java/org/pitest/junit/DescriptionFilter.java b/pitest/src/main/java/org/pitest/junit/DescriptionFilter.java index 82597f2cd..5f7459ef0 100644 --- a/pitest/src/main/java/org/pitest/junit/DescriptionFilter.java +++ b/pitest/src/main/java/org/pitest/junit/DescriptionFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit; diff --git a/pitest/src/main/java/org/pitest/junit/JUnit4SuiteFinder.java b/pitest/src/main/java/org/pitest/junit/JUnit4SuiteFinder.java index 25007f3f8..5aa6f6036 100644 --- a/pitest/src/main/java/org/pitest/junit/JUnit4SuiteFinder.java +++ b/pitest/src/main/java/org/pitest/junit/JUnit4SuiteFinder.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,6 +25,7 @@ public class JUnit4SuiteFinder implements TestSuiteFinder { + @Override public List> apply(final Class a) { final SuiteClasses annotation = a.getAnnotation(SuiteClasses.class); diff --git a/pitest/src/main/java/org/pitest/junit/JUnitCompatibleConfiguration.java b/pitest/src/main/java/org/pitest/junit/JUnitCompatibleConfiguration.java index 7a84c627c..13825eff9 100644 --- a/pitest/src/main/java/org/pitest/junit/JUnitCompatibleConfiguration.java +++ b/pitest/src/main/java/org/pitest/junit/JUnitCompatibleConfiguration.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,9 +22,9 @@ import org.pitest.functional.Option; import org.pitest.help.Help; import org.pitest.help.PitHelpError; -import org.pitest.testapi.TestGroupConfig; import org.pitest.testapi.Configuration; import org.pitest.testapi.TestClassIdentifier; +import org.pitest.testapi.TestGroupConfig; import org.pitest.testapi.TestSuiteFinder; import org.pitest.testapi.TestUnitFinder; @@ -32,28 +32,32 @@ public class JUnitCompatibleConfiguration implements Configuration { private final TestGroupConfig config; - private static final Pattern VERSION_PATTERN = Pattern - .compile("(\\d+)\\.(\\d+).*"); + private static final Pattern VERSION_PATTERN = Pattern + .compile("(\\d+)\\.(\\d+).*"); public JUnitCompatibleConfiguration(TestGroupConfig config) { this.config = config; } + @Override public TestUnitFinder testUnitFinder() { return new CompoundTestUnitFinder(Arrays.asList( new JUnitCustomRunnerTestUnitFinder(), new ParameterisedJUnitTestFinder())); } + @Override public TestSuiteFinder testSuiteFinder() { return new CompoundTestSuiteFinder(Arrays. asList( new JUnit4SuiteFinder(), new RunnerSuiteFinder())); } + @Override public TestClassIdentifier testClassIdentifier() { return new JUnitTestClassIdentifier(this.config); } + @Override public Option verifyEnvironment() { try { final String version = junit.runner.Version.id(); diff --git a/pitest/src/main/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinder.java b/pitest/src/main/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinder.java index 88bb37ea1..a84297fbd 100644 --- a/pitest/src/main/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinder.java +++ b/pitest/src/main/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinder.java @@ -44,6 +44,7 @@ public class JUnitCustomRunnerTestUnitFinder implements TestUnitFinder { @SuppressWarnings("rawtypes") private static final Option CLASS_RULE = findClassRuleClass(); + @Override public List findTestUnits(final Class clazz) { final Runner runner = AdaptedJUnitTestUnit.createRunner(clazz); @@ -71,7 +72,7 @@ private boolean isNotARunnableTest(final Runner runner, final String className) private boolean isAJUnitThreeErrorOrWarning(final Runner runner) { return !runner.getDescription().getChildren().isEmpty() && runner.getDescription().getChildren().get(0).getClassName() - .startsWith("junit.framework.TestSuite"); + .startsWith("junit.framework.TestSuite"); } private boolean shouldTreatAsOneUnit(final Class clazz, final Runner runner) { @@ -127,6 +128,7 @@ private List splitIntoFilteredUnits(final Description description) { private F descriptionToTestUnit() { return new F() { + @Override public TestUnit apply(final Description a) { return descriptionToTest(a); } @@ -137,6 +139,7 @@ public TestUnit apply(final Description a) { private F isTest() { return new F() { + @Override public Boolean apply(final Description a) { return a.isTest(); } diff --git a/pitest/src/main/java/org/pitest/junit/JUnitTestClassIdentifier.java b/pitest/src/main/java/org/pitest/junit/JUnitTestClassIdentifier.java index 827624190..078a1423e 100644 --- a/pitest/src/main/java/org/pitest/junit/JUnitTestClassIdentifier.java +++ b/pitest/src/main/java/org/pitest/junit/JUnitTestClassIdentifier.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,15 +14,15 @@ */ package org.pitest.junit; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.junit.experimental.categories.Category; import org.pitest.classinfo.ClassInfo; import org.pitest.classinfo.ClassName; -import org.pitest.testapi.TestGroupConfig; import org.pitest.testapi.TestClassIdentifier; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.pitest.testapi.TestGroupConfig; public class JUnitTestClassIdentifier implements TestClassIdentifier { @@ -32,37 +32,41 @@ public JUnitTestClassIdentifier(TestGroupConfig config) { this.config = config; } + @Override public boolean isATestClass(final ClassInfo a) { return TestInfo.isWithinATestClass(a); } + @Override public boolean isIncluded(ClassInfo a) { return isIncludedCategory(a) && !isExcludedCategory(a); } - + private boolean isIncludedCategory(ClassInfo a) { - List included = config.getIncludedGroups(); - return included.isEmpty() || !Collections.disjoint(included, Arrays.asList(getCategories(a))); + List included = this.config.getIncludedGroups(); + return included.isEmpty() + || !Collections.disjoint(included, Arrays.asList(getCategories(a))); } private boolean isExcludedCategory(ClassInfo a) { - List excluded = config.getExcludedGroups(); - return !excluded.isEmpty() && !Collections.disjoint(excluded, Arrays.asList(getCategories(a))); + List excluded = this.config.getExcludedGroups(); + return !excluded.isEmpty() + && !Collections.disjoint(excluded, Arrays.asList(getCategories(a))); } private String[] getCategories(ClassInfo a) { - Object[] categoryArray = (Object[]) a.getClassAnnotationValue(ClassName.fromClass(Category.class)); + Object[] categoryArray = (Object[]) a.getClassAnnotationValue(ClassName + .fromClass(Category.class)); if (categoryArray == null) { - return new String[]{}; + return new String[] {}; } return copyArray(categoryArray); } - + private String[] copyArray(Object[] original) { String[] copy = new String[original.length]; System.arraycopy(original, 0, copy, 0, original.length); return copy; } - } diff --git a/pitest/src/main/java/org/pitest/junit/ParameterisedJUnitTestFinder.java b/pitest/src/main/java/org/pitest/junit/ParameterisedJUnitTestFinder.java index aa9cb9642..f310a3f6e 100644 --- a/pitest/src/main/java/org/pitest/junit/ParameterisedJUnitTestFinder.java +++ b/pitest/src/main/java/org/pitest/junit/ParameterisedJUnitTestFinder.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit; @@ -31,6 +31,7 @@ import org.pitest.testapi.TestUnitFinder; public class ParameterisedJUnitTestFinder implements TestUnitFinder { + @Override public List findTestUnits(final Class clazz) { final Runner runner = AdaptedJUnitTestUnit.createRunner(clazz); @@ -60,6 +61,7 @@ private List handleParameterizedTest(final Class clazz, private F parameterizedToTestUnit(final Class clazz) { return new F() { + @Override public TestUnit apply(final Description a) { return new AdaptedJUnitTestUnit(clazz, Option. some(new ParameterisedTestFilter(a.toString()))); diff --git a/pitest/src/main/java/org/pitest/junit/ParameterisedTestFilter.java b/pitest/src/main/java/org/pitest/junit/ParameterisedTestFilter.java index 480f1dfec..f94d16818 100644 --- a/pitest/src/main/java/org/pitest/junit/ParameterisedTestFilter.java +++ b/pitest/src/main/java/org/pitest/junit/ParameterisedTestFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit; diff --git a/pitest/src/main/java/org/pitest/junit/RunnerSuiteFinder.java b/pitest/src/main/java/org/pitest/junit/RunnerSuiteFinder.java index 6b6466686..1206d7f25 100644 --- a/pitest/src/main/java/org/pitest/junit/RunnerSuiteFinder.java +++ b/pitest/src/main/java/org/pitest/junit/RunnerSuiteFinder.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit; @@ -33,6 +33,7 @@ public class RunnerSuiteFinder implements TestSuiteFinder { + @Override @SuppressWarnings("unchecked") public List> apply(final Class a) { @@ -63,6 +64,7 @@ private void flattenChildren(final List allChildren, private static Predicate isSuiteMethodRunner(final Runner runner) { return new Predicate() { + @Override public Boolean apply(final Description a) { return SuiteMethod.class.isAssignableFrom(runner.getClass()); } @@ -73,6 +75,7 @@ public Boolean apply(final Description a) { private static F>> descriptionToTestClass() { return new F>>() { + @Override public Option> apply(final Description a) { final Class clazz = a.getTestClass(); if (clazz != null) { @@ -87,6 +90,7 @@ public Option> apply(final Description a) { private static Predicate isSuite() { return new Predicate() { + @Override public Boolean apply(final Description a) { return a.isSuite(); } diff --git a/pitest/src/main/java/org/pitest/junit/TestInfo.java b/pitest/src/main/java/org/pitest/junit/TestInfo.java index 9a64561e7..634ff2f96 100644 --- a/pitest/src/main/java/org/pitest/junit/TestInfo.java +++ b/pitest/src/main/java/org/pitest/junit/TestInfo.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,6 +44,7 @@ private static boolean isATest(final Option clazz) { public static Predicate isATest() { return new Predicate() { + @Override public Boolean apply(final ClassInfo clazz) { return isATest(clazz); } diff --git a/pitest/src/main/java/org/pitest/junit/adapter/AdaptedJUnitTestUnit.java b/pitest/src/main/java/org/pitest/junit/adapter/AdaptedJUnitTestUnit.java index 286b61bcc..1a1a536f9 100644 --- a/pitest/src/main/java/org/pitest/junit/adapter/AdaptedJUnitTestUnit.java +++ b/pitest/src/main/java/org/pitest/junit/adapter/AdaptedJUnitTestUnit.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -135,7 +135,7 @@ private static RunnerBuilder createRunnerBuilder(final Class clazz) { private void executeInDifferentClassLoader(final ClassLoader loader, final ResultCollector rc, final Runner runner) - throws IllegalAccessException, InvocationTargetException { + throws IllegalAccessException, InvocationTargetException { // must jump through hoops to run in different class loader // when even our framework classes may be duplicated @@ -144,7 +144,7 @@ private void executeInDifferentClassLoader(final ClassLoader loader, runner); @SuppressWarnings("unchecked") Callable> foreignCe = (Callable>) IsolationUtils - .cloneForLoader(ce, loader); + .cloneForLoader(ce, loader); try { final List q = foreignCe.call(); @@ -157,8 +157,7 @@ private void executeInDifferentClassLoader(final ClassLoader loader, private void convertStringsToResults(final ResultCollector rc, final List q) { - Events.applyEvents(q, rc, - this.getDescription()); + Events.applyEvents(q, rc, this.getDescription()); } @Override diff --git a/pitest/src/main/java/org/pitest/junit/adapter/CustomRunnerExecutor.java b/pitest/src/main/java/org/pitest/junit/adapter/CustomRunnerExecutor.java index 3547cefcf..7e92aef4a 100644 --- a/pitest/src/main/java/org/pitest/junit/adapter/CustomRunnerExecutor.java +++ b/pitest/src/main/java/org/pitest/junit/adapter/CustomRunnerExecutor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit.adapter; diff --git a/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListener.java b/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListener.java index 9f180f9ce..21de55350 100644 --- a/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListener.java +++ b/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListener.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit.adapter; diff --git a/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderCustomRunnerExecutor.java b/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderCustomRunnerExecutor.java index 76ba0876b..a3f938607 100644 --- a/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderCustomRunnerExecutor.java +++ b/pitest/src/main/java/org/pitest/junit/adapter/ForeignClassLoaderCustomRunnerExecutor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit.adapter; @@ -22,7 +22,8 @@ import org.junit.runner.notification.RunListener; import org.junit.runner.notification.RunNotifier; -public class ForeignClassLoaderCustomRunnerExecutor implements Callable> { +public class ForeignClassLoaderCustomRunnerExecutor implements + Callable> { private final Runner runner; @@ -30,6 +31,7 @@ public ForeignClassLoaderCustomRunnerExecutor(final Runner runner) { this.runner = runner; } + @Override public List call() { // NO_UCD List queue = new ArrayList(); final RunNotifier rn = new RunNotifier(); @@ -41,5 +43,4 @@ public List call() { // NO_UCD } - } diff --git a/pitest/src/main/java/org/pitest/mutationtest/ClassMutationResults.java b/pitest/src/main/java/org/pitest/mutationtest/ClassMutationResults.java index 0c5af605c..4af192d31 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/ClassMutationResults.java +++ b/pitest/src/main/java/org/pitest/mutationtest/ClassMutationResults.java @@ -7,7 +7,7 @@ /** * Details of mutation results from a single class. - * + * * A single instance will only ever contain mutations relating to a single * class. The mutations for a class may however be spread across multiple * instances. diff --git a/pitest/src/main/java/org/pitest/mutationtest/DetectionStatus.java b/pitest/src/main/java/org/pitest/mutationtest/DetectionStatus.java index a4db42341..0a18f78e4 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/DetectionStatus.java +++ b/pitest/src/main/java/org/pitest/mutationtest/DetectionStatus.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,7 +75,9 @@ public enum DetectionStatus { /** * Converts a process exit code to a mutation status - * @param exitCode Exit code to convert + * + * @param exitCode + * Exit code to convert * @return The status corresponding to the exit code */ public static DetectionStatus getForErrorExitCode(final ExitCode exitCode) { @@ -92,7 +94,7 @@ public static DetectionStatus getForErrorExitCode(final ExitCode exitCode) { * Returns true if this status indicates that the mutation was distinguished * from the un-mutated code by the test suite, ignores the slight ambiguity of * some of the statuses. - * + * * @return True if detected, false if not. */ public boolean isDetected() { diff --git a/pitest/src/main/java/org/pitest/mutationtest/MutationConfig.java b/pitest/src/main/java/org/pitest/mutationtest/MutationConfig.java index aeb822f4b..20ce116d1 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/MutationConfig.java +++ b/pitest/src/main/java/org/pitest/mutationtest/MutationConfig.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest; diff --git a/pitest/src/main/java/org/pitest/mutationtest/MutationMetaData.java b/pitest/src/main/java/org/pitest/mutationtest/MutationMetaData.java index 365b3a202..c44812700 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/MutationMetaData.java +++ b/pitest/src/main/java/org/pitest/mutationtest/MutationMetaData.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,7 +47,7 @@ public Collection toClassResults() { cn = each.getDetails().getClassName(); buffer.add(each); } - if ( !buffer.isEmpty() ) { + if (!buffer.isEmpty()) { cmrs.add(new ClassMutationResults(buffer)); } return cmrs; @@ -57,6 +57,7 @@ public Collection toClassResults() { private static Comparator comparator() { return new Comparator() { + @Override public int compare(final MutationResult arg0, final MutationResult arg1) { return arg0.getDetails().getId().compareTo(arg1.getDetails().getId()); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/MutationResult.java b/pitest/src/main/java/org/pitest/mutationtest/MutationResult.java index 46efa7506..038d68c8d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/MutationResult.java +++ b/pitest/src/main/java/org/pitest/mutationtest/MutationResult.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/MutationResultListenerFactory.java b/pitest/src/main/java/org/pitest/mutationtest/MutationResultListenerFactory.java index 5d3257fcd..4251c4364 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/MutationResultListenerFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/MutationResultListenerFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/MutationStatusMap.java b/pitest/src/main/java/org/pitest/mutationtest/MutationStatusMap.java index 4a3e07e4a..ce5fbc986 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/MutationStatusMap.java +++ b/pitest/src/main/java/org/pitest/mutationtest/MutationStatusMap.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest; @@ -76,6 +76,7 @@ public Set allMutations() { private static F, MutationResult> detailsToMutationResults() { return new F, MutationResult>() { + @Override public MutationResult apply( final Entry a) { return new MutationResult(a.getKey(), a.getValue()); @@ -87,6 +88,7 @@ public MutationResult apply( private static F, MutationDetails> toMutationDetails() { return new F, MutationDetails>() { + @Override public MutationDetails apply( final Entry a) { return a.getKey(); @@ -99,6 +101,7 @@ private static Predicate> hasStat final DetectionStatus status) { return new Predicate>() { + @Override public Boolean apply( final Entry a) { return a.getValue().getStatus().equals(status); @@ -117,6 +120,7 @@ public void markUncoveredMutations() { private static F hasNoCoverage() { return new F() { + @Override public Boolean apply(final MutationDetails a) { return a.getTestsInOrder().isEmpty(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/MutationStatusTestPair.java b/pitest/src/main/java/org/pitest/mutationtest/MutationStatusTestPair.java index a24988917..6eab0c75d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/MutationStatusTestPair.java +++ b/pitest/src/main/java/org/pitest/mutationtest/MutationStatusTestPair.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/SourceLocator.java b/pitest/src/main/java/org/pitest/mutationtest/SourceLocator.java index 8ba996740..b7938483f 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/SourceLocator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/SourceLocator.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest; diff --git a/pitest/src/main/java/org/pitest/mutationtest/TimeoutLengthStrategy.java b/pitest/src/main/java/org/pitest/mutationtest/TimeoutLengthStrategy.java index 42b2cab84..4969381be 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/TimeoutLengthStrategy.java +++ b/pitest/src/main/java/org/pitest/mutationtest/TimeoutLengthStrategy.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest; diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/AnalysisPriorityComparator.java b/pitest/src/main/java/org/pitest/mutationtest/build/AnalysisPriorityComparator.java index fc655f028..15ab0ce74 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/AnalysisPriorityComparator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/AnalysisPriorityComparator.java @@ -5,17 +5,18 @@ /** * Comparator to prioritise the order of mutation analysis units. - * + * * The ones with the most mutations are run first. This should make it less * likely that a single thread remains running at the of a run because it has * just picked up a large unit. - * + * */ class AnalysisPriorityComparator implements Comparator, - Serializable { +Serializable { private static final long serialVersionUID = 1L; + @Override public int compare(final MutationAnalysisUnit a, final MutationAnalysisUnit b) { return b.priority() - a.priority(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultGrouper.java b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultGrouper.java index 1df34725a..c7930930b 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultGrouper.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultGrouper.java @@ -18,7 +18,9 @@ public DefaultGrouper(final int unitSize) { this.unitSize = unitSize; } - public List> groupMutations(final Collection codeClasses, + @Override + public List> groupMutations( + final Collection codeClasses, final Collection mutations) { final Map> bucketed = FCollection .bucket(mutations, byClass()); @@ -45,6 +47,7 @@ private void shrinkToMaximumUnitSize( private static F byClass() { return new F() { + @Override public ClassName apply(final MutationDetails a) { return a.getClassName(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultMutationGrouperFactory.java b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultMutationGrouperFactory.java index 57bc2f557..123c23ad8 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultMutationGrouperFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultMutationGrouperFactory.java @@ -6,10 +6,12 @@ public class DefaultMutationGrouperFactory implements MutationGrouperFactory { + @Override public String description() { return "Default mutation grouping"; } + @Override public MutationGrouper makeFactory(final Properties props, final CodeSource codeSource, final int numberOfThreads, final int unitSize) { return new DefaultGrouper(unitSize); diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiser.java b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiser.java index 8355da591..89bd622c0 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiser.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiser.java @@ -14,45 +14,46 @@ import org.pitest.util.Log; /** - * Assigns tests based on line coverage and order them by execution speed - * with a weighting towards tests whose names imply they are intended to - * test the mutated class + * Assigns tests based on line coverage and order them by execution speed with a + * weighting towards tests whose names imply they are intended to test the + * mutated class + * * @author henry * */ public class DefaultTestPrioritiser implements TestPrioritiser { - - private static final Logger LOG = Log - .getLogger(); - - private static final int TIME_WEIGHTING_FOR_DIRECT_UNIT_TESTS = 1000; - + + private static final Logger LOG = Log + .getLogger(); + + private static final int TIME_WEIGHTING_FOR_DIRECT_UNIT_TESTS = 1000; + private final CoverageDatabase coverage; - + public DefaultTestPrioritiser(CoverageDatabase coverage) { this.coverage = coverage; } + @Override public List assignTests(MutationDetails mutation) { - return prioritizeTests(mutation.getClassName(), pickTests(mutation)); + return prioritizeTests(mutation.getClassName(), pickTests(mutation)); } - + private Collection pickTests(MutationDetails mutation) { if (!mutation.isInStaticInitializer()) { - return this.coverage - .getTestsForClassLine(mutation.getClassLine()); + return this.coverage.getTestsForClassLine(mutation.getClassLine()); } else { LOG.warning("Using untargetted tests"); return this.coverage.getTestsForClass(mutation.getClassName()); } } - - private List prioritizeTests(ClassName clazz,Collection testsForMutant) { + + private List prioritizeTests(ClassName clazz, + Collection testsForMutant) { final List sortedTis = FCollection.map(testsForMutant, Prelude.id(TestInfo.class)); - Collections.sort(sortedTis, - new TestInfoPriorisationComparator(clazz, - TIME_WEIGHTING_FOR_DIRECT_UNIT_TESTS)); + Collections.sort(sortedTis, new TestInfoPriorisationComparator(clazz, + TIME_WEIGHTING_FOR_DIRECT_UNIT_TESTS)); return sortedTis; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiserFactory.java b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiserFactory.java index 73747f775..1e49eb107 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiserFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/DefaultTestPrioritiserFactory.java @@ -7,10 +7,12 @@ public class DefaultTestPrioritiserFactory implements TestPrioritiserFactory { + @Override public String description() { return "Default test prioritiser"; } + @Override public TestPrioritiser makeTestPrioritiser(final Properties props, final CodeSource code, final CoverageDatabase coverage) { return new DefaultTestPrioritiser(coverage); diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnit.java b/pitest/src/main/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnit.java index 04ba9ec67..6fb624ca7 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnit.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnit.java @@ -7,8 +7,7 @@ import org.pitest.mutationtest.MutationResult; import org.pitest.util.Log; -public class KnownStatusMutationTestUnit implements - MutationAnalysisUnit { +public class KnownStatusMutationTestUnit implements MutationAnalysisUnit { private static final Logger LOG = Log.getLogger(); @@ -18,16 +17,17 @@ public KnownStatusMutationTestUnit(final List mutations) { this.mutations = mutations; } + @Override public MutationMetaData call() throws Exception { LOG.fine("Using historic results for " + this.mutations.size() + " mutations"); return new MutationMetaData(this.mutations); - + } + @Override public int priority() { return Integer.MAX_VALUE; } - } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/MutationAnalysisUnit.java b/pitest/src/main/java/org/pitest/mutationtest/build/MutationAnalysisUnit.java index 90c1ae660..84ce45e9f 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/MutationAnalysisUnit.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/MutationAnalysisUnit.java @@ -10,5 +10,5 @@ public interface MutationAnalysisUnit extends Callable { int priority(); - + } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouper.java b/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouper.java index 7c9dacee4..2192f5d04 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouper.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouper.java @@ -6,10 +6,9 @@ import org.pitest.classinfo.ClassName; import org.pitest.mutationtest.engine.MutationDetails; -public interface MutationGrouper { +public interface MutationGrouper { - List> groupMutations( - Collection codeClasses, + List> groupMutations(Collection codeClasses, final Collection mutations); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouperFactory.java b/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouperFactory.java index 6ce0879df..506917ef1 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouperFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/MutationGrouperFactory.java @@ -7,5 +7,6 @@ public interface MutationGrouperFactory extends ToolClasspathPlugin { - MutationGrouper makeFactory(Properties props, CodeSource codeSource, int numberOfThreads, int unitSize); + MutationGrouper makeFactory(Properties props, CodeSource codeSource, + int numberOfThreads, int unitSize); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/MutationSource.java b/pitest/src/main/java/org/pitest/mutationtest/build/MutationSource.java index 11eb1fbcc..ea8a574f4 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/MutationSource.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/MutationSource.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,17 +29,16 @@ public class MutationSource { - private static final Logger LOG = Log - .getLogger(); + private static final Logger LOG = Log.getLogger(); - private final MutationConfig mutationConfig; - private final TestPrioritiser testPrioritiser; - private final MutationFilter filter; - private final ClassByteArraySource source; + private final MutationConfig mutationConfig; + private final TestPrioritiser testPrioritiser; + private final MutationFilter filter; + private final ClassByteArraySource source; public MutationSource(final MutationConfig mutationConfig, - final MutationFilter filter, - final TestPrioritiser testPrioritiser, final ClassByteArraySource source) { + final MutationFilter filter, final TestPrioritiser testPrioritiser, + final ClassByteArraySource source) { this.mutationConfig = mutationConfig; this.testPrioritiser = testPrioritiser; this.filter = filter; @@ -50,7 +49,7 @@ public Collection createMutations(final ClassName clazz) { final Mutater m = this.mutationConfig.createMutator(this.source); - final Collection availableMutations = filter.filter(m + final Collection availableMutations = this.filter.filter(m .findMutations(clazz)); assignTestsToMutations(availableMutations); @@ -62,7 +61,8 @@ public Collection createMutations(final ClassName clazz) { private void assignTestsToMutations( final Collection availableMutations) { for (final MutationDetails mutation : availableMutations) { - final List testDetails = testPrioritiser.assignTests(mutation); + final List testDetails = this.testPrioritiser + .assignTests(mutation); if (testDetails.isEmpty()) { LOG.fine("According to coverage no tests hit the mutation " + mutation); } @@ -70,6 +70,4 @@ private void assignTestsToMutations( } } - - } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestBuilder.java b/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestBuilder.java index 7781159b4..b1e2995e1 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestBuilder.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestBuilder.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,11 +37,11 @@ public class MutationTestBuilder { private final MutationSource mutationSource; private final MutationAnalyser analyser; private final WorkerFactory workerFactory; - private final MutationGrouper grouper; + private final MutationGrouper grouper; public MutationTestBuilder(final WorkerFactory workerFactory, - final MutationAnalyser analyser, - final MutationSource mutationSource, final MutationGrouper grouper) { + final MutationAnalyser analyser, final MutationSource mutationSource, + final MutationGrouper grouper) { this.mutationSource = mutationSource; this.analyser = analyser; @@ -55,7 +55,7 @@ public List createMutationTestUnits( final List mutations = FCollection.flatMap(codeClasses, classToMutations()); - + Collections.sort(mutations, comparator()); final Collection analysedMutations = this.analyser @@ -64,19 +64,20 @@ public List createMutationTestUnits( final Collection needAnalysis = FCollection.filter( analysedMutations, statusNotKnown()).map(resultToDetails()); - final List analysed = FCollection.filter( - analysedMutations, Prelude.not(statusNotKnown())); + final List analysed = FCollection.filter(analysedMutations, + Prelude.not(statusNotKnown())); if (!analysed.isEmpty()) { tus.add(makePreAnalysedUnit(analysed)); } if (!needAnalysis.isEmpty()) { - for (final Collection ms : grouper.groupMutations(codeClasses, needAnalysis)) { + for (final Collection ms : this.grouper.groupMutations( + codeClasses, needAnalysis)) { tus.add(makeUnanalysedUnit(ms)); } } - + Collections.sort(tus, new AnalysisPriorityComparator()); return tus; } @@ -84,6 +85,7 @@ public List createMutationTestUnits( private Comparator comparator() { return new Comparator() { + @Override public int compare(final MutationDetails arg0, final MutationDetails arg1) { return arg0.getId().compareTo(arg1.getId()); } @@ -91,9 +93,9 @@ public int compare(final MutationDetails arg0, final MutationDetails arg1) { }; } - private F> classToMutations() { return new F>() { + @Override public Iterable apply(final ClassName a) { return MutationTestBuilder.this.mutationSource.createMutations(a); } @@ -101,7 +103,6 @@ public Iterable apply(final ClassName a) { }; } - private MutationAnalysisUnit makePreAnalysedUnit( final List analysed) { return new KnownStatusMutationTestUnit(analysed); @@ -113,11 +114,13 @@ private MutationAnalysisUnit makeUnanalysedUnit( FCollection.flatMapTo(needAnalysis, mutationDetailsToTestClass(), uniqueTestClasses); - return new MutationTestUnit(needAnalysis, uniqueTestClasses, this.workerFactory); + return new MutationTestUnit(needAnalysis, uniqueTestClasses, + this.workerFactory); } private static F resultToDetails() { return new F() { + @Override public MutationDetails apply(final MutationResult a) { return a.getDetails(); } @@ -126,6 +129,7 @@ public MutationDetails apply(final MutationResult a) { private static F statusNotKnown() { return new F() { + @Override public Boolean apply(final MutationResult a) { return a.getStatus() == DetectionStatus.NOT_STARTED; } @@ -134,6 +138,7 @@ public Boolean apply(final MutationResult a) { private static F> mutationDetailsToTestClass() { return new F>() { + @Override public Iterable apply(final MutationDetails a) { return FCollection.map(a.getTestsInOrder(), TestInfo.toDefiningClassName()); diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestUnit.java b/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestUnit.java index 6a41e5258..02ef794c8 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestUnit.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/MutationTestUnit.java @@ -43,6 +43,7 @@ public MutationTestUnit(final Collection availableMutations, this.workerFactory = workerFactor; } + @Override public MutationMetaData call() throws Exception { final MutationStatusMap mutations = new MutationStatusMap(); @@ -120,6 +121,7 @@ private MutationMetaData reportResults(final MutationStatusMap mutationsMap) { return new MutationMetaData(mutationsMap.createMutationResults()); } + @Override public int priority() { return this.availableMutations.size(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategy.java b/pitest/src/main/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategy.java index 20b36d461..77f63e1a5 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategy.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategy.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,6 +31,7 @@ public PercentAndConstantTimeoutStrategy(final float percent, this.constant = constant; } + @Override public long getAllowedTime(final long normalDuration) { return Math.round(normalDuration * this.percent) + this.constant; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/TestInfoPriorisationComparator.java b/pitest/src/main/java/org/pitest/mutationtest/build/TestInfoPriorisationComparator.java index 29e672c36..95539e6ef 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/TestInfoPriorisationComparator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/TestInfoPriorisationComparator.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,7 @@ import org.pitest.coverage.TestInfo; public class TestInfoPriorisationComparator implements Comparator, - Serializable { +Serializable { private static final long serialVersionUID = 1L; @@ -34,6 +34,7 @@ public TestInfoPriorisationComparator(final ClassName targetClass, this.distanceTimeWeighting = distanceTimeWeighting; } + @Override public int compare(final TestInfo arg0, final TestInfo arg1) { final int t0 = arg0.getTime(); final int t1 = arg1.getTime(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiser.java b/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiser.java index 82e48aa48..82cc0f84f 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiser.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiser.java @@ -5,13 +5,14 @@ import org.pitest.coverage.TestInfo; import org.pitest.mutationtest.engine.MutationDetails; -public interface TestPrioritiser { +public interface TestPrioritiser { /** - * - * @param mutation Mutation to assign tests to + * + * @param mutation + * Mutation to assign tests to * @return List of tests to run against mutant in priority order */ List assignTests(MutationDetails mutation); - + } diff --git a/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiserFactory.java b/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiserFactory.java index 4a41ddf86..b97711bb1 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiserFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/build/TestPrioritiserFactory.java @@ -8,6 +8,7 @@ public interface TestPrioritiserFactory extends ToolClasspathPlugin { - TestPrioritiser makeTestPrioritiser(Properties props, CodeSource code, CoverageDatabase coverage); - + TestPrioritiser makeTestPrioritiser(Properties props, CodeSource code, + CoverageDatabase coverage); + } diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundConfiguration.java b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundConfiguration.java index 7c7f60709..5e995cd7b 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundConfiguration.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundConfiguration.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -47,6 +47,7 @@ public CompoundConfiguration(final Iterable configs) { private static F asTestIdentifier() { return new F() { + @Override public TestClassIdentifier apply(final Configuration a) { return a.testClassIdentifier(); } @@ -57,6 +58,7 @@ public TestClassIdentifier apply(final Configuration a) { private static F asSuiteFinders() { return new F() { + @Override public TestSuiteFinder apply(final Configuration a) { return a.testSuiteFinder(); } @@ -66,6 +68,7 @@ public TestSuiteFinder apply(final Configuration a) { private static F asTestUnitFinders() { return new F() { + @Override public TestUnitFinder apply(final Configuration a) { return a.testUnitFinder(); } @@ -73,18 +76,22 @@ public TestUnitFinder apply(final Configuration a) { }; } + @Override public TestUnitFinder testUnitFinder() { return this.testUnitFinder; } + @Override public TestSuiteFinder testSuiteFinder() { return this.suiteFinder; } + @Override public TestClassIdentifier testClassIdentifier() { return this.testIdentifier; } + @Override public Option verifyEnvironment() { final List verificationResults = FCollection.flatMap( this.configs, verify()); @@ -97,6 +104,7 @@ public Option verifyEnvironment() { private static F> verify() { return new F>() { + @Override public Iterable apply(final Configuration a) { return a.verifyEnvironment(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundListenerFactory.java b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundListenerFactory.java index a921c159b..df6ca9e65 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundListenerFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundListenerFactory.java @@ -31,6 +31,7 @@ public CompoundListenerFactory( this.children = children; } + @Override public MutationResultListener getListener(final Properties props, final ListenerArguments args) { return new CompoundTestListener(FCollection.map(this.children, @@ -41,6 +42,7 @@ private F factoryToListen final Properties props, final ListenerArguments args) { return new F() { + @Override public MutationResultListener apply(final MutationResultListenerFactory a) { return a.getListener(props, args); } @@ -48,10 +50,12 @@ public MutationResultListener apply(final MutationResultListenerFactory a) { }; } + @Override public String name() { throw new UnsupportedOperationException(); } + @Override public String description() { throw new UnsupportedOperationException(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestClassIdentifier.java b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestClassIdentifier.java index b47f883f5..e2389d906 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestClassIdentifier.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestClassIdentifier.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -28,18 +28,21 @@ public CompoundTestClassIdentifier( this.children = children; } + @Override public boolean isATestClass(final ClassInfo a) { return FCollection.contains(this.children, isATest(a)); } + @Override public boolean isIncluded(ClassInfo a) { return FCollection.contains(this.children, isIncludedClass(a)); } - - private F isIncludedClass(final ClassInfo classInfo) { + private F isIncludedClass( + final ClassInfo classInfo) { return new F() { + @Override public Boolean apply(final TestClassIdentifier a) { return a.isIncluded(classInfo); } @@ -51,6 +54,7 @@ private static F isATest( final ClassInfo classInfo) { return new F() { + @Override public Boolean apply(final TestClassIdentifier a) { return a.isATestClass(classInfo); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestListener.java b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestListener.java index 671fee2a0..1d85fa709 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/CompoundTestListener.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,6 +25,7 @@ public CompoundTestListener(final Iterable children) { this.children = children; } + @Override public void runStart() { for (final MutationResultListener each : this.children) { each.runStart(); @@ -32,12 +33,14 @@ public void runStart() { } + @Override public void handleMutationResult(final ClassMutationResults metaData) { for (final MutationResultListener each : this.children) { each.handleMutationResult(metaData); } } + @Override public void runEnd() { for (final MutationResultListener each : this.children) { each.runEnd(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/ConfigOption.java b/pitest/src/main/java/org/pitest/mutationtest/config/ConfigOption.java index 0807c8a52..d7547f615 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/ConfigOption.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/ConfigOption.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 ("the "License""); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 ("the "License""); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -67,118 +67,119 @@ public enum ConfigOption { */ TIMEOUT_FACTOR("timeoutFactor", PercentAndConstantTimeoutStrategy.DEFAULT_FACTOR), - /** - * Consant addiotnal period of time to allow before considering a mutation to - * have timed out - */ - TIMEOUT_CONST("timeoutConst", - PercentAndConstantTimeoutStrategy.DEFAULT_CONSTANT), - /** - * Filter limiting tests to be considered - */ - TEST_FILTER("targetTests"), - /** - * List of classes no to mutate lines of calls that contain call to - */ - AVOID_CALLS("avoidCallsTo"), - /** - * Filter of methods not to be mutated - */ - EXCLUDED_METHOD("excludedMethods"), - /** - * Maximum number of mutations to allow per class - */ - MAX_MUTATIONS_PER_CLASS("maxMutationsPerClass", 0), - /** - * Flag to indicate if verbose logging should be enabled - */ - VERBOSE("verbose", false), - /** - * Filter defining classes to exclude (both tests and mutees) - */ - EXCLUDED_CLASSES("excludedClasses"), - /** - * Formats in which to output results - */ - OUTPUT_FORMATS("outputFormats"), - - /** - * Classpath entries to analyse. Although classes on the launch classpath will also be - * analysed, this is the preferred place to specify the code to analyse - */ - CLASSPATH("classPath"), - /** - * Flag to indicate if an error should be thrown if no mutations found - */ - FAIL_WHEN_NOT_MUTATIONS("failWhenNoMutations", true), - /** - * Filter defining paths that should be treated as containing mutable code - */ - CODE_PATHS("mutableCodePaths"), - /** - * TestNG groups/JUnit categories to include - */ - INCLUDED_GROUPS("includedGroups"), - /** - * TestNG groupsJUnit categories to exclude - */ - EXCLUDED_GROUPS("excludedGroups"), - /** - * Maximum number of mutations to include within a single unit of analysis. - */ - MUTATION_UNIT_SIZE("mutationUnitSize", 0), - - /** - * Do/don't attempt to detect inlined code from finally blocks - */ - USE_INLINED_CODE_DETECTION("detectInlinedCode", true), - - /** - * Location to read history from for incremental analysis - */ - HISTORY_INPUT_LOCATION("historyInputLocation"), - - /** - * Location to write history to for incremental analysis - */ - HISTORY_OUTPUT_LOCATION("historyOutputLocation"), - - /** - * Mutation score below which to throw an error - */ - MUTATION_THRESHOLD("mutationThreshold", 0), - - /** - * Line coverage score below which to throw an error - */ - COVERAGE_THRESHOLD("coverageThreshold", 0), - - /** - * Mutation engine to use - */ - MUTATION_ENGINE("mutationEngine", "gregor"), - - /** - * Dump per test line coverage to disk - */ - EXPORT_LINE_COVERAGE("exportLineCoverage", false), - - /** - * Include launch classpath in analysis - */ - INCLUDE_LAUNCH_CLASSPATH("includeLaunchClasspath", true), - - /** - * Path to executable with which to run tests - */ - JVM_PATH("jvmPath"), - - /** - * Custom properties for plugins - */ - PLUGIN_CONFIGURATION("pluginConfiguration"); - - private final String text; + /** + * Consant addiotnal period of time to allow before considering a mutation to + * have timed out + */ + TIMEOUT_CONST("timeoutConst", + PercentAndConstantTimeoutStrategy.DEFAULT_CONSTANT), + /** + * Filter limiting tests to be considered + */ + TEST_FILTER("targetTests"), + /** + * List of classes no to mutate lines of calls that contain call to + */ + AVOID_CALLS("avoidCallsTo"), + /** + * Filter of methods not to be mutated + */ + EXCLUDED_METHOD("excludedMethods"), + /** + * Maximum number of mutations to allow per class + */ + MAX_MUTATIONS_PER_CLASS("maxMutationsPerClass", 0), + /** + * Flag to indicate if verbose logging should be enabled + */ + VERBOSE("verbose", false), + /** + * Filter defining classes to exclude (both tests and mutees) + */ + EXCLUDED_CLASSES("excludedClasses"), + /** + * Formats in which to output results + */ + OUTPUT_FORMATS("outputFormats"), + + /** + * Classpath entries to analyse. Although classes on the launch classpath will + * also be analysed, this is the preferred place to specify the code to + * analyse + */ + CLASSPATH("classPath"), + /** + * Flag to indicate if an error should be thrown if no mutations found + */ + FAIL_WHEN_NOT_MUTATIONS("failWhenNoMutations", true), + /** + * Filter defining paths that should be treated as containing mutable code + */ + CODE_PATHS("mutableCodePaths"), + /** + * TestNG groups/JUnit categories to include + */ + INCLUDED_GROUPS("includedGroups"), + /** + * TestNG groupsJUnit categories to exclude + */ + EXCLUDED_GROUPS("excludedGroups"), + /** + * Maximum number of mutations to include within a single unit of analysis. + */ + MUTATION_UNIT_SIZE("mutationUnitSize", 0), + + /** + * Do/don't attempt to detect inlined code from finally blocks + */ + USE_INLINED_CODE_DETECTION("detectInlinedCode", true), + + /** + * Location to read history from for incremental analysis + */ + HISTORY_INPUT_LOCATION("historyInputLocation"), + + /** + * Location to write history to for incremental analysis + */ + HISTORY_OUTPUT_LOCATION("historyOutputLocation"), + + /** + * Mutation score below which to throw an error + */ + MUTATION_THRESHOLD("mutationThreshold", 0), + + /** + * Line coverage score below which to throw an error + */ + COVERAGE_THRESHOLD("coverageThreshold", 0), + + /** + * Mutation engine to use + */ + MUTATION_ENGINE("mutationEngine", "gregor"), + + /** + * Dump per test line coverage to disk + */ + EXPORT_LINE_COVERAGE("exportLineCoverage", false), + + /** + * Include launch classpath in analysis + */ + INCLUDE_LAUNCH_CLASSPATH("includeLaunchClasspath", true), + + /** + * Path to executable with which to run tests + */ + JVM_PATH("jvmPath"), + + /** + * Custom properties for plugins + */ + PLUGIN_CONFIGURATION("pluginConfiguration"); + + private final String text; private final Serializable defaultValue; ConfigOption(final String text) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/ConfigurationFactory.java b/pitest/src/main/java/org/pitest/mutationtest/config/ConfigurationFactory.java index 3f9c6f55b..36ca251d7 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/ConfigurationFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/ConfigurationFactory.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -30,7 +30,7 @@ class ConfigurationFactory { private final ClassByteArraySource source; - private final TestGroupConfig config; + private final TestGroupConfig config; public ConfigurationFactory(final TestGroupConfig config, final ClassByteArraySource source) { @@ -42,8 +42,8 @@ public Configuration createConfiguration() { final Collection configs = new ArrayList(); final Repository classRepository = new Repository(this.source); - if (classRepository.fetchClass( - ClassName.fromString("org.junit.Test")).hasSome()) { + if (classRepository.fetchClass(ClassName.fromString("org.junit.Test")) + .hasSome()) { configs.add(new JUnitCompatibleConfiguration(this.config)); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/DatedDirectoryReportDirCreationStrategy.java b/pitest/src/main/java/org/pitest/mutationtest/config/DatedDirectoryReportDirCreationStrategy.java index 824f155e2..99abe10a6 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/DatedDirectoryReportDirCreationStrategy.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/DatedDirectoryReportDirCreationStrategy.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,8 +19,9 @@ import java.util.Date; public class DatedDirectoryReportDirCreationStrategy implements - ReportDirCreationStrategy { +ReportDirCreationStrategy { + @Override public File createReportDir(final String base) { final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm"); final String timeString = sdf.format(new Date()); diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/DefaultCodePathPredicate.java b/pitest/src/main/java/org/pitest/mutationtest/config/DefaultCodePathPredicate.java index c493d99b4..ba1040852 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/DefaultCodePathPredicate.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/DefaultCodePathPredicate.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -19,6 +19,7 @@ public class DefaultCodePathPredicate implements Predicate { + @Override public Boolean apply(final ClassPathRoot a) { return a.cacheLocation().hasSome() && !isATestPath(a.cacheLocation().value()) diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicate.java b/pitest/src/main/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicate.java index f8239a7f0..264b6b8e5 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicate.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicate.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -23,6 +23,7 @@ public DefaultDependencyPathPredicate() { } + @Override public Boolean apply(final ClassPathRoot a) { return a.cacheLocation().hasSome() && isADependencyPath(a.cacheLocation().value()); diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/DirectoryResultOutputStrategy.java b/pitest/src/main/java/org/pitest/mutationtest/config/DirectoryResultOutputStrategy.java index d1f6e2dae..3938415b3 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/DirectoryResultOutputStrategy.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/DirectoryResultOutputStrategy.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,6 +32,7 @@ public DirectoryResultOutputStrategy(final String baseDir, this.reportDir = dirCreationStrategy.createReportDir(baseDir); } + @Override public Writer createWriterForFile(final String file) { try { final int fileSepIndex = file.lastIndexOf(File.separatorChar); diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/LegacyTestFrameworkPlugin.java b/pitest/src/main/java/org/pitest/mutationtest/config/LegacyTestFrameworkPlugin.java index d9ec0287f..e6df81540 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/LegacyTestFrameworkPlugin.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/LegacyTestFrameworkPlugin.java @@ -7,28 +7,30 @@ /** * Plugin that provides support for both JUnit 3, 4 and TestNG. - * + * * This plugin has been battle tested against many different strange uses and * abuses of JUnit found in real world code bases. - * - * It will probably work well on your legacy code base but some of the code is pretty - * hairy, so support for more modern test frameworks will likely be added via - * different plugins. - * + * + * It will probably work well on your legacy code base but some of the code is + * pretty hairy, so support for more modern test frameworks will likely be added + * via different plugins. + * * Much of the complexity comes from splitting the tests down into smaller * units. * - * Note. No service locator property file is provided for this plugin, it - * is hard coded to be used when no other is provided on the classpath. + * Note. No service locator property file is provided for this plugin, it is + * hard coded to be used when no other is provided on the classpath. */ public class LegacyTestFrameworkPlugin implements TestPluginFactory { + @Override public String description() { return "Default test framework support"; } + @Override public Configuration createTestFrameworkConfiguration(TestGroupConfig config, - ClassByteArraySource source) { + ClassByteArraySource source) { final ConfigurationFactory configFactory = new ConfigurationFactory(config, source); return configFactory.createConfiguration(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/PathNamePredicate.java b/pitest/src/main/java/org/pitest/mutationtest/config/PathNamePredicate.java index 34eac89d1..47dd00a6c 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/PathNamePredicate.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/PathNamePredicate.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -25,6 +25,7 @@ public PathNamePredicate(final Predicate stringFilter) { this.stringFilter = stringFilter; } + @Override public Boolean apply(final ClassPathRoot classPathRoot) { return cacheLocationOptionExists(classPathRoot) && cacheLocationMatchesFilter(classPathRoot); diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/PluginServices.java b/pitest/src/main/java/org/pitest/mutationtest/config/PluginServices.java index 32980d30f..34d40a235 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/PluginServices.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/PluginServices.java @@ -30,7 +30,7 @@ public static PluginServices makeForContextLoader() { /** * Lists all plugin classes that must be present on the classpath of the * controlling process only. - * + * * @return list of plugins */ public Iterable findToolClasspathPlugins() { @@ -55,31 +55,31 @@ public Iterable findClientClasspathPlugins() { } Collection findTestFrameworkPlugins() { - return ServiceLoader.load(TestPluginFactory.class, loader); + return ServiceLoader.load(TestPluginFactory.class, this.loader); } Collection findGroupers() { - return ServiceLoader.load(MutationGrouperFactory.class, loader); + return ServiceLoader.load(MutationGrouperFactory.class, this.loader); } Collection findFilters() { - return ServiceLoader.load(MutationFilterFactory.class, loader); + return ServiceLoader.load(MutationFilterFactory.class, this.loader); } Collection findListeners() { - return ServiceLoader.load(MutationResultListenerFactory.class, loader); + return ServiceLoader.load(MutationResultListenerFactory.class, this.loader); } Collection findMutationEngines() { - return ServiceLoader.load(MutationEngineFactory.class, loader); + return ServiceLoader.load(MutationEngineFactory.class, this.loader); } Collection findTestPrioritisers() { - return ServiceLoader.load(TestPrioritiserFactory.class, loader); + return ServiceLoader.load(TestPrioritiserFactory.class, this.loader); } private Collection nullPlugins() { - return ServiceLoader.load(ClientClasspathPlugin.class, loader); + return ServiceLoader.load(ClientClasspathPlugin.class, this.loader); } } diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/ReportDirCreationStrategy.java b/pitest/src/main/java/org/pitest/mutationtest/config/ReportDirCreationStrategy.java index 079472428..50e27b77e 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/ReportDirCreationStrategy.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/ReportDirCreationStrategy.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/ReportOptions.java b/pitest/src/main/java/org/pitest/mutationtest/config/ReportOptions.java index c61495341..63a717ad8 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/ReportOptions.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/ReportOptions.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -57,23 +57,23 @@ /** * Big ball of user supplied options to configure various aspects of mutation * testing. - * + * */ public class ReportOptions { public static final Collection LOGGING_CLASSES = Arrays - .asList( - "java.util.logging", - "org.apache.log4j", - "org.slf4j", - "org.apache.commons.logging"); + .asList( + "java.util.logging", + "org.apache.log4j", + "org.slf4j", + "org.apache.commons.logging"); private Collection> targetClasses; private Collection> excludedMethods = Collections - .emptyList(); + .emptyList(); private Collection> excludedClasses = Collections - .emptyList(); + .emptyList(); private Collection codePaths; @@ -105,7 +105,7 @@ public class ReportOptions { private final Collection outputs = new LinkedHashSet(); - private TestGroupConfig groupConfig; + private TestGroupConfig groupConfig; private int mutationUnitSize; private boolean shouldCreateTimestampedReports = true; @@ -219,6 +219,7 @@ private ClassPath createClassPathFromElements() { private static F stringToFile() { return new F() { + @Override public File apply(final String a) { return new File(a); } @@ -293,7 +294,7 @@ public Collection> getTargetTests() { public Predicate getTargetTestsFilter() { if ((this.targetTests == null) || this.targetTests.isEmpty()) { return this.getTargetClassesFilter(); // if no tests specified assume the - // target classes filter covers both + // target classes filter covers both } else { return Prelude.and(or(this.targetTests), not(isBlackListed(ReportOptions.this.excludedClasses))); @@ -305,6 +306,7 @@ private static Predicate isBlackListed( final Collection> excludedClasses) { return new Predicate() { + @Override public Boolean apply(final String a) { return or(excludedClasses).apply(a); } @@ -370,7 +372,6 @@ public void setFailWhenNoMutations(final boolean failWhenNoMutations) { this.failWhenNoMutations = failWhenNoMutations; } - public ProjectClassPaths getMutationClassPaths() { return new ProjectClassPaths(this.getClassPath(), createClassesFilter(), @@ -404,7 +405,6 @@ public void setCodePaths(final Collection codePaths) { this.codePaths = codePaths; } - public void setGroupConfig(final TestGroupConfig groupConfig) { this.groupConfig = groupConfig; } @@ -539,9 +539,9 @@ public void setIncludeLaunchClasspath(final boolean b) { public boolean isIncludeLaunchClasspath() { return this.includeLaunchClasspath; } - + public Properties getFreeFormProperties() { - return properties; + return this.properties; } public void setFreeFormProperties(Properties props) { @@ -550,15 +550,14 @@ public void setFreeFormProperties(Properties props) { @Override public String toString() { - return "ReportOptions [targetClasses=" - + this.targetClasses + ", excludedMethods=" + this.excludedMethods - + ", excludedClasses=" + this.excludedClasses + ", codePaths=" - + this.codePaths + ", reportDir=" + this.reportDir - + ", historyInputLocation=" + this.historyInputLocation - + ", historyOutputLocation=" + this.historyOutputLocation - + ", sourceDirs=" + this.sourceDirs + ", classPathElements=" - + this.classPathElements + ", mutators=" + this.mutators - + ", dependencyAnalysisMaxDistance=" + return "ReportOptions [targetClasses=" + this.targetClasses + + ", excludedMethods=" + this.excludedMethods + ", excludedClasses=" + + this.excludedClasses + ", codePaths=" + this.codePaths + + ", reportDir=" + this.reportDir + ", historyInputLocation=" + + this.historyInputLocation + ", historyOutputLocation=" + + this.historyOutputLocation + ", sourceDirs=" + this.sourceDirs + + ", classPathElements=" + this.classPathElements + ", mutators=" + + this.mutators + ", dependencyAnalysisMaxDistance=" + this.dependencyAnalysisMaxDistance + ", mutateStaticInitializers=" + this.mutateStaticInitializers + ", jvmArgs=" + this.jvmArgs + ", numberOfThreads=" + this.numberOfThreads + ", timeoutFactor=" @@ -575,9 +574,8 @@ public String toString() { + this.exportLineCoverage + ", mutationThreshold=" + this.mutationThreshold + ", coverageThreshold=" + this.coverageThreshold + ", mutationEngine=" + this.mutationEngine - + ", javaExecutable=" + this.javaExecutable + ", includeLaunchClasspath=" - + this.includeLaunchClasspath + "]"; + + ", javaExecutable=" + this.javaExecutable + + ", includeLaunchClasspath=" + this.includeLaunchClasspath + "]"; } - } diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/SettingsFactory.java b/pitest/src/main/java/org/pitest/mutationtest/config/SettingsFactory.java index 73afaccfd..d9fbc1d59 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/SettingsFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/SettingsFactory.java @@ -96,6 +96,7 @@ private Iterable findListeners() { private static F nameMatches( final Iterable outputFormats) { return new F() { + @Override public Boolean apply(final MutationResultListenerFactory a) { return FCollection.contains(outputFormats, equalsIgnoreCase(a.name())); } @@ -104,6 +105,7 @@ public Boolean apply(final MutationResultListenerFactory a) { private static Predicate equalsIgnoreCase(final String other) { return new Predicate() { + @Override public Boolean apply(final String a) { return a.equalsIgnoreCase(other); } @@ -122,7 +124,6 @@ public TestPrioritiserFactory getTestPrioritiser() { return firstOrDefault(testPickers, new DefaultTestPrioritiserFactory()); } - public Configuration getTestFrameworkPlugin() { final Collection testPlugins = this.plugins @@ -142,6 +143,7 @@ public CoverageOptions createCoverageOptions() { private static F commonClasses() { return new F() { + @Override public Boolean apply(final String name) { return name.startsWith("java") || name.startsWith("sun/") || name.startsWith("org/junit") || name.startsWith("junit") diff --git a/pitest/src/main/java/org/pitest/mutationtest/config/UndatedReportDirCreationStrategy.java b/pitest/src/main/java/org/pitest/mutationtest/config/UndatedReportDirCreationStrategy.java index cc56f16da..92b9b40cd 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/config/UndatedReportDirCreationStrategy.java +++ b/pitest/src/main/java/org/pitest/mutationtest/config/UndatedReportDirCreationStrategy.java @@ -3,8 +3,9 @@ import java.io.File; public class UndatedReportDirCreationStrategy implements - ReportDirCreationStrategy { +ReportDirCreationStrategy { + @Override public File createReportDir(final String base) { final File reportDir = new File(base); reportDir.mkdirs(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/Location.java b/pitest/src/main/java/org/pitest/mutationtest/engine/Location.java index 379e21ede..57ee6d652 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/Location.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/Location.java @@ -1,16 +1,16 @@ /* * Copyright 2013 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine; @@ -18,7 +18,7 @@ /** * The co-ordinates of a method within a class. - * + * */ public final class Location implements Comparable { @@ -64,7 +64,7 @@ public int hashCode() { } @Override - public boolean equals(final Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -109,6 +109,7 @@ public String describe() { return this.method.name(); } + @Override public int compareTo(final Location o) { int comp = this.clazz.compareTo(o.getClassName()); if (comp != 0) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/Mutant.java b/pitest/src/main/java/org/pitest/mutationtest/engine/Mutant.java index 427744e39..d1611dff3 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/Mutant.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/Mutant.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine; @@ -29,6 +29,7 @@ public Mutant(final MutationDetails details, final byte[] bytes) { /** * Returns a data relating to the mutant + * * @return A MutationDetails object */ public MutationDetails getDetails() { @@ -37,6 +38,7 @@ public MutationDetails getDetails() { /** * Returns a byte array containing the mutant class + * * @return A byte array */ public byte[] getBytes() { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/Mutater.java b/pitest/src/main/java/org/pitest/mutationtest/engine/Mutater.java index a9fde9f67..a1c74d1ac 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/Mutater.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/Mutater.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine; @@ -19,20 +19,24 @@ import org.pitest.classinfo.ClassName; /** - * Generates mutants + * Generates mutants */ public interface Mutater { /** * Creates a mutant matching the given MutationIdentifier - * @param id the mutant to create + * + * @param id + * the mutant to create * @return a Mutant */ Mutant getMutation(MutationIdentifier id); /** * Scans for possible mutants in the given class - * @param classToMutate the class to scan for mutants + * + * @param classToMutate + * the class to scan for mutants * @return a list of possible mutants */ List findMutations(ClassName classToMutate); diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/MutationDetails.java b/pitest/src/main/java/org/pitest/mutationtest/engine/MutationDetails.java index 2c04bf36d..a7401046a 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/MutationDetails.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/MutationDetails.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine; @@ -63,8 +63,10 @@ public String toString() { } /** - * Returns the human readable description of the mutation. This may be a constant string - * or may provide more contextual information depending on the mutation operator. + * Returns the human readable description of the mutation. This may be a + * constant string or may provide more contextual information depending on the + * mutation operator. + * * @return Human readable description of the mutation */ public String getDescription() { @@ -73,6 +75,7 @@ public String getDescription() { /** * Returns the mutation description with special characters escaped + * * @return Escaped description string */ @Deprecated @@ -83,6 +86,7 @@ public String getHtmlSafeDescription() { /** * Returns the method name in which this mutation is located as a string + * * @return method name as string */ @Deprecated @@ -93,6 +97,7 @@ public String getLocation() { /** * Returns the class in which this mutation is located + * * @return class in which mutation is located */ public ClassName getClassName() { @@ -101,6 +106,7 @@ public ClassName getClassName() { /** * Returns the class in which this mutation is located + * * @return class in which mutation is located */ public MethodName getMethod() { @@ -109,6 +115,7 @@ public MethodName getMethod() { /** * Returns the file in which this mutation is located + * * @return file in which mutation is located */ public String getFilename() { @@ -118,6 +125,7 @@ public String getFilename() { /** * Returns the line number on which the mutation occurs as reported within the * jvm bytecode + * * @return The line number on which the mutation occurs. */ public int getLineNumber() { @@ -126,6 +134,7 @@ public int getLineNumber() { /** * Returns the ClassLine in which this mutation is located + * * @return the ClassLine in which this mutation is located */ public ClassLine getClassLine() { @@ -134,6 +143,7 @@ public ClassLine getClassLine() { /** * Returns the identified for this mutation + * * @return a MutationIdentifier */ public MutationIdentifier getId() { @@ -142,15 +152,18 @@ public MutationIdentifier getId() { /** * Returns the tests that cover this mutation in optimised order + * * @return a list of TestInfo objects */ public List getTestsInOrder() { return this.testsInOrder; } - + /** * Adds tests to the list of covering tests - * @param testNames The tests to add + * + * @param testNames + * The tests to add */ public void addTestsInOrder(final Collection testNames) { this.testsInOrder.addAll(testNames); @@ -158,16 +171,18 @@ public void addTestsInOrder(final Collection testNames) { } /** - * Indicates if this mutation might poison state within the jvm - * (e.g affect the values of static variable) + * Indicates if this mutation might poison state within the jvm (e.g affect + * the values of static variable) + * * @return true if the mutation might poison the jvm otherwise false */ public boolean mayPoisonJVM() { - return poison || isInStaticInitializer(); + return this.poison || isInStaticInitializer(); } - + /** * Indicates if this mutation is in a static initializer block + * * @return true if in a static initializer otherwise false */ public boolean isInStaticInitializer() { @@ -175,8 +190,10 @@ public boolean isInStaticInitializer() { } /** - * Returns the basic block in which this mutation occurs. - * See https://github.com/hcoles/pitest/issues/131 for discussion on block coverage + * Returns the basic block in which this mutation occurs. See + * https://github.com/hcoles/pitest/issues/131 for discussion on block + * coverage + * * @return the block within the method that this mutation is located in */ public int getBlock() { @@ -185,7 +202,9 @@ public int getBlock() { /** * Returns true if this mutation has a matching identifier - * @param id the MutationIdentifier to match + * + * @param id + * the MutationIdentifier to match * @return true if the MutationIdentifier matches otherwise false */ public Boolean matchesId(final MutationIdentifier id) { @@ -194,6 +213,7 @@ public Boolean matchesId(final MutationIdentifier id) { /** * Returns the name of the mutator that created this mutation + * * @return the mutator name */ public String getMutator() { @@ -201,9 +221,9 @@ public String getMutator() { } /** - * Returns the index to the first instruction on which this mutation occurs. This index - * is specific to how ASM represents the bytecode. - * + * Returns the index to the first instruction on which this mutation occurs. + * This index is specific to how ASM represents the bytecode. + * * @return the zero based index to the instruction */ public int getFirstIndex() { @@ -212,6 +232,7 @@ public int getFirstIndex() { /** * Indicates if the mutation is within a finally block + * * @return true if in finally block otherwise false */ public boolean isInFinallyBlock() { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/MutationEngine.java b/pitest/src/main/java/org/pitest/mutationtest/engine/MutationEngine.java index 66d3501ba..99b074321 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/MutationEngine.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/MutationEngine.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine; @@ -19,21 +19,24 @@ import org.pitest.classinfo.ClassByteArraySource; /** - * A mutation engine acts as a factory for mutaters capable of creating - * mutant classes. + * A mutation engine acts as a factory for mutaters capable of creating mutant + * classes. */ public interface MutationEngine { /** - * Create a mutator using the given ClassByteArraySource as the source - * of unmated classes - * @param source the source to use to retrieve unmated classes + * Create a mutator using the given ClassByteArraySource as the source of + * unmated classes + * + * @param source + * the source to use to retrieve unmated classes * @return a Mutater */ Mutater createMutator(ClassByteArraySource source); /** * Returns a list of mutation operations this engine can perform + * * @return a list of mutator names */ Collection getMutatorNames(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/MutationIdentifier.java b/pitest/src/main/java/org/pitest/mutationtest/engine/MutationIdentifier.java index 726487e78..7f0671ac5 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/MutationIdentifier.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/MutationIdentifier.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,15 +30,16 @@ public final class MutationIdentifier implements Comparable * The location at which the mutation occurs */ private final Location location; - + /** - * The indexes to the instructions within the method at which the mutation occurs. - * - * Usually this will be a single instruction, but may be multiple if the mutation has - * been inlined by the compiler to implement a finally block + * The indexes to the instructions within the method at which the mutation + * occurs. + * + * Usually this will be a single instruction, but may be multiple if the + * mutation has been inlined by the compiler to implement a finally block */ private final List indexes; - + /** * Name of the mutation operator that created this mutation */ @@ -58,6 +59,7 @@ public MutationIdentifier(final Location location, /** * Returns the location of the mutations + * * @return the location of the mutation */ public Location getLocation() { @@ -66,6 +68,7 @@ public Location getLocation() { /** * Returns the name of the mutator that created this mutation + * * @return the mutator name */ public String getMutator() { @@ -73,9 +76,9 @@ public String getMutator() { } /** - * Returns the index to the first instruction on which this mutation occurs. This index - * is specific to how ASM represents the bytecode. - * + * Returns the index to the first instruction on which this mutation occurs. + * This index is specific to how ASM represents the bytecode. + * * @return the zero based index to the instruction */ public int getFirstIndex() { @@ -90,23 +93,25 @@ public String toString() { /** * Returns true if this mutation has a matching identifier - * @param id the MutationIdentifier to match + * + * @param id + * the MutationIdentifier to match * @return true if the MutationIdentifier matches otherwise false */ public boolean matches(final MutationIdentifier id) { - return this.location.equals(id.location) - && this.mutator.equals(id.mutator) + return this.location.equals(id.location) && this.mutator.equals(id.mutator) && this.indexes.contains(id.getFirstIndex()); } /** * Returns the class in which this mutation is located + * * @return class in which mutation is located */ public ClassName getClassName() { return this.location.getClassName(); } - + @Override public int hashCode() { final int prime = 31; @@ -156,6 +161,7 @@ public boolean equals(final Object obj) { return true; } + @Override public int compareTo(final MutationIdentifier other) { int comp = this.location.compareTo(other.getLocation()); if (comp != 0) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractInsnMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractInsnMutator.java index 06e952830..a21c75e03 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractInsnMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractInsnMutator.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -23,7 +23,7 @@ public abstract class AbstractInsnMutator extends MethodVisitor { private final MethodMutatorFactory factory; - private final MutationContext context; + private final MutationContext context; private final MethodInfo methodInfo; public AbstractInsnMutator(final MethodMutatorFactory factory, diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractJumpMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractJumpMutator.java index 5a11d9801..6f55716bb 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractJumpMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AbstractJumpMutator.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -24,7 +24,7 @@ public abstract class AbstractJumpMutator extends MethodVisitor { private final MethodMutatorFactory factory; - private final MutationContext context; + private final MutationContext context; public static class Substitution { public Substitution(final int newCode, final String description) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapter.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapter.java index 10aa270e0..6cd6619da 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapter.java @@ -1,16 +1,16 @@ /* * Copyright 2012 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -20,15 +20,15 @@ /** * Disables mutations within java assertions - * + * */ public class AvoidAssertsMethodAdapter extends MethodVisitor { - private static final String DISABLE_REASON = "ASSERTS"; + private static final String DISABLE_REASON = "ASSERTS"; - private final MutationContext context; - private boolean assertBlockStarted; - private Label destination; + private final MutationContext context; + private boolean assertBlockStarted; + private Label destination; public AvoidAssertsMethodAdapter(final MutationContext context, final MethodVisitor delegateMethodVisitor) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassContext.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassContext.java index 34d72cc11..16d572fb3 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassContext.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassContext.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -62,6 +62,7 @@ public List getMutationDetails(final MutationIdentifier id) { private static F hasId(final MutationIdentifier id) { return new F() { + @Override public Boolean apply(final MutationDetails a) { return a.matchesId(id); } @@ -84,6 +85,7 @@ public boolean shouldMutate(final MutationIdentifier newId) { private static F idMatches( final MutationIdentifier newId) { return new F() { + @Override public Boolean apply(final MutationIdentifier a) { return a.matches(newId); } @@ -99,15 +101,18 @@ public void addMutation(final MutationDetails details) { } + @Override public void registerNewBlock() { this.blockCounter.registerNewBlock(); } + @Override public void registerFinallyBlockStart() { this.blockCounter.registerFinallyBlockStart(); } + @Override public void registerFinallyBlockEnd() { this.blockCounter.registerFinallyBlockEnd(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassInfo.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassInfo.java index 53cf0f6f0..fa72b9d7c 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassInfo.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ClassInfo.java @@ -32,6 +32,7 @@ public boolean isGroovyClass() { private static F isAGroovyClass() { return new F() { + @Override public Boolean apply(final String a) { return a.startsWith("groovy/lang/") || a.startsWith("org/codehaus/groovy/runtime"); diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java index f43ad4a92..496379b67 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -65,19 +65,21 @@ public GregorMutater(final ClassByteArraySource byteSource, this.inlinedCodeDetector = inlinedCodeDetector; } + @Override public FunctionalList findMutations( final ClassName classToMutate) { final ClassContext context = new ClassContext(); context.setTargetMutation(Option. none()); - return GregorMutater.this.byteSource.getBytes(classToMutate.asInternalName()) - .flatMap(findMutations(context)); + return GregorMutater.this.byteSource.getBytes( + classToMutate.asInternalName()).flatMap(findMutations(context)); } private F> findMutations( final ClassContext context) { return new F>() { + @Override public Iterable apply(final byte[] bytes) { return findMutationsForBytes(context, bytes); } @@ -109,6 +111,7 @@ private PremutationClassInfo performPreScan(final byte[] classToMutate) { } + @Override public Mutant getMutation(final MutationIdentifier id) { final ClassContext context = new ClassContext(); @@ -138,6 +141,7 @@ private static Predicate isMutatorFor( final MutationIdentifier id) { return new Predicate() { + @Override public Boolean apply(final MethodMutatorFactory a) { return id.getMutator().equals(a.getGloballyUniqueId()); } @@ -153,6 +157,7 @@ private Predicate filterMethods() { private static F isGroovyClass() { return new Predicate() { + @Override public Boolean apply(final MethodInfo a) { return a.isInGroovyClass(); } @@ -163,6 +168,7 @@ public Boolean apply(final MethodInfo a) { private static Predicate filterSyntheticMethods() { return new Predicate() { + @Override public Boolean apply(final MethodInfo a) { // filter out synthetic methods, // except lambda$... methods, which contain code from lambda expressions @@ -174,6 +180,7 @@ public Boolean apply(final MethodInfo a) { private static Predicate isGeneratedEnumMethod() { return new Predicate() { + @Override public Boolean apply(final MethodInfo a) { return a.isGeneratedEnumMethod(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngine.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngine.java index 6b828ceef..43ce2aedb 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngine.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngine.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ /** * The default (and currently only) mutation engine for PIT. - * + * * In case anyone was wondering I'm named after either Gregor Mendel or Gregor * Samsa, or maybe both. */ @@ -46,6 +46,7 @@ public GregorMutationEngine(final MutationEngineConfiguration config) { this.inlinedCodeDetector = config.inlinedCodeDetector(); } + @Override public Mutater createMutator(final ClassByteArraySource byteSource) { return new GregorMutater(byteSource, this.methodFilter, this.mutationOperators, this.loggingClasses, this.inlinedCodeDetector); @@ -57,6 +58,7 @@ public String toString() { + ", mutationOperators=" + this.mutationOperators + "]"; } + @Override public Collection getMutatorNames() { return FCollection.map(this.mutationOperators, toName()); } @@ -64,6 +66,7 @@ public Collection getMutatorNames() { private static F toName() { return new F() { + @Override public String apply(final MethodMutatorFactory a) { return a.getName(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/InsnSubstitution.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/InsnSubstitution.java index 172744d56..f7a10cc15 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/InsnSubstitution.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/InsnSubstitution.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -26,10 +26,12 @@ public InsnSubstitution(final int replacementOpcode, final String message) { this.message = message; } + @Override public void apply(final int opCode, final MethodVisitor mv) { mv.visitInsn(this.replacementOpcode); } + @Override public String decribe(final int opCode, final MethodInfo methodInfo) { return this.message; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapter.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapter.java index 0039fb28c..af0494312 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapter.java @@ -8,7 +8,7 @@ class LineFilterMethodAdapter extends MethodVisitor { private static final String DISABLE_REASON = "AVOIDED_LINE"; - private final MutationContext context; + private final MutationContext context; private final PremutationClassInfo classInfo; public LineFilterMethodAdapter(final MutationContext context, diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineTrackingMethodVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineTrackingMethodVisitor.java index 3109bdc72..47c5016e8 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineTrackingMethodVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/LineTrackingMethodVisitor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodInfo.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodInfo.java index 173e8a831..e67bb698a 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodInfo.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodInfo.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutationContext.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutationContext.java index dd196a794..0dc642df5 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutationContext.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutationContext.java @@ -23,6 +23,7 @@ class MethodMutationContext implements MutationContext, InstructionCounter { this.location = location; } + @Override public MutationIdentifier registerMutation( final MethodMutatorFactory factory, final String description) { final MutationIdentifier newId = getNextMutationIdentifer(factory, @@ -51,44 +52,54 @@ private boolean isMutationFindingDisabled() { return !this.mutationFindingDisabledReasons.isEmpty(); } + @Override public void registerCurrentLine(final int line) { this.lastLineNumber = line; } + @Override public void registerNewBlock() { this.classContext.registerNewBlock(); } + @Override public void registerFinallyBlockStart() { this.classContext.registerFinallyBlockStart(); } + @Override public void registerFinallyBlockEnd() { this.classContext.registerFinallyBlockEnd(); } + @Override public ClassInfo getClassInfo() { return this.classContext.getClassInfo(); } + @Override public boolean shouldMutate(final MutationIdentifier newId) { return this.classContext.shouldMutate(newId); } + @Override public void disableMutations(final String reason) { this.mutationFindingDisabledReasons.add(reason); } + @Override public void enableMutatations(final String reason) { this.mutationFindingDisabledReasons.remove(reason); } + @Override public void increment() { this.instructionIndex = this.instructionIndex + 1; } + @Override public int currentInstructionCount() { return this.instructionIndex; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java index 25eb1434a..881b0e604 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,15 +21,15 @@ * method visitors. Those method visitors will serve two purposes: finding new * mutation points (locations in byte code where mutations can be applied) and * applying those mutations to the byte code. - * - * + * + * *

* A MethodMutatorFactory will have a globally unique id and must * provide a human readable name via the getName() method. This * name will be used in the reports created to document and describe the * mutation(s) applied. *

- * + * * @author Henry Coles */ public interface MethodMutatorFactory { @@ -45,8 +45,8 @@ MethodVisitor create(final MutationContext context, * used in reports to document and describe the mutation(s) applied by the * MethodVisitor created by this * MethodMutatorFactory. - * - * + * + * * @return a human readable string representation for end-user report * generation. */ diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java index 28d0c5b4f..84b78bf38 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ class MutatingClassVisitor extends ClassVisitor { private final F filter; - private final ClassContext context; + private final ClassContext context; private final Set methodMutators = new HashSet(); private final PremutationClassInfo classInfo; @@ -64,20 +64,21 @@ public void visitSource(final String source, final String debug) { public MethodVisitor visitMethod(final int access, final String methodName, final String methodDescriptor, final String signature, final String[] exceptions) { - - MethodMutationContext methodContext = new MethodMutationContext(context, Location.location( - ClassName.fromString(context.getClassInfo().getName()), - MethodName.fromString(methodName), methodDescriptor)); - + + MethodMutationContext methodContext = new MethodMutationContext( + this.context, Location.location( + ClassName.fromString(this.context.getClassInfo().getName()), + MethodName.fromString(methodName), methodDescriptor)); + final MethodVisitor methodVisitor = this.cv.visitMethod(access, methodName, methodDescriptor, signature, exceptions); final MethodInfo info = new MethodInfo() - .withOwner(this.context.getClassInfo()).withAccess(access) - .withMethodName(methodName).withMethodDescriptor(methodDescriptor); + .withOwner(this.context.getClassInfo()).withAccess(access) + .withMethodName(methodName).withMethodDescriptor(methodDescriptor); if (this.filter.apply(info)) { - return this.visitMethodForMutation(methodContext, info, methodVisitor); + return this.visitMethodForMutation(methodContext, info, methodVisitor); } else { return methodVisitor; } @@ -97,23 +98,30 @@ private MethodVisitor visitMethodForMutation( methodContext, wrapWithFilters(methodContext, next)), methodContext); } - private MethodVisitor wrapWithDecorators(MethodMutationContext methodContext, final MethodVisitor mv) { - return wrapWithBlockTracker(methodContext, wrapWithLineTracker(methodContext,mv)); + private MethodVisitor wrapWithDecorators(MethodMutationContext methodContext, + final MethodVisitor mv) { + return wrapWithBlockTracker(methodContext, + wrapWithLineTracker(methodContext, mv)); } - private MethodVisitor wrapWithBlockTracker(MethodMutationContext methodContext, final MethodVisitor mv) { + private MethodVisitor wrapWithBlockTracker( + MethodMutationContext methodContext, final MethodVisitor mv) { return new BlockTrackingMethodDecorator(methodContext, mv); } - private MethodVisitor wrapWithLineTracker(MethodMutationContext methodContext, final MethodVisitor mv) { + private MethodVisitor wrapWithLineTracker( + MethodMutationContext methodContext, final MethodVisitor mv) { return new LineTrackingMethodVisitor(methodContext, mv); } - private MethodVisitor wrapWithFilters(MethodMutationContext methodContext,final MethodVisitor wrappedMethodVisitor) { - return wrapWithLineFilter(methodContext, wrapWithAssertFilter(methodContext, wrappedMethodVisitor)); + private MethodVisitor wrapWithFilters(MethodMutationContext methodContext, + final MethodVisitor wrappedMethodVisitor) { + return wrapWithLineFilter(methodContext, + wrapWithAssertFilter(methodContext, wrappedMethodVisitor)); } - private MethodVisitor wrapWithAssertFilter(MethodMutationContext methodContext, + private MethodVisitor wrapWithAssertFilter( + MethodMutationContext methodContext, final MethodVisitor wrappedMethodVisitor) { return new AvoidAssertsMethodAdapter(methodContext, wrappedMethodVisitor); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutationEngineConfiguration.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutationEngineConfiguration.java index 8e19f7572..114f56865 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutationEngineConfiguration.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutationEngineConfiguration.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/PreMutationMethodAnalyzer.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/PreMutationMethodAnalyzer.java index 08a2c9ba5..e30beda44 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/PreMutationMethodAnalyzer.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/PreMutationMethodAnalyzer.java @@ -34,6 +34,7 @@ public void visitMethodInsn(final int opcode, final String owner, private static F matches(final String owner) { return new F() { + @Override public Boolean apply(final String a) { return owner.startsWith(a); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/TryWithResourcesMethodVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/TryWithResourcesMethodVisitor.java index 222240fdd..a08e59dbf 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/TryWithResourcesMethodVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/TryWithResourcesMethodVisitor.java @@ -21,8 +21,8 @@ import static org.objectweb.asm.Opcodes.IFNONNULL; import static org.objectweb.asm.Opcodes.IFNULL; import static org.objectweb.asm.Opcodes.IF_ACMPEQ; -import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; import static org.objectweb.asm.Opcodes.INVOKEINTERFACE; +import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; import java.util.ArrayList; import java.util.Arrays; @@ -33,8 +33,11 @@ import org.objectweb.asm.Opcodes; /** - * Example of code that was generated by 1.7 compiler for try-with-resources block: - *

+ * Example of code that was generated by 1.7 compiler for try-with-resources
+ * block:
+ * 
+ * 
+ * 
  * } finally {
  *   if (closeable != null) { // IFNULL
  *     if (localThrowable2 != null) { // IFNULL
@@ -48,13 +51,18 @@
  *     }
  *   }
  * } // ATHROW
- * 
- * This class considers that only auto generated code may have such sequence without any line change. - * Such an approach make sense only for javac compiler. + *
+ *
+ * + * This class considers that only auto generated code may have such sequence + * without any line change. Such an approach make sense only for javac + * compiler. *

- * Eclipse Java Compiler as well as aspectj have its own opinion - * how to compile try-with-resources block: - *


+ * Eclipse Java Compiler as well as aspectj
+ * have its own opinion how to compile try-with-resources block:
+ * 
+ * 
+ * 
  * } finally {
  *   if (throwable1 == null) { // IFNONNULL
  *     throwable1 = throwable2;
@@ -64,43 +72,98 @@
  *     }
  *   }
  * } // ATHROW
- * 
+ *
+ *
* * @author Artem Khvastunov <contact@artspb.me> */ class TryWithResourcesMethodVisitor extends MethodVisitor { - private static final List JAVAC_CLASS_INS_SEQUENCE = Arrays.asList( - ASTORE, // store throwable - ALOAD, IFNULL, // closeable != null - ALOAD, IFNULL, // localThrowable2 != null - ALOAD, INVOKEVIRTUAL, GOTO, // closeable.close() - ASTORE, // Throwable x2 - ALOAD, ALOAD, INVOKEVIRTUAL, GOTO, // localThrowable2.addSuppressed(x2) - ALOAD, INVOKEVIRTUAL, // closeable.close() - ALOAD, ATHROW); // throw throwable - - private static final List JAVAC_INTERFACE_INS_SEQUENCE = Arrays.asList( - ASTORE, // store throwable - ALOAD, IFNULL, // closeable != null - ALOAD, IFNULL, // localThrowable2 != null - ALOAD, INVOKEINTERFACE, GOTO, // closeable.close() - ASTORE, // Throwable x2 - ALOAD, ALOAD, INVOKEVIRTUAL, GOTO, // localThrowable2.addSuppressed(x2) - ALOAD, INVOKEINTERFACE, // closeable.close() - ALOAD, ATHROW); // throw throwable - - private static final List ECJ_INS_SEQUENCE = Arrays.asList( - ASTORE, // store throwable2 - ALOAD, IFNONNULL, // if (throwable1 == null) - ALOAD, ASTORE, GOTO, // throwable1 = throwable2; - ALOAD, ALOAD, IF_ACMPEQ, // if (throwable1 != throwable2) { - ALOAD, ALOAD, INVOKEVIRTUAL, // throwable1.addSuppressed(throwable2) - ALOAD, ATHROW); // throw throwable1 + private static final List JAVAC_CLASS_INS_SEQUENCE = Arrays + .asList( + ASTORE, // store + // throwable + ALOAD, + IFNULL, // closeable + // != + // null + ALOAD, + IFNULL, // localThrowable2 + // != + // null + ALOAD, + INVOKEVIRTUAL, + GOTO, // closeable.close() + ASTORE, // Throwable + // x2 + ALOAD, + ALOAD, + INVOKEVIRTUAL, + GOTO, // localThrowable2.addSuppressed(x2) + ALOAD, + INVOKEVIRTUAL, // closeable.close() + ALOAD, + ATHROW); // throw + // throwable + + private static final List JAVAC_INTERFACE_INS_SEQUENCE = Arrays + .asList( + ASTORE, // store + // throwable + ALOAD, + IFNULL, // closeable + // != + // null + ALOAD, + IFNULL, // localThrowable2 + // != + // null + ALOAD, + INVOKEINTERFACE, + GOTO, // closeable.close() + ASTORE, // Throwable + // x2 + ALOAD, + ALOAD, + INVOKEVIRTUAL, + GOTO, // localThrowable2.addSuppressed(x2) + ALOAD, + INVOKEINTERFACE, // closeable.close() + ALOAD, + ATHROW); // throw + // throwable + + private static final List ECJ_INS_SEQUENCE = Arrays + .asList( + ASTORE, // store + // throwable2 + ALOAD, + IFNONNULL, // if + // (throwable1 + // == + // null) + ALOAD, + ASTORE, + GOTO, // throwable1 + // = + // throwable2; + ALOAD, + ALOAD, + IF_ACMPEQ, // if + // (throwable1 + // != + // throwable2) + // { + ALOAD, + ALOAD, + INVOKEVIRTUAL, // throwable1.addSuppressed(throwable2) + ALOAD, + ATHROW); // throw + // throwable1 private final PremutationClassInfo context; - private final List opcodesStack = new ArrayList(); + private final List opcodesStack = new ArrayList(); private int currentLineNumber; /** @@ -115,50 +178,50 @@ public TryWithResourcesMethodVisitor(final PremutationClassInfo context) { @Override public void visitLineNumber(int line, Label start) { prepareToStartTracking(); - currentLineNumber = line; + this.currentLineNumber = line; super.visitLineNumber(line, start); } @Override public void visitVarInsn(int opcode, int var) { - opcodesStack.add(opcode); + this.opcodesStack.add(opcode); super.visitVarInsn(opcode, var); } @Override public void visitJumpInsn(int opcode, Label label) { - opcodesStack.add(opcode); + this.opcodesStack.add(opcode); super.visitJumpInsn(opcode, label); } @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { - opcodesStack.add(opcode); + this.opcodesStack.add(opcode); super.visitMethodInsn(opcode, owner, name, desc, itf); } @Override public void visitInsn(int opcode) { if (opcode == Opcodes.ATHROW) { - opcodesStack.add(opcode); + this.opcodesStack.add(opcode); finishTracking(); } super.visitInsn(opcode); } private void finishTracking() { - if (JAVAC_CLASS_INS_SEQUENCE.equals(opcodesStack) - || JAVAC_INTERFACE_INS_SEQUENCE.equals(opcodesStack) - || ECJ_INS_SEQUENCE.equals(opcodesStack)) { - context.registerLineToAvoid(currentLineNumber); + if (JAVAC_CLASS_INS_SEQUENCE.equals(this.opcodesStack) + || JAVAC_INTERFACE_INS_SEQUENCE.equals(this.opcodesStack) + || ECJ_INS_SEQUENCE.equals(this.opcodesStack)) { + this.context.registerLineToAvoid(this.currentLineNumber); } prepareToStartTracking(); } private void prepareToStartTracking() { - if (!opcodesStack.isEmpty()) { - opcodesStack.clear(); + if (!this.opcodesStack.isEmpty()) { + this.opcodesStack.clear(); } } } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ZeroOperandMutation.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ZeroOperandMutation.java index 14ba123e6..d2cfef16d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ZeroOperandMutation.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/ZeroOperandMutation.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/DefaultInstructionCounter.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/DefaultInstructionCounter.java index c47779d68..2e6f5da3d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/DefaultInstructionCounter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/DefaultInstructionCounter.java @@ -1,14 +1,15 @@ package org.pitest.mutationtest.engine.gregor.analysis; - public class DefaultInstructionCounter implements InstructionCounter { private int count; + @Override public void increment() { this.count++; } + @Override public int currentInstructionCount() { return this.count; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitor.java index 50e1d7395..d240e325d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitor.java @@ -110,14 +110,11 @@ public void visitMultiANewArrayInsn(final String desc, final int dims) { this.count.increment(); super.visitMultiANewArrayInsn(desc, dims); } - - @Override public void visitLineNumber(final int line, final Label start) { this.count.increment(); super.visitLineNumber(line, start); } - } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockCounter.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockCounter.java index 5a3788e5a..dfd753a1d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockCounter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockCounter.java @@ -7,5 +7,5 @@ public interface BlockCounter { void registerFinallyBlockStart(); void registerFinallyBlockEnd(); - + } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockTrackingMethodDecorator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockTrackingMethodDecorator.java index a9bce48cc..93bb31248 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockTrackingMethodDecorator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/BlockTrackingMethodDecorator.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/ConcreteBlockCounter.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/ConcreteBlockCounter.java index 51d7fc032..fa901c31e 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/ConcreteBlockCounter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/blocks/ConcreteBlockCounter.java @@ -5,14 +5,17 @@ public class ConcreteBlockCounter implements BlockCounter { private int currentBlock = 0; private boolean isWithinExceptionHandler; + @Override public void registerNewBlock() { this.currentBlock++; } + @Override public void registerFinallyBlockStart() { this.isWithinExceptionHandler = true; } + @Override public void registerFinallyBlockEnd() { this.isWithinExceptionHandler = false; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/DefaultMutationEngineConfiguration.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/DefaultMutationEngineConfiguration.java index efd6bf22c..20515768a 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/DefaultMutationEngineConfiguration.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/DefaultMutationEngineConfiguration.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.config; @@ -23,7 +23,7 @@ import org.pitest.mutationtest.engine.gregor.inlinedcode.InlinedCodeFilter; public class DefaultMutationEngineConfiguration implements - MutationEngineConfiguration { +MutationEngineConfiguration { private final Predicate methodFilter; private final Collection doNotMutate; @@ -40,21 +40,24 @@ public DefaultMutationEngineConfiguration(final Predicate filter, this.inlinedCodeDetector = inlinedCodeDetector; } + @Override public Collection mutators() { return this.mutators; } + @Override public Collection doNotMutateCallsTo() { return this.doNotMutate; } + @Override public Predicate methodFilter() { return this.methodFilter; } + @Override public InlinedCodeFilter inlinedCodeDetector() { return this.inlinedCodeDetector; } - } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/GregorEngineFactory.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/GregorEngineFactory.java index 68ab35bfa..1c5148a64 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/GregorEngineFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/GregorEngineFactory.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.config; @@ -30,6 +30,7 @@ public final class GregorEngineFactory implements MutationEngineFactory { + @Override public MutationEngine createEngine(final boolean mutateStaticInitializers, final Predicate excludedMethods, final Collection loggingClasses, @@ -88,6 +89,7 @@ private static F stringToMethodInfoPredicate( final Predicate excludedMethods) { return new Predicate() { + @Override public Boolean apply(final MethodInfo a) { return excludedMethods.apply(a.getName()); } @@ -98,6 +100,7 @@ public Boolean apply(final MethodInfo a) { private static Predicate notStaticInitializer() { return new Predicate() { + @Override public Boolean apply(final MethodInfo a) { return !a.isStaticInitializer(); } @@ -105,10 +108,12 @@ public Boolean apply(final MethodInfo a) { }; } + @Override public String name() { return "gregor"; } + @Override public String description() { return "Default mutation engine"; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/Mutator.java index 4ddc8441b..069e13825 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/Mutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/Mutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,6 +31,7 @@ import org.pitest.help.Help; import org.pitest.help.PitHelpError; import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; +import org.pitest.mutationtest.engine.gregor.mutators.ArgumentPropagationMutator; import org.pitest.mutationtest.engine.gregor.mutators.ConditionalsBoundaryMutator; import org.pitest.mutationtest.engine.gregor.mutators.ConstructorCallMutator; import org.pitest.mutationtest.engine.gregor.mutators.IncrementsMutator; @@ -41,7 +42,6 @@ import org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator; import org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator; import org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator.Choice; -import org.pitest.mutationtest.engine.gregor.mutators.ArgumentPropagationMutator; import org.pitest.mutationtest.engine.gregor.mutators.ReturnValsMutator; import org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator; import org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveIncrementsMutator; @@ -78,7 +78,7 @@ public final class Mutator { /** * Default mutator that removes method calls to void methods. - * + * */ add("VOID_METHOD_CALLS", VoidMethodCallMutator.VOID_METHOD_CALL_MUTATOR); @@ -124,10 +124,14 @@ public final class Mutator { * ORDER version mutates only those. */ - add("REMOVE_CONDITIONALS_EQ_IF", new RemoveConditionalMutator(Choice.EQUAL, true)); - add("REMOVE_CONDITIONALS_EQ_ELSE", new RemoveConditionalMutator(Choice.EQUAL, false)); - add("REMOVE_CONDITIONALS_ORD_IF", new RemoveConditionalMutator(Choice.ORDER, true)); - add("REMOVE_CONDITIONALS_ORD_ELSE", new RemoveConditionalMutator(Choice.ORDER, false)); + add("REMOVE_CONDITIONALS_EQ_IF", new RemoveConditionalMutator(Choice.EQUAL, + true)); + add("REMOVE_CONDITIONALS_EQ_ELSE", new RemoveConditionalMutator( + Choice.EQUAL, false)); + add("REMOVE_CONDITIONALS_ORD_IF", new RemoveConditionalMutator( + Choice.ORDER, true)); + add("REMOVE_CONDITIONALS_ORD_ELSE", new RemoveConditionalMutator( + Choice.ORDER, false)); addGroup("REMOVE_CONDITIONALS", RemoveConditionalMutator.makeMutators()); /** @@ -143,7 +147,8 @@ public final class Mutator { new org.pitest.mutationtest.engine.gregor.mutators.experimental.SwitchMutator()); /** - * Experimental mutator that replaces method call with one of its parameters of matching type + * Experimental mutator that replaces method call with one of its parameters + * of matching type */ add("EXPERIMENTAL_ARGUMENT_PROPAGATION", ArgumentPropagationMutator.ARGUMENT_PROPAGATION_MUTATOR); @@ -159,12 +164,14 @@ public static Collection all() { } private static Collection stronger() { - return combine(defaults(),group(new RemoveConditionalMutator(Choice.EQUAL, false), new SwitchMutator())); + return combine( + defaults(), + group(new RemoveConditionalMutator(Choice.EQUAL, false), + new SwitchMutator())); } private static Collection combine( - Collection a, - Collection b) { + Collection a, Collection b) { List l = new ArrayList(a); l.addAll(b); return l; @@ -213,6 +220,7 @@ public static Collection fromStrings( private static Comparator compareId() { return new Comparator() { + @Override public int compare(final MethodMutatorFactory o1, final MethodMutatorFactory o2) { return o1.getGloballyUniqueId().compareTo(o2.getGloballyUniqueId()); @@ -222,10 +230,11 @@ public int compare(final MethodMutatorFactory o1, private static F> fromString() { return new F>() { + @Override public Iterable apply(final String a) { Iterable i = MUTATORS.get(a); if (i == null) { - throw new PitHelpError(Help.UNKNOWN_MUTATOR, a); + throw new PitHelpError(Help.UNKNOWN_MUTATOR, a); } return i; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/InlinedFinallyBlockDetector.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/InlinedFinallyBlockDetector.java index 0a7e33a1a..305fe1d13 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/InlinedFinallyBlockDetector.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/InlinedFinallyBlockDetector.java @@ -1,12 +1,12 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,13 +42,14 @@ * Detects mutations on same line, but within different code blocks. This * pattern indicates code inlined for a finally block . . . or normal code that * creates two blocks on the same line. - * + * * Cannot be used with code that uses single line if statements */ public class InlinedFinallyBlockDetector implements InlinedCodeFilter { private static final Logger LOG = Log.getLogger(); + @Override public Collection process( final Collection mutations) { final List combined = new ArrayList( @@ -73,6 +74,7 @@ public Collection process( private static Comparator compareLineNumbers() { return new Comparator() { + @Override public int compare(final MutationDetails arg0, final MutationDetails arg1) { return arg0.getLineNumber() - arg1.getLineNumber(); } @@ -116,6 +118,7 @@ private boolean isPossibleToCorrectInlining( private static F isInFinallyHandler() { return new F() { + @Override public Boolean apply(final MutationDetails a) { return a.isInFinallyBlock(); } @@ -138,6 +141,7 @@ private static MutationDetails makeCombinedMutant( private static F mutationToIndex() { return new F() { + @Override public Integer apply(final MutationDetails a) { return a.getFirstIndex(); } @@ -146,6 +150,7 @@ public Integer apply(final MutationDetails a) { private static F mutationToBlock() { return new F() { + @Override public Integer apply(final MutationDetails a) { return a.getBlock(); } @@ -154,6 +159,7 @@ public Integer apply(final MutationDetails a) { private static F toLineMutatorPair() { return new F() { + @Override public LineMutatorPair apply(final MutationDetails a) { return new LineMutatorPair(a.getLineNumber(), a.getMutator()); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/NoInlinedCodeDetection.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/NoInlinedCodeDetection.java index 1c76834ab..d9acb6fd3 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/NoInlinedCodeDetection.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/inlinedcode/NoInlinedCodeDetection.java @@ -6,6 +6,7 @@ public class NoInlinedCodeDetection implements InlinedCodeFilter { + @Override public Collection process( final Collection mutations) { return mutations; diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutator.java index 2c986da2c..b9f8078f2 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2014 Stefan Mandel, Urs Metz - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,45 +21,46 @@ import org.pitest.mutationtest.engine.gregor.MutationContext; /** - * Mutator for non-void methods that have a parameter that matches - * the return type: it replaces the result of the method call with a - * parameter. E. g. the method call + * Mutator for non-void methods that have a parameter that matches the return + * type: it replaces the result of the method call with a parameter. E. g. the + * method call * *
- *   public int originalMethod() {
- *     int someInt = 3;
- *     return someOtherMethod(someInt);
- *   }
- *
- *   private int someOtherMethod(int parameter) {
- *     return parameter + 1;
- *   }
+ * public int originalMethod() {
+ *   int someInt = 3;
+ *   return someOtherMethod(someInt);
+ * }
+ * 
+ * private int someOtherMethod(int parameter) {
+ *   return parameter + 1;
+ * }
  * 
* * is mutated to * *
- *   public int mutatedMethod() {
- *     int someInt = 3;
- *     return someInt;
- *   }
+ * public int mutatedMethod() {
+ *   int someInt = 3;
+ *   return someInt;
+ * }
  * 
*/ -public enum ArgumentPropagationMutator - implements MethodMutatorFactory { +public enum ArgumentPropagationMutator implements MethodMutatorFactory { ARGUMENT_PROPAGATION_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new ArgumentPropagationVisitor( - context, methodVisitor, this); + return new ArgumentPropagationVisitor(context, methodVisitor, this); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationVisitor.java index 30ef71823..852ca11f7 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationVisitor.java @@ -50,7 +50,7 @@ public void visitMethodInsn(final int opcode, final String owner, if (hasArgumentMatchingTheReturnType(desc)) { final MutationIdentifier newId = this.context.registerMutation( this.factory, "replaced call to " + owner + "::" + name - + " with argument"); + + " with argument"); if (this.context.shouldMutate(newId)) { final Type returnType = Type.getReturnType(desc); replaceMethodCallWithArgumentHavingSameTypeAsReturnValue( diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutator.java index 2d003765a..6d1ce2e3d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,15 +28,18 @@ public enum ConditionalsBoundaryMutator implements MethodMutatorFactory { CONDITIONALS_BOUNDARY_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new ConditionalsBoundaryMethodVisitor(this, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutator.java index 4e13431dd..dc5b7ddc8 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,12 +25,14 @@ public enum ConstructorCallMutator implements MethodMutatorFactory { CONSTRUCTOR_CALL_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new MethodCallMethodVisitor(methodInfo, context, methodVisitor, this, constructors()); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } @@ -38,6 +40,7 @@ public String getGloballyUniqueId() { private static F2 constructors() { return new F2() { + @Override public Boolean apply(final String name, final String desc) { return MethodInfo.isConstructor(name); } @@ -45,6 +48,7 @@ public Boolean apply(final String name, final String desc) { }; } + @Override public String getName() { return name(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutator.java index 09f8da47f..140daff8c 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,15 +25,18 @@ public enum IncrementsMutator implements MethodMutatorFactory { INCREMENTS_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new IncrementsMethodVisitor(this, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } @@ -42,7 +45,7 @@ public String getName() { class IncrementsMethodVisitor extends MethodVisitor { private final MethodMutatorFactory factory; - private final MutationContext context; + private final MutationContext context; public IncrementsMethodVisitor(final MethodMutatorFactory factory, final MutationContext context, final MethodVisitor delegateMethodVisitor) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutator.java index 8569c618d..7480af9fd 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,8 +27,8 @@ * The InlineConstantMutator is a mutator that mutates integer * inline constants (including short, byte, long) by adding 1 and that mutates * float inline constants (including double) by replacing them with 1. - * - * + * + * * @author Stefan Penndorf <stefan.penndorf@gmail.com> */ public class InlineConstantMutator implements MethodMutatorFactory { @@ -193,7 +193,7 @@ private void translateToByteCode(final Long constant) { /** * Translates the opcode to a number (inline constant) if possible or * returns null if the opcode cannot be translated. - * + * * @param opcode * that might represent an inline constant. * @return the value of the inline constant represented by opcode or @@ -237,7 +237,7 @@ private Number translateToNumber(final int opcode) { /* * (non-Javadoc) - * + * * @see org.objectweb.asm.MethodAdapter#visitInsn(int) */ @Override @@ -255,7 +255,7 @@ public void visitInsn(final int opcode) { /* * (non-Javadoc) - * + * * @see org.objectweb.asm.MethodAdapter#visitIntInsn(int, int) */ @Override @@ -269,7 +269,7 @@ public void visitIntInsn(final int opcode, final int operand) { /* * (non-Javadoc) - * + * * @see org.objectweb.asm.MethodAdapter#visitLdcInsn(java.lang.Object) */ @Override @@ -284,11 +284,13 @@ public void visitLdcInsn(final Object constant) { } + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new InlineConstantVisitor(context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } @@ -298,6 +300,7 @@ public String toString() { return "INLINE_CONSTANT_MUTATOR"; } + @Override public String getName() { return toString(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutator.java index 9c35b0112..34a529903 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,15 +30,18 @@ public enum InvertNegsMutator implements MethodMutatorFactory { INVERT_NEGS_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new InvertNegsMethodVisitor(this, methodInfo, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutator.java index d58825335..254eb5d1a 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,15 +30,18 @@ public enum MathMutator implements MethodMutatorFactory { MATH_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new MathMethodVisitor(this, methodInfo, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MethodCallMethodVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MethodCallMethodVisitor.java index 6a407cef5..97d884080 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MethodCallMethodVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/MethodCallMethodVisitor.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,7 +40,7 @@ class MethodCallMethodVisitor extends MethodVisitor { private final F2 filter; private final MethodMutatorFactory factory; - private final MutationContext context; + private final MutationContext context; private final MethodInfo methodInfo; static { diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutator.java index 47770f7da..34035c53c 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutator.java @@ -28,15 +28,18 @@ public enum NegateConditionalsMutator implements MethodMutatorFactory { NEGATE_CONDITIONALS_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new ConditionalMethodVisitor(this, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutator.java index baea04092..9dfaf21c6 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,16 +25,19 @@ public enum NonVoidMethodCallMutator implements MethodMutatorFactory { NON_VOID_METHOD_CALL_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new MethodCallMethodVisitor(methodInfo, context, methodVisitor, this, nonVoidMethods()); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } @@ -42,6 +45,7 @@ public String getName() { private F2 nonVoidMethods() { return new F2() { + @Override public Boolean apply(final String name, final String desc) { return !MethodInfo.isVoid(desc); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutator.java index 4a4b2512b..7e32c2b5c 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutator.java @@ -20,11 +20,13 @@ public class RemoveConditionalMutator implements MethodMutatorFactory { public enum Choice { EQUAL("equality"), ORDER("comparison"); private String desc; + Choice(String desc) { this.desc = desc; } + String description() { - return desc; + return this.desc; } } @@ -48,18 +50,21 @@ public static Iterable makeMutators() { return variations; } + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new RemoveConditionalMethodVisitor(this, context, methodVisitor, - "removed conditional - replaced " + this.kind.description() + " check with " - + this.replaceWith); + "removed conditional - replaced " + this.kind.description() + + " check with " + this.replaceWith); } + @Override public String getGloballyUniqueId() { return this.getClass().getName() + "_" + this.kind + "_" + (this.replaceWith ? "IF" : "ELSE"); } + @Override public String getName() { return "REMOVE_CONDITIONALS_" + this.kind + "_" + (this.replaceWith ? "IF" : "ELSE") + "_MUTATOR"; @@ -72,7 +77,8 @@ private final class RemoveConditionalMethodVisitor extends MethodVisitor { private final MethodMutatorFactory factory; public RemoveConditionalMethodVisitor(final MethodMutatorFactory factory, - final MutationContext context, final MethodVisitor delegateMethodVisitor, String description) { + final MutationContext context, + final MethodVisitor delegateMethodVisitor, String description) { super(Opcodes.ASM5, delegateMethodVisitor); this.context = context; this.factory = factory; @@ -84,7 +90,7 @@ public void visitJumpInsn(final int opcode, final Label label) { if (canMutate(opcode)) { final MutationIdentifier newId = this.context.registerMutation( - this.factory, description); + this.factory, this.description); if (this.context.shouldMutate(newId)) { emptyStack(opcode); diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutator.java index 856bc78ac..e031db601 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,15 +38,18 @@ public enum ReturnValsMutator implements MethodMutatorFactory { RETURN_VALS_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new ReturnValsMethodVisitor(this, methodInfo, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } @@ -74,6 +77,7 @@ public ReturnValsMethodVisitor(final MethodMutatorFactory factory, private static ZeroOperandMutation areturnMutation() { return new ZeroOperandMutation() { + @Override public void apply(final int opCode, final MethodVisitor mv) { // Strategy translated from jumble BCEL code @@ -91,6 +95,7 @@ public void apply(final int opCode, final MethodVisitor mv) { mv.visitInsn(Opcodes.ARETURN); } + @Override public String decribe(final int opCode, final MethodInfo methodInfo) { return "mutated return of Object value for " + methodInfo.getDescription() @@ -103,12 +108,14 @@ public String decribe(final int opCode, final MethodInfo methodInfo) { private static ZeroOperandMutation lreturnMutation() { return new ZeroOperandMutation() { + @Override public void apply(final int opcode, final MethodVisitor mv) { mv.visitInsn(LCONST_1); mv.visitInsn(LADD); mv.visitInsn(opcode); } + @Override public String decribe(final int opCode, final MethodInfo methodInfo) { return "replaced return of long value with value + 1 for " + methodInfo.getDescription(); @@ -120,6 +127,7 @@ public String decribe(final int opCode, final MethodInfo methodInfo) { private static ZeroOperandMutation freturnMutation() { return new ZeroOperandMutation() { + @Override public void apply(final int opcode, final MethodVisitor mv) { // Strategy translated from jumble BCEL code // The following is complicated by the problem of NaNs. By default @@ -139,6 +147,7 @@ public void apply(final int opcode, final MethodVisitor mv) { mv.visitInsn(Opcodes.FRETURN); } + @Override public String decribe(final int opCode, final MethodInfo methodInfo) { return "replaced return of float value with -(x + 1) for " + methodInfo.getDescription(); @@ -150,6 +159,7 @@ public String decribe(final int opCode, final MethodInfo methodInfo) { private static ZeroOperandMutation dreturnMutation() { return new ZeroOperandMutation() { + @Override public void apply(final int opCode, final MethodVisitor mv) { // Strategy translated from jumble BCEL code // The following is complicated by the problem of NaNs. By default @@ -169,6 +179,7 @@ public void apply(final int opCode, final MethodVisitor mv) { mv.visitInsn(Opcodes.DRETURN); } + @Override public String decribe(final int opCode, final MethodInfo methodInfo) { return "replaced return of double value with -(x + 1) for " + methodInfo.getDescription(); @@ -180,6 +191,7 @@ public String decribe(final int opCode, final MethodInfo methodInfo) { private static ZeroOperandMutation ireturnMutation() { return new ZeroOperandMutation() { + @Override public void apply(final int opCode, final MethodVisitor mv) { final Label l1 = new Label(); mv.visitJumpInsn(Opcodes.IFEQ, l1); @@ -190,6 +202,7 @@ public void apply(final int opCode, final MethodVisitor mv) { mv.visitInsn(Opcodes.IRETURN); } + @Override public String decribe(final int opCode, final MethodInfo methodInfo) { return "replaced return of integer sized value with (x == 0 ? 1 : 0)"; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutator.java index e952cfd74..ea5545e8d 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,16 +25,19 @@ public enum VoidMethodCallMutator implements MethodMutatorFactory { VOID_METHOD_CALL_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new MethodCallMethodVisitor(methodInfo, context, methodVisitor, this, voidMethods()); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } @@ -42,6 +45,7 @@ public String getName() { private static F2 voidMethods() { return new F2() { + @Override public Boolean apply(final String name, final String desc) { return MethodInfo.isVoid(desc) && !MethodInfo.isConstructor(name); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutator.java index 40cebb814..a29a17aba 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutator.java @@ -1,17 +1,17 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators.experimental; @@ -26,7 +26,7 @@ /** * The MemberVariableMutator is a mutator that mutates assignments * to member variables by removing them. - * + * * @author Stefan Penndorf <stefan.penndorf@gmail.com> */ public class MemberVariableMutator implements MethodMutatorFactory { @@ -62,7 +62,7 @@ public void visitFieldInsn(final int opcode, final String owner, /* * (non-Javadoc) - * + * * @see org.objectweb.asm.MethodAdapter#visitMethodInsn(int, * java.lang.String, java.lang.String, java.lang.String) */ @@ -81,11 +81,13 @@ private boolean shouldMutate(final String fieldName) { } + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new MemberVariableVisitor(context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } @@ -95,6 +97,7 @@ public String toString() { return "EXPERIMENTAL_MEMBER_VARIABLE_MUTATOR"; } + @Override public String getName() { return toString(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutator.java index 75441af7e..0109e48a6 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutator.java @@ -25,15 +25,18 @@ public enum RemoveIncrementsMutator implements MethodMutatorFactory { REMOVE_INCREMENTS_MUTATOR; + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new RemoveIncrementsMethodVisitor(this, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return name(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutator.java index 77d1aac18..d5af282af 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutator.java @@ -13,41 +13,43 @@ /** * Remove switch statements. We get an array of labels to jump to, plus a - * default label. We change each label to the default label, thus removing - * it + * default label. We change each label to the default label, thus removing it */ public class RemoveSwitchMutator implements MethodMutatorFactory { - //EXPERIMENTAL_REMOVE_SWITCH_MUTATOR; + // EXPERIMENTAL_REMOVE_SWITCH_MUTATOR; private final int key; - + public RemoveSwitchMutator(final int i) { - key = i; + this.key = i; } public static Iterable makeMutators() { List variations = new ArrayList(); - for (int i = 0; i != 100; i++ ) { - variations.add(new RemoveSwitchMutator(i) ); + for (int i = 0; i != 100; i++) { + variations.add(new RemoveSwitchMutator(i)); } return variations; } - + + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new RemoveSwitchMethodVisitor(context, methodVisitor); } + @Override public String getGloballyUniqueId() { - return this.getClass().getName() + "_" + key; + return this.getClass().getName() + "_" + this.key; } + @Override public String getName() { return toString(); } @Override public String toString() { - return "EXPERIMENTAL_REMOVE_SWITCH_MUTATOR_" + key; + return "EXPERIMENTAL_REMOVE_SWITCH_MUTATOR_" + this.key; } private final class RemoveSwitchMethodVisitor extends MethodVisitor { @@ -63,9 +65,9 @@ public RemoveSwitchMethodVisitor(final MutationContext context, @Override public void visitTableSwitchInsn(final int i, final int i1, final Label defaultLabel, final Label... labels) { - if (labels.length > key && shouldMutate()) { + if ((labels.length > RemoveSwitchMutator.this.key) && shouldMutate()) { Label[] newLabels = labels.clone(); - newLabels[key] = defaultLabel; + newLabels[RemoveSwitchMutator.this.key] = defaultLabel; super.visitTableSwitchInsn(i, i1, defaultLabel, newLabels); } else { super.visitTableSwitchInsn(i, i1, defaultLabel, labels); @@ -73,10 +75,11 @@ public void visitTableSwitchInsn(final int i, final int i1, } @Override - public void visitLookupSwitchInsn(final Label defaultLabel, final int[] ints, final Label[] labels) { - if (labels.length > key && shouldMutate()) { + public void visitLookupSwitchInsn(final Label defaultLabel, + final int[] ints, final Label[] labels) { + if ((labels.length > RemoveSwitchMutator.this.key) && shouldMutate()) { Label[] newLabels = labels.clone(); - newLabels[key] = defaultLabel; + newLabels[RemoveSwitchMutator.this.key] = defaultLabel; super.visitLookupSwitchInsn(defaultLabel, ints, newLabels); } else { super.visitLookupSwitchInsn(defaultLabel, ints, labels); @@ -85,7 +88,8 @@ public void visitLookupSwitchInsn(final Label defaultLabel, final int[] ints, fi private boolean shouldMutate() { final MutationIdentifier mutationId = this.context.registerMutation( - RemoveSwitchMutator.this, "RemoveSwitch " + key + " mutation"); + RemoveSwitchMutator.this, "RemoveSwitch " + + RemoveSwitchMutator.this.key + " mutation"); return this.context.shouldMutate(mutationId); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutator.java index af08d06f9..26fd28b66 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,11 +30,11 @@ * *

* Replacements for primitive types are simple. Replacements of object - * references are handled by ObjectReferenceReplacer. Those replacements - * can get more complex. + * references are handled by ObjectReferenceReplacer. Those replacements can get + * more complex. *

- * - * + * + * * @author Stefan Penndorf <stefan.penndorf@gmail.com> */ public class ReturnValuesMutator implements MethodMutatorFactory { @@ -129,10 +129,10 @@ private Object replaceObjectInstance(final Object object, private final class ReturnValuesMethodVisitor extends MethodVisitor { - private static final String DESCRIPTION_MESSAGE_PATTERN = "replaced return of %s value with %s"; + private static final String DESCRIPTION_MESSAGE_PATTERN = "replaced return of %s value with %s"; - private final MutationContext context; - private final MethodInfo methodInfo; + private final MutationContext context; + private final MethodInfo methodInfo; private ReturnValuesMethodVisitor(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor delegateVisitor) { @@ -161,7 +161,7 @@ private void mutateObjectReferenceReturn() { * complicated by the problem of NaNs. By default the new value is * -(x + 1), but this doesn't work for NaNs. But for a * NaN x != x is true, and we use this to detect them. - * + * * @see #mutatePrimitiveFloatReturn() */ private void mutatePrimitiveDoubleReturn() { @@ -191,7 +191,7 @@ private void mutatePrimitiveDoubleReturn() { * complicated by the problem of NaNs. By default the new value is * -(x + 1), but this doesn't work for NaNs. But for a * NaN x != x is true, and we use this to detect them. - * + * * @see #mutatePrimitiveDoubleReturn() */ private void mutatePrimitiveFloatReturn() { @@ -298,7 +298,7 @@ public void visitInsn(final int opcode) { * parameter clazz will be the class of the object * or one of it's super classes. The returned object must be of type * clazz or one of it's child classes. - * + * * @param object * the object reference to mutate, maybe null. * @param clazz @@ -312,15 +312,18 @@ public static Object mutateObjectInstance(final Object object, return SINGLETON_REPLACER.replaceObjectInstance(object, clazz); } + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new ReturnValuesMethodVisitor(context, methodInfo, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return "EXPERIMENTAL_RETURN_VALUES_MUTATOR"; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutator.java index 51d537999..0ad46328c 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutator.java @@ -16,15 +16,18 @@ */ public class SwitchMutator implements MethodMutatorFactory { + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new SwitchMethodVisitor(context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return "EXPERIMENTAL_SWITCH_MUTATOR"; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java b/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java index 585df0ccd..68f19a99c 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,19 +25,22 @@ public class CheckTestHasFailedResultListener implements TestListener { private Option lastFailingTest = Option.none(); private int testsRun = 0; - + @Override public void onTestFailure(final TestResult tr) { this.lastFailingTest = Option.some(tr.getDescription()); } + @Override public void onTestSkipped(final TestResult tr) { } + @Override public void onTestStart(final Description d) { this.testsRun++; } + @Override public void onTestSuccess(final TestResult tr) { } @@ -58,10 +61,12 @@ public int getNumberOfTestsRun() { return this.testsRun; } + @Override public void onRunEnd() { } + @Override public void onRunStart() { } diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultPITClassloader.java b/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultPITClassloader.java index c6bae4702..1586d9a60 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultPITClassloader.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultPITClassloader.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -70,10 +70,12 @@ protected Enumeration findResources(final String name) { return new Enumeration() { private URL element = findResource(name); + @Override public boolean hasMoreElements() { return this.element != null; } + @Override public URL nextElement() { if (this.element != null) { final URL next = this.element; diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultReporter.java b/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultReporter.java index c91d74b75..0a49924ba 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultReporter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/DefaultReporter.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,6 +31,7 @@ public class DefaultReporter implements Reporter { this.w = new SafeDataOutputStream(w); } + @Override public synchronized void describe(final MutationIdentifier i) throws IOException { this.w.writeByte(Id.DESCRIBE); @@ -38,6 +39,7 @@ public synchronized void describe(final MutationIdentifier i) this.w.flush(); } + @Override public synchronized void report(final MutationIdentifier i, final MutationStatusTestPair mutationDetected) throws IOException { this.w.writeByte(Id.REPORT); @@ -46,6 +48,7 @@ public synchronized void report(final MutationIdentifier i, this.w.flush(); } + @Override public synchronized void done(final ExitCode exitCode) { this.w.writeByte(Id.DONE); this.w.writeInt(exitCode.getCode()); diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/HotSwap.java b/pitest/src/main/java/org/pitest/mutationtest/execute/HotSwap.java index 6820b5a30..7f708d82b 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/HotSwap.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/HotSwap.java @@ -11,18 +11,19 @@ class HotSwap implements F3 { private final ClassByteArraySource byteSource; private byte[] lastClassPreMutation; private ClassName lastMutatedClass; - private ClassLoader lastUsedLoader; + private ClassLoader lastUsedLoader; HotSwap(final ClassByteArraySource byteSource) { this.byteSource = byteSource; } + @Override public Boolean apply(final ClassName clazzName, final ClassLoader loader, final byte[] b) { Class clazz; try { restoreLastClass(this.byteSource, clazzName, loader); - lastUsedLoader = loader; + this.lastUsedLoader = loader; clazz = Class.forName(clazzName.asJavaName(), false, loader); return HotSwapAgent.hotSwap(clazz, b); } catch (final ClassNotFoundException e) { @@ -33,9 +34,9 @@ public Boolean apply(final ClassName clazzName, final ClassLoader loader, private void restoreLastClass(final ClassByteArraySource byteSource, final ClassName clazzName, final ClassLoader loader) - throws ClassNotFoundException { + throws ClassNotFoundException { if ((this.lastMutatedClass != null) - && !this.lastMutatedClass.equals(clazzName)) { + && !this.lastMutatedClass.equals(clazzName)) { restoreForLoader(this.lastUsedLoader); restoreForLoader(loader); } @@ -49,8 +50,10 @@ private void restoreLastClass(final ClassByteArraySource byteSource, this.lastMutatedClass = clazzName; } - private void restoreForLoader(ClassLoader loader) throws ClassNotFoundException { - Class clazz = Class.forName(this.lastMutatedClass.asJavaName(), false, loader); + private void restoreForLoader(ClassLoader loader) + throws ClassNotFoundException { + Class clazz = Class.forName(this.lastMutatedClass.asJavaName(), false, + loader); HotSwapAgent.hotSwap(clazz, this.lastClassPreMutation); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationAnalysisExecutor.java b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationAnalysisExecutor.java index 97b73b057..d36f6af93 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationAnalysisExecutor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationAnalysisExecutor.java @@ -40,15 +40,16 @@ public void run(final List testUnits) { LOG.fine("Running " + testUnits.size() + " units"); signalRunStartToAllListeners(); - - List> results = new ArrayList>(testUnits.size()); - + + List> results = new ArrayList>( + testUnits.size()); + for (final MutationAnalysisUnit unit : testUnits) { - results.add(executor.submit(unit)); + results.add(this.executor.submit(unit)); } - + this.executor.shutdown(); - + try { processResult(results); } catch (InterruptedException e) { @@ -56,16 +57,16 @@ public void run(final List testUnits) { } catch (ExecutionException e) { throw Unchecked.translateCheckedException(e); } - - signalRunEndToAllListeners(); + signalRunEndToAllListeners(); } - private void processResult(List> results) throws InterruptedException, ExecutionException { - for ( Future f : results ) { + private void processResult(List> results) + throws InterruptedException, ExecutionException { + for (Future f : results) { MutationMetaData r = f.get(); - for ( MutationResultListener l : listeners ) { + for (MutationResultListener l : this.listeners) { for (final ClassMutationResults cr : r.toClassResults()) { l.handleMutationResult(cr); } @@ -74,21 +75,23 @@ private void processResult(List> results) throws Interr } private void signalRunStartToAllListeners() { - FCollection.forEach(listeners, new SideEffect1() { - public void apply(final MutationResultListener a) { - a.runStart(); - } - }); + FCollection.forEach(this.listeners, + new SideEffect1() { + @Override + public void apply(final MutationResultListener a) { + a.runStart(); + } + }); } - private void signalRunEndToAllListeners() { - FCollection.forEach(listeners, new SideEffect1() { - public void apply(final MutationResultListener a) { - a.runEnd(); - } - }); + FCollection.forEach(this.listeners, + new SideEffect1() { + @Override + public void apply(final MutationResultListener a) { + a.runEnd(); + } + }); } - } diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestCommunicationThread.java b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestCommunicationThread.java index 460bf2da1..875fdbf9e 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestCommunicationThread.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestCommunicationThread.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,6 +40,7 @@ private static class SendData implements SideEffect1 { this.arguments = arguments; } + @Override public void apply(final SafeDataOutputStream dos) { dos.write(this.arguments); dos.flush(); @@ -54,6 +55,7 @@ private static class Receive implements ReceiveStrategy { this.idMap = idMap; } + @Override public void apply(final byte control, final SafeDataInputStream is) { switch (control) { case Id.DESCRIBE: diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestProcess.java b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestProcess.java index cc69e3a01..a4079ce50 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestProcess.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestProcess.java @@ -31,8 +31,7 @@ public void start() throws IOException, InterruptedException { this.process.start(); } - public void results(final MutationStatusMap allmutations) - throws IOException { + public void results(final MutationStatusMap allmutations) throws IOException { for (final MutationDetails each : allmutations.allMutations()) { final MutationStatusTestPair status = this.thread.getStatus(each.getId()); diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestSlave.java b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestSlave.java index 593c0b635..894a4135a 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestSlave.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestSlave.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -154,6 +154,7 @@ private static void safelyCloseSocket(final Socket s) { private static void addMemoryWatchDog(final Reporter r) { final NotificationListener listener = new NotificationListener() { + @Override public void handleNotification(final Notification notification, final Object handback) { final String type = notification.getType(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java index 543cbd401..1a7fb419a 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java @@ -48,11 +48,11 @@ public class MutationTestWorker { private static final Logger LOG = Log - .getLogger(); + .getLogger(); // micro optimise debug logging private static final boolean DEBUG = LOG - .isLoggable(Level.FINE); + .isLoggable(Level.FINE); private final Mutater mutater; private final ClassLoader loader; @@ -208,7 +208,7 @@ private MutationStatusTestPair createStatusTestPair( if (listener.lastFailingTest().hasSome()) { return new MutationStatusTestPair(listener.getNumberOfTestsRun(), listener.status(), listener.lastFailingTest().value() - .getQualifiedName()); + .getQualifiedName()); } else { return new MutationStatusTestPair(listener.getNumberOfTestsRun(), listener.status()); diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTimeoutDecorator.java b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTimeoutDecorator.java index e88f6e1db..14423c231 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTimeoutDecorator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTimeoutDecorator.java @@ -83,10 +83,10 @@ private Runnable createRunnable(final ClassLoader loader, final ResultCollector rc) { return new Runnable() { + @Override public void run() { try { - child().execute( - loader,rc); + child().execute(loader, rc); } catch (final Throwable ex) { rc.notifyEnd(child().getDescription(), ex); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/Reporter.java b/pitest/src/main/java/org/pitest/mutationtest/execute/Reporter.java index 8de7b6ed3..8a0e15433 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/Reporter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/Reporter.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/SlaveArguments.java b/pitest/src/main/java/org/pitest/mutationtest/execute/SlaveArguments.java index 7128016e6..62c081e41 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/SlaveArguments.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/SlaveArguments.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSource.java b/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSource.java index c102dc984..c00bb4425 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSource.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSource.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -53,6 +53,7 @@ public List translateTests(final List testsInOrder) { private F> testToTestUnit() { return new F>() { + @Override public Option apply(final TestInfo a) { final TestUnit tu = TimeOutDecoratedTestSource.this.allTests.get(a .getName()); @@ -61,7 +62,7 @@ public Option apply(final TestInfo a) { . some(new MutationTimeoutDecorator(tu, new TimeOutSystemExitSideEffect( TimeOutDecoratedTestSource.this.r), - TimeOutDecoratedTestSource.this.timeoutStrategy, a.getTime())); + TimeOutDecoratedTestSource.this.timeoutStrategy, a.getTime())); } return Option.none(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffect.java b/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffect.java index 6b99c3d45..2dacab78e 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffect.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffect.java @@ -11,6 +11,7 @@ public TimeOutSystemExitSideEffect(final Reporter r) { this.r = r; } + @Override public void apply() { this.r.done(ExitCode.TIMEOUT); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundFilterFactory.java b/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundFilterFactory.java index 06ea61a10..eb26ca09b 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundFilterFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundFilterFactory.java @@ -10,29 +10,36 @@ import org.pitest.functional.FCollection; public class CompoundFilterFactory implements MutationFilterFactory { - + private final List children = new ArrayList(); - - public CompoundFilterFactory( Collection filters ) { + + public CompoundFilterFactory( + Collection filters) { this.children.addAll(filters); } + @Override public String description() { return null; } - public MutationFilter createFilter(Properties props, CodeSource source, int maxMutationsPerClass) { - List filters = FCollection.map(children, toFilter(props, source, maxMutationsPerClass)); + @Override + public MutationFilter createFilter(Properties props, CodeSource source, + int maxMutationsPerClass) { + List filters = FCollection.map(this.children, + toFilter(props, source, maxMutationsPerClass)); return new CompoundMutationFilter(filters); } - private static F toFilter(final Properties props, final CodeSource source, + private static F toFilter( + final Properties props, final CodeSource source, final int maxMutationsPerClass) { - return new F () { + return new F() { + @Override public MutationFilter apply(MutationFilterFactory a) { - return a.createFilter(props, source, maxMutationsPerClass); + return a.createFilter(props, source, maxMutationsPerClass); } - + }; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundMutationFilter.java b/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundMutationFilter.java index 554af5980..6ed926880 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundMutationFilter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/filter/CompoundMutationFilter.java @@ -14,10 +14,11 @@ class CompoundMutationFilter implements MutationFilter { this.children.addAll(children); } + @Override public Collection filter( Collection mutations) { Collection modified = mutations; - for (MutationFilter each : children) { + for (MutationFilter each : this.children) { modified = each.filter(modified); } return modified; diff --git a/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilter.java b/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilter.java index 3b3371691..251e710f0 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.filter; @@ -28,7 +28,7 @@ public LimitNumberOfMutationPerClassFilter(final int max) { this.maxMutationsPerClass = max; } - + @Override public Collection filter( final Collection mutations) { if (mutations.size() <= this.maxMutationsPerClass) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactory.java b/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactory.java index af9e44c0d..f44f62642 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactory.java @@ -4,18 +4,22 @@ import org.pitest.classpath.CodeSource; -public class LimitNumberOfMutationsPerClassFilterFactory implements MutationFilterFactory { +public class LimitNumberOfMutationsPerClassFilterFactory implements + MutationFilterFactory { - public MutationFilter createFilter(Properties props, CodeSource source, int maxMutationsPerClass) { - if ( maxMutationsPerClass > 0 ) { - return new LimitNumberOfMutationPerClassFilter(maxMutationsPerClass); + @Override + public MutationFilter createFilter(Properties props, CodeSource source, + int maxMutationsPerClass) { + if (maxMutationsPerClass > 0) { + return new LimitNumberOfMutationPerClassFilter(maxMutationsPerClass); } else { return UnfilteredMutationFilter.INSTANCE; } } + @Override public String description() { return "Default limit mutations plugin"; } - + } diff --git a/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilter.java b/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilter.java index 1cc6c4cef..93c3edd87 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.filter; diff --git a/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilterFactory.java b/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilterFactory.java index fb699379f..ebbb1375f 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilterFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/filter/MutationFilterFactory.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.filter; @@ -21,6 +21,7 @@ public interface MutationFilterFactory extends ToolClasspathPlugin { - MutationFilter createFilter(Properties props, CodeSource source, int maxMutationsPerClass); - + MutationFilter createFilter(Properties props, CodeSource source, + int maxMutationsPerClass); + } diff --git a/pitest/src/main/java/org/pitest/mutationtest/filter/UnfilteredMutationFilter.java b/pitest/src/main/java/org/pitest/mutationtest/filter/UnfilteredMutationFilter.java index be1a26f40..9f5033888 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/filter/UnfilteredMutationFilter.java +++ b/pitest/src/main/java/org/pitest/mutationtest/filter/UnfilteredMutationFilter.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.filter; @@ -21,6 +21,7 @@ public enum UnfilteredMutationFilter implements MutationFilter { INSTANCE; + @Override public Collection filter( final Collection mutations) { return mutations; diff --git a/pitest/src/main/java/org/pitest/mutationtest/incremental/DefaultCodeHistory.java b/pitest/src/main/java/org/pitest/mutationtest/incremental/DefaultCodeHistory.java index 295d3c21e..b6ece16b1 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/incremental/DefaultCodeHistory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/incremental/DefaultCodeHistory.java @@ -33,11 +33,13 @@ public DefaultCodeHistory(final ClassInfoSource code, this.previousClassPath = previousClassPath; } + @Override public Option getPreviousResult( final MutationIdentifier id) { return Option.some(this.previousResults.get(id)); } + @Override public boolean hasClassChanged(final ClassName className) { final ClassHistory historic = this.previousClassPath.get(className); if (historic == null) { @@ -49,6 +51,7 @@ public boolean hasClassChanged(final ClassName className) { } + @Override public boolean hasCoverageChanged(final ClassName className, final BigInteger currentCoverage) { return !this.previousClassPath.get(className).getCoverageId() diff --git a/pitest/src/main/java/org/pitest/mutationtest/incremental/FileWriterFactory.java b/pitest/src/main/java/org/pitest/mutationtest/incremental/FileWriterFactory.java index 8c8f45f74..a978b0b71 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/incremental/FileWriterFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/incremental/FileWriterFactory.java @@ -17,6 +17,7 @@ public FileWriterFactory(final File file) { this.file = file; } + @Override public PrintWriter create() { this.file.getParentFile().mkdirs(); try { @@ -31,6 +32,7 @@ public PrintWriter create() { } } + @Override public void close() { if (this.writer != null) { this.writer.close(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/incremental/HistoryListener.java b/pitest/src/main/java/org/pitest/mutationtest/incremental/HistoryListener.java index db4031188..c14790658 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/incremental/HistoryListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/incremental/HistoryListener.java @@ -13,10 +13,12 @@ public HistoryListener(final HistoryStore historyStore) { this.historyStore = historyStore; } + @Override public void runStart() { } + @Override public void handleMutationResult(final ClassMutationResults metaData) { for (final MutationResult each : metaData.getMutations()) { this.historyStore.recordResult(each); @@ -24,6 +26,7 @@ public void handleMutationResult(final ClassMutationResults metaData) { } + @Override public void runEnd() { } diff --git a/pitest/src/main/java/org/pitest/mutationtest/incremental/IncrementalAnalyser.java b/pitest/src/main/java/org/pitest/mutationtest/incremental/IncrementalAnalyser.java index 3ca045b8f..6f2340a7e 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/incremental/IncrementalAnalyser.java +++ b/pitest/src/main/java/org/pitest/mutationtest/incremental/IncrementalAnalyser.java @@ -43,6 +43,7 @@ private static Map createStatusMap() { return map; } + @Override public Collection analyse( final Collection mutation) { @@ -109,7 +110,7 @@ private boolean killingTestHasNotChanged(final MutationDetails each, final List testClasses = FCollection.filter(allTests, testIsCalled(mutationStatusTestPair.getKillingTest().value())).map( - TestInfo.toDefiningClassName()); + TestInfo.toDefiningClassName()); if (testClasses.isEmpty()) { return false; @@ -121,6 +122,7 @@ private boolean killingTestHasNotChanged(final MutationDetails each, private static F testIsCalled(final String testName) { return new F() { + @Override public Boolean apply(final TestInfo a) { return a.getName().equals(testName); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/incremental/NullWriterFactory.java b/pitest/src/main/java/org/pitest/mutationtest/incremental/NullWriterFactory.java index ce002bab8..77a927489 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/incremental/NullWriterFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/incremental/NullWriterFactory.java @@ -22,10 +22,12 @@ public void write(final int b) throws IOException { }; } + @Override public PrintWriter create() { return this.pw; } + @Override public void close() { this.pw.close(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/incremental/XStreamHistoryStore.java b/pitest/src/main/java/org/pitest/mutationtest/incremental/XStreamHistoryStore.java index bc9c4f43b..69f0c5b14 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/incremental/XStreamHistoryStore.java +++ b/pitest/src/main/java/org/pitest/mutationtest/incremental/XStreamHistoryStore.java @@ -33,7 +33,7 @@ public class XStreamHistoryStore implements HistoryStore { private static final Logger LOG = Log - .getLogger(); + .getLogger(); private static final XStream XSTREAM_INSTANCE = configureXStream(); @@ -74,6 +74,7 @@ private BufferedReader createReader(final Option input) { return null; } + @Override public void recordClassPath(final Collection ids, final CoverageDatabase coverageInfo) { final PrintWriter output = this.outputFactory.create(); @@ -86,6 +87,7 @@ public void recordClassPath(final Collection ids, output.flush(); } + @Override public void recordResult(final MutationResult result) { final PrintWriter output = this.outputFactory.create(); output.println(toXml(new IdResult(result.getDetails().getId(), result @@ -93,14 +95,17 @@ public void recordResult(final MutationResult result) { output.flush(); } + @Override public Map getHistoricResults() { return this.previousResults; } + @Override public Map getHistoricClassPath() { return this.previousClassPath; } + @Override public void initialize() { if (this.input != null) { restoreClassPath(); diff --git a/pitest/src/main/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformer.java b/pitest/src/main/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformer.java index 2f0fc4982..923ed38c7 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformer.java +++ b/pitest/src/main/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformer.java @@ -17,17 +17,20 @@ public BendJavassistToMyWillTransformer(final Predicate filter) { this.filter = filter; } + @Override public byte[] transform(final ClassLoader loader, final String className, final Class classBeingRedefined, final ProtectionDomain protectionDomain, final byte[] classfileBuffer) - throws IllegalClassFormatException { + throws IllegalClassFormatException { if (shouldInclude(className)) { final ClassReader reader = new ClassReader(classfileBuffer); - final ClassWriter writer = new ClassWriter(FrameOptions.pickFlags(classfileBuffer)); + final ClassWriter writer = new ClassWriter( + FrameOptions.pickFlags(classfileBuffer)); - reader.accept(new JavassistInputStreamInterceptorAdapater(writer), ClassReader.EXPAND_FRAMES); + reader.accept(new JavassistInputStreamInterceptorAdapater(writer), + ClassReader.EXPAND_FRAMES); return writer.toByteArray(); } else { return null; diff --git a/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapater.java b/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapater.java index 93e19ade8..cc5f2083a 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapater.java +++ b/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapater.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInterceptor.java b/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInterceptor.java index c6593b67b..5b888e1d4 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInterceptor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistInterceptor.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -56,7 +56,7 @@ private static InputStream returnNormalBytes(final Object classPath, private static boolean isMutatedClass(final String name) { return (mutant != null) && mutant.getDetails().getClassName() - .equals(ClassName.fromString(name)); + .equals(ClassName.fromString(name)); } public static void setMutant(final Mutant newMutant) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportFactory.java b/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportFactory.java index bdce8a605..05e6c42e7 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,15 +22,18 @@ public class CSVReportFactory implements MutationResultListenerFactory { + @Override public MutationResultListener getListener(Properties props, final ListenerArguments args) { return new CSVReportListener(args.getOutputStrategy()); } + @Override public String name() { return "CSV"; } + @Override public String description() { return "Default csv report plugin"; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportListener.java b/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportListener.java index 2ddf66053..c997fbefc 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/report/csv/CSVReportListener.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,10 +55,12 @@ private String makeCsv(final Object... os) { return sb.toString(); } + @Override public void runStart() { - + } + @Override public void runEnd() { try { this.out.close(); @@ -67,6 +69,7 @@ public void runEnd() { } } + @Override public void handleMutationResult(final ClassMutationResults metaData) { try { diff --git a/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportFactory.java b/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportFactory.java index 33d54d549..cf2113d2b 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,15 +22,18 @@ public class XMLReportFactory implements MutationResultListenerFactory { + @Override public MutationResultListener getListener(Properties props, final ListenerArguments args) { return new XMLReportListener(args.getOutputStrategy()); } + @Override public String name() { return "XML"; } + @Override public String description() { return "Default xml report plugin"; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportListener.java b/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportListener.java index 38788324a..0400360fe 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/report/xml/XMLReportListener.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -73,7 +73,8 @@ private String makeMutationNode(final MutationResult mutation) { return makeNode(clean(details.getFilename()), sourceFile) + makeNode(clean(details.getClassName().asJavaName()), mutatedClass) + makeNode(clean(details.getMethod().name()), mutatedMethod) - + makeNode(clean(details.getId().getLocation().getMethodDesc()), methodDescription) + + makeNode(clean(details.getId().getLocation().getMethodDesc()), + methodDescription) + makeNode("" + details.getLineNumber(), lineNumber) + makeNode(clean(details.getMutator()), mutator) + makeNode("" + details.getFirstIndex(), index) @@ -119,15 +120,18 @@ private void write(final String value) { } } + @Override public void runStart() { write("\n"); write("\n"); } + @Override public void handleMutationResult(final ClassMutationResults metaData) { writeResult(metaData); } + @Override public void runEnd() { try { write("\n"); diff --git a/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatistics.java b/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatistics.java index 73df92e3f..0c813e3c0 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatistics.java +++ b/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatistics.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.statistics; @@ -38,6 +38,7 @@ public void registerResults(final Collection results) { private SideEffect1 register() { return new SideEffect1() { + @Override public void apply(final MutationResult mr) { MutationStatistics.this.numberOfTestsRun = MutationStatistics.this.numberOfTestsRun + mr.getNumberOfTestsRun(); @@ -82,6 +83,7 @@ public long getPercentageDetected() { private static F2 addDetectedTotals() { return new F2() { + @Override public Long apply(final Long a, final Score b) { return a + b.getTotalDetectedMutations(); } @@ -92,6 +94,7 @@ public Long apply(final Long a, final Score b) { private static F2 addTotals() { return new F2() { + @Override public Long apply(final Long a, final Score b) { return a + b.getTotalMutations(); } @@ -105,7 +108,7 @@ public void report(final PrintStream out) { + this.getPercentageDetected() + "%)"); out.println(">> Ran " + this.numberOfTestsRun + " tests (" + getTestsPerMutation() + " tests per mutation)"); - + } private String getTestsPerMutation() { @@ -116,7 +119,7 @@ private String getTestsPerMutation() { final float testsPerMutation = this.numberOfTestsRun / (float) this.getTotalMutations(); return new DecimalFormat("#.##", new DecimalFormatSymbols(Locale.ENGLISH)) - .format(testsPerMutation); + .format(testsPerMutation); } } diff --git a/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatisticsListener.java b/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatisticsListener.java index 032c72f66..786918f38 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatisticsListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/statistics/MutationStatisticsListener.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.statistics; @@ -18,22 +18,26 @@ import org.pitest.mutationtest.MutationResultListener; public class MutationStatisticsListener implements MutationResultListener, - MutationStatisticsSource { +MutationStatisticsSource { private final MutationStatistics mutatorScores = new MutationStatistics(); + @Override public MutationStatistics getStatistics() { return this.mutatorScores; } + @Override public void runStart() { } + @Override public void handleMutationResult(final ClassMutationResults metaData) { processMetaData(metaData); } + @Override public void runEnd() { } diff --git a/pitest/src/main/java/org/pitest/mutationtest/statistics/Score.java b/pitest/src/main/java/org/pitest/mutationtest/statistics/Score.java index d877ae58b..5d968c596 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/statistics/Score.java +++ b/pitest/src/main/java/org/pitest/mutationtest/statistics/Score.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.statistics; @@ -75,6 +75,7 @@ public long getPercentageDetected() { private static F isDetected() { return new F() { + @Override public Boolean apply(final StatusCount a) { return a.getStatus().isDetected(); } @@ -85,6 +86,7 @@ public Boolean apply(final StatusCount a) { private F2 addTotals() { return new F2() { + @Override public Long apply(final Long a, final StatusCount b) { return a + b.getCount(); } diff --git a/pitest/src/main/java/org/pitest/mutationtest/statistics/StatusCount.java b/pitest/src/main/java/org/pitest/mutationtest/statistics/StatusCount.java index 71973e9c7..b7bad6380 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/statistics/StatusCount.java +++ b/pitest/src/main/java/org/pitest/mutationtest/statistics/StatusCount.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.statistics; diff --git a/pitest/src/main/java/org/pitest/mutationtest/tooling/DirectorySourceLocator.java b/pitest/src/main/java/org/pitest/mutationtest/tooling/DirectorySourceLocator.java index 4016958ca..1781cef52 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/tooling/DirectorySourceLocator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/tooling/DirectorySourceLocator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,6 +33,7 @@ public class DirectorySourceLocator implements SourceLocator { private static class FileToReader implements F> { + @Override public Option apply(final File f) { if (f.exists()) { try { @@ -56,6 +57,7 @@ public DirectorySourceLocator(final File root) { this(root, new FileToReader()); } + @Override public Option locate(final Collection classes, final String fileName) { final List matches = FCollection.flatMap(classes, @@ -71,6 +73,7 @@ private F> classNameToSourceFileReader( final String fileName) { return new F>() { + @Override public Iterable apply(final String className) { if (className.contains(".")) { final File f = new File(className.replace(".", File.separator)); diff --git a/pitest/src/main/java/org/pitest/mutationtest/tooling/EntryPoint.java b/pitest/src/main/java/org/pitest/mutationtest/tooling/EntryPoint.java index b35bc42e1..0d931b038 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/tooling/EntryPoint.java +++ b/pitest/src/main/java/org/pitest/mutationtest/tooling/EntryPoint.java @@ -1,5 +1,10 @@ package org.pitest.mutationtest.tooling; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.util.Map; + import org.pitest.classpath.ClassPath; import org.pitest.classpath.ClassPathByteArraySource; import org.pitest.classpath.CodeSource; @@ -20,11 +25,6 @@ import org.pitest.util.ResultOutputStrategy; import org.pitest.util.Timings; -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.util.Map; - public class EntryPoint { /** @@ -32,18 +32,17 @@ public class EntryPoint { * * The big grab bag of config stored in ReportOptions must be setup correctly * first. - * @param baseDir + * + * @param baseDir * directory from which analysis will be run * @param data * @param environmentVariables * */ - public AnalysisResult execute(File baseDir, - ReportOptions data, - PluginServices plugins, - Map environmentVariables) { + public AnalysisResult execute(File baseDir, ReportOptions data, + PluginServices plugins, Map environmentVariables) { SettingsFactory settings = new SettingsFactory(data, plugins); - return execute(baseDir, data, settings,environmentVariables); + return execute(baseDir, data, settings, environmentVariables); } /** @@ -57,10 +56,8 @@ public AnalysisResult execute(File baseDir, * factory for various strategies. Override default to provide tool * specific behaviours */ - public AnalysisResult execute(File baseDir, - ReportOptions data, - SettingsFactory settings, - Map environmentVariables) { + public AnalysisResult execute(File baseDir, ReportOptions data, + SettingsFactory settings, Map environmentVariables) { final ClassPath cp = data.getClassPath(); @@ -81,7 +78,8 @@ public AnalysisResult execute(File baseDir, .createListener(); final CoverageOptions coverageOptions = settings.createCoverageOptions(); - final LaunchOptions launchOptions = new LaunchOptions(ja,settings.getJavaExecutable(), data.getJvmArgs(),environmentVariables); + final LaunchOptions launchOptions = new LaunchOptions(ja, + settings.getJavaExecutable(), data.getJvmArgs(), environmentVariables); final ProjectClassPaths cps = data.getMutationClassPaths(); final CodeSource code = new CodeSource(cps, coverageOptions.getPitConfig() diff --git a/pitest/src/main/java/org/pitest/mutationtest/tooling/JarCreatingJarFinder.java b/pitest/src/main/java/org/pitest/mutationtest/tooling/JarCreatingJarFinder.java index 624f1b5a6..9e73d9da3 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/tooling/JarCreatingJarFinder.java +++ b/pitest/src/main/java/org/pitest/mutationtest/tooling/JarCreatingJarFinder.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,6 @@ import java.util.jar.Manifest; import java.util.zip.ZipEntry; - import org.pitest.boot.HotSwapAgent; import org.pitest.classinfo.ClassByteArraySource; import org.pitest.classpath.ClassPathByteArraySource; @@ -44,7 +43,7 @@ public class JarCreatingJarFinder implements JavaAgent { protected static final String BOOT_CLASSPATH = "Boot-Class-Path"; private static final String AGENT_CLASS_NAME = HotSwapAgent.class - .getName(); + .getName(); private Option location = Option.none(); @@ -58,6 +57,7 @@ public JarCreatingJarFinder() { this(new ClassPathByteArraySource()); } + @Override public Option getJarLocation() { if (this.location.hasNone()) { this.location = createJar(); @@ -118,12 +118,13 @@ private byte[] classBytes(final String className) { final Option bytes = this.classByteSource.getBytes(className); if (bytes.hasSome()) { - return bytes.value(); + return bytes.value(); } throw new PitError("Unable to load class content for " + className); } + @Override public void close() { if (this.location.hasSome()) { final File f = new File(this.location.value()); diff --git a/pitest/src/main/java/org/pitest/mutationtest/tooling/KnownLocationJavaAgentFinder.java b/pitest/src/main/java/org/pitest/mutationtest/tooling/KnownLocationJavaAgentFinder.java index 3d7270fc6..fd6a062a3 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/tooling/KnownLocationJavaAgentFinder.java +++ b/pitest/src/main/java/org/pitest/mutationtest/tooling/KnownLocationJavaAgentFinder.java @@ -11,10 +11,12 @@ public KnownLocationJavaAgentFinder(final String location) { this.location = location; } + @Override public Option getJarLocation() { return Option.some(this.location); } + @Override public void close() { } diff --git a/pitest/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java b/pitest/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java index 2e8c819ae..35cf1cf78 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java +++ b/pitest/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -65,22 +65,20 @@ public class MutationCoverage { - private static final int MB = 1024 * 1024; + private static final int MB = 1024 * 1024; - private static final Logger LOG = Log.getLogger(); - private final ReportOptions data; + private static final Logger LOG = Log.getLogger(); + private final ReportOptions data; + private final MutationStrategies strategies; + private final Timings timings; + private final CodeSource code; + private final File baseDir; + private final SettingsFactory settings; - private final MutationStrategies strategies; - private final Timings timings; - private final CodeSource code; - private final File baseDir; - private final SettingsFactory settings; - - - public MutationCoverage( - final MutationStrategies strategies, final File baseDir, - final CodeSource code, final ReportOptions data, final SettingsFactory settings, final Timings timings) { + public MutationCoverage(final MutationStrategies strategies, + final File baseDir, final CodeSource code, final ReportOptions data, + final SettingsFactory settings, final Timings timings) { this.strategies = strategies; this.data = data; this.settings = settings; @@ -144,7 +142,8 @@ public CombinedStatistics runReport() throws IOException { LOG.fine("Free Memory before analysis start " + (runtime.freeMemory() / MB) + " mb"); - final MutationAnalysisExecutor mae = new MutationAnalysisExecutor(numberOfThreads(),config); + final MutationAnalysisExecutor mae = new MutationAnalysisExecutor( + numberOfThreads(), config); this.timings.registerStart(Timings.Stage.RUN_MUTATION_TESTS); mae.run(tus); this.timings.registerEnd(Timings.Stage.RUN_MUTATION_TESTS); @@ -157,7 +156,7 @@ public CombinedStatistics runReport() throws IOException { coverageData.createSummary()); } - + private int numberOfThreads() { return Math.max(1, this.data.getNumberOfThreads()); } @@ -174,7 +173,7 @@ private List createConfig(final long t0, this.data.getSourceDirs()), engine, t0); final MutationResultListener mutationReportListener = this.strategies - .listenerFactory().getListener(data.getFreeFormProperties(), args); + .listenerFactory().getListener(this.data.getFreeFormProperties(), args); ls.add(mutationReportListener); ls.add(new HistoryListener(history())); @@ -234,14 +233,16 @@ private List buildMutationTests( final MutationConfig mutationConfig = new MutationConfig(engine, coverage() .getLaunchOptions()); - ClassByteArraySource bas = new ClassPathByteArraySource(data.getClassPath()); + ClassByteArraySource bas = new ClassPathByteArraySource( + this.data.getClassPath()); - TestPrioritiser testPrioritiser = settings.getTestPrioritiser() - .makeTestPrioritiser(data.getFreeFormProperties(), code, coverageData); + TestPrioritiser testPrioritiser = this.settings.getTestPrioritiser() + .makeTestPrioritiser(this.data.getFreeFormProperties(), this.code, + coverageData); final MutationSource source = new MutationSource(mutationConfig, - makeFilter().createFilter(data.getFreeFormProperties(), code, - data.getMaxMutationsPerClass()), testPrioritiser, bas); + makeFilter().createFilter(this.data.getFreeFormProperties(), this.code, + this.data.getMaxMutationsPerClass()), testPrioritiser, bas); final MutationAnalyser analyser = new IncrementalAnalyser( new DefaultCodeHistory(this.code, history()), coverageData); @@ -252,9 +253,9 @@ private List buildMutationTests( this.data.getTimeoutConstant()), this.data.isVerbose(), this.data .getClassPath().getLocalClassPath()); - MutationGrouper grouper = settings.getMutationGrouper().makeFactory( - data.getFreeFormProperties(), code, data.getNumberOfThreads(), - data.getMutationUnitSize()); + MutationGrouper grouper = this.settings.getMutationGrouper().makeFactory( + this.data.getFreeFormProperties(), this.code, + this.data.getNumberOfThreads(), this.data.getMutationUnitSize()); final MutationTestBuilder builder = new MutationTestBuilder(wf, analyser, source, grouper); @@ -262,7 +263,7 @@ private List buildMutationTests( } private MutationFilterFactory makeFilter() { - return settings.createMutationFilter(); + return this.settings.createMutationFilter(); } private void checkMutationsFound(final List tus) { @@ -275,7 +276,6 @@ private void checkMutationsFound(final List tus) { } } - private String timeSpan(final long t0) { return "" + ((System.currentTimeMillis() - t0) / 1000) + " seconds"; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/tooling/SmartSourceLocator.java b/pitest/src/main/java/org/pitest/mutationtest/tooling/SmartSourceLocator.java index fe2f6c936..79d24b9da 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/tooling/SmartSourceLocator.java +++ b/pitest/src/main/java/org/pitest/mutationtest/tooling/SmartSourceLocator.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.tooling; @@ -36,6 +36,7 @@ public SmartSourceLocator(final Collection roots) { childDirs.addAll(roots); final F fileToSourceLocator = new F() { + @Override public SourceLocator apply(final File a) { return new DirectorySourceLocator(a); } @@ -45,6 +46,7 @@ public SourceLocator apply(final File a) { private F> collectChildren(final int depth) { return new F>() { + @Override public Collection apply(final File a) { return collectDirectories(a, depth); } @@ -63,6 +65,7 @@ private Collection collectDirectories(final File root, final int depth) { private static Collection listFirstLevelDirectories(final File root) { final F p = new F() { + @Override public Boolean apply(final File a) { return a.isDirectory(); } @@ -71,6 +74,7 @@ public Boolean apply(final File a) { return FArray.filter(root.listFiles(), p); } + @Override public Option locate(final Collection classes, final String fileName) { for (final SourceLocator each : this.children) { diff --git a/pitest/src/main/java/org/pitest/mutationtest/tooling/SpinnerListener.java b/pitest/src/main/java/org/pitest/mutationtest/tooling/SpinnerListener.java index 5895b52e8..8d488a181 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/tooling/SpinnerListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/tooling/SpinnerListener.java @@ -8,7 +8,7 @@ public class SpinnerListener implements MutationResultListener { private static final String[] SPINNER_CHARS = new String[] { "\u0008/", - "\u0008-", "\u0008\\", "\u0008|" }; + "\u0008-", "\u0008\\", "\u0008|" }; private final PrintStream out; @@ -18,15 +18,18 @@ public SpinnerListener(final PrintStream out) { this.out = out; } + @Override public void runStart() { } + @Override public void handleMutationResult(final ClassMutationResults metaData) { this.out.printf("%s", SPINNER_CHARS[this.position % SPINNER_CHARS.length]); this.position++; } + @Override public void runEnd() { } diff --git a/pitest/src/main/java/org/pitest/mutationtest/verify/DefaultBuildVerifier.java b/pitest/src/main/java/org/pitest/mutationtest/verify/DefaultBuildVerifier.java index ba1f40353..611b35d70 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/verify/DefaultBuildVerifier.java +++ b/pitest/src/main/java/org/pitest/mutationtest/verify/DefaultBuildVerifier.java @@ -2,13 +2,13 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,6 +27,7 @@ public class DefaultBuildVerifier implements BuildVerifier { + @Override public void verify(final CodeSource code) { final Collection codeClasses = code.getCode(); // perform only a weak check for line numbers as @@ -45,6 +46,7 @@ private void checkAtLeastOneClassHasLineNumbers( private static F aClassWithLineNumbers() { return new F() { + @Override public Boolean apply(final ClassInfo a) { return a.getNumberOfCodeLines() != 0; } @@ -54,6 +56,7 @@ public Boolean apply(final ClassInfo a) { private SideEffect1 throwErrorIfHasNoSourceFile() { return new SideEffect1() { + @Override public void apply(final ClassInfo a) { if (a.getSourceFileName() == null) { throw new PitHelpError(Help.NO_SOURCE_FILE, a.getName().asJavaName()); diff --git a/pitest/src/main/java/org/pitest/plugin/ClientClasspathPlugin.java b/pitest/src/main/java/org/pitest/plugin/ClientClasspathPlugin.java index e2b402d84..8986ad3db 100644 --- a/pitest/src/main/java/org/pitest/plugin/ClientClasspathPlugin.java +++ b/pitest/src/main/java/org/pitest/plugin/ClientClasspathPlugin.java @@ -3,11 +3,11 @@ /** * Plugins that must be present on the classpath of client code at runtime * should provide an implementation of this interface. - * + * * Plugins that share the classpath with client code will need to embed their * dependencies within their own jar under different package names so as not to * pollute the client classpath. - * + * */ public interface ClientClasspathPlugin { diff --git a/pitest/src/main/java/org/pitest/plugin/ToolClasspathPlugin.java b/pitest/src/main/java/org/pitest/plugin/ToolClasspathPlugin.java index a34db5a6b..08449609a 100644 --- a/pitest/src/main/java/org/pitest/plugin/ToolClasspathPlugin.java +++ b/pitest/src/main/java/org/pitest/plugin/ToolClasspathPlugin.java @@ -3,7 +3,7 @@ /** * Plugins that do not need to be available at runtime chould implement this * interface - * + * */ public interface ToolClasspathPlugin { diff --git a/pitest/src/main/java/org/pitest/process/DefaultJavaExecutableLocator.java b/pitest/src/main/java/org/pitest/process/DefaultJavaExecutableLocator.java index b98bbe866..3c673ed48 100644 --- a/pitest/src/main/java/org/pitest/process/DefaultJavaExecutableLocator.java +++ b/pitest/src/main/java/org/pitest/process/DefaultJavaExecutableLocator.java @@ -5,6 +5,7 @@ */ public class DefaultJavaExecutableLocator implements JavaExecutableLocator { + @Override public String javaExecutable() { final String separator = System.getProperty("file.separator"); return System.getProperty("java.home") + separator + "bin" + separator diff --git a/pitest/src/main/java/org/pitest/process/JavaAgent.java b/pitest/src/main/java/org/pitest/process/JavaAgent.java index d2dff4241..6ef19fd0a 100644 --- a/pitest/src/main/java/org/pitest/process/JavaAgent.java +++ b/pitest/src/main/java/org/pitest/process/JavaAgent.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/process/JavaProcess.java b/pitest/src/main/java/org/pitest/process/JavaProcess.java index 5789c0b12..93c4b815f 100644 --- a/pitest/src/main/java/org/pitest/process/JavaProcess.java +++ b/pitest/src/main/java/org/pitest/process/JavaProcess.java @@ -24,31 +24,30 @@ public class JavaProcess { private final Monitor out; private final Monitor err; - public JavaProcess( Process process, - SideEffect1 sysoutHandler, - SideEffect1 syserrHandler) { + public JavaProcess(Process process, SideEffect1 sysoutHandler, + SideEffect1 syserrHandler) { this.process = process; - out = new StreamMonitor(process.getInputStream(), sysoutHandler); - err = new StreamMonitor(process.getErrorStream(), syserrHandler); + this.out = new StreamMonitor(process.getInputStream(), sysoutHandler); + this.err = new StreamMonitor(process.getErrorStream(), syserrHandler); } public void destroy() { - out.requestStop(); - err.requestStop(); - process.destroy(); + this.out.requestStop(); + this.err.requestStop(); + this.process.destroy(); } public int waitToDie() throws InterruptedException { - int exitVal = process.waitFor(); - out.requestStop(); - err.requestStop(); + int exitVal = this.process.waitFor(); + this.out.requestStop(); + this.err.requestStop(); return exitVal; } public boolean isAlive() { try { - process.exitValue(); + this.process.exitValue(); return false; } catch (IllegalThreadStateException e) { return true; diff --git a/pitest/src/main/java/org/pitest/process/KnownLocationJavaExecutableLocator.java b/pitest/src/main/java/org/pitest/process/KnownLocationJavaExecutableLocator.java index c4cc58a89..c24a95ebb 100644 --- a/pitest/src/main/java/org/pitest/process/KnownLocationJavaExecutableLocator.java +++ b/pitest/src/main/java/org/pitest/process/KnownLocationJavaExecutableLocator.java @@ -1,7 +1,7 @@ package org.pitest.process; public class KnownLocationJavaExecutableLocator implements - JavaExecutableLocator { +JavaExecutableLocator { private final String location; @@ -9,6 +9,7 @@ public KnownLocationJavaExecutableLocator(final String location) { this.location = location; } + @Override public String javaExecutable() { return this.location; } diff --git a/pitest/src/main/java/org/pitest/process/LaunchOptions.java b/pitest/src/main/java/org/pitest/process/LaunchOptions.java index bedc622ee..155f44123 100644 --- a/pitest/src/main/java/org/pitest/process/LaunchOptions.java +++ b/pitest/src/main/java/org/pitest/process/LaunchOptions.java @@ -24,16 +24,16 @@ public class LaunchOptions { private final JavaAgent javaAgentFinder; private final List childJVMArgs; private final JavaExecutableLocator javaExecutable; - private final Map environmentVariables; + private final Map environmentVariables; public LaunchOptions(JavaAgent javaAgentFinder) { this(javaAgentFinder, new DefaultJavaExecutableLocator(), Collections - . emptyList(),new HashMap()); + . emptyList(), new HashMap()); } - public LaunchOptions( JavaAgent javaAgentFinder, - JavaExecutableLocator javaExecutable, - List childJVMArgs,Map environmentVariables) { + public LaunchOptions(JavaAgent javaAgentFinder, + JavaExecutableLocator javaExecutable, List childJVMArgs, + Map environmentVariables) { this.javaAgentFinder = javaAgentFinder; this.childJVMArgs = childJVMArgs; this.javaExecutable = javaExecutable; @@ -53,6 +53,6 @@ public String getJavaExecutable() { } public Map getEnvironmentVariables() { - return environmentVariables; + return this.environmentVariables; } } diff --git a/pitest/src/main/java/org/pitest/process/ProcessArgs.java b/pitest/src/main/java/org/pitest/process/ProcessArgs.java index a1541b5dd..30f284800 100644 --- a/pitest/src/main/java/org/pitest/process/ProcessArgs.java +++ b/pitest/src/main/java/org/pitest/process/ProcessArgs.java @@ -14,16 +14,16 @@ */ package org.pitest.process; -import org.pitest.classpath.ClassPath; -import org.pitest.functional.SideEffect1; +import static org.pitest.functional.prelude.Prelude.print; +import static org.pitest.functional.prelude.Prelude.printTo; import java.io.File; import java.util.Collections; import java.util.List; import java.util.Map; -import static org.pitest.functional.prelude.Prelude.print; -import static org.pitest.functional.prelude.Prelude.printTo; +import org.pitest.classpath.ClassPath; +import org.pitest.functional.SideEffect1; public final class ProcessArgs { @@ -112,6 +112,6 @@ public ProcessArgs andLaunchOptions(final LaunchOptions launchOptions) { } public Map getEnvironmentVariables() { - return environmentVariables; + return this.environmentVariables; } } diff --git a/pitest/src/main/java/org/pitest/process/WrappingProcess.java b/pitest/src/main/java/org/pitest/process/WrappingProcess.java index 4baa08f57..e0124d296 100644 --- a/pitest/src/main/java/org/pitest/process/WrappingProcess.java +++ b/pitest/src/main/java/org/pitest/process/WrappingProcess.java @@ -1,9 +1,6 @@ package org.pitest.process; -import org.pitest.functional.FCollection; -import org.pitest.functional.FunctionalList; -import org.pitest.functional.Option; -import org.pitest.functional.predicate.Predicate; +import static org.pitest.functional.prelude.Prelude.or; import java.io.File; import java.io.IOException; @@ -14,15 +11,18 @@ import java.util.List; import java.util.Map; -import static org.pitest.functional.prelude.Prelude.or; +import org.pitest.functional.FCollection; +import org.pitest.functional.FunctionalList; +import org.pitest.functional.Option; +import org.pitest.functional.predicate.Predicate; public class WrappingProcess { - private final int port; + private final int port; private final ProcessArgs processArgs; - private final Class slaveClass; + private final Class slaveClass; - private JavaProcess process; + private JavaProcess process; public WrappingProcess(int port, ProcessArgs args, Class slaveClass) { this.port = port; @@ -31,45 +31,43 @@ public WrappingProcess(int port, ProcessArgs args, Class slaveClass) { } public void start() throws IOException { - final String[] args = {"" + this.port}; + final String[] args = { "" + this.port }; ProcessBuilder processBuilder = createProcessBuilder( - processArgs.getJavaExecutable(), - processArgs.getJvmArgs(), - slaveClass, - Arrays.asList(args), - processArgs.getJavaAgentFinder()); + this.processArgs.getJavaExecutable(), this.processArgs.getJvmArgs(), + this.slaveClass, Arrays.asList(args), + this.processArgs.getJavaAgentFinder()); - configureProcessBuilder(processBuilder, - processArgs.getWorkingDir(), - processArgs.getLaunchClassPath(), - processArgs.getEnvironmentVariables()); + configureProcessBuilder(processBuilder, this.processArgs.getWorkingDir(), + this.processArgs.getLaunchClassPath(), + this.processArgs.getEnvironmentVariables()); Process process = processBuilder.start(); - this.process = new JavaProcess(process, - processArgs.getStdout(), - processArgs.getStdErr()); + this.process = new JavaProcess(process, this.processArgs.getStdout(), + this.processArgs.getStdErr()); } private void configureProcessBuilder(ProcessBuilder processBuilder, - File workingDirectory, - String initialClassPath, Map environmentVariables) { + File workingDirectory, String initialClassPath, + Map environmentVariables) { processBuilder.directory(workingDirectory); Map environment = processBuilder.environment(); environment.put("CLASSPATH", initialClassPath); - for (Map.Entry entry:environmentVariables.entrySet()) { + for (Map.Entry entry : environmentVariables.entrySet()) { environment.put(entry.getKey(), entry.getValue()); } } public void destroy() { - process.destroy(); + this.process.destroy(); } - private static ProcessBuilder createProcessBuilder(String javaProc, List args, Class mainClass, List programArgs, JavaAgent javaAgent) { - List cmd = createLaunchArgs(javaProc, javaAgent, args, - mainClass, programArgs); + private static ProcessBuilder createProcessBuilder(String javaProc, + List args, Class mainClass, List programArgs, + JavaAgent javaAgent) { + List cmd = createLaunchArgs(javaProc, javaAgent, args, mainClass, + programArgs); // IBM jdk adds this, thereby breaking everything removeClassPathProperties(cmd); @@ -86,10 +84,8 @@ private static void removeClassPathProperties(List cmd) { } private static List createLaunchArgs(String javaProcess, - JavaAgent agentJarLocator, - List args, - Class mainClass, - List programArgs) { + JavaAgent agentJarLocator, List args, Class mainClass, + List programArgs) { List cmd = new ArrayList(); cmd.add(javaProcess); @@ -103,7 +99,8 @@ private static List createLaunchArgs(String javaProcess, return cmd; } - private static void addPITJavaAgent(JavaAgent agentJarLocator, List cmd) { + private static void addPITJavaAgent(JavaAgent agentJarLocator, + List cmd) { Option jarLocation = agentJarLocator.getJarLocation(); for (String each : jarLocation) { cmd.add("-javaagent:" + each); @@ -113,13 +110,14 @@ private static void addPITJavaAgent(JavaAgent agentJarLocator, List cmd) private static void addLaunchJavaAgents(List cmd) { RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); @SuppressWarnings("unchecked") - FunctionalList agents = FCollection.filter( - rt.getInputArguments(), or(isJavaAgentParam(), isEnvironmentSetting())); + FunctionalList agents = FCollection.filter(rt.getInputArguments(), + or(isJavaAgentParam(), isEnvironmentSetting())); cmd.addAll(agents); } private static Predicate isEnvironmentSetting() { return new Predicate() { + @Override public Boolean apply(String a) { return a.startsWith("-D"); } @@ -128,6 +126,7 @@ public Boolean apply(String a) { private static Predicate isJavaAgentParam() { return new Predicate() { + @Override public Boolean apply(String a) { return a.toLowerCase().startsWith("-javaagent"); } @@ -135,6 +134,6 @@ public Boolean apply(String a) { } public JavaProcess getProcess() { - return process; + return this.process; } } diff --git a/pitest/src/main/java/org/pitest/reflection/IsAnnotatedWith.java b/pitest/src/main/java/org/pitest/reflection/IsAnnotatedWith.java index 58354f3b0..015d0ad1a 100644 --- a/pitest/src/main/java/org/pitest/reflection/IsAnnotatedWith.java +++ b/pitest/src/main/java/org/pitest/reflection/IsAnnotatedWith.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.reflection; @@ -21,7 +21,7 @@ /** * @author henry - * + * */ public class IsAnnotatedWith implements Predicate { @@ -35,6 +35,7 @@ public IsAnnotatedWith(final Class clazz) { this.clazz = clazz; } + @Override public Boolean apply(final AccessibleObject a) { return a.isAnnotationPresent(this.clazz); } diff --git a/pitest/src/main/java/org/pitest/reflection/Reflection.java b/pitest/src/main/java/org/pitest/reflection/Reflection.java index 0a96e8e9e..f6d47cde1 100644 --- a/pitest/src/main/java/org/pitest/reflection/Reflection.java +++ b/pitest/src/main/java/org/pitest/reflection/Reflection.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ /** * @author henry - * + * */ public abstract class Reflection { @@ -65,6 +65,7 @@ public static Set allMethods(final Class c) { public static Method publicMethod(final Class clazz, final String name) { final Predicate p = new Predicate() { + @Override public Boolean apply(final Method a) { return a.getName().equals(name); } diff --git a/pitest/src/main/java/org/pitest/testapi/AbstractTestUnit.java b/pitest/src/main/java/org/pitest/testapi/AbstractTestUnit.java index 75897e900..4bf66a9c2 100644 --- a/pitest/src/main/java/org/pitest/testapi/AbstractTestUnit.java +++ b/pitest/src/main/java/org/pitest/testapi/AbstractTestUnit.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; /** * @author henry - * + * */ public abstract class AbstractTestUnit implements TestUnit { @@ -26,9 +26,11 @@ public AbstractTestUnit(final Description description) { this.description = description; } + @Override public abstract void execute(final ClassLoader loader, final ResultCollector rc); + @Override public final Description getDescription() { return this.description; } diff --git a/pitest/src/main/java/org/pitest/testapi/BaseTestClassIdentifier.java b/pitest/src/main/java/org/pitest/testapi/BaseTestClassIdentifier.java index fefb1f70c..3491e9132 100644 --- a/pitest/src/main/java/org/pitest/testapi/BaseTestClassIdentifier.java +++ b/pitest/src/main/java/org/pitest/testapi/BaseTestClassIdentifier.java @@ -4,8 +4,9 @@ public abstract class BaseTestClassIdentifier implements TestClassIdentifier { + @Override public boolean isIncluded(ClassInfo a) { return true; } - + } diff --git a/pitest/src/main/java/org/pitest/testapi/Configuration.java b/pitest/src/main/java/org/pitest/testapi/Configuration.java index 03b2904fb..89ee19485 100644 --- a/pitest/src/main/java/org/pitest/testapi/Configuration.java +++ b/pitest/src/main/java/org/pitest/testapi/Configuration.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/testapi/Description.java b/pitest/src/main/java/org/pitest/testapi/Description.java index 7a0f82d3a..a2054d812 100644 --- a/pitest/src/main/java/org/pitest/testapi/Description.java +++ b/pitest/src/main/java/org/pitest/testapi/Description.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,11 +15,10 @@ package org.pitest.testapi; - public final class Description { - private final String testClass; - private final String name; + private final String testClass; + private final String name; public Description(final String name) { this(name, (String) null); diff --git a/pitest/src/main/java/org/pitest/testapi/ResultCollector.java b/pitest/src/main/java/org/pitest/testapi/ResultCollector.java index f1b0a6c25..17f8235d1 100644 --- a/pitest/src/main/java/org/pitest/testapi/ResultCollector.java +++ b/pitest/src/main/java/org/pitest/testapi/ResultCollector.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; diff --git a/pitest/src/main/java/org/pitest/testapi/TestClassIdentifier.java b/pitest/src/main/java/org/pitest/testapi/TestClassIdentifier.java index c461577e4..50ed8a08b 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestClassIdentifier.java +++ b/pitest/src/main/java/org/pitest/testapi/TestClassIdentifier.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/testapi/TestGroupConfig.java b/pitest/src/main/java/org/pitest/testapi/TestGroupConfig.java index 6919fcd0d..fd7ed3ff4 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestGroupConfig.java +++ b/pitest/src/main/java/org/pitest/testapi/TestGroupConfig.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; diff --git a/pitest/src/main/java/org/pitest/testapi/TestListener.java b/pitest/src/main/java/org/pitest/testapi/TestListener.java index d5da47813..be8376de4 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestListener.java +++ b/pitest/src/main/java/org/pitest/testapi/TestListener.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; /** * @author henry - * + * */ public interface TestListener { diff --git a/pitest/src/main/java/org/pitest/testapi/TestResult.java b/pitest/src/main/java/org/pitest/testapi/TestResult.java index 04119fdd0..f4e335aa3 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestResult.java +++ b/pitest/src/main/java/org/pitest/testapi/TestResult.java @@ -1,23 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; - /** * @author henry - * + * */ public final class TestResult { diff --git a/pitest/src/main/java/org/pitest/testapi/TestSuiteFinder.java b/pitest/src/main/java/org/pitest/testapi/TestSuiteFinder.java index 94d1287f5..23e652034 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestSuiteFinder.java +++ b/pitest/src/main/java/org/pitest/testapi/TestSuiteFinder.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; diff --git a/pitest/src/main/java/org/pitest/testapi/TestUnit.java b/pitest/src/main/java/org/pitest/testapi/TestUnit.java index d905530a0..b56b296e5 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestUnit.java +++ b/pitest/src/main/java/org/pitest/testapi/TestUnit.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; /** * @author henry - * + * */ public interface TestUnit { diff --git a/pitest/src/main/java/org/pitest/testapi/TestUnitFinder.java b/pitest/src/main/java/org/pitest/testapi/TestUnitFinder.java index e66302178..8838665eb 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestUnitFinder.java +++ b/pitest/src/main/java/org/pitest/testapi/TestUnitFinder.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/testapi/TestUnitState.java b/pitest/src/main/java/org/pitest/testapi/TestUnitState.java index a0b7c3df1..941b51aee 100644 --- a/pitest/src/main/java/org/pitest/testapi/TestUnitState.java +++ b/pitest/src/main/java/org/pitest/testapi/TestUnitState.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi; diff --git a/pitest/src/main/java/org/pitest/testapi/execute/Container.java b/pitest/src/main/java/org/pitest/testapi/execute/Container.java index d49e95a6b..419fa6638 100644 --- a/pitest/src/main/java/org/pitest/testapi/execute/Container.java +++ b/pitest/src/main/java/org/pitest/testapi/execute/Container.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.execute; diff --git a/pitest/src/main/java/org/pitest/testapi/execute/ExitingResultCollector.java b/pitest/src/main/java/org/pitest/testapi/execute/ExitingResultCollector.java index 7be7dfbfd..7dac22150 100644 --- a/pitest/src/main/java/org/pitest/testapi/execute/ExitingResultCollector.java +++ b/pitest/src/main/java/org/pitest/testapi/execute/ExitingResultCollector.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.execute; @@ -26,18 +26,22 @@ public ExitingResultCollector(final ResultCollector child) { this.child = child; } + @Override public void notifySkipped(final Description description) { this.child.notifySkipped(description); } + @Override public void notifyStart(final Description description) { this.child.notifyStart(description); } + @Override public boolean shouldExit() { return this.hadFailure; } + @Override public void notifyEnd(final Description description, final Throwable t) { this.child.notifyEnd(description, t); if (t != null) { @@ -46,6 +50,7 @@ public void notifyEnd(final Description description, final Throwable t) { } + @Override public void notifyEnd(final Description description) { this.child.notifyEnd(description); } diff --git a/pitest/src/main/java/org/pitest/testapi/execute/MultipleTestGroup.java b/pitest/src/main/java/org/pitest/testapi/execute/MultipleTestGroup.java index d8215df71..b4be33754 100644 --- a/pitest/src/main/java/org/pitest/testapi/execute/MultipleTestGroup.java +++ b/pitest/src/main/java/org/pitest/testapi/execute/MultipleTestGroup.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/testapi/execute/Pitest.java b/pitest/src/main/java/org/pitest/testapi/execute/Pitest.java index f6471b683..be9f2870e 100644 --- a/pitest/src/main/java/org/pitest/testapi/execute/Pitest.java +++ b/pitest/src/main/java/org/pitest/testapi/execute/Pitest.java @@ -31,7 +31,7 @@ public class Pitest { - private static final Logger LOG = Log.getLogger(); + private static final Logger LOG = Log.getLogger(); private final List listeners; @@ -44,7 +44,7 @@ public void run(final Container container, final List testUnits) { LOG.fine("Running " + testUnits.size() + " units"); - + signalRunStartToAllListeners(); executeTests(container, testUnits); @@ -85,6 +85,7 @@ private void processResults(final List results) { private void signalRunStartToAllListeners() { FCollection.forEach(this.listeners, new SideEffect1() { + @Override public void apply(final TestListener a) { a.onRunStart(); } @@ -93,6 +94,7 @@ public void apply(final TestListener a) { private void signalRunEndToAllListeners() { FCollection.forEach(this.listeners, new SideEffect1() { + @Override public void apply(final TestListener a) { a.onRunEnd(); } diff --git a/pitest/src/main/java/org/pitest/testapi/execute/ResultType.java b/pitest/src/main/java/org/pitest/testapi/execute/ResultType.java index 64c98fe18..6a8236768 100644 --- a/pitest/src/main/java/org/pitest/testapi/execute/ResultType.java +++ b/pitest/src/main/java/org/pitest/testapi/execute/ResultType.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.execute; @@ -21,36 +21,40 @@ /** * @author henry - * + * */ public enum ResultType { PASS(new ResultToListenerSideEffect() { + @Override public SideEffect1 apply(final TestResult a) { return success(a); } }), FAIL(new ResultToListenerSideEffect() { + @Override public SideEffect1 apply(final TestResult a) { return failure(a); } }), SKIPPED(new ResultToListenerSideEffect() { + @Override public SideEffect1 apply(final TestResult a) { return skipped(a); } }), STARTED(new ResultToListenerSideEffect() { + @Override public SideEffect1 apply(final TestResult a) { return started(a); } }); private interface ResultToListenerSideEffect extends - F> { + F> { }; ResultType(final ResultToListenerSideEffect f) { @@ -65,6 +69,7 @@ public SideEffect1 getListenerFunction(final TestResult result) { public static SideEffect1 success(final TestResult result) { return new SideEffect1() { + @Override public void apply(final TestListener a) { a.onTestSuccess(result); } @@ -73,6 +78,7 @@ public void apply(final TestListener a) { public static SideEffect1 failure(final TestResult result) { return new SideEffect1() { + @Override public void apply(final TestListener a) { a.onTestFailure(result); } @@ -81,6 +87,7 @@ public void apply(final TestListener a) { public static SideEffect1 skipped(final TestResult result) { return new SideEffect1() { + @Override public void apply(final TestListener a) { a.onTestSkipped(result); } @@ -89,6 +96,7 @@ public void apply(final TestListener a) { public static SideEffect1 started(final TestResult result) { return new SideEffect1() { + @Override public void apply(final TestListener a) { a.onTestStart(result.getDescription()); } diff --git a/pitest/src/main/java/org/pitest/testapi/execute/containers/ConcreteResultCollector.java b/pitest/src/main/java/org/pitest/testapi/execute/containers/ConcreteResultCollector.java index 7159e57cf..e45f979c6 100644 --- a/pitest/src/main/java/org/pitest/testapi/execute/containers/ConcreteResultCollector.java +++ b/pitest/src/main/java/org/pitest/testapi/execute/containers/ConcreteResultCollector.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.execute.containers; @@ -29,26 +29,31 @@ public ConcreteResultCollector(final Collection feedback) { this.feedback = feedback; } + @Override public void notifyStart(final Description tu) { put(new TestResult(tu, null, TestUnitState.STARTED)); } + @Override public void notifySkipped(final Description tu) { put(new TestResult(tu, null, TestUnitState.NOT_RUN)); } + @Override public void notifyEnd(final Description description, final Throwable t) { put(new TestResult(description, t)); } + @Override public void notifyEnd(final Description description) { put(new TestResult(description, null)); } private void put(final TestResult tr) { - this.feedback.add(tr); + this.feedback.add(tr); } + @Override public boolean shouldExit() { return false; } diff --git a/pitest/src/main/java/org/pitest/testapi/execute/containers/UnContainer.java b/pitest/src/main/java/org/pitest/testapi/execute/containers/UnContainer.java index d40212882..5b374c1d2 100644 --- a/pitest/src/main/java/org/pitest/testapi/execute/containers/UnContainer.java +++ b/pitest/src/main/java/org/pitest/testapi/execute/containers/UnContainer.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.execute.containers; @@ -25,6 +25,7 @@ public class UnContainer implements Container { + @Override public List execute(final TestUnit group) { List results = new ArrayList(12); final ConcreteResultCollector rc = new ConcreteResultCollector(results); diff --git a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Events.java b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Events.java index b2a125ea8..1066a76cc 100644 --- a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Events.java +++ b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Events.java @@ -8,13 +8,13 @@ import org.pitest.util.IsolationUtils; public class Events { - + public static void applyEvents(final List encodedEvents, final ResultCollector rc, final Description description) { for (final String each : encodedEvents) { @SuppressWarnings("unchecked") final SideEffect2 event = (SideEffect2) IsolationUtils - .fromXml(each); + .fromXml(each); event.apply(rc, description); } diff --git a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Fail.java b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Fail.java index 1164e82b3..582fd1d28 100644 --- a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Fail.java +++ b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Fail.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.foreignclassloader; @@ -27,6 +27,7 @@ public Fail(final Throwable throwable) { this.throwable = throwable; } + @Override public void apply(final ResultCollector rc, final Description description) { rc.notifyEnd(description, this.throwable); } diff --git a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Skipped.java b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Skipped.java index 03979224e..07a246df7 100644 --- a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Skipped.java +++ b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Skipped.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.foreignclassloader; @@ -21,6 +21,7 @@ public class Skipped implements SideEffect2 { + @Override public void apply(final ResultCollector rc, final Description description) { rc.notifySkipped(description); } diff --git a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Start.java b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Start.java index 91e72e950..4c8199b7b 100644 --- a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Start.java +++ b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Start.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.foreignclassloader; @@ -21,6 +21,7 @@ public class Start implements SideEffect2 { + @Override public void apply(final ResultCollector rc, final Description description) { rc.notifyStart(description); } diff --git a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Success.java b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Success.java index a5d17b3d6..fe0f51510 100644 --- a/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Success.java +++ b/pitest/src/main/java/org/pitest/testapi/foreignclassloader/Success.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.foreignclassloader; @@ -21,6 +21,7 @@ public class Success implements SideEffect2 { + @Override public void apply(final ResultCollector rc, final Description description) { rc.notifyEnd(description); } diff --git a/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderAdaptingListener.java b/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderAdaptingListener.java index 952cee55f..0695c47e6 100644 --- a/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderAdaptingListener.java +++ b/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderAdaptingListener.java @@ -15,15 +15,16 @@ import org.testng.SkipException; public class ForeignClassLoaderAdaptingListener implements ITestListener { - + private final List events; - private Throwable error; - private boolean hasHadFailure = false; - + private Throwable error; + private boolean hasHadFailure = false; + public ForeignClassLoaderAdaptingListener(List events) { this.events = events; } + @Override public void onFinish(ITestContext arg0) { if (this.error != null) { storeAsString(new Fail(this.error)); @@ -32,24 +33,29 @@ public void onFinish(ITestContext arg0) { } } + @Override public void onStart(ITestContext arg0) { - storeAsString(new Start()); + storeAsString(new Start()); } + @Override public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) { storeAsString(new TestSuccess(arg0.getMethod().getMethodName())); } + @Override public void onTestFailure(ITestResult arg0) { this.hasHadFailure = true; this.error = arg0.getThrowable(); - storeAsString(new TestFail(arg0.getMethod().getMethodName(), error)); + storeAsString(new TestFail(arg0.getMethod().getMethodName(), this.error)); } + @Override public void onTestSkipped(ITestResult arg0) { - storeAsString(new TestSkipped(arg0.getMethod().getMethodName())); + storeAsString(new TestSkipped(arg0.getMethod().getMethodName())); } + @Override public void onTestStart(ITestResult result) { if (this.hasHadFailure) { throw new SkipException("skipping"); @@ -57,64 +63,73 @@ public void onTestStart(ITestResult result) { storeAsString(new TestStart(result.getMethod().getMethodName())); } + @Override public void onTestSuccess(ITestResult arg0) { - storeAsString(new TestSuccess(arg0.getMethod().getMethodName())); + storeAsString(new TestSuccess(arg0.getMethod().getMethodName())); } - + private void storeAsString( final SideEffect2 result) { this.events.add(IsolationUtils.toXml(result)); } - } -class TestStart implements SideEffect2 { - private String methodName; - +class TestStart implements + SideEffect2 { + private final String methodName; + TestStart(String methodName) { - this.methodName = methodName; + this.methodName = methodName; } + @Override public void apply(ResultCollector rc, Description d) { - rc.notifyStart(new Description(methodName, d.getFirstTestClass())); + rc.notifyStart(new Description(this.methodName, d.getFirstTestClass())); } } -class TestSuccess implements SideEffect2 { - private String methodName; - +class TestSuccess implements + SideEffect2 { + private final String methodName; + TestSuccess(String methodName) { - this.methodName = methodName; + this.methodName = methodName; } + @Override public void apply(ResultCollector rc, Description d) { - rc.notifyEnd(new Description(methodName, d.getFirstTestClass())); + rc.notifyEnd(new Description(this.methodName, d.getFirstTestClass())); } } -class TestFail implements SideEffect2 { - private String methodName; +class TestFail implements + SideEffect2 { + private final String methodName; private final Throwable throwable; - + TestFail(String methodName, Throwable throwable) { - this.methodName = methodName; - this.throwable = throwable; + this.methodName = methodName; + this.throwable = throwable; } + @Override public void apply(ResultCollector rc, Description d) { - rc.notifyEnd(new Description(methodName, d.getFirstTestClass()), throwable); + rc.notifyEnd(new Description(this.methodName, d.getFirstTestClass()), + this.throwable); } } -class TestSkipped implements SideEffect2 { - private String methodName; - +class TestSkipped implements + SideEffect2 { + private final String methodName; + TestSkipped(String methodName) { - this.methodName = methodName; + this.methodName = methodName; } + @Override public void apply(ResultCollector rc, Description d) { - rc.notifySkipped(new Description(methodName, d.getFirstTestClass())); + rc.notifySkipped(new Description(this.methodName, d.getFirstTestClass())); } } \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderTestNGExecutor.java b/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderTestNGExecutor.java index f8b462c4a..f22aa0e6c 100644 --- a/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderTestNGExecutor.java +++ b/pitest/src/main/java/org/pitest/testng/ForeignClassLoaderTestNGExecutor.java @@ -10,27 +10,25 @@ import org.testng.xml.XmlSuite; public class ForeignClassLoaderTestNGExecutor implements Callable> { - + private final XmlSuite suite; - + public ForeignClassLoaderTestNGExecutor(XmlSuite suite) { this.suite = suite; } - + + @Override public List call() throws Exception { List queue = new ArrayList(); final ITestListener listener = new ForeignClassLoaderAdaptingListener(queue); final TestNG testng = new TestNG(false); - testng.setDefaultSuiteName(suite.getName()); - testng.setXmlSuites(Collections.singletonList(suite)); + testng.setDefaultSuiteName(this.suite.getName()); + testng.setXmlSuites(Collections.singletonList(this.suite)); testng.addListener(listener); testng.run(); - + return queue; } - } - - diff --git a/pitest/src/main/java/org/pitest/testng/TestNGAdapter.java b/pitest/src/main/java/org/pitest/testng/TestNGAdapter.java index bca63db87..7ddf12101 100644 --- a/pitest/src/main/java/org/pitest/testng/TestNGAdapter.java +++ b/pitest/src/main/java/org/pitest/testng/TestNGAdapter.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; @@ -36,6 +36,7 @@ public TestNGAdapter(final Class clazz, final Description d, this.clazz = clazz; } + @Override public void onFinish(final ITestContext arg0) { if (this.error != null) { this.rc.notifyEnd(this.description, this.error); @@ -44,25 +45,30 @@ public void onFinish(final ITestContext arg0) { } } + @Override public void onStart(final ITestContext arg0) { this.rc.notifyStart(this.description); } + @Override public void onTestFailedButWithinSuccessPercentage(final ITestResult arg0) { // is this success or failure? this.rc.notifyEnd(makeDescription(arg0)); } + @Override public void onTestFailure(final ITestResult arg0) { this.hasHadFailure = true; this.error = arg0.getThrowable(); this.rc.notifyEnd(makeDescription(arg0), this.error); } + @Override public void onTestSkipped(final ITestResult arg0) { this.rc.notifySkipped(makeDescription(arg0)); } + @Override public void onTestStart(final ITestResult arg0) { if (this.hasHadFailure) { throw new SkipException("skipping"); @@ -70,6 +76,7 @@ public void onTestStart(final ITestResult arg0) { this.rc.notifyStart(makeDescription(arg0)); } + @Override public void onTestSuccess(final ITestResult arg0) { this.rc.notifyEnd(makeDescription(arg0)); } diff --git a/pitest/src/main/java/org/pitest/testng/TestNGConfiguration.java b/pitest/src/main/java/org/pitest/testng/TestNGConfiguration.java index e2c65cb8f..de9d7913c 100644 --- a/pitest/src/main/java/org/pitest/testng/TestNGConfiguration.java +++ b/pitest/src/main/java/org/pitest/testng/TestNGConfiguration.java @@ -1,25 +1,25 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; import org.pitest.extension.common.NoTestSuiteFinder; import org.pitest.functional.Option; import org.pitest.help.PitHelpError; -import org.pitest.testapi.TestGroupConfig; import org.pitest.testapi.Configuration; import org.pitest.testapi.TestClassIdentifier; +import org.pitest.testapi.TestGroupConfig; import org.pitest.testapi.TestSuiteFinder; import org.pitest.testapi.TestUnitFinder; @@ -31,18 +31,22 @@ public TestNGConfiguration(final TestGroupConfig config) { this.config = config; } + @Override public TestUnitFinder testUnitFinder() { return new TestNGTestUnitFinder(this.config); } + @Override public TestSuiteFinder testSuiteFinder() { return new NoTestSuiteFinder(); } + @Override public TestClassIdentifier testClassIdentifier() { return new TestNGTestClassIdentifier(); } + @Override public Option verifyEnvironment() { return Option.none(); } diff --git a/pitest/src/main/java/org/pitest/testng/TestNGTestClassIdentifier.java b/pitest/src/main/java/org/pitest/testng/TestNGTestClassIdentifier.java index 85abbc725..226993c6e 100644 --- a/pitest/src/main/java/org/pitest/testng/TestNGTestClassIdentifier.java +++ b/pitest/src/main/java/org/pitest/testng/TestNGTestClassIdentifier.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; @@ -21,8 +21,9 @@ public class TestNGTestClassIdentifier extends BaseTestClassIdentifier { private static final ClassName ANNOTATION_NAME = new ClassName( - "org.testng.annotations.Test"); + "org.testng.annotations.Test"); + @Override public boolean isATestClass(final ClassInfo a) { return a.hasAnnotation(ANNOTATION_NAME) || isATestClass(a.getSuperClass()); } diff --git a/pitest/src/main/java/org/pitest/testng/TestNGTestUnit.java b/pitest/src/main/java/org/pitest/testng/TestNGTestUnit.java index 673fca855..51441b8f0 100644 --- a/pitest/src/main/java/org/pitest/testng/TestNGTestUnit.java +++ b/pitest/src/main/java/org/pitest/testng/TestNGTestUnit.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; @@ -38,13 +38,13 @@ * tests. */ public class TestNGTestUnit extends AbstractTestUnit { - + // needs to be static as jmockit assumes only a single instance per jvm - private static final TestNG TESTNG = new TestNG(false); + private static final TestNG TESTNG = new TestNG(false); private final ClassLoaderDetectionStrategy classloaderDetection; private final Class clazz; - private final TestGroupConfig config; + private final TestGroupConfig config; public TestNGTestUnit( final ClassLoaderDetectionStrategy classloaderDetection, @@ -73,8 +73,8 @@ public void execute(final ClassLoader loader, final ResultCollector rc) { private void executeInForeignLoader(ResultCollector rc, ClassLoader loader) { @SuppressWarnings("unchecked") Callable> e = (Callable>) IsolationUtils - .cloneForLoader(new ForeignClassLoaderTestNGExecutor(createSuite()), - loader); + .cloneForLoader(new ForeignClassLoaderTestNGExecutor(createSuite()), + loader); try { List q = e.call(); Events.applyEvents(q, rc, this.getDescription()); @@ -84,10 +84,10 @@ private void executeInForeignLoader(ResultCollector rc, ClassLoader loader) { } - private void executeInCurrentLoader( final ResultCollector rc) { + private void executeInCurrentLoader(final ResultCollector rc) { final ITestListener listener = new TestNGAdapter(this.clazz, this.getDescription(), rc); - + final XmlSuite suite = createSuite(); TESTNG.setDefaultSuiteName(suite.getName()); diff --git a/pitest/src/main/java/org/pitest/testng/TestNGTestUnitFinder.java b/pitest/src/main/java/org/pitest/testng/TestNGTestUnitFinder.java index fdbea79c1..f1782be1e 100644 --- a/pitest/src/main/java/org/pitest/testng/TestNGTestUnitFinder.java +++ b/pitest/src/main/java/org/pitest/testng/TestNGTestUnitFinder.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; @@ -18,9 +18,9 @@ import java.util.List; import org.pitest.functional.FCollection; -import org.pitest.testapi.TestGroupConfig; import org.pitest.reflection.IsAnnotatedWith; import org.pitest.reflection.Reflection; +import org.pitest.testapi.TestGroupConfig; import org.pitest.testapi.TestUnit; import org.pitest.testapi.TestUnitFinder; @@ -32,6 +32,7 @@ public TestNGTestUnitFinder(final TestGroupConfig config) { this.config = config; } + @Override public List findTestUnits(final Class clazz) { if (hasClassAnnotation(clazz) || hasMethodAnnotation(clazz)) { diff --git a/pitest/src/main/java/org/pitest/util/CommandLineMessage.java b/pitest/src/main/java/org/pitest/util/CommandLineMessage.java index bd33413e6..6b7c476b1 100644 --- a/pitest/src/main/java/org/pitest/util/CommandLineMessage.java +++ b/pitest/src/main/java/org/pitest/util/CommandLineMessage.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; diff --git a/pitest/src/main/java/org/pitest/util/CommunicationThread.java b/pitest/src/main/java/org/pitest/util/CommunicationThread.java index 5310fa8e0..8bf52fd63 100644 --- a/pitest/src/main/java/org/pitest/util/CommunicationThread.java +++ b/pitest/src/main/java/org/pitest/util/CommunicationThread.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/util/ExitCode.java b/pitest/src/main/java/org/pitest/util/ExitCode.java index b3cb5eb2c..d3ffa0354 100644 --- a/pitest/src/main/java/org/pitest/util/ExitCode.java +++ b/pitest/src/main/java/org/pitest/util/ExitCode.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; diff --git a/pitest/src/main/java/org/pitest/util/Functions.java b/pitest/src/main/java/org/pitest/util/Functions.java index c13551124..b57afd93b 100644 --- a/pitest/src/main/java/org/pitest/util/Functions.java +++ b/pitest/src/main/java/org/pitest/util/Functions.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,7 @@ public abstract class Functions { public static F classNameToJVMClassName() { return new F() { + @Override public String apply(final String a) { return a.replace(".", "/"); } @@ -32,6 +33,7 @@ public String apply(final String a) { public static F jvmClassToClassName() { return new F() { + @Override public String apply(final String a) { return a.replace("/", "."); } @@ -41,6 +43,7 @@ public String apply(final String a) { public static F, String> classToName() { return new F, String>() { + @Override public String apply(final Class clazz) { return clazz.getName(); } @@ -50,6 +53,7 @@ public String apply(final Class clazz) { public static Predicate startsWith(final String filter) { return new Predicate() { + @Override public Boolean apply(final String a) { return a.startsWith(filter); } @@ -60,6 +64,7 @@ public Boolean apply(final String a) { public static > F stringToEnum( final Class clazz) { return new F() { + @Override public T apply(final String name) { return Enum.valueOf(clazz, name); } diff --git a/pitest/src/main/java/org/pitest/util/Glob.java b/pitest/src/main/java/org/pitest/util/Glob.java index 9c3f51295..b0bfc4a7d 100644 --- a/pitest/src/main/java/org/pitest/util/Glob.java +++ b/pitest/src/main/java/org/pitest/util/Glob.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; @@ -35,6 +35,7 @@ public boolean matches(final CharSequence seq) { public static F> toGlobPredicate() { return new F>() { + @Override public Glob apply(final String glob) { return new Glob(glob); } @@ -74,6 +75,7 @@ private static String convertGlobToRegex(final String glob) { return out.toString(); } + @Override public Boolean apply(final String value) { return matches(value); } diff --git a/pitest/src/main/java/org/pitest/util/Id.java b/pitest/src/main/java/org/pitest/util/Id.java index a84bc4757..7a0c2303b 100644 --- a/pitest/src/main/java/org/pitest/util/Id.java +++ b/pitest/src/main/java/org/pitest/util/Id.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ public abstract class Id { public static final byte DESCRIBE = 1; public static final byte REPORT = 2; - public static final byte PROBES = 4; + public static final byte PROBES = 4; public static final byte OUTCOME = 16; public static final byte CLAZZ = 32; public static final byte DONE = 64; diff --git a/pitest/src/main/java/org/pitest/util/InputStreamLineIterable.java b/pitest/src/main/java/org/pitest/util/InputStreamLineIterable.java index 1d7790c02..d48ca24d0 100644 --- a/pitest/src/main/java/org/pitest/util/InputStreamLineIterable.java +++ b/pitest/src/main/java/org/pitest/util/InputStreamLineIterable.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; @@ -50,17 +50,21 @@ public String next() { return t; } + @Override public Iterator iterator() { return new Iterator() { + @Override public boolean hasNext() { return InputStreamLineIterable.this.next != null; } + @Override public String next() { return InputStreamLineIterable.this.next(); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -68,27 +72,33 @@ public void remove() { }; } + @Override public FunctionalList filter(final F predicate) { return FCollection.filter(this, predicate); } + @Override public void forEach(final SideEffect1 e) { FCollection.forEach(this, e); } + @Override public FunctionalList map(final F f) { return FCollection.map(this, f); } + @Override public void mapTo(final F f, final Collection bs) { FCollection.mapTo(this, f, bs); } + @Override public FunctionalList flatMap(final F> f) { return FCollection.flatMap(this, f); } + @Override public boolean contains(final F predicate) { return FCollection.contains(this, predicate); } diff --git a/pitest/src/main/java/org/pitest/util/IsolationUtils.java b/pitest/src/main/java/org/pitest/util/IsolationUtils.java index 8e06ab13f..72eeb3eb3 100644 --- a/pitest/src/main/java/org/pitest/util/IsolationUtils.java +++ b/pitest/src/main/java/org/pitest/util/IsolationUtils.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,20 +27,21 @@ public abstract class IsolationUtils { private static final XStream XSTREAM_INSTANCE = new XStream( - new PitXmlDriver()); + new PitXmlDriver()); private static final WeakHashMap CACHE = new WeakHashMap(); private static final ClassLoaderDetectionStrategy LOADER_DETECTION_STRATEGY = new ClassLoaderDetectionStrategy() { + @Override public boolean fromDifferentLoader( - final Class clazz, - final ClassLoader loader) { - return IsolationUtils - .fromIncompatibleLoader( - clazz, - loader); - } - - }; + final Class clazz, + final ClassLoader loader) { + return IsolationUtils + .fromIncompatibleLoader( + clazz, + loader); + } + + }; public static ClassLoaderDetectionStrategy loaderDetectionStrategy() { return LOADER_DETECTION_STRATEGY; diff --git a/pitest/src/main/java/org/pitest/util/Log.java b/pitest/src/main/java/org/pitest/util/Log.java index 854664fe6..67e1f5215 100644 --- a/pitest/src/main/java/org/pitest/util/Log.java +++ b/pitest/src/main/java/org/pitest/util/Log.java @@ -57,7 +57,7 @@ private static void setLevel(final Level level) { static class PlainFormatter extends Formatter { private static final String LINE_SEPARATOR = System - .getProperty("line.separator"); + .getProperty("line.separator"); private final DateFormat dateFormat = DateFormat.getTimeInstance(); @Override diff --git a/pitest/src/main/java/org/pitest/util/MemoryWatchdog.java b/pitest/src/main/java/org/pitest/util/MemoryWatchdog.java index 5734a3c9c..bd03f544e 100644 --- a/pitest/src/main/java/org/pitest/util/MemoryWatchdog.java +++ b/pitest/src/main/java/org/pitest/util/MemoryWatchdog.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; diff --git a/pitest/src/main/java/org/pitest/util/PitError.java b/pitest/src/main/java/org/pitest/util/PitError.java index 5b44a0a35..e0321a9c4 100644 --- a/pitest/src/main/java/org/pitest/util/PitError.java +++ b/pitest/src/main/java/org/pitest/util/PitError.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,22 +37,22 @@ private static String info() { final RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); return "\n\nPlease copy and paste the information and the complete stacktrace below when reporting an issue\n" - + "VM : " - + rt.getVmName() - + "\n" - + "Vendor : " - + rt.getVmVendor() - + "\n" - + "Version : " - + rt.getVmVersion() - + "\n" - + "Uptime : " - + rt.getUptime() - + "\n" - + "Input -> " - + createInputString(rt.getInputArguments()) - + "\n" - + "BootClassPathSupported : " + rt.isBootClassPathSupported() + "\n"; + + "VM : " + + rt.getVmName() + + "\n" + + "Vendor : " + + rt.getVmVendor() + + "\n" + + "Version : " + + rt.getVmVersion() + + "\n" + + "Uptime : " + + rt.getUptime() + + "\n" + + "Input -> " + + createInputString(rt.getInputArguments()) + + "\n" + + "BootClassPathSupported : " + rt.isBootClassPathSupported() + "\n"; } @@ -66,6 +66,7 @@ private static F2 append() { return new F2() { private int position = 0; + @Override public StringBuilder apply(final StringBuilder a, final String b) { this.position++; return a.append("\n " + this.position + " : " + b); diff --git a/pitest/src/main/java/org/pitest/util/PitXmlDriver.java b/pitest/src/main/java/org/pitest/util/PitXmlDriver.java index 3b282ec6a..b9814b6e6 100644 --- a/pitest/src/main/java/org/pitest/util/PitXmlDriver.java +++ b/pitest/src/main/java/org/pitest/util/PitXmlDriver.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; diff --git a/pitest/src/main/java/org/pitest/util/ReceiveStrategy.java b/pitest/src/main/java/org/pitest/util/ReceiveStrategy.java index 8a58848e9..b2c7d742e 100644 --- a/pitest/src/main/java/org/pitest/util/ReceiveStrategy.java +++ b/pitest/src/main/java/org/pitest/util/ReceiveStrategy.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/util/ResultOutputStrategy.java b/pitest/src/main/java/org/pitest/util/ResultOutputStrategy.java index d78ea67e1..e4b7183d6 100644 --- a/pitest/src/main/java/org/pitest/util/ResultOutputStrategy.java +++ b/pitest/src/main/java/org/pitest/util/ResultOutputStrategy.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/util/SafeDataInputStream.java b/pitest/src/main/java/org/pitest/util/SafeDataInputStream.java index 8a41856c2..520aa4cea 100644 --- a/pitest/src/main/java/org/pitest/util/SafeDataInputStream.java +++ b/pitest/src/main/java/org/pitest/util/SafeDataInputStream.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/util/SafeDataOutputStream.java b/pitest/src/main/java/org/pitest/util/SafeDataOutputStream.java index fe8e8c46a..35f757ef6 100644 --- a/pitest/src/main/java/org/pitest/util/SafeDataOutputStream.java +++ b/pitest/src/main/java/org/pitest/util/SafeDataOutputStream.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/util/ServiceLoader.java b/pitest/src/main/java/org/pitest/util/ServiceLoader.java index feca85125..6b16d48b8 100644 --- a/pitest/src/main/java/org/pitest/util/ServiceLoader.java +++ b/pitest/src/main/java/org/pitest/util/ServiceLoader.java @@ -14,7 +14,7 @@ * Simple java 1.6 ServiceLoader like behaviour for 1.5 From * http://stackoverflow * .com/questions/251336/is-something-similar-to-serviceloader-in-java-1-5 - * + * */ public abstract class ServiceLoader { diff --git a/pitest/src/main/java/org/pitest/util/SocketFinder.java b/pitest/src/main/java/org/pitest/util/SocketFinder.java index bd4e81f7c..b6438ad3b 100644 --- a/pitest/src/main/java/org/pitest/util/SocketFinder.java +++ b/pitest/src/main/java/org/pitest/util/SocketFinder.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/org/pitest/util/SocketReadingCallable.java b/pitest/src/main/java/org/pitest/util/SocketReadingCallable.java index 36ac4a64c..38e74b752 100644 --- a/pitest/src/main/java/org/pitest/util/SocketReadingCallable.java +++ b/pitest/src/main/java/org/pitest/util/SocketReadingCallable.java @@ -23,6 +23,7 @@ public SocketReadingCallable(final ServerSocket socket, this.receive = receive; } + @Override public ExitCode call() throws Exception { final Socket clientSocket = this.socket.accept(); ExitCode exitCode = ExitCode.UNKNOWN_ERROR; diff --git a/pitest/src/main/java/org/pitest/util/StreamMonitor.java b/pitest/src/main/java/org/pitest/util/StreamMonitor.java index 6615fbab2..9e743e1c6 100644 --- a/pitest/src/main/java/org/pitest/util/StreamMonitor.java +++ b/pitest/src/main/java/org/pitest/util/StreamMonitor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; @@ -35,6 +35,7 @@ public StreamMonitor(final InputStream in, setDaemon(true); } + @Override public void requestStart() { start(); } @@ -71,6 +72,7 @@ private void readFromStream() { } } + @Override public void requestStop() { this.interrupt(); } diff --git a/pitest/src/main/java/org/pitest/util/StringUtil.java b/pitest/src/main/java/org/pitest/util/StringUtil.java index e967b76ae..d04da0c35 100644 --- a/pitest/src/main/java/org/pitest/util/StringUtil.java +++ b/pitest/src/main/java/org/pitest/util/StringUtil.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; diff --git a/pitest/src/main/java/org/pitest/util/TimeSpan.java b/pitest/src/main/java/org/pitest/util/TimeSpan.java index eadd950a3..7b2e501ae 100644 --- a/pitest/src/main/java/org/pitest/util/TimeSpan.java +++ b/pitest/src/main/java/org/pitest/util/TimeSpan.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; diff --git a/pitest/src/main/java/org/pitest/util/Timings.java b/pitest/src/main/java/org/pitest/util/Timings.java index ac5299182..eb07cb53c 100644 --- a/pitest/src/main/java/org/pitest/util/Timings.java +++ b/pitest/src/main/java/org/pitest/util/Timings.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; @@ -24,7 +24,7 @@ public class Timings { public static enum Stage { BUILD_MUTATION_TESTS("build mutation tests"), RUN_MUTATION_TESTS( "run mutation analysis"), SCAN_CLASS_PATH("scan classpath"), COVERAGE( - "coverage and dependency analysis"); + "coverage and dependency analysis"); private final String description; diff --git a/pitest/src/main/java/org/pitest/util/Unchecked.java b/pitest/src/main/java/org/pitest/util/Unchecked.java index 45a48f58d..d2e070a66 100644 --- a/pitest/src/main/java/org/pitest/util/Unchecked.java +++ b/pitest/src/main/java/org/pitest/util/Unchecked.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/main/java/sun/pitest/CodeCoverageStore.java b/pitest/src/main/java/sun/pitest/CodeCoverageStore.java index 4d4124c31..32d78125a 100644 --- a/pitest/src/main/java/sun/pitest/CodeCoverageStore.java +++ b/pitest/src/main/java/sun/pitest/CodeCoverageStore.java @@ -2,14 +2,14 @@ * Originally based on http://code.google.com/p/javacoveragent/ by * "alex.mq0" and "dmitry.kandalov" - but don't think anything of the original * now remains in terms of either code or design. - * - * + * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,17 +31,17 @@ */ public final class CodeCoverageStore { - private static final int CLASS_HIT_INDEX = 0; + private static final int CLASS_HIT_INDEX = 0; - public static final String CLASS_NAME = CodeCoverageStore.class - .getName() - .replace( - '.', - '/'); - public static final String PROBE_METHOD_NAME = "visitProbes"; + public static final String CLASS_NAME = CodeCoverageStore.class + .getName() + .replace( + '.', + '/'); + public static final String PROBE_METHOD_NAME = "visitProbes"; private static InvokeReceiver invokeQueue; - private static int classId = 0; + private static int classId = 0; // array of probe hits, first slot indicates any hits to the class. // testing suggests boolean array with synchronization to ensure happens @@ -49,8 +49,7 @@ public final class CodeCoverageStore { // both AtomicInteger array with bit per flag and integer per flag. // optimisation with other methods of ensuring a happens before not yet // investigated - private static final Map CLASS_HITS = new ConcurrentHashMap(); - + private static final Map CLASS_HITS = new ConcurrentHashMap(); public static void init(final InvokeReceiver invokeQueue) { CodeCoverageStore.invokeQueue = invokeQueue; @@ -77,11 +76,11 @@ public static void visitProbes(final int classId, final int offset, } // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // + // // Overloaded special case implementations for methods with 1 to N probes. // Allows probes to be implemented as // local variables and the loop in the array based version to be unrolled. - // + // public static void visitProbes(final int classId, final int offset, final boolean p0) { // NO_UCD @@ -569,7 +568,7 @@ public static synchronized Collection getHits() { continue; } final int classId = each.getKey(); - // final int[] mapping = classProbeToBlockMapping.get(classId); + // final int[] mapping = classProbeToBlockMapping.get(classId); for (int probeId = 1; probeId != bs.length; probeId++) { if (bs[probeId]) { blockHits.add(encode(classId, probeId - 1)); @@ -584,11 +583,13 @@ public static int registerClass(final String className) { invokeQueue.registerClass(id, className); return id; } - - public static void registerMethod(final int clazz, final String methodName, final String methodDesc, final int firstProbe, final int lastProbe) { - invokeQueue.registerProbes(clazz, methodName, methodDesc, firstProbe, lastProbe); + + public static void registerMethod(final int clazz, final String methodName, + final String methodDesc, final int firstProbe, final int lastProbe) { + invokeQueue.registerProbes(clazz, methodName, methodDesc, firstProbe, + lastProbe); } - + private static synchronized int nextId() { return classId++; } diff --git a/pitest/src/main/java/sun/pitest/InvokeReceiver.java b/pitest/src/main/java/sun/pitest/InvokeReceiver.java index 2bf33a9a3..c07479c0b 100644 --- a/pitest/src/main/java/sun/pitest/InvokeReceiver.java +++ b/pitest/src/main/java/sun/pitest/InvokeReceiver.java @@ -1,10 +1,10 @@ package sun.pitest; - public interface InvokeReceiver { void registerClass(int id, String className); - - void registerProbes(int classId, String methodName, String methodDesc, int firstProbe, int lastProbe); - + + void registerProbes(int classId, String methodName, String methodDesc, + int firstProbe, int lastProbe); + } diff --git a/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTested.java b/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTested.java index e6861e6d9..b2fc5a578 100644 --- a/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTested.java +++ b/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTested.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTestedTest.java b/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTestedTest.java index 7565e09d6..cab3ecba0 100644 --- a/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTestedTest.java +++ b/pitest/src/test/java/com/example/CoveredButOnlyPartiallyTestedTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/com/example/CoveredByEasyMock.java b/pitest/src/test/java/com/example/CoveredByEasyMock.java index 6fa2a0035..e7f0f42bf 100644 --- a/pitest/src/test/java/com/example/CoveredByEasyMock.java +++ b/pitest/src/test/java/com/example/CoveredByEasyMock.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/com/example/CoveredByJMockit.java b/pitest/src/test/java/com/example/CoveredByJMockit.java index 9d0fb127f..4eac46760 100644 --- a/pitest/src/test/java/com/example/CoveredByJMockit.java +++ b/pitest/src/test/java/com/example/CoveredByJMockit.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/com/example/EasyMockTest.java b/pitest/src/test/java/com/example/EasyMockTest.java index 3a4d9dcb6..e287bdefa 100644 --- a/pitest/src/test/java/com/example/EasyMockTest.java +++ b/pitest/src/test/java/com/example/EasyMockTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/com/example/FullyCoveredTestee.java b/pitest/src/test/java/com/example/FullyCoveredTestee.java index 5d156d496..706382c81 100644 --- a/pitest/src/test/java/com/example/FullyCoveredTestee.java +++ b/pitest/src/test/java/com/example/FullyCoveredTestee.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/HasExcludedMethodsTestee.java b/pitest/src/test/java/com/example/HasExcludedMethodsTestee.java index f8f42c463..7790950b4 100644 --- a/pitest/src/test/java/com/example/HasExcludedMethodsTestee.java +++ b/pitest/src/test/java/com/example/HasExcludedMethodsTestee.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/HasExcludedMethodsTesteeTest.java b/pitest/src/test/java/com/example/HasExcludedMethodsTesteeTest.java index a5c516495..11bf537d3 100644 --- a/pitest/src/test/java/com/example/HasExcludedMethodsTesteeTest.java +++ b/pitest/src/test/java/com/example/HasExcludedMethodsTesteeTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/HasMutableStaticInitializer.java b/pitest/src/test/java/com/example/HasMutableStaticInitializer.java index a2ac20ef1..26d23e7b6 100644 --- a/pitest/src/test/java/com/example/HasMutableStaticInitializer.java +++ b/pitest/src/test/java/com/example/HasMutableStaticInitializer.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/HasMutableStaticInitializerTest.java b/pitest/src/test/java/com/example/HasMutableStaticInitializerTest.java index 9b5343486..919874048 100644 --- a/pitest/src/test/java/com/example/HasMutableStaticInitializerTest.java +++ b/pitest/src/test/java/com/example/HasMutableStaticInitializerTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/KeepAliveThread.java b/pitest/src/test/java/com/example/KeepAliveThread.java index f60c7faee..98b9009bf 100644 --- a/pitest/src/test/java/com/example/KeepAliveThread.java +++ b/pitest/src/test/java/com/example/KeepAliveThread.java @@ -1,17 +1,17 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.example; @@ -21,8 +21,8 @@ import java.util.concurrent.Future; /** - * - * + * + * * @author Stefan Penndorf */ public class KeepAliveThread { @@ -36,6 +36,7 @@ public KeepAliveThread() { public Future run() { return this.ex.submit(new Callable() { + @Override public String call() throws Exception { return System.getProperty("foobar"); } diff --git a/pitest/src/test/java/com/example/KeepAliveThreadTest.java b/pitest/src/test/java/com/example/KeepAliveThreadTest.java index d6e32d508..7fe275577 100644 --- a/pitest/src/test/java/com/example/KeepAliveThreadTest.java +++ b/pitest/src/test/java/com/example/KeepAliveThreadTest.java @@ -1,17 +1,17 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.example; @@ -20,8 +20,8 @@ import org.junit.Test; /** - * - * + * + * * @author Stefan Penndorf */ public class KeepAliveThreadTest { diff --git a/pitest/src/test/java/com/example/LineNumbersSpanBlocks.java b/pitest/src/test/java/com/example/LineNumbersSpanBlocks.java index ea98f4a50..63a24542a 100644 --- a/pitest/src/test/java/com/example/LineNumbersSpanBlocks.java +++ b/pitest/src/test/java/com/example/LineNumbersSpanBlocks.java @@ -1,20 +1,21 @@ package com.example; + //@formatter:off public class LineNumbersSpanBlocks { public static int foo(int digits) { - final int result; + final int result; - if (digits == 1) { - final int day = 6; + if (digits == 1) { + final int day = 6; - result = day * 7; - } else if (digits == 2) { - result = 13; - } else { - result = 0; - } + result = day * 7; + } else if (digits == 2) { + result = 13; + } else { + result = 0; + } - return result; + return result; } } -//@formatter:on \ No newline at end of file +// @formatter:on \ No newline at end of file diff --git a/pitest/src/test/java/com/example/LoadsResourcesFromClassPath.java b/pitest/src/test/java/com/example/LoadsResourcesFromClassPath.java index 5531a41f8..210140c5e 100644 --- a/pitest/src/test/java/com/example/LoadsResourcesFromClassPath.java +++ b/pitest/src/test/java/com/example/LoadsResourcesFromClassPath.java @@ -11,7 +11,7 @@ public static boolean loadResource() { .getResourceAsStream( "resource folder with spaces/text in folder with spaces.txt"); final boolean result = stream != null; // store result to nudge compiler - // towards single IRETURN + // towards single IRETURN return result; } diff --git a/pitest/src/test/java/com/example/MockitoRunnerTest.java b/pitest/src/test/java/com/example/MockitoRunnerTest.java index 50010c54b..32eb038b5 100644 --- a/pitest/src/test/java/com/example/MockitoRunnerTest.java +++ b/pitest/src/test/java/com/example/MockitoRunnerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/com/example/MultipleMutations.java b/pitest/src/test/java/com/example/MultipleMutations.java index 148483a8a..224a14dbb 100644 --- a/pitest/src/test/java/com/example/MultipleMutations.java +++ b/pitest/src/test/java/com/example/MultipleMutations.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/PartiallyCoveredTestee.java b/pitest/src/test/java/com/example/PartiallyCoveredTestee.java index de2b0406e..4a1de0563 100644 --- a/pitest/src/test/java/com/example/PartiallyCoveredTestee.java +++ b/pitest/src/test/java/com/example/PartiallyCoveredTestee.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/PartiallyCoveredTesteeTest.java b/pitest/src/test/java/com/example/PartiallyCoveredTesteeTest.java index f0e93b984..949cb1407 100644 --- a/pitest/src/test/java/com/example/PartiallyCoveredTesteeTest.java +++ b/pitest/src/test/java/com/example/PartiallyCoveredTesteeTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/TheoryTest.java b/pitest/src/test/java/com/example/TheoryTest.java index ef7a7142f..988a958e6 100644 --- a/pitest/src/test/java/com/example/TheoryTest.java +++ b/pitest/src/test/java/com/example/TheoryTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example; diff --git a/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/TestThrowsExceptionInFinallyBlock.java b/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/TestThrowsExceptionInFinallyBlock.java index ea649aa35..ed0c7fe1a 100644 --- a/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/TestThrowsExceptionInFinallyBlock.java +++ b/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/TestThrowsExceptionInFinallyBlock.java @@ -9,5 +9,5 @@ public void test() { final ThrowsExceptionInFinallyBlockTestee t = new ThrowsExceptionInFinallyBlockTestee(); t.foo(); } - + } diff --git a/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/ThrowsExceptionFromLargeMethodTestee.java b/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/ThrowsExceptionFromLargeMethodTestee.java index e90471c47..95ff36f2d 100644 --- a/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/ThrowsExceptionFromLargeMethodTestee.java +++ b/pitest/src/test/java/com/example/coverage/execute/samples/exceptions/ThrowsExceptionFromLargeMethodTestee.java @@ -2,39 +2,39 @@ public class ThrowsExceptionFromLargeMethodTestee { int i; - + public int foo() { - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - i++; - throwsException(); - return i; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + this.i++; + throwsException(); + return this.i; } private void throwsException() { diff --git a/pitest/src/test/java/com/example/coverage/execute/samples/simple/Testee.java b/pitest/src/test/java/com/example/coverage/execute/samples/simple/Testee.java index 54013d8cd..3563995a9 100644 --- a/pitest/src/test/java/com/example/coverage/execute/samples/simple/Testee.java +++ b/pitest/src/test/java/com/example/coverage/execute/samples/simple/Testee.java @@ -8,6 +8,7 @@ public void bar() { } + @Override public void run() { new Testee2().bar(); } diff --git a/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructors.java b/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructors.java index 61b409568..1b35fb50c 100644 --- a/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructors.java +++ b/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructors.java @@ -3,12 +3,12 @@ public class TesteeWithComplexConstructors { public int f; - + TesteeWithComplexConstructors(int a) { - if ( a > 10 ) { - f = 11; + if (a > 10) { + this.f = 11; } else { - f = 42; + this.f = 42; } } } diff --git a/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructorsTest.java b/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructorsTest.java index e4f03a8dc..8a0eef28d 100644 --- a/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructorsTest.java +++ b/pitest/src/test/java/com/example/coverage/execute/samples/simple/TesteeWithComplexConstructorsTest.java @@ -6,13 +6,12 @@ public class TesteeWithComplexConstructorsTest { @Test public void testLow() { - new TesteeWithComplexConstructors(1); + new TesteeWithComplexConstructors(1); } - + @Test public void testHigh() { - new TesteeWithComplexConstructors(100); + new TesteeWithComplexConstructors(100); } - } diff --git a/pitest/src/test/java/com/example/coverage/execute/samples/simple/TestsForMultiBlockCoverage.java b/pitest/src/test/java/com/example/coverage/execute/samples/simple/TestsForMultiBlockCoverage.java index e5dbf5adc..e6df9a1d2 100644 --- a/pitest/src/test/java/com/example/coverage/execute/samples/simple/TestsForMultiBlockCoverage.java +++ b/pitest/src/test/java/com/example/coverage/execute/samples/simple/TestsForMultiBlockCoverage.java @@ -11,14 +11,14 @@ public void test1() { MultiBlockCoverageTestee.blocks1(1); } -// @Test -// public void test2() { -// try { -// MultiBlockCoverageTestee.blocks2(1); -// } catch(UnsupportedOperationException e) { -// -// } -// } + // @Test + // public void test2() { + // try { + // MultiBlockCoverageTestee.blocks2(1); + // } catch(UnsupportedOperationException e) { + // + // } + // } @Test public void test3() { diff --git a/pitest/src/test/java/com/example/testhasignores/MuteeTest.java b/pitest/src/test/java/com/example/testhasignores/MuteeTest.java index 4af9117e1..a719048b6 100644 --- a/pitest/src/test/java/com/example/testhasignores/MuteeTest.java +++ b/pitest/src/test/java/com/example/testhasignores/MuteeTest.java @@ -8,25 +8,25 @@ import org.junit.Test; public class MuteeTest { - + @BeforeClass public static void foo() { - + } - - @Test(expected=NullPointerException.class) + + @Test(expected = NullPointerException.class) public void test1() { // does nothing throw new NullPointerException(); } - + @Ignore @Test public void test2() { fail("not yet supported"); } - - @Test(expected=NullPointerException.class) + + @Test(expected = NullPointerException.class) public void thisOneKills() { assertEquals(1, Mutee.returnOne()); throw new NullPointerException(); diff --git a/pitest/src/test/java/com/example/testng/AbstractClass.java b/pitest/src/test/java/com/example/testng/AbstractClass.java index b4c588986..634d5c291 100644 --- a/pitest/src/test/java/com/example/testng/AbstractClass.java +++ b/pitest/src/test/java/com/example/testng/AbstractClass.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/AnnotatedAtClassLevel.java b/pitest/src/test/java/com/example/testng/AnnotatedAtClassLevel.java index bcfd7e03a..e83182508 100644 --- a/pitest/src/test/java/com/example/testng/AnnotatedAtClassLevel.java +++ b/pitest/src/test/java/com/example/testng/AnnotatedAtClassLevel.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/AnnotatedAtMethodLevel.java b/pitest/src/test/java/com/example/testng/AnnotatedAtMethodLevel.java index 37176a47c..4d2453fec 100644 --- a/pitest/src/test/java/com/example/testng/AnnotatedAtMethodLevel.java +++ b/pitest/src/test/java/com/example/testng/AnnotatedAtMethodLevel.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/AnnotatedBase.java b/pitest/src/test/java/com/example/testng/AnnotatedBase.java index bddf0bba9..c696e9305 100644 --- a/pitest/src/test/java/com/example/testng/AnnotatedBase.java +++ b/pitest/src/test/java/com/example/testng/AnnotatedBase.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/Fails.java b/pitest/src/test/java/com/example/testng/Fails.java index 9ffbe1635..99f1bcb2c 100644 --- a/pitest/src/test/java/com/example/testng/Fails.java +++ b/pitest/src/test/java/com/example/testng/Fails.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; @@ -21,9 +21,9 @@ public class Fails { public void fails() { assertTrue(false); } - + @org.testng.annotations.Test public void passes() { - + } } \ No newline at end of file diff --git a/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTestee.java b/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTestee.java index 51d262071..852e85946 100644 --- a/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTestee.java +++ b/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTestee.java @@ -1,32 +1,32 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ public class FullyCoveredByTestNGTestee { diff --git a/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTesteeTest.java b/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTesteeTest.java index c8f5b3383..d43661d34 100644 --- a/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTesteeTest.java +++ b/pitest/src/test/java/com/example/testng/FullyCoveredByTestNGTesteeTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/HasGroups.java b/pitest/src/test/java/com/example/testng/HasGroups.java index 98af83b89..609e2f96a 100644 --- a/pitest/src/test/java/com/example/testng/HasGroups.java +++ b/pitest/src/test/java/com/example/testng/HasGroups.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/HasOnePassingAndOneFailingMethod.java b/pitest/src/test/java/com/example/testng/HasOnePassingAndOneFailingMethod.java index 091480da9..f7238e0a0 100644 --- a/pitest/src/test/java/com/example/testng/HasOnePassingAndOneFailingMethod.java +++ b/pitest/src/test/java/com/example/testng/HasOnePassingAndOneFailingMethod.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/InheritsFromAnnotatedBase.java b/pitest/src/test/java/com/example/testng/InheritsFromAnnotatedBase.java index ec8877a1a..60ffe8f9a 100644 --- a/pitest/src/test/java/com/example/testng/InheritsFromAnnotatedBase.java +++ b/pitest/src/test/java/com/example/testng/InheritsFromAnnotatedBase.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/Passes.java b/pitest/src/test/java/com/example/testng/Passes.java index bf8c46be8..5155fb592 100644 --- a/pitest/src/test/java/com/example/testng/Passes.java +++ b/pitest/src/test/java/com/example/testng/Passes.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/com/example/testng/Skips.java b/pitest/src/test/java/com/example/testng/Skips.java index b90b63ce7..06e94eab1 100644 --- a/pitest/src/test/java/com/example/testng/Skips.java +++ b/pitest/src/test/java/com/example/testng/Skips.java @@ -2,7 +2,6 @@ import org.testng.SkipException; - public class Skips { @org.testng.annotations.Test() diff --git a/pitest/src/test/java/com/example/testng/StaticMethods.java b/pitest/src/test/java/com/example/testng/StaticMethods.java index 8d4a40a53..66e29cba3 100644 --- a/pitest/src/test/java/com/example/testng/StaticMethods.java +++ b/pitest/src/test/java/com/example/testng/StaticMethods.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package com.example.testng; diff --git a/pitest/src/test/java/org/pitest/DescriptionMother.java b/pitest/src/test/java/org/pitest/DescriptionMother.java index 7f1989c10..bc8296c34 100644 --- a/pitest/src/test/java/org/pitest/DescriptionMother.java +++ b/pitest/src/test/java/org/pitest/DescriptionMother.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java b/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java index 22e4f1c5d..e2878eb49 100644 --- a/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java +++ b/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java @@ -52,19 +52,19 @@ public class TestJUnitConfiguration { - private final JUnitCompatibleConfiguration testee = new JUnitCompatibleConfiguration(new TestGroupConfig()); + private final JUnitCompatibleConfiguration testee = new JUnitCompatibleConfiguration( + new TestGroupConfig()); private Pitest pitest; private Container container; @Mock private TestListener listener; - @Before public void createTestee() { MockitoAnnotations.initMocks(this); this.container = new UnContainer(); - + this.pitest = new Pitest(Collections.singletonList(this.listener)); } @@ -82,7 +82,7 @@ public void shouldFindJunit4Tests() { } public static class JUnit3TestWithSingleStringConstructorAndJUnit4Annotations - extends TestCase { + extends TestCase { private final String name; @@ -163,7 +163,6 @@ public void shouldPassTestsThatThrowExpectedException() { verify(this.listener).onTestSuccess(any(TestResult.class)); } - public static class SimpleJUnit3Test extends TestCase { public void testOne() { @@ -463,12 +462,12 @@ public void shouldSkipAllMethodsAnnotatedWithIgnore() { verify(this.listener, times(2)).onTestSkipped((any(TestResult.class))); verify(this.listener).onTestSuccess((any(TestResult.class))); } - + public static class HasMethodAnnotatedAsIgnoredAndBeforeClassAnnotation { - + @BeforeClass public static void foo() { - + } @Test @@ -486,13 +485,13 @@ public void dontIgnoreMe() { @Test public void shouldNotSkipEnabledTestsInAClassWithBeforeClassAnotationAndAnIgnoredTest() { - run(HasMethodAnnotatedAsIgnoredAndBeforeClassAnnotation.class); - verify(this.listener).onTestSuccess((any(TestResult.class))); + run(HasMethodAnnotatedAsIgnoredAndBeforeClassAnnotation.class); + verify(this.listener).onTestSuccess((any(TestResult.class))); } @Test public void shouldNotReportAnErrorWhenCorrectJUnitVersionOnClasspath() { - assertEquals(Option.none(), this.testee.verifyEnvironment()); + assertEquals(Option. none(), this.testee.verifyEnvironment()); } public static class HasAssumptionFailure { @@ -579,7 +578,6 @@ public void shouldFindTestInJUnitParamsTest() { verify(this.listener, times(3)).onTestSuccess(any(TestResult.class)); } - public static class HasOneMethodAnnotatedAsIgnored { @Test @@ -605,14 +603,15 @@ public void shouldRunOtherMethodsInAClassWithOneIgnoredTest() { run(HasOneMethodAnnotatedAsIgnored.class); verify(this.listener, times(2)).onTestSuccess((any(TestResult.class))); } - + private void run(final Class clazz) { this.pitest.run(this.container, this.testee, clazz); } private List find(Class clazz) { FindTestUnits finder = new FindTestUnits(this.testee); - return finder.findTestUnitsForAllSuppliedClasses(Arrays.>asList(clazz)); + return finder.findTestUnitsForAllSuppliedClasses(Arrays + .> asList(clazz)); } - + } diff --git a/pitest/src/test/java/org/pitest/bytecode/FrameOptionsTest.java b/pitest/src/test/java/org/pitest/bytecode/FrameOptionsTest.java index 49f3ff36f..002995778 100644 --- a/pitest/src/test/java/org/pitest/bytecode/FrameOptionsTest.java +++ b/pitest/src/test/java/org/pitest/bytecode/FrameOptionsTest.java @@ -16,48 +16,48 @@ public void shouldComputeFramesForJava7() { public void shouldComputeFramesForJava8() { assertEquals(ClassWriter.COMPUTE_FRAMES, bytesToTestee("CAFEBABE00000034")); } - + @Test public void shouldNotComputeFramesForJava6() { assertEquals(ClassWriter.COMPUTE_MAXS, bytesToTestee("CAFEBABE00000032")); } - + @Test public void shouldNotComputeFramesForJava5() { assertEquals(ClassWriter.COMPUTE_MAXS, bytesToTestee("CAFEBABE00000031")); } - + @Test public void shouldNotComputeFramesForJava4() { assertEquals(ClassWriter.COMPUTE_MAXS, bytesToTestee("CAFEBABE00000030")); } - + @Test public void shouldNotComputeFramesForJava3() { assertEquals(ClassWriter.COMPUTE_MAXS, bytesToTestee("CAFEBABE0000002F")); } - + @Test public void shouldNotComputeFramesForJava2() { assertEquals(ClassWriter.COMPUTE_MAXS, bytesToTestee("CAFEBABE0000002E")); } - + @Test public void shouldNotComputeFramesForJava1() { assertEquals(ClassWriter.COMPUTE_MAXS, bytesToTestee("CAFEBABE0000002D")); } - + private int bytesToTestee(String hex) { return FrameOptions.pickFlags(toByteArray(hex)); } - + private static byte[] toByteArray(String s) { int len = s.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { - data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) - + Character.digit(s.charAt(i+1), 16)); + data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character + .digit(s.charAt(i + 1), 16)); } return data; -} + } } diff --git a/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java b/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java index 9ea6cef4e..281d8476b 100644 --- a/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java +++ b/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2012 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.bytecode; diff --git a/pitest/src/test/java/org/pitest/classinfo/ClassIdentifierTest.java b/pitest/src/test/java/org/pitest/classinfo/ClassIdentifierTest.java index 86a0e9183..215165627 100644 --- a/pitest/src/test/java/org/pitest/classinfo/ClassIdentifierTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/ClassIdentifierTest.java @@ -9,6 +9,6 @@ public class ClassIdentifierTest { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(ClassIdentifier.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/classinfo/ClassInfoMother.java b/pitest/src/test/java/org/pitest/classinfo/ClassInfoMother.java index 5f5d77b92..a2d535f51 100644 --- a/pitest/src/test/java/org/pitest/classinfo/ClassInfoMother.java +++ b/pitest/src/test/java/org/pitest/classinfo/ClassInfoMother.java @@ -3,10 +3,10 @@ import org.pitest.quickbuilder.Builder; public class ClassInfoMother { - - interface ClassInfoBuilderf extends Builder { - ClassInfoBuilder withId(Builder id); - } + + interface ClassInfoBuilderf extends Builder { + ClassInfoBuilder withId(Builder id); + } public static ClassInfo make(final ClassIdentifier id) { return make(id, new DefaultClassPointer(null)); diff --git a/pitest/src/test/java/org/pitest/classinfo/ClassInfoTest.java b/pitest/src/test/java/org/pitest/classinfo/ClassInfoTest.java index 941f609c1..9995f1e9d 100644 --- a/pitest/src/test/java/org/pitest/classinfo/ClassInfoTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/ClassInfoTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -64,6 +64,7 @@ public void shouldCreateDifferentHierarchicalHashWhenOuterClassChanges() { private ClassPointer emptyClassPointer() { return new ClassPointer() { + @Override public Option fetch() { return Option.none(); } @@ -73,6 +74,7 @@ public Option fetch() { private ClassPointer pointerTo(final ClassInfo ci) { return new ClassPointer() { + @Override public Option fetch() { return Option.some(ci); } @@ -104,7 +106,7 @@ public void matchIfAbstractShouldReturnTrueForAbstractClasses() { makeTestee(); assertTrue(ClassInfo.matchIfAbstract().apply(this.testee)); } - + private void makeTestee() { this.testee = new ClassInfo(null, null, this.data); } diff --git a/pitest/src/test/java/org/pitest/classinfo/ClassInfoVisitorTest.java b/pitest/src/test/java/org/pitest/classinfo/ClassInfoVisitorTest.java index d4fa09d41..170258974 100644 --- a/pitest/src/test/java/org/pitest/classinfo/ClassInfoVisitorTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/ClassInfoVisitorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,6 +14,16 @@ */ package org.pitest.classinfo; +import static java.lang.annotation.ElementType.TYPE; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + import org.junit.Test; import org.junit.experimental.categories.Category; import org.pitest.coverage.codeassist.ClassUtils; @@ -21,13 +31,6 @@ import org.pitest.coverage.codeassist.samples.HasDefaultConstructor; import org.pitest.coverage.codeassist.samples.NoDefaultConstructor; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.TYPE; -import static org.junit.Assert.*; - public class ClassInfoVisitorTest { @Test @@ -83,33 +86,42 @@ public void shouldRecordSourceFile() throws ClassNotFoundException { @Test public void shouldRecordClassAnnotationValues() throws ClassNotFoundException { final String sampleName = HasSimpleValue.class.getName(); - ClassInfoBuilder actual = getClassInfo(sampleName, ClassUtils.classAsBytes(sampleName)); + ClassInfoBuilder actual = getClassInfo(sampleName, + ClassUtils.classAsBytes(sampleName)); assertEquals(1, actual.classAnnotationValues.size()); Object expectedValue = "blah"; - Object actualValue = actual.classAnnotationValues.get(ClassName.fromClass(SimpleValue.class)); + Object actualValue = actual.classAnnotationValues.get(ClassName + .fromClass(SimpleValue.class)); assertEquals(expectedValue, actualValue); } @Test - public void shouldRecordClassAnnotationArrayValues() throws ClassNotFoundException { + public void shouldRecordClassAnnotationArrayValues() + throws ClassNotFoundException { final String sampleName = HasStringValues.class.getName(); - ClassInfoBuilder actual = getClassInfo(sampleName, ClassUtils.classAsBytes(sampleName)); + ClassInfoBuilder actual = getClassInfo(sampleName, + ClassUtils.classAsBytes(sampleName)); assertEquals(1, actual.classAnnotationValues.size()); - Object[] expectedStrings = {"this", "that"}; - Object[] actualStrings = (Object[]) actual.classAnnotationValues.get(ClassName.fromClass(StringValues.class)); + Object[] expectedStrings = { "this", "that" }; + Object[] actualStrings = (Object[]) actual.classAnnotationValues + .get(ClassName.fromClass(StringValues.class)); assertArrayEquals(expectedStrings, actualStrings); } @Test - public void shouldStoreTypeArrayValuesAsClassNames() throws ClassNotFoundException { + public void shouldStoreTypeArrayValuesAsClassNames() + throws ClassNotFoundException { final String sampleName = HasCategory.class.getName(); - ClassInfoBuilder actual = getClassInfo(sampleName, ClassUtils.classAsBytes(sampleName)); + ClassInfoBuilder actual = getClassInfo(sampleName, + ClassUtils.classAsBytes(sampleName)); assertEquals(1, actual.classAnnotationValues.size()); - Object[] expectedCategoryNames = {First.class.getName(), Second.class.getName()}; - Object[] actualCategoryNames = (Object[]) actual.classAnnotationValues.get(ClassName.fromClass(Category.class)); + Object[] expectedCategoryNames = { First.class.getName(), + Second.class.getName() }; + Object[] actualCategoryNames = (Object[]) actual.classAnnotationValues + .get(ClassName.fromClass(Category.class)); assertArrayEquals(expectedCategoryNames, actualCategoryNames); } @@ -124,7 +136,8 @@ private ClassInfoBuilder getClassInfo(final String name, final byte[] bytes) { } @SimpleValue("blah") - private class HasSimpleValue{} + private class HasSimpleValue { + } @Target(TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -132,13 +145,17 @@ private class HasSimpleValue{} String[] value(); } - @StringValues({"this", "that"}) - private class HasStringValues{} + @StringValues({ "this", "that" }) + private class HasStringValues { + } - private interface First{} - private interface Second{} + private interface First { + } - @Category({First.class, Second.class}) - private class HasCategory{} -} + private interface Second { + } + @Category({ First.class, Second.class }) + private class HasCategory { + } +} diff --git a/pitest/src/test/java/org/pitest/classinfo/ClassNameTest.java b/pitest/src/test/java/org/pitest/classinfo/ClassNameTest.java index 562cc9883..20763fd1d 100644 --- a/pitest/src/test/java/org/pitest/classinfo/ClassNameTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/ClassNameTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -140,7 +140,7 @@ public void shouldTreatDifferentClassesAsNotEqual() { assertFalse(ClassName.fromString("org/example/Foo").equals( ClassName.fromString("org.example.Bar"))); } - + @Test public void nameToClassShouldReturnClassWhenKnownToLoader() { assertEquals(Option.some(String.class), @@ -152,10 +152,10 @@ public void stringToClassShouldReturnNoneWhenClassNotKnownToLoader() { assertEquals(Option.none(), ClassName.nameToClass().apply(new ClassName("org.unknown.Unknown"))); } - + @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(ClassName.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/classinfo/ComputeClassWriterTest.java b/pitest/src/test/java/org/pitest/classinfo/ComputeClassWriterTest.java index bb9eecd2a..8122c6a96 100644 --- a/pitest/src/test/java/org/pitest/classinfo/ComputeClassWriterTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/ComputeClassWriterTest.java @@ -5,18 +5,16 @@ import java.util.HashMap; import org.junit.Test; -import org.pitest.classinfo.ClassName; -import org.pitest.classinfo.ComputeClassWriter; import org.pitest.classpath.ClassloaderByteArraySource; import org.pitest.util.IsolationUtils; public class ComputeClassWriterTest { private final ComputeClassWriter testee = new ComputeClassWriter( - new ClassloaderByteArraySource( - IsolationUtils - .getContextClassLoader()), - new HashMap(), 0); + new ClassloaderByteArraySource( + IsolationUtils + .getContextClassLoader()), + new HashMap(), 0); @Test public void shouldResolveObjectAsSuperClassWhenNoCommonParentExists() { diff --git a/pitest/src/test/java/org/pitest/classinfo/HierarchicalClassIdTest.java b/pitest/src/test/java/org/pitest/classinfo/HierarchicalClassIdTest.java index 4b78612d5..8308382c9 100644 --- a/pitest/src/test/java/org/pitest/classinfo/HierarchicalClassIdTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/HierarchicalClassIdTest.java @@ -9,6 +9,6 @@ public class HierarchicalClassIdTest { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(HierarchicalClassId.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java b/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java index 27560a6f8..397e93d19 100644 --- a/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -215,7 +215,6 @@ public void shouldReportCodeLines() { aClass.value().isCodeLine(139); // flakey } - @Ignore static class Annotated { diff --git a/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java b/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java index 346750b71..ff4094274 100644 --- a/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classinfo; @@ -42,7 +42,8 @@ public void setUp() { @Test public void shouldMapTestsPostfixedWithTestToTesteeWhenTesteeExists() { final byte[] bytes = { 0 }; - when(this.source.getBytes("com.example.Foo")).thenReturn(Option.some(bytes)); + when(this.source.getBytes("com.example.Foo")) + .thenReturn(Option.some(bytes)); assertEquals(new ClassName("com.example.Foo"), this.testee.findTestee("com.example.FooTest").value()); } @@ -50,7 +51,8 @@ public void shouldMapTestsPostfixedWithTestToTesteeWhenTesteeExists() { @Test public void shouldMapTestsPrefixedWithTestToTesteeWhenTesteeExists() { final byte[] bytes = { 0 }; - when(this.source.getBytes("com.example.Foo")).thenReturn(Option.some(bytes)); + when(this.source.getBytes("com.example.Foo")) + .thenReturn(Option.some(bytes)); assertEquals(new ClassName("com.example.Foo"), this.testee.findTestee("com.example.TestFoo").value()); } @@ -58,7 +60,8 @@ public void shouldMapTestsPrefixedWithTestToTesteeWhenTesteeExists() { @Test public void shouldReturnNoneWhenNoTesteeExistsMatchingNamingConvention() { final byte[] bytes = null; - when(this.source.getBytes("com.example.Foo")).thenReturn(Option.some(bytes)); + when(this.source.getBytes("com.example.Foo")) + .thenReturn(Option.some(bytes)); assertEquals(Option.none(), this.testee.findTestee("com.example.TestFoo")); } diff --git a/pitest/src/test/java/org/pitest/classpath/ArchiveClassPathRootTest.java b/pitest/src/test/java/org/pitest/classpath/ArchiveClassPathRootTest.java index fd2983b42..785d6a0ad 100644 --- a/pitest/src/test/java/org/pitest/classpath/ArchiveClassPathRootTest.java +++ b/pitest/src/test/java/org/pitest/classpath/ArchiveClassPathRootTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -27,7 +27,6 @@ import org.junit.Before; import org.junit.Test; -import org.pitest.classpath.ArchiveClassPathRoot; public class ArchiveClassPathRootTest { diff --git a/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java b/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java index 7a29214e2..72261d423 100644 --- a/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java +++ b/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -30,8 +30,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.pitest.classpath.ClassPath; -import org.pitest.classpath.ClassPathRoot; import org.pitest.functional.Option; import org.pitest.functional.predicate.Predicate; import org.pitest.functional.prelude.Prelude; @@ -89,6 +87,7 @@ public void shouldAllowSubComponentsToBeSelected() { private Predicate rootIsEqualTo(final String value) { return new Predicate() { + @Override public Boolean apply(final ClassPathRoot a) { return a.cacheLocation().value().equals(value); } diff --git a/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java b/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java index 579afde14..de9286f8d 100644 --- a/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java +++ b/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java @@ -28,7 +28,7 @@ public class CodeSourceTest { private Repository repository; @Mock - private ProjectClassPaths classPath; + private ProjectClassPaths classPath; @Mock private TestClassIdentifier testIdentifer; @@ -74,8 +74,9 @@ public void shouldIdentifyTestClassesOnTestPath() { @Test public void shouldOnlyIdentifyIncludedTestClassesOnTestPath() { - when(this.testIdentifer.isATestClass(any(ClassInfo.class))).thenReturn(true); - when(this.testIdentifer.isIncluded(foo)).thenReturn(true); + when(this.testIdentifer.isATestClass(any(ClassInfo.class))) + .thenReturn(true); + when(this.testIdentifer.isIncluded(this.foo)).thenReturn(true); when(this.classPath.test()).thenReturn( Arrays.asList(this.foo.getName(), this.bar.getName())); @@ -84,7 +85,8 @@ public void shouldOnlyIdentifyIncludedTestClassesOnTestPath() { @Test public void shouldNotIdentifyExcludedTestClassesOnTestPath() { - when(this.testIdentifer.isATestClass(any(ClassInfo.class))).thenReturn(true); + when(this.testIdentifer.isATestClass(any(ClassInfo.class))) + .thenReturn(true); when(this.testIdentifer.isIncluded(any(ClassInfo.class))).thenReturn(false); when(this.classPath.test()).thenReturn( Arrays.asList(this.foo.getName(), this.bar.getName())); @@ -107,7 +109,7 @@ public void shouldProvideNamesOfNonTestClasses() { @Test public void shouldMapTestsPostfixedWithTestToTesteeWhenTesteeExists() { when(this.repository.hasClass(new ClassName("com.example.Foo"))) - .thenReturn(true); + .thenReturn(true); assertEquals(new ClassName("com.example.Foo"), this.testee.findTestee("com.example.FooTest").value()); } @@ -115,7 +117,7 @@ public void shouldMapTestsPostfixedWithTestToTesteeWhenTesteeExists() { @Test public void shouldMapTestsPrefixedWithTestToTesteeWhenTesteeExists() { when(this.repository.hasClass(new ClassName("com.example.Foo"))) - .thenReturn(true); + .thenReturn(true); assertEquals(new ClassName("com.example.Foo"), this.testee.findTestee("com.example.TestFoo").value()); } @@ -123,8 +125,9 @@ public void shouldMapTestsPrefixedWithTestToTesteeWhenTesteeExists() { @Test public void shouldReturnNoneWhenNoTesteeExistsMatchingNamingConvention() { when(this.repository.hasClass(new ClassName("com.example.Foo"))) - .thenReturn(false); - assertEquals(Option.none(), this.testee.findTestee("com.example.TestFoo")); + .thenReturn(false); + assertEquals(Option. none(), + this.testee.findTestee("com.example.TestFoo")); } @Test @@ -132,7 +135,7 @@ public void shouldProvideDetailsOfRequestedClasses() { when(this.repository.fetchClass(ClassName.fromString("Foo"))).thenReturn( Option.some(this.foo)); when(this.repository.fetchClass(ClassName.fromString("Unknown"))) - .thenReturn(Option. none()); + .thenReturn(Option. none()); assertEquals(Arrays.asList(this.foo), this.testee.getClassInfo(Arrays .asList(ClassName.fromString("Foo"), ClassName.fromString("Unknown")))); } @@ -142,7 +145,7 @@ public void shouldAllowClientsToRetrieveBytecode() { this.testee.fetchClassBytes(ClassName.fromString("Foo")); verify(this.repository).querySource(ClassName.fromString("Foo")); } - + private ClassInfo makeClassInfo(final String name) { final ClassInfo ci = ClassInfoMother.make(name); when(this.repository.fetchClass(ClassName.fromString(name))).thenReturn( diff --git a/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java b/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java index 3bec4c293..c1da6602e 100644 --- a/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java +++ b/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java @@ -18,7 +18,6 @@ public class CompoundClassPathRootTest { - private CompoundClassPathRoot testee; @Mock @@ -48,12 +47,12 @@ public void shouldReturnNamesOfAllClassesKnownByChildren() { public void shouldReturnNullWhenNoChildCanSupplyData() throws IOException { assertThat(this.testee.getData("unknown")).isNull(); } - + @Test public void shouldReturnNullWhenNoChildCanSupplyResource() throws IOException { assertThat(this.testee.getResource("unknown")).isNull(); } - + @Test public void shouldReturnClassDataFromChildren() throws IOException { when(this.child1.getData(any(String.class))).thenReturn(null); @@ -69,5 +68,5 @@ public void shouldReturnResourcesFromChildren() throws IOException { when(this.child1.getResource(any(String.class))).thenReturn(url); assertThat(this.testee.getResource("Foo")).isSameAs(url); } - + } diff --git a/pitest/src/test/java/org/pitest/classpath/DirectoryClassPathRootTest.java b/pitest/src/test/java/org/pitest/classpath/DirectoryClassPathRootTest.java index 7c55922f9..ea555af5c 100644 --- a/pitest/src/test/java/org/pitest/classpath/DirectoryClassPathRootTest.java +++ b/pitest/src/test/java/org/pitest/classpath/DirectoryClassPathRootTest.java @@ -6,7 +6,6 @@ import java.io.File; import org.junit.Test; -import org.pitest.classpath.DirectoryClassPathRoot; public class DirectoryClassPathRootTest { diff --git a/pitest/src/test/java/org/pitest/classpath/OtherClassLoaderClassPathRootTest.java b/pitest/src/test/java/org/pitest/classpath/OtherClassLoaderClassPathRootTest.java index 26b7ced0f..aa0664e17 100644 --- a/pitest/src/test/java/org/pitest/classpath/OtherClassLoaderClassPathRootTest.java +++ b/pitest/src/test/java/org/pitest/classpath/OtherClassLoaderClassPathRootTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.classpath; @@ -19,7 +19,6 @@ import org.junit.Before; import org.junit.Test; -import org.pitest.classpath.OtherClassLoaderClassPathRoot; public class OtherClassLoaderClassPathRootTest { diff --git a/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java b/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java index c4b4cb30a..41e142baf 100644 --- a/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java +++ b/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -66,6 +66,7 @@ public static Collection containers() { private static Object uncontainerFactory() { return new ContainerFactory() { + @Override public Container getContainer() { return new UnContainer(); } @@ -77,7 +78,7 @@ public Container getContainer() { public void setUp() { MockitoAnnotations.initMocks(this); this.config = new ConfigurationForTesting(); - this.pit = new Pitest(Collections.singletonList(listener)); + this.pit = new Pitest(Collections.singletonList(this.listener)); } public static class OnePassingTest { diff --git a/pitest/src/test/java/org/pitest/coverage/BlockLocationTest.java b/pitest/src/test/java/org/pitest/coverage/BlockLocationTest.java index 5856e816e..6d4602fd4 100644 --- a/pitest/src/test/java/org/pitest/coverage/BlockLocationTest.java +++ b/pitest/src/test/java/org/pitest/coverage/BlockLocationTest.java @@ -9,6 +9,6 @@ public class BlockLocationTest { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(BlockLocation.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/coverage/ClassLineTest.java b/pitest/src/test/java/org/pitest/coverage/ClassLineTest.java index b381d1c2b..e71077dca 100644 --- a/pitest/src/test/java/org/pitest/coverage/ClassLineTest.java +++ b/pitest/src/test/java/org/pitest/coverage/ClassLineTest.java @@ -9,7 +9,6 @@ public class ClassLineTest { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(ClassLine.class).verify(); - } - + } } diff --git a/pitest/src/test/java/org/pitest/coverage/CoverageDataTest.java b/pitest/src/test/java/org/pitest/coverage/CoverageDataTest.java index c0c94020e..b1f3d89f1 100644 --- a/pitest/src/test/java/org/pitest/coverage/CoverageDataTest.java +++ b/pitest/src/test/java/org/pitest/coverage/CoverageDataTest.java @@ -1,12 +1,12 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,9 +55,9 @@ public class CoverageDataTest { @Mock private CodeSource code; - + @Mock - private LineMap lm; + private LineMap lm; private final ClassName foo = ClassName.fromString("foo"); private final ClassName bar = ClassName.fromString("bar"); @@ -65,15 +65,15 @@ public class CoverageDataTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - when(lm.mapLines(any(ClassName.class))).thenReturn(new HashMap>()); - this.testee = new CoverageData(this.code, lm); + when(this.lm.mapLines(any(ClassName.class))).thenReturn( + new HashMap>()); + this.testee = new CoverageData(this.code, this.lm); } - - @Test public void shouldReturnNoTestsWhenNoTestsCoverALine() { - when(lm.mapLines(any(ClassName.class))).thenReturn(new HashMap>()); + when(this.lm.mapLines(any(ClassName.class))).thenReturn( + new HashMap>()); final ClassLine line = new ClassLine("foo", 1); assertEquals(Collections.emptyList(), this.testee.getTestsForClassLine(line)); @@ -81,19 +81,22 @@ public void shouldReturnNoTestsWhenNoTestsCoverALine() { @Test public void shouldStoreExecutionTimesOfTests() { - + int line = 1; int time = 42; - - BlockLocationBuilder block = aBlockLocation().withLocation(aLocation().withClass(foo)); - when(lm.mapLines(any(ClassName.class))).thenReturn(makeCoverageMapForBlock(block, line)); - - CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks(block.build(1)).withExecutionTime(time); - + + BlockLocationBuilder block = aBlockLocation().withLocation( + aLocation().withClass(this.foo)); + when(this.lm.mapLines(any(ClassName.class))).thenReturn( + makeCoverageMapForBlock(block, line)); + + CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks( + block.build(1)).withExecutionTime(time); + this.testee.calculateClassCoverage(cr.build()); assertEquals(Arrays.asList(42), FCollection.map( - this.testee.getTestsForClassLine(new ClassLine(foo, line)), + this.testee.getTestsForClassLine(new ClassLine(this.foo, line)), testInfoToExecutionTime())); } @@ -105,16 +108,19 @@ public void shouldReportNumberOfCoveredLinesWhenNoneCovered() { @Test public void shouldReportNumberOfCoveredLinesWhenSomeCovered() { - - BlockLocationBuilder block = aBlockLocation().withLocation(aLocation().withClass(foo)); - when(lm.mapLines(any(ClassName.class))).thenReturn(makeCoverageMapForBlock(block, 101,300)); - - CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks(block.build(1)); - + + BlockLocationBuilder block = aBlockLocation().withLocation( + aLocation().withClass(this.foo)); + when(this.lm.mapLines(any(ClassName.class))).thenReturn( + makeCoverageMapForBlock(block, 101, 300)); + + CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks( + block.build(1)); + this.testee.calculateClassCoverage(cr.build()); assertEquals(2, this.testee.getNumberOfCoveredLines(Collections - .singletonList(foo))); + .singletonList(this.foo))); } @Test @@ -160,29 +166,31 @@ public void shouldProvideAccessToClassData() { public void shouldReturnCoverageIdOf0WhenNoTestsCoverClass() { assertEquals(0, this.testee.getCoverageIdForClass(ClassName.fromString("unknown")) - .longValue()); + .longValue()); } @SuppressWarnings("unchecked") @Test public void shouldReturnNonZeroCoverageIdWhenTestsCoverClass() { - + final ClassName foo = ClassName.fromString("Foo"); final ClassInfo ci = ClassInfoMother.make(foo); - + when(this.code.getClassInfo(any(Collection.class))).thenReturn( Collections.singletonList(ci)); - - BlockLocationBuilder block = aBlockLocation().withLocation(aLocation().withClass(foo)); - HashMap> map = makeCoverageMapForBlock(block, 42); - when(lm.mapLines(any(ClassName.class))).thenReturn(map); - this.testee.calculateClassCoverage(aCoverageResult().withVisitedBlocks(block.build(1)).build()); - - assertThat(this.testee.getCoverageIdForClass(foo).longValue()).isNotEqualTo(0); - } + BlockLocationBuilder block = aBlockLocation().withLocation( + aLocation().withClass(foo)); + HashMap> map = makeCoverageMapForBlock(block, + 42); + when(this.lm.mapLines(any(ClassName.class))).thenReturn(map); + this.testee.calculateClassCoverage(aCoverageResult().withVisitedBlocks( + block.build(1)).build()); + assertThat(this.testee.getCoverageIdForClass(foo).longValue()) + .isNotEqualTo(0); + } @Test public void shouldProvideEmptyBlockCoverageListWhenNoCoverage() { @@ -191,12 +199,14 @@ public void shouldProvideEmptyBlockCoverageListWhenNoCoverage() { @Test public void shouldProvideCoverageListWhenCoverageRecorded() { - - BlockLocationBuilder block = aBlockLocation().withLocation(aLocation().withClass(foo)); - CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks(block.build(1)); - - testee.calculateClassCoverage(cr.build()); - + + BlockLocationBuilder block = aBlockLocation().withLocation( + aLocation().withClass(this.foo)); + CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks( + block.build(1)); + + this.testee.calculateClassCoverage(cr.build()); + this.testee.calculateClassCoverage(makeCoverageResult("foo", "fooTest", 0, 1)); final BlockCoverage actual = this.testee.createCoverage().get(0); @@ -207,13 +217,13 @@ public void shouldProvideCoverageListWhenCoverageRecorded() { @Test public void shouldProvideListOfClassesForSourceFile() { - final ClassInfo fooClass = ClassInfoMother.make(foo, "foo.java"); - final ClassInfo barClass = ClassInfoMother.make(bar, "bar.java"); + final ClassInfo fooClass = ClassInfoMother.make(this.foo, "foo.java"); + final ClassInfo barClass = ClassInfoMother.make(this.bar, "bar.java"); final Collection classes = Arrays.asList(fooClass, barClass); when(this.code.getCode()).thenReturn(classes); - this.testee = new CoverageData(this.code, lm); - + this.testee = new CoverageData(this.code, this.lm); + assertEquals(Arrays.asList(barClass), this.testee.getClassesForFile("bar.java", "")); } @@ -227,29 +237,33 @@ public void shouldMatchPackageWhenFindingSources() { final Collection classes = Arrays.asList(foo1Class, foo2Class); when(this.code.getCode()).thenReturn(classes); - this.testee = new CoverageData(this.code, lm); - + this.testee = new CoverageData(this.code, this.lm); + assertEquals(Arrays.asList(foo1Class), this.testee.getClassesForFile("foo.java", "a.b.c")); } @Test public void shouldIncludeAllCoveredLinesInCoverageSummary() { - + BlockLocationBuilder block = aBlockLocation(); - when(this.code.getCodeUnderTestNames()).thenReturn(Collections.singleton(block.build().getLocation().getClassName())); - when(lm.mapLines(any(ClassName.class))).thenReturn(makeCoverageMapForBlock(block, 1,2,3,4)); - - CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks(block.build(1)); - + when(this.code.getCodeUnderTestNames()).thenReturn( + Collections.singleton(block.build().getLocation().getClassName())); + when(this.lm.mapLines(any(ClassName.class))).thenReturn( + makeCoverageMapForBlock(block, 1, 2, 3, 4)); + + CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks( + block.build(1)); + this.testee.calculateClassCoverage(cr.build()); - CoverageSummary actual = testee.createSummary(); + CoverageSummary actual = this.testee.createSummary(); assertEquals(4, actual.getNumberOfCoveredLines()); } - + private static F testInfoToExecutionTime() { return new F() { + @Override public Integer apply(final TestInfo a) { return a.getTime(); } @@ -258,6 +272,7 @@ public Integer apply(final TestInfo a) { private static F testInfoToString() { return new F() { + @Override public String apply(final TestInfo a) { return a.getName(); } @@ -266,33 +281,32 @@ public String apply(final TestInfo a) { private CoverageResult makeCoverageResult(final String clazz, final String testName, final int time, final int block) { - return makeCoverageResult(clazz, new Description(testName), time, - block, true); + return makeCoverageResult(clazz, new Description(testName), time, block, + true); } private CoverageResult makeCoverageResult(final String clazz, final Description desc, final int time, final int block, final boolean testPassed) { - return new CoverageResult(desc, time, testPassed, makeCoverage(clazz, - block)); + return new CoverageResult(desc, time, testPassed, + makeCoverage(clazz, block)); } private Collection makeCoverage(final String clazz, final int block) { - final BlockLocation cs = new BlockLocation(Location.location(ClassName.fromString(clazz), MethodName.fromString("foo"), "V"),block); + final BlockLocation cs = new BlockLocation(Location.location( + ClassName.fromString(clazz), MethodName.fromString("foo"), "V"), block); return Collections.singleton(cs); } - - private HashMap> makeCoverageMapForBlock( - BlockLocationBuilder blocks, Integer ... lines) { - HashMap> map = new HashMap>(); + BlockLocationBuilder blocks, Integer... lines) { + HashMap> map = new HashMap>(); Set s = new HashSet(); s.addAll(Arrays.asList(lines)); map.put(blocks.build(), s); return map; } - + } diff --git a/pitest/src/test/java/org/pitest/coverage/CoverageMother.java b/pitest/src/test/java/org/pitest/coverage/CoverageMother.java index aef8b56de..96f3747c7 100644 --- a/pitest/src/test/java/org/pitest/coverage/CoverageMother.java +++ b/pitest/src/test/java/org/pitest/coverage/CoverageMother.java @@ -14,18 +14,21 @@ import org.pitest.testapi.Description; public class CoverageMother { - + public interface BlockLocationBuilder extends SequenceBuilder { BlockLocationBuilder withLocation(Builder location); + BlockLocationBuilder withLocation(Location location); + BlockLocationBuilder withBlock(int block); - + Location _Location(); + int _Block(); } public interface CoverageResultBuilder extends - SequenceBuilder { + SequenceBuilder { CoverageResultBuilder withTestUnitDescription(Description d); @@ -44,11 +47,11 @@ public interface CoverageResultBuilder extends boolean _GreenSuite(); } - - public static BlockLocationBuilder aBlockLocation() { - return QB.builder(BlockLocationBuilder.class, blockLocationSeed()).withBlock(1).withLocation(aLocation()); - } + public static BlockLocationBuilder aBlockLocation() { + return QB.builder(BlockLocationBuilder.class, blockLocationSeed()) + .withBlock(1).withLocation(aLocation()); + } public static CoverageResultBuilder aCoverageResult() { final ClassName fooTest = ClassName.fromString("FooTest"); @@ -56,21 +59,23 @@ public static CoverageResultBuilder aCoverageResult() { .builder(CoverageResultBuilder.class, CoverageResultSeed()) .withTestUnitDescription( new Description("fooTest", fooTest.asJavaName())) - .withExecutionTime(1).withGreenSuite(true) - .withVisitedBlocks(Collections. emptyList()); + .withExecutionTime(1).withGreenSuite(true) + .withVisitedBlocks(Collections. emptyList()); } - + private static Generator blockLocationSeed() { return new Generator() { + @Override public BlockLocation generate(BlockLocationBuilder b) { - return BlockLocation.blockLocation(b._Location(), b._Block()); + return BlockLocation.blockLocation(b._Location(), b._Block()); } - + }; } private static Generator CoverageResultSeed() { return new Generator() { + @Override public CoverageResult generate(CoverageResultBuilder b) { return new CoverageResult(b._TestUnitDescription(), b._ExecutionTime(), b._GreenSuite(), b._VisitedBlocks()); diff --git a/pitest/src/test/java/org/pitest/coverage/CoverageResultTest.java b/pitest/src/test/java/org/pitest/coverage/CoverageResultTest.java index 005dcef67..1697f94e4 100644 --- a/pitest/src/test/java/org/pitest/coverage/CoverageResultTest.java +++ b/pitest/src/test/java/org/pitest/coverage/CoverageResultTest.java @@ -36,8 +36,9 @@ public void shouldCalculateCorrectNumberOfCoveredBlocksWhenMultiplesClassesHaveC } private BlockLocation makeCoverage(final String name, final int block) { - Location l = Location.location(ClassName.fromString(name), MethodName.fromString("amethod"), "methodDesc"); - final BlockLocation bl = new BlockLocation(l,block); + Location l = Location.location(ClassName.fromString(name), + MethodName.fromString("amethod"), "methodDesc"); + final BlockLocation bl = new BlockLocation(l, block); return bl; } diff --git a/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java b/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java index 2714ea457..cc7efd179 100644 --- a/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java +++ b/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java @@ -14,7 +14,6 @@ import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -36,12 +35,12 @@ import sun.pitest.InvokeReceiver; public class CoverageTransformerTest { - - private final ClassLoader loader = IsolationUtils - .getContextClassLoader(); - private final ClassByteArraySource bytes = new ClassloaderByteArraySource(loader - ); + private final ClassLoader loader = IsolationUtils + .getContextClassLoader(); + + private final ClassByteArraySource bytes = new ClassloaderByteArraySource( + this.loader); @Mock private InvokeReceiver invokeQueue; @@ -86,36 +85,34 @@ public void shouldGenerateValidClasses() throws IllegalClassFormatException { assertValidClass(Math.class); } - private void assertValidClass(final Class clazz) throws IllegalClassFormatException { final byte[] bs = transform(clazz); - // printClass(bs); + // printClass(bs); final StringWriter sw = new StringWriter(); CheckClassAdapter.verify(new ClassReader(bs), false, new PrintWriter(sw)); assertTrue(sw.toString(), sw.toString().length() == 0); } - protected void printRaw(final Class clazz) throws IOException { - OtherClassLoaderClassPathRoot r = new OtherClassLoaderClassPathRoot(IsolationUtils.getContextClassLoader()); + OtherClassLoaderClassPathRoot r = new OtherClassLoaderClassPathRoot( + IsolationUtils.getContextClassLoader()); printClass(StreamUtil.streamToByteArray(r.getData(clazz.getName()))); } - + protected void printClass(final byte[] bs) { final ClassReader reader = new ClassReader(bs); - reader.accept(new TraceClassVisitor(null, new ASMifier(), - new PrintWriter(System.out)), ClassReader.EXPAND_FRAMES); + reader.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter( + System.out)), ClassReader.EXPAND_FRAMES); } - private byte[] transform(final Class clazz) throws IllegalClassFormatException { final CoverageTransformer testee = new CoverageTransformer( True. all()); - final byte[] bs = testee.transform(loader, clazz.getName(), null, null, - this.bytes.getBytes(clazz.getName()).value()); + final byte[] bs = testee.transform(this.loader, clazz.getName(), null, + null, this.bytes.getBytes(clazz.getName()).value()); return bs; } diff --git a/pitest/src/test/java/org/pitest/coverage/TestInfoTest.java b/pitest/src/test/java/org/pitest/coverage/TestInfoTest.java index 934cd3423..bfba7f13f 100644 --- a/pitest/src/test/java/org/pitest/coverage/TestInfoTest.java +++ b/pitest/src/test/java/org/pitest/coverage/TestInfoTest.java @@ -9,5 +9,5 @@ public class TestInfoTest { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(TestInfo.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/coverage/analysis/BlockTest.java b/pitest/src/test/java/org/pitest/coverage/analysis/BlockTest.java index 370d0ca40..455096019 100644 --- a/pitest/src/test/java/org/pitest/coverage/analysis/BlockTest.java +++ b/pitest/src/test/java/org/pitest/coverage/analysis/BlockTest.java @@ -9,6 +9,6 @@ public class BlockTest { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(Block.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/ClassUtils.java b/pitest/src/test/java/org/pitest/coverage/codeassist/ClassUtils.java index 0f42f51e1..e6fdc89a9 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/ClassUtils.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/ClassUtils.java @@ -25,7 +25,7 @@ public static byte[] classAsBytes(final String className) final BufferedInputStream stream = new BufferedInputStream( resource.openStream()); final byte[] result = new byte[resource.openConnection() - .getContentLength()]; + .getContentLength()]; int i; int counter = 0; diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/CoverageClassVisitorTest.java b/pitest/src/test/java/org/pitest/coverage/codeassist/CoverageClassVisitorTest.java index 139a6a2b7..af277dda6 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/CoverageClassVisitorTest.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/CoverageClassVisitorTest.java @@ -39,8 +39,8 @@ public void shouldRegisterProbesWithCodeCoverageStore() { this.testee.registerProbes(6); this.testee.visitEnd(); - CodeCoverageStore.visitProbes(this.classId, 0, - new boolean[] { false, false, true, false, false, false, false }); + CodeCoverageStore.visitProbes(this.classId, 0, new boolean[] { false, + false, true, false, false, false, false }); assertEquals(Arrays.asList(CodeCoverageStore.encode(this.classId, 2)), CodeCoverageStore.getHits()); diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java b/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java index 52610944a..43d5f4ff5 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java @@ -56,17 +56,19 @@ public void shouldMapAllLinesWhenMethodContainsThreeBlocks() throws Exception { } @Test - public void shouldMapAllLinesWhenMethodContainsThreeMultiLineBlocks() throws Exception { + public void shouldMapAllLinesWhenMethodContainsThreeMultiLineBlocks() + throws Exception { Map> actual = analyse(ThreeMultiLineBlocks.class); - Location l = Location.location(ClassName.fromClass(ThreeMultiLineBlocks.class), + Location l = Location.location( + ClassName.fromClass(ThreeMultiLineBlocks.class), MethodName.fromString("foo"), "(I)I"); - assertThat(actual.get(BlockLocation.blockLocation(l, 0))).contains(5,6); - assertThat(actual.get(BlockLocation.blockLocation(l, 1))).contains(7,8); - assertThat(actual.get(BlockLocation.blockLocation(l, 2))).contains(10,11); + assertThat(actual.get(BlockLocation.blockLocation(l, 0))).contains(5, 6); + assertThat(actual.get(BlockLocation.blockLocation(l, 1))).contains(7, 8); + assertThat(actual.get(BlockLocation.blockLocation(l, 2))).contains(10, 11); } - + @Test public void shouldMapLinesWhenLinesSpanBlocks() throws Exception { @@ -75,47 +77,44 @@ public void shouldMapLinesWhenLinesSpanBlocks() throws Exception { ClassName.fromClass(com.example.LineNumbersSpanBlocks.class), MethodName.fromString("foo"), "(I)I"); - assertThat(actual.get(BlockLocation.blockLocation(l, 2))).containsOnly(11); + assertThat(actual.get(BlockLocation.blockLocation(l, 2))).containsOnly(12); } - + @Test - public void shouldIncludeLastLinesConstructorsInBlock() throws Exception { + public void shouldIncludeLastLinesConstructorsInBlock() throws Exception { Map> actual = analyse(LastLineOfContructorCheck.class); - Location l = Location.location(ClassName.fromClass(LastLineOfContructorCheck.class), + Location l = Location.location( + ClassName.fromClass(LastLineOfContructorCheck.class), MethodName.fromString(""), "()V"); assertThat(actual.get(BlockLocation.blockLocation(l, 0))).contains(6); } @Test - public void shouldI() throws Exception { + public void shouldI() throws Exception { Map> actual = analyse(ThreeBlocks2.class); Location l = Location.location(ClassName.fromClass(ThreeBlocks2.class), MethodName.fromString("foo"), "(I)I"); - assertThat(actual.get(BlockLocation.blockLocation(l, 0))).containsOnly(103); - assertThat(actual.get(BlockLocation.blockLocation(l, 1))).containsOnly(104); - assertThat(actual.get(BlockLocation.blockLocation(l, 2))).containsOnly(106); + assertThat(actual.get(BlockLocation.blockLocation(l, 0))).containsOnly(105); + assertThat(actual.get(BlockLocation.blockLocation(l, 1))).containsOnly(106); + assertThat(actual.get(BlockLocation.blockLocation(l, 2))).containsOnly(108); } - static class ThreeBlocks2 { int foo(int i) { - if (i > 30 ) { + if (i > 30) { return 1; } return 2; } } - + private Map> analyse(Class clazz) throws ClassNotFoundException { - when(source.fetchClassBytes(any(ClassName.class))).thenReturn( + when(this.source.fetchClassBytes(any(ClassName.class))).thenReturn( Option.some(ClassUtils.classAsBytes(clazz))); - LineMap testee = new LineMapper(source); + LineMap testee = new LineMapper(this.source); return testee.mapLines(ClassName.fromClass(clazz)); } - - - } diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/Bridge.java b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/Bridge.java index 5733a2a0d..993ea434a 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/Bridge.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/Bridge.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage.codeassist.samples; diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithAMethod.java b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithAMethod.java index 1247d8480..7460baf2f 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithAMethod.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithAMethod.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage.codeassist.samples; diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithInitialisedField.java b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithInitialisedField.java index bc1ab3b56..fcb1052fe 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithInitialisedField.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/ClassWithInitialisedField.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage.codeassist.samples; diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/HasDefaultConstructor.java b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/HasDefaultConstructor.java index ec8805805..319f14819 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/HasDefaultConstructor.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/HasDefaultConstructor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage.codeassist.samples; diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/NoDefaultConstructor.java b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/NoDefaultConstructor.java index f68b1904f..de83f94e1 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/samples/NoDefaultConstructor.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/samples/NoDefaultConstructor.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.coverage.codeassist.samples; diff --git a/pitest/src/test/java/org/pitest/coverage/execute/CoverageProcessSystemTest.java b/pitest/src/test/java/org/pitest/coverage/execute/CoverageProcessSystemTest.java index 09682e563..35a119bab 100644 --- a/pitest/src/test/java/org/pitest/coverage/execute/CoverageProcessSystemTest.java +++ b/pitest/src/test/java/org/pitest/coverage/execute/CoverageProcessSystemTest.java @@ -61,7 +61,7 @@ public class CoverageProcessSystemTest { @Test public void shouldRecordSomeCoverage() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coverage = runCoverageForTest(TestsForMultiBlockCoverage.class); assertFalse(coverage.iterator().next().getCoverage().isEmpty()); } @@ -84,14 +84,14 @@ public void shouldCalculateCoverageForSingleBlockMethods() @Test public void shouldCalculateCoverageFor3BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test3", 2); } @Test public void shouldCalculateCoverageForConstructors() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TesteeWithComplexConstructorsTest.class); assertTrue(coversBlock(coveredClasses, "testHigh", 0)); assertTrue(coversBlock(coveredClasses, "testHigh", 1)); @@ -104,91 +104,91 @@ public void shouldCalculateCoverageForConstructors() throws IOException, @Test public void shouldCalculateCoverageFor4BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test4", 2); } @Test public void shouldCalculateCoverageFor5BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test5", 2); } @Test public void shouldCalculateCoverageForBlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test6", 2); } @Test public void shouldCalculateCoverageFor7BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test7", 2); } @Test public void shouldCalculateCoverageFor8BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test8", 2); } @Test public void shouldCalculateCoverageFor9BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test9", 2); } @Test public void shouldCalculateCoverageFor10BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test10", 2); } @Test public void shouldCalculateCoverageFor11BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test11", 2); } @Test public void shouldCalculateCoverageFor12BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test12", 2); } @Test public void shouldCalculateCoverageFor13BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test13", 2); } @Test public void shouldCalculateCoverageFor14BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test14", 2); } @Test public void shouldCalculateCoverageFor15BlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "test15", 2); } @Test public void shouldCalculateCoverageForLargeBlockMethods() throws IOException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { final FunctionalList coveredClasses = runCoverageForTest(TestsForMultiBlockCoverage.class); assertCoverage(coveredClasses, "testMany", 2); } @@ -216,7 +216,7 @@ public void shouldCalculateCoverageForSmallMethodThatThrowsException() .fromClass(ThrowsExceptionTestee.class); assertTrue(coveredClasses.contains(coverageFor(BlockLocation.blockLocation( - Location.location(throwsException, foo, "()V"), 0)))); + Location.location(throwsException, this.foo, "()V"), 0)))); assertTrue(coveredClasses.contains(coverageFor(BlockLocation.blockLocation( Location.location(throwsException, @@ -233,10 +233,10 @@ public void shouldCalculateCoverageForMethodThatThrowsExceptionWithFinallyBlock( .fromClass(ThrowsExceptionInFinallyBlockTestee.class); assertTrue(coveredClasses.contains(coverageFor(BlockLocation.blockLocation( - Location.location(clazz, foo, "()V"), 0)))); + Location.location(clazz, this.foo, "()V"), 0)))); assertTrue(coveredClasses.contains(coverageFor(BlockLocation.blockLocation( - Location.location(clazz, foo, "()V"), 1)))); + Location.location(clazz, this.foo, "()V"), 1)))); } @Test @@ -248,7 +248,7 @@ public void shouldCalculateCoverageForLargeMethodThatThrowsException() .fromClass(ThrowsExceptionFromLargeMethodTestee.class); assertTrue(coveredClasses.contains(coverageFor(BlockLocation.blockLocation( - Location.location(clazz, foo, "()I"), 0)))); + Location.location(clazz, this.foo, "()I"), 0)))); } @@ -301,6 +301,7 @@ public void shouldNotCorruptedTheSystemNewLineProperty() throws Exception { @Test public void shouldFailWithExitCode() throws Exception { final SideEffect1 noOpHandler = new SideEffect1() { + @Override public void apply(final CoverageResult a) { } }; @@ -324,6 +325,7 @@ public void apply(final CoverageResult a) { private ClassPath classPathWithoutJUnit() { FunctionalList cpWithoutJUnit = FCollection.filter( ClassPath.getClassPathElementsAsFiles(), new F() { + @Override public Boolean apply(File file) { return !file.getName().contains("junit"); } @@ -335,6 +337,7 @@ public Boolean apply(File file) { private F failingTest() { return new F() { + @Override public Boolean apply(final CoverageResult a) { return !a.isGreenTest(); } @@ -356,6 +359,7 @@ private void runCoverageProcess(final Class test, InterruptedException { final SideEffect1 handler = new SideEffect1() { + @Override public void apply(final CoverageResult a) { coveredClasses.add(a); } @@ -384,6 +388,7 @@ public void apply(final CoverageResult a) { private F coverageFor(final Class class1) { return new F() { + @Override public Boolean apply(final CoverageResult a) { return FCollection.contains(a.getCoverage(), resultFor(class1)); } @@ -391,6 +396,7 @@ public Boolean apply(final CoverageResult a) { private F resultFor(final Class class1) { return new F() { + @Override public Boolean apply(final BlockLocation a) { return a.isFor(ClassName.fromClass(class1)); @@ -403,6 +409,7 @@ public Boolean apply(final BlockLocation a) { private F coverageFor(final BlockLocation location) { return new F() { + @Override public Boolean apply(final CoverageResult a) { return a.getCoverage().contains(location); } @@ -413,6 +420,7 @@ private Predicate coverOnlyTestees() { return new Predicate() { + @Override public Boolean apply(final String a) { return a.contains("Testee") && !a.endsWith("Test"); } @@ -424,6 +432,7 @@ private F coverage(final String testName, final int numberOfBlocks) { return new F() { + @Override public Boolean apply(final CoverageResult a) { return a.getTestUnitDescription().getName().startsWith(testName) && (a.getNumberOfCoveredBlocks() == numberOfBlocks); @@ -447,6 +456,7 @@ private boolean coversBlock( private F hitsBlock(final String testName, final int block) { return new F() { + @Override public Boolean apply(final CoverageResult a) { return a.getTestUnitDescription().getName().startsWith(testName) && (FCollection.contains(a.getCoverage(), hasBlock(block))); @@ -454,6 +464,7 @@ public Boolean apply(final CoverageResult a) { private F hasBlock(final int block) { return new F() { + @Override public Boolean apply(BlockLocation a) { System.out.println(a); return a.getBlock() == block; diff --git a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java index 0835f336d..25c884412 100644 --- a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java +++ b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java @@ -68,7 +68,7 @@ public void shouldReturnOnlyTestUnitsForClassesWithinReach() when( this.extractor.extractCallDependenciesForPackages(eq(this.aTestUnit .getDescription().getFirstTestClass()), any(Predicate.class))) - .thenReturn(Arrays.asList("foo")); + .thenReturn(Arrays.asList("foo")); when( this.extractor.extractCallDependenciesForPackages( eq(this.anotherTestUnit.getDescription().getFirstTestClass()), @@ -87,7 +87,7 @@ public void shouldNotRecalculateDependenciesForAlreadyAnalysedClasses() when( this.extractor.extractCallDependenciesForPackages(eq(this.aTestUnit .getDescription().getFirstTestClass()), any(Predicate.class))) - .thenReturn(Arrays.asList("foo")); + .thenReturn(Arrays.asList("foo")); this.tus = Arrays.asList(this.aTestUnit, this.aTestUnit); @@ -100,10 +100,12 @@ public void shouldNotRecalculateDependenciesForAlreadyAnalysedClasses() private TestUnit makeTestUnit(final Description d) { return new TestUnit() { + @Override public void execute(final ClassLoader loader, final ResultCollector rc) { } + @Override public Description getDescription() { return d; } diff --git a/pitest/src/test/java/org/pitest/coverage/execute/ReceiveTest.java b/pitest/src/test/java/org/pitest/coverage/execute/ReceiveTest.java index 2b37771ed..5ad4d4124 100644 --- a/pitest/src/test/java/org/pitest/coverage/execute/ReceiveTest.java +++ b/pitest/src/test/java/org/pitest/coverage/execute/ReceiveTest.java @@ -40,6 +40,7 @@ public void setUp() { private SideEffect1 stubHandler() { return new SideEffect1() { + @Override public void apply(final CoverageResult a) { ReceiveTest.this.result = a; } @@ -64,13 +65,12 @@ public void shouldReportWhenTestPasses() { assertEquals(true, this.result.isGreenTest()); } - private void recordTestCoverage(final int executionTime, final int classId, final int probeNumber, final boolean testPassed) { when(this.is.readInt()).thenReturn(classId, executionTime); when(this.is.readString()).thenReturn("foo"); this.testee.apply(Id.CLAZZ, this.is); - + when(this.is.read(Description.class)).thenReturn(this.description); when(this.is.readInt()).thenReturn(1); when(this.is.readLong()).thenReturn(1l, diff --git a/pitest/src/test/java/org/pitest/coverage/execute/SendDataTest.java b/pitest/src/test/java/org/pitest/coverage/execute/SendDataTest.java index 298e02e7b..8b4937af5 100644 --- a/pitest/src/test/java/org/pitest/coverage/execute/SendDataTest.java +++ b/pitest/src/test/java/org/pitest/coverage/execute/SendDataTest.java @@ -9,8 +9,6 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.pitest.coverage.execute.CoverageOptions; -import org.pitest.coverage.execute.SendData; import org.pitest.util.SafeDataOutputStream; public class SendDataTest { diff --git a/pitest/src/test/java/org/pitest/coverage/export/DefaultCoverageExporterTest.java b/pitest/src/test/java/org/pitest/coverage/export/DefaultCoverageExporterTest.java index 6cd72de4b..36def9ad0 100644 --- a/pitest/src/test/java/org/pitest/coverage/export/DefaultCoverageExporterTest.java +++ b/pitest/src/test/java/org/pitest/coverage/export/DefaultCoverageExporterTest.java @@ -32,6 +32,7 @@ public void setup() { private ResultOutputStrategy createOutputStrategy() { return new ResultOutputStrategy() { + @Override public Writer createWriterForFile(final String sourceFile) { return DefaultCoverageExporterTest.this.out; } @@ -43,7 +44,7 @@ public Writer createWriterForFile(final String sourceFile) { public void shouldWriteValidXMLDocumentWhenNoCoverage() { this.testee.recordCoverage(Collections. emptyList()); String actual = this.out.toString(); - assertThat(actual).contains(""); + assertThat(actual).contains(""); assertThat(actual).contains(""); assertThat(actual).contains(""); } @@ -53,17 +54,23 @@ public void shouldExportSuppliedCoverage() { LocationBuilder loc = aLocation().withMethod("method"); BlockLocationBuilder block = aBlockLocation().withBlock(42); final Collection coverage = Arrays.asList( - new BlockCoverage(block.withLocation(loc.withClass(ClassName.fromString("Foo"))).build(), Arrays.asList("Test1", - "Test2")), - new BlockCoverage(block.withLocation(loc.withClass(ClassName.fromString("Bar"))).build(), Arrays.asList("Test3", - "Test4"))); + new BlockCoverage(block.withLocation( + loc.withClass(ClassName.fromString("Foo"))).build(), Arrays.asList( + "Test1", "Test2")), + new BlockCoverage(block.withLocation( + loc.withClass(ClassName.fromString("Bar"))).build(), Arrays.asList( + "Test3", "Test4"))); this.testee.recordCoverage(coverage); String actual = this.out.toString(); - assertThat(actual).contains(""); - assertThat(actual).contains(""); - assertThat(actual).contains("\n\n\n"); - assertThat(actual).contains("\n\n\n"); + assertThat(actual).contains( + ""); + assertThat(actual).contains( + ""); + assertThat(actual).contains( + "\n\n\n"); + assertThat(actual).contains( + "\n\n\n"); } } diff --git a/pitest/src/test/java/org/pitest/dependency/DependencyAccessTest.java b/pitest/src/test/java/org/pitest/dependency/DependencyAccessTest.java index 5cf1fa4de..e38dd0907 100644 --- a/pitest/src/test/java/org/pitest/dependency/DependencyAccessTest.java +++ b/pitest/src/test/java/org/pitest/dependency/DependencyAccessTest.java @@ -9,6 +9,6 @@ public class DependencyAccessTest { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(DependencyAccess.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/dependency/DependencyClassVisitorTest.java b/pitest/src/test/java/org/pitest/dependency/DependencyClassVisitorTest.java index f8ba410ad..e0e06c7d3 100644 --- a/pitest/src/test/java/org/pitest/dependency/DependencyClassVisitorTest.java +++ b/pitest/src/test/java/org/pitest/dependency/DependencyClassVisitorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.dependency; @@ -42,6 +42,7 @@ public class DependencyClassVisitorTest { @Before public void setUp() { final SideEffect1 se = new SideEffect1() { + @Override public void apply(final DependencyAccess a) { DependencyClassVisitorTest.this.gatheredAccess.add(a); DependencyClassVisitorTest.this.gatheredDependencies.add(a.getDest() @@ -111,6 +112,7 @@ private Set classesToNames(final Class... classes) { private F, String> classToJvmName() { return new F, String>() { + @Override public String apply(final Class a) { return a.getName().replace(".", "/"); } diff --git a/pitest/src/test/java/org/pitest/dependency/DependencyExtractorTest.java b/pitest/src/test/java/org/pitest/dependency/DependencyExtractorTest.java index 82903e962..b5a046c0c 100644 --- a/pitest/src/test/java/org/pitest/dependency/DependencyExtractorTest.java +++ b/pitest/src/test/java/org/pitest/dependency/DependencyExtractorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -136,6 +136,7 @@ public void shouldHandleCyclicDependencies() throws Exception { private Predicate ignoreCoreClasses() { return new Predicate() { + @Override public Boolean apply(final DependencyAccess a) { return !a.getDest().getOwner().startsWith("java"); } @@ -147,6 +148,7 @@ public Boolean apply(final DependencyAccess a) { private Predicate includeOnlyThingsCalled(final String subString) { return new Predicate() { + @Override public Boolean apply(final String a) { return a.contains(subString); } @@ -161,6 +163,7 @@ private void constructWithDepthOf(final int depth) { private Predicate excludeMethodsCalledOne() { return new Predicate() { + @Override public Boolean apply(final DependencyAccess a) { return !a.getSource().getName().equals("one"); } diff --git a/pitest/src/test/java/org/pitest/dependency/IgnoreCoreClassesTest.java b/pitest/src/test/java/org/pitest/dependency/IgnoreCoreClassesTest.java index fcdf8921f..431be90c1 100644 --- a/pitest/src/test/java/org/pitest/dependency/IgnoreCoreClassesTest.java +++ b/pitest/src/test/java/org/pitest/dependency/IgnoreCoreClassesTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/functional/FArrayTest.java b/pitest/src/test/java/org/pitest/functional/FArrayTest.java index 8cd257a25..597df8abe 100644 --- a/pitest/src/test/java/org/pitest/functional/FArrayTest.java +++ b/pitest/src/test/java/org/pitest/functional/FArrayTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.pitest.functional; @@ -20,7 +20,7 @@ /** * @author henry - * + * */ public class FArrayTest { @@ -41,6 +41,7 @@ public void shouldReturnEmptyListWhenFilteredOnFalse() { @Test public void shouldReturnOnlyMatchesToPredicate() { final Predicate p = new Predicate() { + @Override public Boolean apply(final Integer a) { return a <= 2; } @@ -57,6 +58,7 @@ public void shouldReturnEmptyListWhenGivenNull() { @Test public void shouldApplyFlatMapToAllItems() { final F> f = new F>() { + @Override public List apply(final Integer a) { return Arrays.asList(a, a); } @@ -74,6 +76,7 @@ public void flatMapShouldTreatNullAsEmptyIterable() { private F> objectToObjectIterable() { return new F>() { + @Override public Option apply(final Object a) { return Option.some(a); } @@ -98,6 +101,7 @@ public void containsShouldStopProcessingOnFirstMatch() { final Integer[] xs = { 1, 2, 3 }; final Predicate predicate = new Predicate() { + @Override public Boolean apply(final Integer a) { if (a == 2) { throw new PitError("Did not shortcut"); diff --git a/pitest/src/test/java/org/pitest/functional/FCollectionTest.java b/pitest/src/test/java/org/pitest/functional/FCollectionTest.java index 6ed0edc9c..704feb6da 100644 --- a/pitest/src/test/java/org/pitest/functional/FCollectionTest.java +++ b/pitest/src/test/java/org/pitest/functional/FCollectionTest.java @@ -1,11 +1,11 @@ /** - * + * */ package org.pitest.functional; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertTrue; import java.util.ArrayList; @@ -26,7 +26,7 @@ /** * @author henry - * + * */ public class FCollectionTest { @@ -52,6 +52,7 @@ public void shouldReturnEmptyListWhenFilteredOnFalse() { @Test public void shouldReturnOnlyMatchesToPredicate() { final Predicate p = new Predicate() { + @Override public Boolean apply(final Integer a) { return a <= 2; } @@ -64,6 +65,7 @@ public Boolean apply(final Integer a) { public void shouldApplyForEachToAllItems() { final List actual = new ArrayList(); final SideEffect1 e = new SideEffect1() { + @Override public void apply(final Integer a) { actual.add(a); } @@ -88,6 +90,7 @@ public void mapShouldTreatNullAsAnEmptyIterable() { @Test public void shouldApplyFlatMapToAllItems() { final F> f = new F>() { + @Override public List apply(final Integer a) { return Arrays.asList(a, a); } @@ -105,6 +108,7 @@ public void flatMapShouldTreatNullAsEmptyIterable() { private F> objectToObjectIterable() { return new F>() { + @Override public Option apply(final Object a) { return Option.some(a); } @@ -129,6 +133,7 @@ public void containsShouldStopProcessingOnFirstMatch() { final Collection xs = Arrays.asList(1, 2, 3); final Predicate predicate = new Predicate() { + @Override public Boolean apply(final Integer a) { if (a == 2) { throw new PitError("Did not shortcut"); @@ -146,6 +151,7 @@ public void foldShouldFoldValues() { final Collection xs = Arrays.asList(1, 2, 3); final F2 f = new F2() { + @Override public Integer apply(final Integer a, final Integer b) { return a + b; } @@ -217,6 +223,7 @@ public void shouldSplitIntoMultipleBuckets() { private F fortyTwo() { return new F() { + @Override public Integer apply(final Integer a) { return 42; } diff --git a/pitest/src/test/java/org/pitest/functional/MutableListTest.java b/pitest/src/test/java/org/pitest/functional/MutableListTest.java index 79cc35b3f..e6525d87d 100644 --- a/pitest/src/test/java/org/pitest/functional/MutableListTest.java +++ b/pitest/src/test/java/org/pitest/functional/MutableListTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional; @@ -210,9 +210,9 @@ public void shouldBeAbleToCreateSubList() { this.testee.addAll(Arrays.asList(2, 4, 6, 8)); assertEquals(Arrays.asList(4, 6), this.testee.subList(1, 3)); } - + @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(MutableList.class).verify(); - } + } } diff --git a/pitest/src/test/java/org/pitest/functional/OptionTest.java b/pitest/src/test/java/org/pitest/functional/OptionTest.java index 5ce4e23c8..1c56c5856 100644 --- a/pitest/src/test/java/org/pitest/functional/OptionTest.java +++ b/pitest/src/test/java/org/pitest/functional/OptionTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -150,8 +150,7 @@ public void shouldImplementContains() { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(Some.class).verify(); - EqualsVerifier.forClass(None.class).verify(); - } - - + EqualsVerifier.forClass(None.class).verify(); + } + } diff --git a/pitest/src/test/java/org/pitest/functional/predicate/FalseTest.java b/pitest/src/test/java/org/pitest/functional/predicate/FalseTest.java index 34247478b..c286cd8bb 100644 --- a/pitest/src/test/java/org/pitest/functional/predicate/FalseTest.java +++ b/pitest/src/test/java/org/pitest/functional/predicate/FalseTest.java @@ -6,7 +6,7 @@ /** * @author henry - * + * */ public class FalseTest { diff --git a/pitest/src/test/java/org/pitest/functional/predicate/NotTest.java b/pitest/src/test/java/org/pitest/functional/predicate/NotTest.java index d0002c38f..5ae42889c 100644 --- a/pitest/src/test/java/org/pitest/functional/predicate/NotTest.java +++ b/pitest/src/test/java/org/pitest/functional/predicate/NotTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.pitest.functional.predicate; @@ -11,7 +11,7 @@ /** * @author henry - * + * */ public class NotTest { diff --git a/pitest/src/test/java/org/pitest/functional/predicate/TrueTest.java b/pitest/src/test/java/org/pitest/functional/predicate/TrueTest.java index 5e819442c..01be4d622 100644 --- a/pitest/src/test/java/org/pitest/functional/predicate/TrueTest.java +++ b/pitest/src/test/java/org/pitest/functional/predicate/TrueTest.java @@ -6,7 +6,7 @@ /** * @author henry - * + * */ public class TrueTest { diff --git a/pitest/src/test/java/org/pitest/functional/prelude/PreludeTest.java b/pitest/src/test/java/org/pitest/functional/prelude/PreludeTest.java index 0626de2f7..8a87924e0 100644 --- a/pitest/src/test/java/org/pitest/functional/prelude/PreludeTest.java +++ b/pitest/src/test/java/org/pitest/functional/prelude/PreludeTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.functional.prelude; @@ -22,7 +22,6 @@ import org.junit.Test; import org.mockito.Mockito; -import org.pitest.functional.prelude.Prelude; public class PreludeTest { diff --git a/pitest/src/test/java/org/pitest/help/PitHelpErrorTest.java b/pitest/src/test/java/org/pitest/help/PitHelpErrorTest.java index b9f2a5bdc..2f28e7682 100644 --- a/pitest/src/test/java/org/pitest/help/PitHelpErrorTest.java +++ b/pitest/src/test/java/org/pitest/help/PitHelpErrorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/junit/JUnit4SuiteFinderTest.java b/pitest/src/test/java/org/pitest/junit/JUnit4SuiteFinderTest.java index 65e3ed4f9..2c38e4a8b 100644 --- a/pitest/src/test/java/org/pitest/junit/JUnit4SuiteFinderTest.java +++ b/pitest/src/test/java/org/pitest/junit/JUnit4SuiteFinderTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit; @@ -53,7 +53,7 @@ private static class AnnotatedJUnit { @Test public void shouldReturnTestClassForEachClassInSuiteClassesAnnotationWhenRunnerIsSuite() { final Class annotated = HideFromJUnit.AnnotatedJUnit.class; - final Collection> expected = Arrays.>asList( + final Collection> expected = Arrays.> asList( String.class, Integer.class); assertEquals(expected, this.testee.apply(annotated)); } diff --git a/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java b/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java index c3992f2fe..09cf69bb5 100644 --- a/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java +++ b/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,11 @@ import junit.framework.TestSuite; import org.jmock.MockObjectTestCase; -import org.junit.*; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; import org.junit.rules.ExternalResource; import org.junit.rules.TestRule; import org.junit.runner.RunWith; @@ -237,7 +241,8 @@ public static class ClassRuleMethod { @ClassRule public static TestRule rule() { - return new ExternalResource() {}; + return new ExternalResource() { + }; } @Test @@ -250,7 +255,8 @@ public void testTwo() { } @Test - public void shouldCreateSingleAtomicUnitWhenAnyMethodAnnotatedWithClassRule() throws Exception { + public void shouldCreateSingleAtomicUnitWhenAnyMethodAnnotatedWithClassRule() + throws Exception { final Collection actual = findWithTestee(ClassRuleMethod.class); assertEquals(1, actual.size()); } @@ -258,7 +264,8 @@ public void shouldCreateSingleAtomicUnitWhenAnyMethodAnnotatedWithClassRule() th public static class ClassRuleField { @ClassRule - public static TestRule rule = new ExternalResource() {}; + public static TestRule rule = new ExternalResource() { + }; @Test public void testOne() { @@ -270,7 +277,8 @@ public void testTwo() { } @Test - public void shouldCreateSingleAtomicUnitWhenAnyFieldAnnotatedWithClassRule() throws Exception { + public void shouldCreateSingleAtomicUnitWhenAnyFieldAnnotatedWithClassRule() + throws Exception { final Collection actual = findWithTestee(ClassRuleMethod.class); assertEquals(1, actual.size()); } diff --git a/pitest/src/test/java/org/pitest/junit/JUnitTestClassIdentifierTest.java b/pitest/src/test/java/org/pitest/junit/JUnitTestClassIdentifierTest.java index 9faeba9e1..f6cd5f6e4 100644 --- a/pitest/src/test/java/org/pitest/junit/JUnitTestClassIdentifierTest.java +++ b/pitest/src/test/java/org/pitest/junit/JUnitTestClassIdentifierTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,6 +14,12 @@ */ package org.pitest.junit; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + import junit.framework.TestCase; import org.junit.Before; @@ -27,22 +33,17 @@ import org.pitest.testapi.TestGroupConfig; import org.pitest.util.IsolationUtils; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class JUnitTestClassIdentifierTest { private JUnitTestClassIdentifier testee; private Repository classRepostory; - private List excludedGroups = new ArrayList(); - private List includedGroups = new ArrayList(); + private final List excludedGroups = new ArrayList(); + private final List includedGroups = new ArrayList(); @Before public void setUp() { - TestGroupConfig groupConfig = new TestGroupConfig(excludedGroups, includedGroups); + TestGroupConfig groupConfig = new TestGroupConfig(this.excludedGroups, + this.includedGroups); this.testee = new JUnitTestClassIdentifier(groupConfig); this.classRepostory = new Repository(new ClassloaderByteArraySource( IsolationUtils.getContextClassLoader())); @@ -110,24 +111,33 @@ public void shouldRecogniseDecendentsOfTestsAsTestsClasses() { assertTrue(this.testee.isATestClass(find(DescendentOfTest.class))); } - private interface AlphaTests {} - private interface BetaTests {} - private interface GammaTests {} + private interface AlphaTests { + } + + private interface BetaTests { + } + + private interface GammaTests { + } - private class NoCategoryTest extends HasTestAnnotation {} + private class NoCategoryTest extends HasTestAnnotation { + } @Category(AlphaTests.class) - private class AlphaCategoryTest extends HasTestAnnotation {} + private class AlphaCategoryTest extends HasTestAnnotation { + } @Category(BetaTests.class) - private class BetaCategoryTest extends HasTestAnnotation {} + private class BetaCategoryTest extends HasTestAnnotation { + } - @Category({BetaTests.class, GammaTests.class}) - private class TwoCategoryTest extends HasTestAnnotation {} + @Category({ BetaTests.class, GammaTests.class }) + private class TwoCategoryTest extends HasTestAnnotation { + } @Test public void shouldIncludeEverythingWhenNoCategoriesSpecified() { - includedGroups.clear(); + this.includedGroups.clear(); assertTrue(this.testee.isIncluded(find(NoCategoryTest.class))); assertTrue(this.testee.isIncluded(find(AlphaCategoryTest.class))); assertTrue(this.testee.isIncluded(find(BetaCategoryTest.class))); @@ -136,7 +146,7 @@ public void shouldIncludeEverythingWhenNoCategoriesSpecified() { @Test public void shouldOnlyIncludeTestsInIncludedCategories() { - includedGroups.add(BetaTests.class.getName()); + this.includedGroups.add(BetaTests.class.getName()); assertFalse(this.testee.isIncluded(find(NoCategoryTest.class))); assertFalse(this.testee.isIncluded(find(AlphaCategoryTest.class))); assertTrue(this.testee.isIncluded(find(BetaCategoryTest.class))); @@ -145,7 +155,7 @@ public void shouldOnlyIncludeTestsInIncludedCategories() { @Test public void shouldNotExcludeWhenNoCategoriesSpecified() { - excludedGroups.clear(); + this.excludedGroups.clear(); assertTrue(this.testee.isIncluded(find(NoCategoryTest.class))); assertTrue(this.testee.isIncluded(find(AlphaCategoryTest.class))); assertTrue(this.testee.isIncluded(find(BetaCategoryTest.class))); @@ -154,7 +164,7 @@ public void shouldNotExcludeWhenNoCategoriesSpecified() { @Test public void shouldOnlyExcludeTestsInExcludedCategories() { - excludedGroups.add(BetaTests.class.getName()); + this.excludedGroups.add(BetaTests.class.getName()); assertTrue(this.testee.isIncluded(find(NoCategoryTest.class))); assertTrue(this.testee.isIncluded(find(AlphaCategoryTest.class))); assertFalse(this.testee.isIncluded(find(BetaCategoryTest.class))); diff --git a/pitest/src/test/java/org/pitest/junit/ParameterisedJUnitTestFinderTest.java b/pitest/src/test/java/org/pitest/junit/ParameterisedJUnitTestFinderTest.java index f19779691..fdbcf5c78 100644 --- a/pitest/src/test/java/org/pitest/junit/ParameterisedJUnitTestFinderTest.java +++ b/pitest/src/test/java/org/pitest/junit/ParameterisedJUnitTestFinderTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit; diff --git a/pitest/src/test/java/org/pitest/junit/RunnerSuiteFinderTest.java b/pitest/src/test/java/org/pitest/junit/RunnerSuiteFinderTest.java index d9db46051..506e55da6 100644 --- a/pitest/src/test/java/org/pitest/junit/RunnerSuiteFinderTest.java +++ b/pitest/src/test/java/org/pitest/junit/RunnerSuiteFinderTest.java @@ -60,8 +60,8 @@ static class CustomSuite { @Test public void shouldFindSuiteClassesInCustomSuite() { final Collection> actual = findWithTestee(CustomSuite.class); - final Collection> expected = Arrays.>asList( - One.class, Two.class); + final Collection> expected = Arrays.> asList(One.class, + Two.class); assertContains(expected, actual); } @@ -80,8 +80,8 @@ public static junit.framework.Test suite() { @Test public void shouldFindSuiteClassesInJUnit3Suite() { final Collection> actual = findWithTestee(JUnit3Suite.class); - final Collection> expected = Arrays.>asList( - One.class, Two.class); + final Collection> expected = Arrays.> asList(One.class, + Two.class); assertContains(expected, actual); } @@ -102,16 +102,16 @@ public static junit.framework.Test suite() { @Test public void shouldFindSuiteClassesInJUnit3SuiteMethod() { final Collection> actual = findWithTestee(JUnit3SuiteMethod.class); - final Collection> expected = Arrays.>asList( - One.class, Two.class); + final Collection> expected = Arrays.> asList(One.class, + Two.class); assertContains(expected, actual); } @Test public void shouldFindSuiteClasseInNestedJUnit3Suite() { final Collection> actual = findWithTestee(com.example.JUnitThreeSuite.class); - final Collection> expected = Arrays.>asList( - com.example.JUnitThreeTest.class); + final Collection> expected = Arrays + .> asList(com.example.JUnitThreeTest.class); assertContains(expected, actual); } diff --git a/pitest/src/test/java/org/pitest/junit/TestInfoTest.java b/pitest/src/test/java/org/pitest/junit/TestInfoTest.java index 2192df9fe..e4fecb55f 100644 --- a/pitest/src/test/java/org/pitest/junit/TestInfoTest.java +++ b/pitest/src/test/java/org/pitest/junit/TestInfoTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -70,7 +70,7 @@ static class Nested { public void isWithinATestClassShouldReturnTrueForNestedClassesWithinATest() { assertTrue(TestInfo.isWithinATestClass(fetchClass(Nested.class))); } - + private ClassInfo fetchClass(final Class clazz) { return this.repository.fetchClass(clazz).value(); } diff --git a/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java b/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java index f4a49bbf3..a096adb89 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit.adapter; @@ -143,6 +143,7 @@ public String describe() { private ClassLoaderDetectionStrategy neverMatchLoaderDetectionStrategy() { return new ClassLoaderDetectionStrategy() { + @Override public boolean fromDifferentLoader(final Class clazz, final ClassLoader loader) { return true; diff --git a/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java b/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java index e6fcb4f07..77dc375d6 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit.adapter; @@ -30,17 +30,17 @@ public class AdaptingRunListenerTest { - private AdaptingRunListener testee; + private AdaptingRunListener testee; private org.pitest.testapi.Description pitDescription; - private Throwable throwable; + private Throwable throwable; @Mock - private Description junitDesc; + private Description junitDesc; @Mock - private ResultCollector rc; + private ResultCollector rc; @Before public void setUp() { diff --git a/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java b/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java index d8595b986..57a5cddb6 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit.adapter; diff --git a/pitest/src/test/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListenerTest.java b/pitest/src/test/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListenerTest.java index 6ae4dff19..f9237016e 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListenerTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/ForeignClassLoaderAdaptingRunListenerTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.junit.adapter; @@ -42,7 +42,7 @@ public class ForeignClassLoaderAdaptingRunListenerTest { @Mock private Throwable throwable; - private org.pitest.testapi.Description pitDescription; + private org.pitest.testapi.Description pitDescription; @Mock private Description junitDesc; @@ -106,7 +106,6 @@ public void shouldReportStartedTests() throws Exception { } private void applyEvents() { - Events.applyEvents(this.queue, this.rc, - this.pitDescription); + Events.applyEvents(this.queue, this.rc, this.pitDescription); } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/DetectionStatusTest.java b/pitest/src/test/java/org/pitest/mutationtest/DetectionStatusTest.java index 13a68dd65..f6b55efa4 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/DetectionStatusTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/DetectionStatusTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,6 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; -import org.pitest.mutationtest.DetectionStatus; import org.pitest.util.ExitCode; public class DetectionStatusTest { @@ -69,22 +68,22 @@ public void shouldConsiderRunErrorAsDetected() { public void shouldConsiderUnCoveredKilledMutationsToBeUnDetected() { assertFalse(DetectionStatus.NO_COVERAGE.isDetected()); } - + @Test public void shouldConverytutOfMemoryExitCode() { assertEquals(DetectionStatus.MEMORY_ERROR, DetectionStatus.getForErrorExitCode(ExitCode.OUT_OF_MEMORY)); } - + @Test public void shouldConvertTimeOutExitCode() { assertEquals(DetectionStatus.TIMED_OUT, DetectionStatus.getForErrorExitCode(ExitCode.TIMEOUT)); } - + @Test public void shouldConvertUnknownErrorExitCode() { assertEquals(DetectionStatus.RUN_ERROR, - DetectionStatus.getForErrorExitCode(ExitCode.UNKNOWN_ERROR )); + DetectionStatus.getForErrorExitCode(ExitCode.UNKNOWN_ERROR)); } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/LocationMother.java b/pitest/src/test/java/org/pitest/mutationtest/LocationMother.java index fc6083753..716b1ca24 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/LocationMother.java +++ b/pitest/src/test/java/org/pitest/mutationtest/LocationMother.java @@ -12,9 +12,10 @@ public class LocationMother { public interface MutationIdentifierBuilder extends - SequenceBuilder { + SequenceBuilder { MutationIdentifierBuilder withLocation(Location location); + MutationIdentifierBuilder withLocation(Builder location); MutationIdentifierBuilder withIndex(int index); @@ -43,7 +44,7 @@ public interface LocationBuilder extends SequenceBuilder { String _MethodDescription(); } - + public static LocationBuilder aLocation(String clazz) { return aLocation().withClass(ClassName.fromString(clazz)); } @@ -56,6 +57,7 @@ public static LocationBuilder aLocation() { private static Generator locationSeed() { return new Generator() { + @Override public Location generate(LocationBuilder b) { return Location.location(b._Class(), MethodName.fromString(b._Method()), b._MethodDescription()); @@ -70,6 +72,7 @@ public static MutationIdentifierBuilder aMutationId() { private static Generator idSeed() { return new Generator() { + @Override public MutationIdentifier generate(MutationIdentifierBuilder b) { return new MutationIdentifier(b._Location(), b._Index(), b._Mutator()); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/MetaDataExtractor.java b/pitest/src/test/java/org/pitest/mutationtest/MetaDataExtractor.java index 32979ee61..b0e81c143 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/MetaDataExtractor.java +++ b/pitest/src/test/java/org/pitest/mutationtest/MetaDataExtractor.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,6 +42,7 @@ public List getLineNumbers() { public int getNumberOfTestsRun() { final F2 sum = new F2() { + @Override public Integer apply(final Integer a, final MutationResult b) { return a + b.getNumberOfTestsRun(); } @@ -50,14 +51,17 @@ public Integer apply(final Integer a, final MutationResult b) { return FCollection.fold(sum, 0, this.data); } + @Override public void runStart() { } + @Override public void handleMutationResult(final ClassMutationResults metaData) { this.data.addAll(metaData.getMutations()); } + @Override public void runEnd() { // TODO Auto-generated method stub diff --git a/pitest/src/test/java/org/pitest/mutationtest/Mutable.java b/pitest/src/test/java/org/pitest/mutationtest/Mutable.java index 0e27a0330..50f359a11 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/Mutable.java +++ b/pitest/src/test/java/org/pitest/mutationtest/Mutable.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest; diff --git a/pitest/src/test/java/org/pitest/mutationtest/MutableIncrement.java b/pitest/src/test/java/org/pitest/mutationtest/MutableIncrement.java index cfcb6ff18..0d4634617 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/MutableIncrement.java +++ b/pitest/src/test/java/org/pitest/mutationtest/MutableIncrement.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest; diff --git a/pitest/src/test/java/org/pitest/mutationtest/MutationCoverageReportSystemTest.java b/pitest/src/test/java/org/pitest/mutationtest/MutationCoverageReportSystemTest.java index 0c4729283..ae2ab62fb 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/MutationCoverageReportSystemTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/MutationCoverageReportSystemTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -91,7 +91,7 @@ public void shouldReportUnCoveredMutations() { @Test public void shouldReportSurvivingMutations() { this.data - .setTargetClasses(predicateFor("com.example.CoveredButOnlyPartiallyTested*")); + .setTargetClasses(predicateFor("com.example.CoveredButOnlyPartiallyTested*")); createAndRun(); verifyResults(KILLED, SURVIVED); } @@ -100,7 +100,7 @@ public void shouldReportSurvivingMutations() { public void shouldKillMutationsInStaticInitializersWhenThereIsCoverageAndMutateStaticFlagIsSet() { this.data.setMutateStaticInitializers(true); this.data - .setTargetClasses(predicateFor("com.example.HasMutableStaticInitializer*")); + .setTargetClasses(predicateFor("com.example.HasMutableStaticInitializer*")); createAndRun(); verifyResults(KILLED); } @@ -109,7 +109,7 @@ public void shouldKillMutationsInStaticInitializersWhenThereIsCoverageAndMutateS public void shouldNotCreateMutationsInStaticInitializersWhenFlagNotSet() { this.data.setMutateStaticInitializers(false); this.data - .setTargetClasses(predicateFor("com.example.HasMutableStaticInitializer*")); + .setTargetClasses(predicateFor("com.example.HasMutableStaticInitializer*")); createAndRun(); verifyResults(); } @@ -118,7 +118,7 @@ public void shouldNotCreateMutationsInStaticInitializersWhenFlagNotSet() { public void shouldFailRunWithHelpfulMessageIfTestsNotGreen() { setMutators("MATH"); this.data - .setTargetClasses(predicateFor("com.example.FailsTestWhenEnvVariableSet*")); + .setTargetClasses(predicateFor("com.example.FailsTestWhenEnvVariableSet*")); this.data.addChildJVMArgs(Arrays.asList("-D" + FailsTestWhenEnvVariableSetTestee.class.getName() + "=true")); createAndRun(); @@ -129,9 +129,9 @@ public void shouldFailRunWithHelpfulMessageIfTestsNotGreen() { public void shouldOnlyRunTestsMathchingSuppliedFilter() { this.data.setMutateStaticInitializers(true); this.data - .setTargetClasses(predicateFor(com.example.HasMutableStaticInitializer.class)); + .setTargetClasses(predicateFor(com.example.HasMutableStaticInitializer.class)); this.data - .setTargetTests(predicateFor(com.example.HasMutableStaticInitializerTest.class)); + .setTargetTests(predicateFor(com.example.HasMutableStaticInitializerTest.class)); createAndRun(); verifyResults(KILLED); } @@ -140,7 +140,7 @@ public void shouldOnlyRunTestsMathchingSuppliedFilter() { public void shouldLoadResoucesOffClassPathFromFolderWithSpaces() { setMutators("RETURN_VALS"); this.data - .setTargetClasses(predicateFor("com.example.LoadsResourcesFromClassPath*")); + .setTargetClasses(predicateFor("com.example.LoadsResourcesFromClassPath*")); createAndRun(); verifyResults(KILLED); } @@ -149,7 +149,7 @@ public void shouldLoadResoucesOffClassPathFromFolderWithSpaces() { public void shouldPickRelevantTestsFromSuppliedTestSuites() { this.data.setTargetClasses(predicateFor("com.example.FullyCovered*")); this.data - .setTargetTests(predicateFor(com.example.SuiteForFullyCovered.class)); + .setTargetTests(predicateFor(com.example.SuiteForFullyCovered.class)); createAndRun(); verifyResults(KILLED); } @@ -166,7 +166,7 @@ public void shouldNotMutateMethodsMatchingExclusionPredicate() { public void shouldLimitNumberOfMutationsPerClass() { this.data.setTargetClasses(predicateFor(MultipleMutations.class)); this.data - .setTargetTests(predicateFor(com.example.FullyCoveredTesteeTest.class)); + .setTargetTests(predicateFor(com.example.FullyCoveredTesteeTest.class)); this.data.setMaxMutationsPerClass(1); createAndRun(); verifyResults(NO_COVERAGE); @@ -217,7 +217,7 @@ public void shouldExcludeFilteredTests() { @Test public void willAllowExcludedClassesToBeReIncludedViaSuite() { this.data - .setTargetTests(predicateFor("com.example.*SuiteForFullyCovered*")); + .setTargetTests(predicateFor("com.example.*SuiteForFullyCovered*")); this.data.setTargetClasses(predicateFor("com.example.FullyCovered*")); this.data.setExcludedClasses(predicateFor(FullyCoveredTesteeTest.class)); createAndRun(); @@ -246,11 +246,11 @@ public void shouldMutateClassesSuppliedToAlternateClassPath() this.data.setTargetClasses(predicateFor("com.outofclasspath.*Mutee*")); this.data.setTargetTests(predicateFor("com.outofclasspath.*")); - + List cp = new ArrayList(); cp.addAll(ClassPath.getClassPathElementsAsPaths()); cp.add(location); - + this.data.setClassPathElements(cp); this.data.setDependencyAnalysisMaxDistance(-1); this.data.setExcludedClasses(predicateFor("*Power*", "*JMockit*")); @@ -264,7 +264,7 @@ public void shouldMutateClassesSuppliedToAlternateClassPath() @Test public void shouldSupportTestNG() { this.data - .setTargetClasses(predicateFor("com.example.testng.FullyCovered*")); + .setTargetClasses(predicateFor("com.example.testng.FullyCovered*")); this.data.setVerbose(true); createAndRun(new TestNGConfiguration(new TestGroupConfig( Collections. emptyList(), Collections. emptyList()))); @@ -275,7 +275,7 @@ public void shouldSupportTestNG() { public void shouldTerminateWhenThreadpoolCreated() { this.data.setTargetClasses(predicateFor(KeepAliveThread.class)); this.data - .setTargetTests(predicateFor(com.example.KeepAliveThreadTest.class)); + .setTargetTests(predicateFor(com.example.KeepAliveThreadTest.class)); createAndRun(); verifyResults(SURVIVED); } @@ -285,7 +285,7 @@ public void shouldMarkChildJVMCrashesAsRunErrors() { setMutators("NEGATE_CONDITIONALS"); this.data.setTargetClasses(predicateFor(CrashesJVMWhenMutated.class)); this.data - .setTargetTests(predicateFor(com.example.TestCrashesJVMWhenMutated.class)); + .setTargetTests(predicateFor(com.example.TestCrashesJVMWhenMutated.class)); createAndRun(); verifyResults(RUN_ERROR); @@ -319,7 +319,7 @@ public void shouldReportCombinedCoveredButNotTestedMutationsInFinallyBlocksAsSur setMutators("INCREMENTS"); this.data.setTargetClasses(predicateFor(HasMutationsInFinallyBlock.class)); this.data - .setTargetTests(predicateFor(HasMutationInFinallyBlockNonTest.class)); + .setTargetTests(predicateFor(HasMutationInFinallyBlockNonTest.class)); this.data.setDetectInlinedCode(true); createAndRun(); @@ -330,7 +330,7 @@ public void shouldReportCombinedCoveredButNotTestedMutationsInFinallyBlocksAsSur public void shouldExitAfterFirstFailureWhenTestClassAnnotatedWithBeforeClass() { setMutators("RETURN_VALS"); this.data - .setTargetClasses(predicateFor(CoveredByABeforeAfterClassTest.class)); + .setTargetClasses(predicateFor(CoveredByABeforeAfterClassTest.class)); this.data.setTargetTests(predicateFor(BeforeAfterClassTest.class)); createAndRun(); @@ -344,23 +344,23 @@ public void shouldKillMutationsWhenMutationsPreventsConstructionOfTestClass() { setMutators("RETURN_VALS"); this.data - .setTargetClasses(predicateFor(com.example.mutatablecodeintest.Mutee.class)); + .setTargetClasses(predicateFor(com.example.mutatablecodeintest.Mutee.class)); this.data - .setTargetTests(predicateFor(com.example.mutatablecodeintest.MuteeTest.class)); + .setTargetTests(predicateFor(com.example.mutatablecodeintest.MuteeTest.class)); createAndRun(); verifyResults(KILLED); } - + @Test public void shouldKillMutationsWhenKillingTestClassContainsAnIgnoreOnAnotherMethod() { setMutators("RETURN_VALS"); this.data - .setTargetClasses(predicateFor(com.example.testhasignores.Mutee.class)); + .setTargetClasses(predicateFor(com.example.testhasignores.Mutee.class)); this.data - .setTargetTests(predicateFor(com.example.testhasignores.MuteeTest.class)); + .setTargetTests(predicateFor(com.example.testhasignores.MuteeTest.class)); createAndRun(); @@ -378,5 +378,4 @@ private static void copy(final InputStream in, final OutputStream out) } } - } diff --git a/pitest/src/test/java/org/pitest/mutationtest/MutationMetaDataTest.java b/pitest/src/test/java/org/pitest/mutationtest/MutationMetaDataTest.java index 65a93d2b8..5269269ee 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/MutationMetaDataTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/MutationMetaDataTest.java @@ -21,20 +21,20 @@ public class MutationMetaDataTest { @Test public void shouldPartitionResultsByMutatedClass() { - MutationResult a = makeResult("Foo", "a"); - MutationResult b = makeResult("Bar", "a"); - MutationResult c = makeResult("Foo", "b"); - MutationResult d = makeResult("Foo", "c"); - - MutationMetaData testee = new MutationMetaData(Arrays.asList(a,b,c,d)); + MutationResult a = makeResult("Foo", "a"); + MutationResult b = makeResult("Bar", "a"); + MutationResult c = makeResult("Foo", "b"); + MutationResult d = makeResult("Foo", "c"); + + MutationMetaData testee = new MutationMetaData(Arrays.asList(a, b, c, d)); Collection actual = testee.toClassResults(); - + assertThat(actual).hasSize(2); - + Iterator it = actual.iterator(); ClassMutationResults first = it.next(); ClassMutationResults second = it.next(); - + assertThat(first.getMutatedClass()).isEqualTo(ClassName.fromString("Bar")); assertThat(first.getMutations()).hasSize(1); @@ -45,21 +45,24 @@ public void shouldPartitionResultsByMutatedClass() { @Test public void shouldNotCreateEmptyClassResultsObjects() { - MutationMetaData testee = new MutationMetaData(Collections.emptyList()); + MutationMetaData testee = new MutationMetaData( + Collections. emptyList()); assertThat(testee.toClassResults()).isEmpty(); } - + @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(MutationMetaData.class).verify(); } - + private MutationResult makeResult(String clazz, String method) { - Location location = Location.location(ClassName.fromString(clazz), MethodName.fromString(method), "()V"); - MutationDetails md = aMutationDetail().withId(aMutationId().withLocation(location)).build(); - final MutationResult mr = new MutationResult(md, new MutationStatusTestPair(0, - DetectionStatus.KILLED)); + Location location = Location.location(ClassName.fromString(clazz), + MethodName.fromString(method), "()V"); + MutationDetails md = aMutationDetail().withId( + aMutationId().withLocation(location)).build(); + final MutationResult mr = new MutationResult(md, + new MutationStatusTestPair(0, DetectionStatus.KILLED)); return mr; } - + } diff --git a/pitest/src/test/java/org/pitest/mutationtest/MutationResultTest.java b/pitest/src/test/java/org/pitest/mutationtest/MutationResultTest.java index 9fb9980ad..b53cd145e 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/MutationResultTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/MutationResultTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,6 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.Test; -import org.pitest.mutationtest.DetectionStatus; public class MutationResultTest { @@ -44,7 +43,7 @@ public void shouldReturnStatusDescription() { DetectionStatus.TIMED_OUT)); assertEquals("TIMED_OUT", this.testee.getStatusDescription()); } - + @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(MutationResult.class).verify(); diff --git a/pitest/src/test/java/org/pitest/mutationtest/MutationStatusMapTest.java b/pitest/src/test/java/org/pitest/mutationtest/MutationStatusMapTest.java index f06901582..e8468b917 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/MutationStatusMapTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/MutationStatusMapTest.java @@ -4,6 +4,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.pitest.mutationtest.LocationMother.aMutationId; +import static org.pitest.mutationtest.engine.MutationDetailsMother.aMutationDetail; import java.util.Arrays; import java.util.Collections; @@ -13,9 +15,6 @@ import org.pitest.mutationtest.LocationMother.MutationIdentifierBuilder; import org.pitest.mutationtest.engine.MutationDetails; -import static org.pitest.mutationtest.engine.MutationDetailsMother.*; -import static org.pitest.mutationtest.LocationMother.*; - public class MutationStatusMapTest { private MutationStatusMap testee; @@ -28,8 +27,8 @@ public class MutationStatusMapTest { public void setUp() { this.testee = new MutationStatusMap(); MutationIdentifierBuilder id = aMutationId().withIndex(1); - details = aMutationDetail().withId(id.withIndex(1)).build(); - detailsTwo = aMutationDetail().withId(id.withIndex(2)).build(); + this.details = aMutationDetail().withId(id.withIndex(1)).build(); + this.detailsTwo = aMutationDetail().withId(id.withIndex(2)).build(); } @Test @@ -49,7 +48,8 @@ public void shouldReturnUnRunMutationsWhenSomePresent() { this.testee.setStatusForMutations( Arrays.asList(this.details, this.detailsTwo), DetectionStatus.NOT_STARTED); - assertThat(this.testee.getUnrunMutations()).contains(this.details, this.detailsTwo); + assertThat(this.testee.getUnrunMutations()).contains(this.details, + this.detailsTwo); } @Test @@ -63,7 +63,8 @@ public void shouldReturnEmptyListMutationsWhenNoUnrunMutationsPresent() { public void shouldReturnUnfinishedMutationsWhenSomePresent() { this.testee.setStatusForMutations( Arrays.asList(this.details, this.detailsTwo), DetectionStatus.STARTED); - assertThat(this.testee.getUnfinishedRuns()).contains(this.details, this.detailsTwo); + assertThat(this.testee.getUnfinishedRuns()).contains(this.details, + this.detailsTwo); } @Test @@ -87,7 +88,8 @@ public void shouldCreateResultsForAllMutations() { statusPairTwo); this.testee.setStatusForMutation(this.detailsTwo, statusPairTwo); - assertThat(this.testee.createMutationResults()).contains(resultOne, resultTwo); + assertThat(this.testee.createMutationResults()).contains(resultOne, + resultTwo); } @Test @@ -110,7 +112,8 @@ public void shouldSetStatusToUncoveredWhenMutationHasNoTests() { statusPairTwo); this.testee.setStatusForMutation(this.detailsTwo, statusPairTwo); - assertThat(this.testee.createMutationResults()).contains(resultOne, resultTwo); + assertThat(this.testee.createMutationResults()).contains(resultOne, + resultTwo); } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/NullAnalyser.java b/pitest/src/test/java/org/pitest/mutationtest/NullAnalyser.java index 844d3ff71..7fa2f8ade 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/NullAnalyser.java +++ b/pitest/src/test/java/org/pitest/mutationtest/NullAnalyser.java @@ -8,10 +8,11 @@ /** * Always selects the start status for a mutation - * + * */ public class NullAnalyser implements MutationAnalyser { + @Override public Collection analyse( final Collection mutationsForClasses) { return FCollection.map(mutationsForClasses, mutationToResult()); @@ -20,6 +21,7 @@ public Collection analyse( private F mutationToResult() { return new F() { + @Override public MutationResult apply(final MutationDetails a) { return new MutationResult(a, new MutationStatusTestPair(0, DetectionStatus.NOT_STARTED)); diff --git a/pitest/src/test/java/org/pitest/mutationtest/ReportTestBase.java b/pitest/src/test/java/org/pitest/mutationtest/ReportTestBase.java index a0915a572..140b4997d 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/ReportTestBase.java +++ b/pitest/src/test/java/org/pitest/mutationtest/ReportTestBase.java @@ -1,5 +1,16 @@ package org.pitest.mutationtest; +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; + import org.junit.Before; import org.pitest.classpath.ClassPathRoot; import org.pitest.classpath.CodeSource; @@ -29,12 +40,6 @@ import org.pitest.util.Timings; import org.pitest.util.Unchecked; -import java.io.File; -import java.io.IOException; -import java.util.*; - -import static org.junit.Assert.assertEquals; - public abstract class ReportTestBase { protected MetaDataExtractor metaDataExtractor; @@ -52,15 +57,18 @@ public void setUp() { protected MutationResultListenerFactory listenerFactory() { return new MutationResultListenerFactory() { + @Override public MutationResultListener getListener(Properties props, ListenerArguments args) { return ReportTestBase.this.metaDataExtractor; } + @Override public String name() { return null; } + @Override public String description() { return null; } @@ -97,7 +105,8 @@ protected void createAndRun(final Configuration configuration) { final CoverageOptions coverageOptions = createCoverageOptions(configuration); final LaunchOptions launchOptions = new LaunchOptions(agent, - new DefaultJavaExecutableLocator(), this.data.getJvmArgs(),new HashMap()); + new DefaultJavaExecutableLocator(), this.data.getJvmArgs(), + new HashMap()); final PathFilter pf = new PathFilter(new True(), new True()); @@ -119,7 +128,8 @@ protected void createAndRun(final Configuration configuration) { listenerFactory(), null); final MutationCoverage testee = new MutationCoverage(strategies, null, - code, this.data, new SettingsFactory(this.data, plugins), timings); + code, this.data, new SettingsFactory(this.data, this.plugins), + timings); testee.runReport(); } catch (final IOException e) { @@ -130,8 +140,9 @@ protected void createAndRun(final Configuration configuration) { } private CoverageOptions createCoverageOptions(Configuration configuration) { - return new CoverageOptions(data.getTargetClassesFilter(), configuration, - data.isVerbose(), data.getDependencyAnalysisMaxDistance()); + return new CoverageOptions(this.data.getTargetClassesFilter(), + configuration, this.data.isVerbose(), + this.data.getDependencyAnalysisMaxDistance()); } protected void setMutators(final String mutator) { diff --git a/pitest/src/test/java/org/pitest/mutationtest/TestMutationTesting.java b/pitest/src/test/java/org/pitest/mutationtest/TestMutationTesting.java index 30dfb8705..215702c9b 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/TestMutationTesting.java +++ b/pitest/src/test/java/org/pitest/mutationtest/TestMutationTesting.java @@ -14,8 +14,22 @@ */ package org.pitest.mutationtest; -import com.example.MutationsInNestedClasses; -import com.example.MutationsInNestedClassesTest; +import static org.junit.Assert.assertEquals; +import static org.pitest.mutationtest.DetectionStatus.KILLED; +import static org.pitest.mutationtest.DetectionStatus.MEMORY_ERROR; +import static org.pitest.mutationtest.DetectionStatus.NON_VIABLE; +import static org.pitest.mutationtest.DetectionStatus.NO_COVERAGE; +import static org.pitest.mutationtest.DetectionStatus.SURVIVED; +import static org.pitest.mutationtest.DetectionStatus.TIMED_OUT; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -37,7 +51,13 @@ import org.pitest.functional.predicate.False; import org.pitest.functional.predicate.Predicate; import org.pitest.functional.prelude.Prelude; -import org.pitest.mutationtest.build.*; +import org.pitest.mutationtest.build.DefaultGrouper; +import org.pitest.mutationtest.build.DefaultTestPrioritiser; +import org.pitest.mutationtest.build.MutationAnalysisUnit; +import org.pitest.mutationtest.build.MutationSource; +import org.pitest.mutationtest.build.MutationTestBuilder; +import org.pitest.mutationtest.build.PercentAndConstantTimeoutStrategy; +import org.pitest.mutationtest.build.WorkerFactory; import org.pitest.mutationtest.config.DefaultDependencyPathPredicate; import org.pitest.mutationtest.config.ReportOptions; import org.pitest.mutationtest.engine.MutationEngine; @@ -57,10 +77,8 @@ import org.pitest.util.IsolationUtils; import org.pitest.util.Timings; -import java.util.*; - -import static org.junit.Assert.assertEquals; -import static org.pitest.mutationtest.DetectionStatus.*; +import com.example.MutationsInNestedClasses; +import com.example.MutationsInNestedClassesTest; @Category(SystemTest.class) public class TestMutationTesting { @@ -76,7 +94,8 @@ public void setUp() { this.config = new ConfigurationForTesting(); this.metaDataExtractor = new MetaDataExtractor(); this.mae = new MutationAnalysisExecutor(1, - Collections. singletonList(metaDataExtractor)); + Collections + . singletonList(this.metaDataExtractor)); } public static class NoMutations { @@ -323,7 +342,8 @@ private void createEngineAndRun(final ReportOptions data, final CoverageOptions coverageOptions = createCoverageOptions(data); final LaunchOptions launchOptions = new LaunchOptions(agent, - new DefaultJavaExecutableLocator(), data.getJvmArgs(),new HashMap()); + new DefaultJavaExecutableLocator(), data.getJvmArgs(), + new HashMap()); final PathFilter pf = new PathFilter( Prelude.not(new DefaultDependencyPathPredicate()), @@ -345,8 +365,8 @@ null, coverageOptions, launchOptions, code, new NullCoverageExporter(), ClassInfo.toClassName()); final MutationEngine engine = new GregorEngineFactory() - .createEngineWithMutators(false, False. instance(), - Collections. emptyList(), mutators, true); + .createEngineWithMutators(false, False. instance(), + Collections. emptyList(), mutators, true); final MutationConfig mutationConfig = new MutationConfig(engine, launchOptions); diff --git a/pitest/src/test/java/org/pitest/mutationtest/UnviableClassMutator.java b/pitest/src/test/java/org/pitest/mutationtest/UnviableClassMutator.java index 39fd20d8a..9370c8f2d 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/UnviableClassMutator.java +++ b/pitest/src/test/java/org/pitest/mutationtest/UnviableClassMutator.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,16 +28,19 @@ public class UnviableClassMutator implements MethodMutatorFactory { + @Override public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { return new UnviableClassMethodVisitor(this, methodInfo, context, methodVisitor); } + @Override public String getGloballyUniqueId() { return this.getClass().getName(); } + @Override public String getName() { return "UNVIABLE_CLASS_MUTATOR"; } diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/AnalyisPriorityComparatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/AnalyisPriorityComparatorTest.java index f76e2e072..069dd5121 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/AnalyisPriorityComparatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/AnalyisPriorityComparatorTest.java @@ -36,6 +36,7 @@ public void shouldPreserveCorrectOrder() { private MutationAnalysisUnit unit(final int count) { return new MutationAnalysisUnit() { + @Override public int priority() { return count; } @@ -45,6 +46,7 @@ public String toString() { return "" + count; } + @Override public MutationMetaData call() throws Exception { return null; } diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/DefaultGrouperTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/DefaultGrouperTest.java index b9d79355e..2dfa7e2d4 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/DefaultGrouperTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/DefaultGrouperTest.java @@ -51,7 +51,8 @@ private void makeTesteeWithUnitSizeOf(final int i) { } public static MutationDetails createDetails(final String clazz) { - LocationBuilder lb = LocationMother.aLocation().withClass(ClassName.fromString(clazz)); + LocationBuilder lb = LocationMother.aLocation().withClass( + ClassName.fromString(clazz)); return new MutationDetails(aMutationId().withLocation(lb).build(), "", "desc", 42, 0); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java index d106c159f..c9d1d8e50 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java @@ -26,21 +26,20 @@ public class DefaultTestPrioritiserTest { - private DefaultTestPrioritiser testee; - + private DefaultTestPrioritiser testee; @Mock - private CoverageDatabase coverage; + private CoverageDatabase coverage; @Mock - private ClassByteArraySource source; + private ClassByteArraySource source; - private final ClassName foo = ClassName.fromString("foo"); + private final ClassName foo = ClassName.fromString("foo"); @Before public void setUp() { MockitoAnnotations.initMocks(this); - this.testee = new DefaultTestPrioritiser(coverage); + this.testee = new DefaultTestPrioritiser(this.coverage); } @Test @@ -56,7 +55,8 @@ public void shouldAssignTestsForRelevantLineToGeneratedMutations() { public void shouldAssignAllTestsForClassWhenMutationInStaticInitialiser() { final List expected = makeTestInfos(0); when(this.coverage.getTestsForClass(this.foo)).thenReturn(expected); - final List actual = this.testee.assignTests(makeMutation("")); + final List actual = this.testee + .assignTests(makeMutation("")); assertEquals(expected, actual); } @@ -67,15 +67,17 @@ public void shouldPrioritiseTestsByExecutionTime() { unorderedTests); final List actual = this.testee.assignTests(makeMutation("foo")); - assertEquals(Arrays.asList(1,100,1000,10000), FCollection.map(actual, toTime())); + assertEquals(Arrays.asList(1, 100, 1000, 10000), + FCollection.map(actual, toTime())); } private F toTime() { return new F() { + @Override public Integer apply(TestInfo a) { return a.getTime(); } - + }; } @@ -86,6 +88,7 @@ private List makeTestInfos(final Integer... times) { private F timeToTestInfo() { return new F() { + @Override public TestInfo apply(final Integer a) { return new TestInfo("foo", "bar", a, Option. none(), 0); } @@ -95,7 +98,7 @@ public TestInfo apply(final Integer a) { private MutationDetails makeMutation(final String method) { final MutationIdentifier id = new MutationIdentifier(aLocation() - .withClass(foo).withMethod(method).build(), 0, "mutator"); + .withClass(this.foo).withMethod(method).build(), 0, "mutator"); return new MutationDetails(id, "file", "desc", 1, 2); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java index ffb4bd1cf..a53564f93 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java @@ -20,12 +20,12 @@ public class KnownStatusMutationTestUnitTest { private KnownStatusMutationTestUnit testee; - @Before public void setUp() { MockitoAnnotations.initMocks(this); } + @Test public void shouldCreateMutationMetaDataForSuppliedResults() throws Exception { final MutationResult mr = new MutationResult( diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java index 6da3d4140..42e2232f1 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java @@ -70,7 +70,7 @@ public void shouldAssignTestsFromPrioritiserToMutant() { when(this.prioritiser.assignTests(any(MutationDetails.class))).thenReturn( expected); when(this.mutater.findMutations(any(ClassName.class))) - .thenReturn(mutations); + .thenReturn(mutations); final MutationDetails actual = this.testee.createMutations(this.foo) .iterator().next(); assertEquals(expected, actual.getTestsInOrder()); @@ -83,6 +83,7 @@ private List makeTestInfos(final Integer... times) { private F timeToTestInfo() { return new F() { + @Override public TestInfo apply(final Integer a) { return new TestInfo("foo", "bar", a, Option. none(), 0); } @@ -96,8 +97,8 @@ private List makeMutations(final String method) { } private MutationDetails makeMutation(final String method) { - final MutationIdentifier id = new MutationIdentifier(aLocation().withClass( - this.foo).withMethod(method).build(), 0, "mutator"); + final MutationIdentifier id = new MutationIdentifier(aLocation() + .withClass(this.foo).withMethod(method).build(), 0, "mutator"); return new MutationDetails(id, "file", "desc", 1, 2); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java index 822a3c8b8..75fad6ca1 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java @@ -91,8 +91,8 @@ private void assertCreatesOneTestUnitForTwoMutations() { } private void makeTesteeWithUnitSizeOf(int unitSize) { - testee = new MutationTestBuilder(this.wf, new NullAnalyser(), this.source, - new DefaultGrouper(unitSize)); + this.testee = new MutationTestBuilder(this.wf, new NullAnalyser(), + this.source, new DefaultGrouper(unitSize)); } public static MutationDetails createDetails(String clazz) { diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java index e9fba5026..1fdc65a7b 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java @@ -53,8 +53,8 @@ public void setUp() { this.mutations = new ArrayList(); this.tests = new ArrayList(); this.testee = new MutationTestUnit(this.mutations, this.tests, - new WorkerFactory(null, config, mutationConfig, - timeout, false, null)); + new WorkerFactory(null, this.config, this.mutationConfig, this.timeout, + false, null)); } @Test @@ -69,10 +69,10 @@ public void shouldReportWhenMutationsNotCoveredByAnyTest() throws Exception { @Test public void shouldReportPriorityBasedOnNumberOfMutations() { - mutations.add(MutationDetailsMother.aMutationDetail().build()); - testee = new MutationTestUnit(MutationDetailsMother.aMutationDetail() - .build(42), tests, null); - assertThat(testee.priority()).isEqualTo(42); + this.mutations.add(MutationDetailsMother.aMutationDetail().build()); + this.testee = new MutationTestUnit(MutationDetailsMother.aMutationDetail() + .build(42), this.tests, null); + assertThat(this.testee.priority()).isEqualTo(42); } private void addMutation() { diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategyTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategyTest.java index d1d63a084..3db28137a 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategyTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/PercentAndConstantTimeoutStrategyTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.build; @@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.pitest.mutationtest.build.PercentAndConstantTimeoutStrategy; public class PercentAndConstantTimeoutStrategyTest { diff --git a/pitest/src/test/java/org/pitest/mutationtest/build/TestInfoPriorisationComparatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/build/TestInfoPriorisationComparatorTest.java index 82801d64c..9b481baac 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/build/TestInfoPriorisationComparatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/build/TestInfoPriorisationComparatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,6 @@ import org.pitest.classinfo.ClassName; import org.pitest.coverage.TestInfo; import org.pitest.functional.Option; -import org.pitest.mutationtest.build.TestInfoPriorisationComparator; public class TestInfoPriorisationComparatorTest { diff --git a/pitest/src/test/java/org/pitest/mutationtest/commandline/MutationCoverageReportTest.java b/pitest/src/test/java/org/pitest/mutationtest/commandline/MutationCoverageReportTest.java index d999de5d8..49bffb089 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/commandline/MutationCoverageReportTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/commandline/MutationCoverageReportTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.commandline; @@ -122,9 +122,9 @@ private void mockMutationEngine() { when( this.mutationFactory.createEngine(anyBoolean(), any(Predicate.class), anyCollection(), anyCollection(), anyBoolean())).thenReturn( - this.engine); + this.engine); when(this.engine.createMutator(any(ClassByteArraySource.class))) - .thenReturn(this.mutater); + .thenReturn(this.mutater); } @Test @@ -193,8 +193,8 @@ public void shouldReportMutationsFoundWhenSomeDetected() { private CombinedStatistics createAndRunTestee() { final MutationStrategies strategies = new MutationStrategies( new GregorEngineFactory(), this.history, this.coverage, - this.listenerFactory, output).with(this.mutationFactory).with( - this.verifier); + this.listenerFactory, this.output).with(this.mutationFactory).with( + this.verifier); this.testee = new MutationCoverage(strategies, null, this.code, this.data, new SettingsFactory(this.data, PluginServices.makeForContextLoader()), diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundConfigurationTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundConfigurationTest.java index e40eb1962..1960ba5f8 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundConfigurationTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundConfigurationTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -101,7 +101,7 @@ public void shouldFindSuiteClassesWhenAChildFindsSuiteClasses() { when(this.suiteFinderOne.apply(any(Class.class))).thenReturn( Collections.> emptyList()); when(this.suiteFinderTwo.apply(any(Class.class))).thenReturn( - Arrays.>asList(tc)); + Arrays.> asList(tc)); assertEquals(Arrays.asList(tc), this.testee.testSuiteFinder().apply(tc)); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java index 6b2bbacd9..7ca3321c4 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,13 +33,13 @@ public class CompoundListenerFactoryTest { - private CompoundListenerFactory testee; + private CompoundListenerFactory testee; @Mock - private MutationResultListenerFactory firstChild; + private MutationResultListenerFactory firstChild; @Mock - private MutationResultListenerFactory secondChild; + private MutationResultListenerFactory secondChild; @Before public void setUp() { @@ -53,10 +53,12 @@ public void shouldCreateACombinedListenerForAllChildFactories() { final MutationResultListener listenerOne = mock(MutationResultListener.class); final MutationResultListener listenerTwo = mock(MutationResultListener.class); when( - this.firstChild.getListener(any(Properties.class),any(ListenerArguments.class))).thenReturn(listenerOne); + this.firstChild.getListener(any(Properties.class), + any(ListenerArguments.class))).thenReturn(listenerOne); when( - this.secondChild.getListener(any(Properties.class),any(ListenerArguments.class))).thenReturn(listenerTwo); - this.testee.getListener(null,null).runStart(); + this.secondChild.getListener(any(Properties.class), + any(ListenerArguments.class))).thenReturn(listenerTwo); + this.testee.getListener(null, null).runStart(); verify(listenerOne, times(1)).runStart(); verify(listenerTwo, times(1)).runStart(); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestClassIdentifierTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestClassIdentifierTest.java index a97473841..abee03c96 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestClassIdentifierTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestClassIdentifierTest.java @@ -1,18 +1,18 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ -package org.pitest.mutationtest.config; +package org.pitest.mutationtest.config; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -27,7 +27,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.pitest.classinfo.ClassInfo; -import org.pitest.mutationtest.config.CompoundTestClassIdentifier; import org.pitest.testapi.TestClassIdentifier; public class CompoundTestClassIdentifierTest { diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java index 33f0ed7c6..8d14fd54c 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/ConfigurationFactoryTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/ConfigurationFactoryTest.java index 01b8ad14b..28497ad18 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/ConfigurationFactoryTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/ConfigurationFactoryTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -36,7 +36,7 @@ public class ConfigurationFactoryTest { private ConfigurationFactory testee; @Mock - private TestGroupConfig groupConfig; + private TestGroupConfig groupConfig; @Mock private ClassByteArraySource source; diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/DefaultCodePathPredicateTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/DefaultCodePathPredicateTest.java index d97a8e301..ce6d97147 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/DefaultCodePathPredicateTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/DefaultCodePathPredicateTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -24,7 +24,6 @@ import org.pitest.classpath.ArchiveClassPathRoot; import org.pitest.classpath.ClassPathRoot; import org.pitest.classpath.DirectoryClassPathRoot; -import org.pitest.mutationtest.config.DefaultCodePathPredicate; public class DefaultCodePathPredicateTest { diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicateTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicateTest.java index 71f7a7bd8..e7ddcbefd 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicateTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/DefaultDependencyPathPredicateTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -24,7 +24,6 @@ import org.pitest.classpath.ArchiveClassPathRoot; import org.pitest.classpath.ClassPathRoot; import org.pitest.classpath.DirectoryClassPathRoot; -import org.pitest.mutationtest.config.DefaultDependencyPathPredicate; public class DefaultDependencyPathPredicateTest { diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/PathNamePredicateTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/PathNamePredicateTest.java index 5cc3705f4..1b07d8128 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/PathNamePredicateTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/PathNamePredicateTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; @@ -24,7 +24,6 @@ import org.pitest.classpath.ClassPathRoot; import org.pitest.classpath.DirectoryClassPathRoot; import org.pitest.functional.prelude.Prelude; -import org.pitest.mutationtest.config.PathNamePredicate; public class PathNamePredicateTest { diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/PluginServicesTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/PluginServicesTest.java index bfea55e6e..dec2becdc 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/PluginServicesTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/PluginServicesTest.java @@ -5,36 +5,39 @@ import org.junit.Test; import org.pitest.functional.F; import org.pitest.functional.FCollection; -import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.engine.gregor.config.GregorEngineFactory; import org.pitest.mutationtest.filter.LimitNumberOfMutationsPerClassFilterFactory; import org.pitest.mutationtest.report.csv.CSVReportFactory; public class PluginServicesTest { - + private final PluginServices testee = PluginServices.makeForContextLoader(); @Test public void shouldListDefaultEngineAsClientClasspathPlugin() { - assertTrue(FCollection.contains(testee.findClientClasspathPlugins(), theClass(GregorEngineFactory.class))); + assertTrue(FCollection.contains(this.testee.findClientClasspathPlugins(), + theClass(GregorEngineFactory.class))); } @Test public void shouldListCSVReportAsToolClasspathPlugin() { - assertTrue(FCollection.contains(testee.findToolClasspathPlugins(), theClass(CSVReportFactory.class))); + assertTrue(FCollection.contains(this.testee.findToolClasspathPlugins(), + theClass(CSVReportFactory.class))); } - + @Test public void shouldListDefaultMutationFilterAsToolClasspathPlugin() { - assertTrue(FCollection.contains(testee.findToolClasspathPlugins(), theClass(LimitNumberOfMutationsPerClassFilterFactory.class))); + assertTrue(FCollection.contains(this.testee.findToolClasspathPlugins(), + theClass(LimitNumberOfMutationsPerClassFilterFactory.class))); } - + private static F theClass(final Class clss) { return new F() { + @Override public Boolean apply(Object a) { return a.getClass().equals(clss); } - + }; } diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/ReportOptionsTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/ReportOptionsTest.java index e5220ecbf..e16fd7484 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/ReportOptionsTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/ReportOptionsTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.config; diff --git a/pitest/src/test/java/org/pitest/mutationtest/config/SettingsFactoryTest.java b/pitest/src/test/java/org/pitest/mutationtest/config/SettingsFactoryTest.java index 00b8de00c..efa5cb94f 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/config/SettingsFactoryTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/config/SettingsFactoryTest.java @@ -20,22 +20,22 @@ public class SettingsFactoryTest { - private final ReportOptions options = new ReportOptions(); + private final ReportOptions options = new ReportOptions(); private final PluginServices plugins = PluginServices.makeForContextLoader(); - private SettingsFactory testee; + private SettingsFactory testee; @Before public void setUp() { - this.testee = new SettingsFactory(this.options, plugins); + this.testee = new SettingsFactory(this.options, this.plugins); } @Test public void shouldReturnTheLegacyTestFrameworkPluginWhenNoOtherOnClasspath() { - assertTrue(testee.getTestFrameworkPlugin() != null); + assertTrue(this.testee.getTestFrameworkPlugin() != null); } - + @Test public void shouldReturnANullCoverageExporterWhenOptionSetToFalse() { this.options.setExportLineCoverage(false); @@ -52,7 +52,7 @@ public void shouldThrowErrorWhenRequestedEngineNotKnown() { this.options.setMutationEngine("unknown"); this.testee.createEngine(); } - + @Test public void shouldReturnListenerWhenRequestedListenerIsKnown() { this.options.addOutputFormats(Arrays.asList("XML")); @@ -61,31 +61,32 @@ public void shouldReturnListenerWhenRequestedListenerIsKnown() { @Test public void shouldSupportXMLAndCSV() { - this.options.addOutputFormats(Arrays.asList("CSV","XML")); + this.options.addOutputFormats(Arrays.asList("CSV", "XML")); assertNotNull(this.testee.createListener()); } - + @Test(expected = PitError.class) public void shouldThrowErrorWhenRequestedListenerNotKnown() { this.options.addOutputFormats(Arrays.asList("unknown")); this.testee.createListener(); } - + @Test public void shouldReturnADefaultJavaExecutableWhenNoneIsSpecified() { this.options.setJavaExecutable(null); - File actual = new File(testee.getJavaExecutable().javaExecutable()); - if(System.getProperty("os.name").contains("Windows")) - actual = new File(actual.getPath() + ".exe"); + File actual = new File(this.testee.getJavaExecutable().javaExecutable()); + if (System.getProperty("os.name").contains("Windows")) { + actual = new File(actual.getPath() + ".exe"); + } assertTrue(actual.exists()); } - + @Test public void shouldReturnSpecifiedJavaExecutableWhenOneSet() { this.options.setJavaExecutable("foo"); - assertEquals("foo",testee.getJavaExecutable().javaExecutable()); + assertEquals("foo", this.testee.getJavaExecutable().javaExecutable()); } - + @Test public void shouldNotAllowUserToCalculateCoverageForCoreClasses() { this.options.setTargetClasses(Glob.toGlobPredicates(Collections @@ -101,7 +102,6 @@ public void shouldNotAllowUserToCalculateCoverageForCoverageImplementation() { final CoverageOptions actual = this.testee.createCoverageOptions(); assertFalse(actual.getFilter().apply("org/pitest/coverage")); } - @Test(expected = PitHelpError.class) public void shouldNotAllowUserToMakePITMutateItself() { @@ -110,5 +110,4 @@ public void shouldNotAllowUserToMakePITMutateItself() { this.testee.createCoverageOptions(); } - } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/LocationTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/LocationTest.java index 09f10ca7a..02b224f60 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/LocationTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/LocationTest.java @@ -16,15 +16,19 @@ public class LocationTest { @Test public void shouldSortInConsistantOrder() { - Location a = location(ClassName.fromString("A"), MethodName.fromString("A"), "A"); - Location b = location(ClassName.fromString("AA"), MethodName.fromString("A"), "A"); - Location c = location(ClassName.fromString("A"), MethodName.fromString("AA"), "A"); - Location d = location(ClassName.fromString("A"), MethodName.fromString("AA"), "AA"); - List ls = Arrays.asList(a,b,c,d); + Location a = location(ClassName.fromString("A"), + MethodName.fromString("A"), "A"); + Location b = location(ClassName.fromString("AA"), + MethodName.fromString("A"), "A"); + Location c = location(ClassName.fromString("A"), + MethodName.fromString("AA"), "A"); + Location d = location(ClassName.fromString("A"), + MethodName.fromString("AA"), "AA"); + List ls = Arrays.asList(a, b, c, d); Collections.sort(ls); - assertEquals(Arrays.asList(a,c,d,b),ls); + assertEquals(Arrays.asList(a, c, d, b), ls); } - + @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(Location.class).verify(); diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/MutationDetailsMother.java b/pitest/src/test/java/org/pitest/mutationtest/engine/MutationDetailsMother.java index 7ae228c4f..a667733d0 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/MutationDetailsMother.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/MutationDetailsMother.java @@ -13,29 +13,44 @@ import org.pitest.quickbuilder.builders.QB; public class MutationDetailsMother { - - public interface MutationDetailsBuilder extends SequenceBuilder { + + public interface MutationDetailsBuilder extends + SequenceBuilder { MutationDetailsBuilder withId(Builder id); + MutationDetailsBuilder withId(MutationIdentifier id); + MutationDetailsBuilder withFilename(String filename); + MutationDetailsBuilder withBlock(int block); + MutationDetailsBuilder withLineNumber(int lineNumber); + MutationDetailsBuilder withDescription(String desc); + MutationDetailsBuilder withTestsInOrder(List tests); + MutationDetailsBuilder withIsInFinallyBlock(boolean b); + MutationDetailsBuilder withPoison(boolean b); - + MutationIdentifier _Id(); + String _Filename(); + int _Block(); + int _LineNumber(); + String _Description(); + boolean _IsInFinallyBlock(); + boolean _Poison(); - + List _TestsInOrder(); } - + public static MutationDetailsBuilder aMutationDetail() { return QB.builder(MutationDetailsBuilder.class, seed()).withBlock(0) .withDescription("A mutation").withFilename("foo.java") @@ -46,6 +61,7 @@ public static MutationDetailsBuilder aMutationDetail() { private static Generator seed() { return new Generator() { + @Override public MutationDetails generate(MutationDetailsBuilder b) { MutationDetails md = new MutationDetails(b._Id(), b._Filename(), b._Description(), b._LineNumber(), b._Block(), @@ -62,9 +78,9 @@ public static MutationDetails makeMutation() { } public static MutationDetails makeMutation(final ClassName clazz) { - return new MutationDetails(new MutationIdentifier(Location.location(clazz, new MethodName("aMethod"), "()V"), 1, - "mutatorId"), "foo.java", "A mutation", 0, - 0); + return new MutationDetails(new MutationIdentifier(Location.location(clazz, + new MethodName("aMethod"), "()V"), 1, "mutatorId"), "foo.java", + "A mutation", 0, 0); } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/MutationIdentifierTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/MutationIdentifierTest.java index 42a41839e..9dca04eac 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/MutationIdentifierTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/MutationIdentifierTest.java @@ -16,13 +16,13 @@ import org.junit.Test; public class MutationIdentifierTest { - + @Test public void shouldEqualSelf() { MutationIdentifier a = aMutationId().withIndex(1).withMutator("M").build(); assertTrue(a.equals(a)); } - + @Test public void shouldBeUnEqualWhenIndexDiffers() { MutationIdentifier a = aMutationId().withIndex(1).build(); @@ -30,7 +30,7 @@ public void shouldBeUnEqualWhenIndexDiffers() { assertFalse(a.equals(b)); assertFalse(b.equals(a)); } - + @Test public void shouldBeUnEqualWhenMutatorDiffers() { MutationIdentifier a = aMutationId().withMutator("FOO").build(); @@ -41,13 +41,14 @@ public void shouldBeUnEqualWhenMutatorDiffers() { @Test public void shouldBeUnEqualWhenLocationDiffers() { - MutationIdentifier a = aMutationId().withLocation(aLocation().withMethod("FOO")).build(); - MutationIdentifier b = aMutationId().withLocation(aLocation().withMethod("BAR")).build(); + MutationIdentifier a = aMutationId().withLocation( + aLocation().withMethod("FOO")).build(); + MutationIdentifier b = aMutationId().withLocation( + aLocation().withMethod("BAR")).build(); assertFalse(a.equals(b)); assertFalse(b.equals(a)); } - @Test public void shouldHaveSymmetricEqulasImplementation() { MutationIdentifier a = aMutationId().withIndex(1).withMutator("M").build(); @@ -56,70 +57,75 @@ public void shouldHaveSymmetricEqulasImplementation() { assertTrue(b.equals(a)); assertTrue(a.hashCode() == b.hashCode()); } - + @Test public void shouldMatchWhenObjectsAreEqual() { MutationIdentifier a = aMutationId().build(); MutationIdentifier b = aMutationId().build(); assertTrue(a.matches(b)); } - + @Test public void shouldMatchWhenIndexesOverlap() { - MutationIdentifier a = new MutationIdentifier(aLocation().build(), new HashSet(Arrays.asList(1,2)), "M" ); - MutationIdentifier b = new MutationIdentifier(aLocation().build(), 1, "M" ); + MutationIdentifier a = new MutationIdentifier(aLocation().build(), + new HashSet(Arrays.asList(1, 2)), "M"); + MutationIdentifier b = new MutationIdentifier(aLocation().build(), 1, "M"); assertTrue(a.matches(b)); } - + @Test public void shouldNotMatchWhenIndexesDoNotOverlap() { - MutationIdentifier a = new MutationIdentifier(aLocation().build(), new HashSet(100,200), "M" ); - MutationIdentifier b = new MutationIdentifier(aLocation().build(), 1, "M" ); + MutationIdentifier a = new MutationIdentifier(aLocation().build(), + new HashSet(100, 200), "M"); + MutationIdentifier b = new MutationIdentifier(aLocation().build(), 1, "M"); assertFalse(a.matches(b)); } - + @Test public void shouldNotMatchWhenMutatorsDiffer() { MutationIdentifier a = aMutationId().withMutator("A").build(); MutationIdentifier b = aMutationId().withMutator("XXXX").build(); assertFalse(a.matches(b)); } - - + @Test public void shouldNotMatchWhenIndexesDiffer() { MutationIdentifier a = aMutationId().withIndex(1).build(); MutationIdentifier b = aMutationId().withIndex(100).build(); assertFalse(a.matches(b)); } - + @Test public void shouldNotMatchWhenLocationsDiffer() { - MutationIdentifier a = new MutationIdentifier(aLocation().withMethodDescription("X").build(), 1, "M" ); - MutationIdentifier b = new MutationIdentifier(aLocation().withMethodDescription("Y").build(), 1, "M" ); + MutationIdentifier a = new MutationIdentifier(aLocation() + .withMethodDescription("X").build(), 1, "M"); + MutationIdentifier b = new MutationIdentifier(aLocation() + .withMethodDescription("Y").build(), 1, "M"); assertFalse(a.matches(b)); } - + @Test public void shouldSortInConsistantOrder() { MutationIdentifier a = aMutationId().withIndex(1).withMutator("A").build(); MutationIdentifier b = aMutationId().withIndex(1).withMutator("Z").build(); MutationIdentifier c = aMutationId().withIndex(1).withMutator("AA").build(); MutationIdentifier d = aMutationId().withIndex(3).withMutator("AA").build(); - MutationIdentifier e = aMutationId().withLocation(aLocation().withMethod("a")).withIndex(3).withMutator("AA").build(); - List mis = Arrays.asList(a,b,c,d,e); + MutationIdentifier e = aMutationId() + .withLocation(aLocation().withMethod("a")).withIndex(3) + .withMutator("AA").build(); + List mis = Arrays.asList(a, b, c, d, e); Collections.sort(mis); - final List expectedOrder = Arrays.asList(e,a,c,d,b); + final List expectedOrder = Arrays.asList(e, a, c, d, b); assertEquals(expectedOrder, mis); - mis = Arrays.asList(e,b,d,a,c); + mis = Arrays.asList(e, b, d, a, c); Collections.sort(mis); assertEquals(expectedOrder, mis); - + } - + @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(MutationIdentifier.class).verify(); - } - + } + } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java index ad8a14692..1c1cb564b 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java @@ -16,7 +16,7 @@ public class AvoidAssertsMethodAdapterTest extends MethodDecoratorTest { @Mock - private MethodMutationContext context; + private MethodMutationContext context; @Mock private Label label; @@ -80,10 +80,10 @@ public void shouldDisableMutationsForCodeSettingWhenAssertionDisabledFlagIsSetIn "desiredAssertionStatus", "()Z", true); verify(this.context).disableMutations(anyString()); this.testee - .visitFieldInsn( - Opcodes.PUTSTATIC, - "org/pitest/mutationtest/engine/gregor/TestGregorMutater$HasAssertStatement", - "$assertionsDisabled", "Z"); + .visitFieldInsn( + Opcodes.PUTSTATIC, + "org/pitest/mutationtest/engine/gregor/TestGregorMutater$HasAssertStatement", + "$assertionsDisabled", "Z"); verify(this.context).enableMutatations(anyString()); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/ClassInfoTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/ClassInfoTest.java index 9f63cc663..d4d7b0f00 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/ClassInfoTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/ClassInfoTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngineTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngineTest.java index c500ba7ef..33ca9b683 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngineTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/GregorMutationEngineTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,8 +34,8 @@ public class GregorMutationEngineTest { @Test public void shouldReportNamesOfSuppliedMutators() { - final Collection mutators = - Mutator.fromStrings(Arrays.asList("CONDITIONALS_BOUNDARY", "MATH")); + final Collection mutators = Mutator + .fromStrings(Arrays.asList("CONDITIONALS_BOUNDARY", "MATH")); final DefaultMutationEngineConfiguration config = new DefaultMutationEngineConfiguration( True. all(), Collections. emptyList(), mutators, new NoInlinedCodeDetection()); diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapterTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapterTest.java index 238deae58..2c58f4eb8 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/LineFilterMethodAdapterTest.java @@ -14,7 +14,7 @@ public class LineFilterMethodAdapterTest extends MethodDecoratorTest { @Mock - private MethodMutationContext context; + private MethodMutationContext context; @Mock private PremutationClassInfo classInfo; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MethodInfoTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MethodInfoTest.java index 516dedd7b..f79a4f8d2 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MethodInfoTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MethodInfoTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -32,9 +32,9 @@ public class MethodInfoTest { private static final String ONE_PARAMETER = "(Ljava/lang/String;)V"; private static final int SYNTHETIC_MODIFIER = Opcodes.ACC_SYNTHETIC; private static final ClassInfo ENUMERATION_CLASS = new ClassInfo(0, 0, - "", "", - "java/lang/Enum", - new String[0]); + "", "", + "java/lang/Enum", + new String[0]); private final MethodInfo methodInfo = new MethodInfo(); @Test diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MutatorTestBase.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MutatorTestBase.java index d04063e86..bbfd48e77 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MutatorTestBase.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/MutatorTestBase.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -132,6 +132,7 @@ private ClassLoader createClassLoader(final Mutant mutant) throws Exception { private Transformation createTransformation(final Mutant mutant) { return new Transformation() { + @Override public byte[] transform(final String name, final byte[] bytes) { if (name.equals(mutant.getDetails().getClassName().asJavaName())) { return mutant.getBytes(); @@ -160,6 +161,7 @@ protected List getMutants( private F createMutant() { return new F() { + @Override public Mutant apply(final MutationDetails a) { return MutatorTestBase.this.engine.getMutation(a.getId()); } @@ -199,14 +201,14 @@ protected void printMutant(final Mutant mutant) { protected void assertMutantsReturn(final Callable mutee, - final FunctionalList details, + final FunctionalList details, final String... expectedResults) { final List mutants = this.getMutants(details); assertEquals("Should return one mutant for each request", details.size(), mutants.size()); - final FunctionalList results = FCollection.map(mutants - ,mutantToStringReults(mutee)); + final FunctionalList results = FCollection.map(mutants, + mutantToStringReults(mutee)); int i = 0; for (final String actual : results) { @@ -218,6 +220,7 @@ protected void assertMutantsReturn(final Callable mutee, private F mutantToStringReults(final Callable mutee) { return new F() { + @Override public String apply(final Mutant mutant) { return mutateAndCall(mutee, mutant); } @@ -245,6 +248,7 @@ protected Mutant createFirstMutant( protected Predicate mutateOnlyCallMethod() { return new Predicate() { + @Override public Boolean apply(final MethodInfo a) { return a.getName().equals("call"); } @@ -254,6 +258,7 @@ public Boolean apply(final MethodInfo a) { protected F descriptionContaining(final String value) { return new F() { + @Override public Boolean apply(final MutationDetails a) { return a.getDescription().contains(value); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestGregorMutater.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestGregorMutater.java index 1f42b7e0f..ab08cef0f 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestGregorMutater.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestGregorMutater.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor; @@ -125,6 +125,7 @@ public void shouldMutateCustomConstructorsAddedToEnums() { private static Matcher> aNonEmptyCollection() { return new TypeSafeMatcher>() { + @Override public void describeTo(final Description description) { description.appendText("a non empty collection"); } @@ -348,25 +349,27 @@ public int a() { } public int a(int i) { - if ( i > 2) { + if (i > 2) { System.out.println(i); } return 1; } } - + @Test public void shouldScopeMutationIndexesByInstructionCounter() { createTesteeWith(Mutator.byName("RETURN_VALS")); final List actualDetails = findMutationsFor(HasTwoMutableMethods.class); assertEquals(2, actualDetails.size()); - assertEquals(4,actualDetails.get(0).getId().getFirstIndex()); - assertEquals(15,actualDetails.get(1).getId().getFirstIndex()); // differs by target? + assertEquals(4, actualDetails.get(0).getId().getFirstIndex()); + assertEquals(15, actualDetails.get(1).getId().getFirstIndex()); // differs + // by + // target? } - private static F isInFinallyBlock() { return new F() { + @Override public Boolean apply(final MutationDetails a) { return a.isInFinallyBlock(); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestTryWithResources.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestTryWithResources.java index 8ffc144e3..c2f4efa5f 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestTryWithResources.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/TestTryWithResources.java @@ -14,6 +14,13 @@ */ package org.pitest.mutationtest.engine.gregor; +import static org.junit.Assert.assertEquals; + +import java.text.MessageFormat; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; @@ -25,54 +32,43 @@ import org.pitest.mutationtest.engine.gregor.inlinedcode.InlinedFinallyBlockDetector; import org.pitest.util.ResourceFolderByteArraySource; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - -import static org.junit.Assert.assertEquals; - /** * @author Artem Khvastunov <contact@artspb.me> */ @RunWith(Theories.class) public class TestTryWithResources extends MutatorTestBase { - private static final Collection COMPILERS = Arrays.asList("javac", "ecj", "aspectj"); - private static final String PATH = "trywithresources/{0}_{1}"; - private static final String MESSAGE = "class={0}, compiler={1}"; + private static final Collection COMPILERS = Arrays.asList("javac", + "ecj", "aspectj"); + private static final String PATH = "trywithresources/{0}_{1}"; + private static final String MESSAGE = "class={0}, compiler={1}"; - @DataPoints - public static String[][] data = new String[][]{ - {"1", "TryExample"}, - {"2", "TryCatchExample"}, - {"3", "TryCatchFinallyExample"}, - {"2", "TryFinallyExample"}, - {"1", "TryWithTwoCloseableExample"}, - {"1", "TryWithNestedTryExample"}, - {"1", "TryWithInterfaceExample"} - }; + @DataPoints + public static String[][] data = new String[][] { + { "1", "TryExample" }, { "2", "TryCatchExample" }, + { "3", "TryCatchFinallyExample" }, { "2", "TryFinallyExample" }, + { "1", "TryWithTwoCloseableExample" }, + { "1", "TryWithNestedTryExample" }, { "1", "TryWithInterfaceExample" } }; - @Theory - public void testTryWithResourcesMutationsWithFilter(String... data) { - createEngine(new InlinedFinallyBlockDetector()); - testWithExpected(data[0], data[1]); - } + @Theory + public void testTryWithResourcesMutationsWithFilter(String... data) { + createEngine(new InlinedFinallyBlockDetector()); + testWithExpected(data[0], data[1]); + } - private void createEngine(InlinedCodeFilter inlinedCodeDetector) { - this.engine = new GregorMutater(new ResourceFolderByteArraySource(), - True.all(), - Mutator.defaults(), - Collections.emptyList(), - inlinedCodeDetector); - } + private void createEngine(InlinedCodeFilter inlinedCodeDetector) { + this.engine = new GregorMutater(new ResourceFolderByteArraySource(), + True. all(), Mutator.defaults(), + Collections. emptyList(), inlinedCodeDetector); + } - private void testWithExpected(String expected, String className) { - for (String compiler : COMPILERS) { - String clazz = MessageFormat.format(PATH, className, compiler); - final Collection actualDetails = findMutationsFor(clazz); - String message = MessageFormat.format(MESSAGE, className, compiler); - assertEquals(message, Long.valueOf(expected), Long.valueOf(actualDetails.size())); - } + private void testWithExpected(String expected, String className) { + for (String compiler : COMPILERS) { + String clazz = MessageFormat.format(PATH, className, compiler); + final Collection actualDetails = findMutationsFor(clazz); + String message = MessageFormat.format(MESSAGE, className, compiler); + assertEquals(message, Long.valueOf(expected), + Long.valueOf(actualDetails.size())); } + } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitorTest.java index dbcecbe29..968f1c5d7 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/analysis/InstructionTrackingMethodVisitorTest.java @@ -17,8 +17,8 @@ public class InstructionTrackingMethodVisitorTest { private final ClassByteArraySource byteSource = new ClassloaderByteArraySource( - IsolationUtils - .getContextClassLoader()); + IsolationUtils + .getContextClassLoader()); private final InstructionCounter counter = new DefaultInstructionCounter(); @@ -26,7 +26,8 @@ public class InstructionTrackingMethodVisitorTest { public void shouldGiveIndexConsistentWithTreeApiForStringEquals() { analyse(String.class, "equals"); final MethodNode tree = makeTree(String.class, "equals"); - assertEquals(tree.instructions.size(), this.counter.currentInstructionCount()); + assertEquals(tree.instructions.size(), + this.counter.currentInstructionCount()); } class HasMethodCallsAndBranches { @@ -46,7 +47,8 @@ private void bar() { public void shouldGiveIndexConsistentWithTreeApiWhenMethodCallsPresent() { analyse(HasMethodCallsAndBranches.class, "foo"); final MethodNode tree = makeTree(HasMethodCallsAndBranches.class, "foo"); - assertEquals(tree.instructions.size(), this.counter.currentInstructionCount()); + assertEquals(tree.instructions.size(), + this.counter.currentInstructionCount()); } class HasSwitchStatements { @@ -74,11 +76,10 @@ public int foo(final int j) { public void shouldGiveIndexConsistentWithTreeApiWhenSwitchStatementsPresent() { analyse(HasSwitchStatements.class, "foo"); final MethodNode tree = makeTree(HasSwitchStatements.class, "foo"); - assertEquals(tree.instructions.size(), this.counter.currentInstructionCount()); + assertEquals(tree.instructions.size(), + this.counter.currentInstructionCount()); } - - private InstructionTrackingMethodVisitor analyse(final Class clazz, final String targetMethod) { final ClassReader reader = new ClassReader(this.byteSource.getBytes( @@ -93,7 +94,7 @@ private MethodNode makeTree(final Class clazz, final String name) { ClassName.fromClass(clazz).asJavaName()).value()); final ClassNode tree = new ClassNode(); reader.accept(tree, 0); - for ( Object m : tree.methods ) { + for (Object m : tree.methods) { MethodNode mn = (MethodNode) m; if (mn.name.equals(name)) { return mn; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java index 8d2c88131..7af9f1bec 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.config; @@ -21,9 +21,9 @@ import org.junit.Test; import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; +import org.pitest.mutationtest.engine.gregor.mutators.ArgumentPropagationMutator; import org.pitest.mutationtest.engine.gregor.mutators.InvertNegsMutator; import org.pitest.mutationtest.engine.gregor.mutators.MathMutator; -import org.pitest.mutationtest.engine.gregor.mutators.ArgumentPropagationMutator; public class MutatorTest { @@ -45,7 +45,7 @@ public void shouldNotCreateDuplicatesWhenRequestedViaGroup() { assertThat(parseStrings("MATH", "DEFAULTS")).hasSameSizeAs( parseStrings("DEFAULTS")); } - + private Collection parseStrings(final String... s) { return Mutator.fromStrings(Arrays.asList(s)); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutatorTest.java index f2c109cf5..742d9f439 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ArgumentPropagationMutatorTest.java @@ -1,33 +1,33 @@ /* * Copyright 2014 Stefan Mandel, Urs Metz - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.pitest.mutationtest.engine.gregor.mutators.ArgumentPropagationMutator.ARGUMENT_PROPAGATION_MUTATOR; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.pitest.mutationtest.engine.gregor.mutators.ArgumentPropagationMutator.ARGUMENT_PROPAGATION_MUTATOR; +import org.junit.Before; +import org.junit.Test; +import org.pitest.mutationtest.engine.Mutant; +import org.pitest.mutationtest.engine.gregor.MutatorTestBase; public class ArgumentPropagationMutatorTest extends MutatorTestBase { @@ -44,7 +44,7 @@ public void shouldReplaceMethodCallWithStringArgument() throws Exception { } private static class HasStringMethodCall implements Callable { - private String arg; + private final String arg; public HasStringMethodCall(String arg) { this.arg = arg; @@ -54,8 +54,9 @@ public String delegate(final String aString) { return "abc" + aString; } + @Override public String call() throws Exception { - return delegate(arg); + return delegate(this.arg); } } @@ -66,7 +67,7 @@ public void shouldReplaceMethodCallWithIntArgument() throws Exception { } private static class HasIntMethodCall implements Callable { - private int arg; + private final int arg; public HasIntMethodCall(int arg) { this.arg = arg; @@ -76,8 +77,9 @@ public int delegate(int aInt) { return 22 + aInt; } + @Override public String call() throws Exception { - return String.valueOf(delegate(arg)); + return String.valueOf(delegate(this.arg)); } } @@ -88,7 +90,7 @@ public void shouldReplaceMethodCallWithLongArgument() throws Exception { } private static class HasLongMethodCall implements Callable { - private long arg; + private final long arg; public HasLongMethodCall(long arg) { this.arg = arg; @@ -98,8 +100,9 @@ public long delegate(long argument) { return 22L + argument; } + @Override public String call() throws Exception { - return String.valueOf(delegate(arg)); + return String.valueOf(delegate(this.arg)); } } @@ -109,6 +112,7 @@ public void shouldNotMutateMethodThatReturnsDifferentType() throws Exception { } class ReturnsDifferentType implements Callable { + @Override public String call() { return addThreeAndConvertToString(3); } @@ -126,9 +130,9 @@ public void continuesUntilMatchingArgumentTypeIsFound() throws Exception { } private class OnlyFirstArgumentHasMatchingType implements Callable { - private String aString; - private Object anObject; - private long aLong; + private final String aString; + private final Object anObject; + private final long aLong; public OnlyFirstArgumentHasMatchingType(String aString, Object anObject, long aLong) { @@ -137,8 +141,9 @@ public OnlyFirstArgumentHasMatchingType(String aString, Object anObject, this.aLong = aLong; } + @Override public String call() throws Exception { - return aMethod(aString, anObject, aLong); + return aMethod(this.aString, this.anObject, this.aLong); } private String aMethod(String aString, Object anObject, long aLong) { @@ -154,17 +159,18 @@ public void usesLastArgumentOfMatchingTypeToReplaceMethod() throws Exception { } private class HasSeveralArgumentWithMatchingType implements Callable { - private int int1; - private int int2; + private final int int1; + private final int int2; public HasSeveralArgumentWithMatchingType(int i, int j) { this.int1 = i; this.int2 = j; } + @Override public String call() throws Exception { String anInt = "3"; - return String.valueOf(aMethod(int1, anInt, int2)); + return String.valueOf(aMethod(this.int1, anInt, this.int2)); } private int aMethod(int int1, String aString, int int2) { @@ -180,11 +186,13 @@ public void alsoReplaceCallToMethodWhenReturnValueIsNotUsed() } private class ReturnValueNotUsed implements Callable { - private List aList = asList("xyz"); + private final List aList = asList("xyz"); + @Override public Boolean call() throws Exception { - aList.set(0, "will not be present in list in mutated version"); - return aList.contains("will not be present in list in mutated version"); + this.aList.set(0, "will not be present in list in mutated version"); + return this.aList + .contains("will not be present in list in mutated version"); } } @@ -203,6 +211,7 @@ public String[] delegate(final String[] ss) { return new String[] {}; } + @Override public String[] call() throws Exception { String[] s = { "1", "2" }; return delegate(s); @@ -216,12 +225,13 @@ public void shouldNotReplaceMethodsReturningArraysOfUnmatchedType() } private static class HasArrayMethodOfDifferentType implements - Callable { + Callable { public String[] delegate(final Integer[] ss) { return new String[] {}; } + @Override public String[] call() throws Exception { Integer[] s = { 1, 2 }; return delegate(s); @@ -243,6 +253,7 @@ public List delegate(final List is) { return Arrays.asList(new String[] { "foo", "bar" }); } + @Override public List call() throws Exception { List s = Collections.emptyList(); return delegate(s); @@ -252,18 +263,16 @@ public List call() throws Exception { @Test public void shouldReplaceInstanceMethodCallThatIsUsedAsArgumentForCallToOtherObject() throws Exception { - final Mutant mutant = getFirstMutant( - CallsOtherObjectWithResultOfInstanceMethod.class); + final Mutant mutant = getFirstMutant(CallsOtherObjectWithResultOfInstanceMethod.class); MyListener listener = new MyListener(); - assertMutantCallableReturns( - new CallsOtherObjectWithResultOfInstanceMethod("lowercase", listener), - mutant, "lowercase"); + assertMutantCallableReturns(new CallsOtherObjectWithResultOfInstanceMethod( + "lowercase", listener), mutant, "lowercase"); } - private class CallsOtherObjectWithResultOfInstanceMethod - implements Callable { - private String arg; - private MyListener listener; + private class CallsOtherObjectWithResultOfInstanceMethod implements + Callable { + private final String arg; + private final MyListener listener; public CallsOtherObjectWithResultOfInstanceMethod(String arg, MyListener listener) { @@ -275,27 +284,26 @@ private String delegate(String aString) { return aString.toUpperCase(); } + @Override public String call() throws Exception { - listener.call(delegate(arg)); - return listener.getCalledWith(); + this.listener.call(delegate(this.arg)); + return this.listener.getCalledWith(); } } @Test public void shouldReplaceStaticMethodCallThatIsUsedAsArgumentForCallToOtherObject() throws Exception { - final Mutant mutant = getFirstMutant( - CallsOtherObjectWithResultOfStaticMethod.class); + final Mutant mutant = getFirstMutant(CallsOtherObjectWithResultOfStaticMethod.class); MyListener listener = new MyListener(); - assertMutantCallableReturns( - new CallsOtherObjectWithResultOfStaticMethod("lowercase", listener), - mutant, "lowercase"); + assertMutantCallableReturns(new CallsOtherObjectWithResultOfStaticMethod( + "lowercase", listener), mutant, "lowercase"); } - private static class CallsOtherObjectWithResultOfStaticMethod - implements Callable { - private String arg; - private MyListener listener; + private static class CallsOtherObjectWithResultOfStaticMethod implements + Callable { + private final String arg; + private final MyListener listener; public CallsOtherObjectWithResultOfStaticMethod(String arg, MyListener listener) { @@ -307,45 +315,44 @@ private static String delegate(int i, String aString, long l) { return aString.toUpperCase(); } + @Override public String call() throws Exception { - listener.call(delegate(3, arg, 5L)); - return listener.getCalledWith(); + this.listener.call(delegate(3, this.arg, 5L)); + return this.listener.getCalledWith(); } } @Test public void shouldReplaceInstanceMethodCallWithSeveralArgumentsThatIsUsedAsArgumentForCallToOtherObject() throws Exception { - final Mutant mutant = getFirstMutant( - CallsOtherObjectWithResultOfInstanceMethodHavingSeveralArguments.class); + final Mutant mutant = getFirstMutant(CallsOtherObjectWithResultOfInstanceMethodHavingSeveralArguments.class); MyListener listener = new MyListener(); assertMutantCallableReturns( new CallsOtherObjectWithResultOfInstanceMethodHavingSeveralArguments( - "lowercase", listener), - mutant, "lowercase"); + "lowercase", listener), mutant, "lowercase"); } private static class CallsOtherObjectWithResultOfInstanceMethodHavingSeveralArguments - implements Callable { - private String arg; - private MyListener listener; + implements Callable { + private final String arg; + private final MyListener listener; public CallsOtherObjectWithResultOfInstanceMethodHavingSeveralArguments( - String arg, - MyListener listener) { + String arg, MyListener listener) { this.arg = arg; this.listener = listener; } - private String delegate(int i, double aDouble, Object object, String aString, - long l) { + private String delegate(int i, double aDouble, Object object, + String aString, long l) { return aString.toUpperCase(); } + @Override public String call() throws Exception { - listener.call(delegate(3, 4.2D, new Object(), arg, 5L)); - return listener.getCalledWith(); + this.listener.call(delegate(3, 4.2D, new Object(), this.arg, 5L)); + return this.listener.getCalledWith(); } } @@ -353,11 +360,11 @@ private static class MyListener { private String calledWith = "not called"; public void call(String text) { - calledWith = text; + this.calledWith = text; } public String getCalledWith() { - return calledWith; + return this.calledWith; } } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutatorTest.java index 9077b76a7..8d5300464 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConditionalsBoundaryMutatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,6 +47,7 @@ private static class HasIFLE implements Callable { this.i = i; } + @Override public String call() { if (this.i > 0) { return "was > zero"; @@ -71,6 +72,7 @@ private static class HasIFGE implements Callable { this.i = i; } + @Override public String call() { if (this.i < 0) { return "was < zero"; @@ -95,6 +97,7 @@ private static class HasIFGT implements Callable { this.i = i; } + @Override public String call() { if (this.i <= 0) { return "was <= zero"; @@ -119,6 +122,7 @@ private static class HasIFLT implements Callable { this.i = i; } + @Override public String call() { if (this.i >= 0) { return "was >= zero"; @@ -143,6 +147,7 @@ private static class HasIF_ICMPLE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i > j) { @@ -168,6 +173,7 @@ private static class HasIF_ICMPGE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i < j) { @@ -193,6 +199,7 @@ private static class HasIF_ICMPGT implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i <= j) { @@ -218,6 +225,7 @@ private static class HasIF_ICMPLT implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i >= j) { diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutatorTest.java index acd5fcc0c..580222d21 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ConstructorCallMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; @@ -33,6 +33,7 @@ public class ConstructorCallMutatorTest extends MutatorTestBase { static class HasConstructorCall implements Callable { + @Override public String call() throws Exception { final Integer i = new Integer(12); return "" + (i == null); @@ -84,6 +85,7 @@ private static class HasDelegateConstructorCall implements Callable { this.i = i; } + @Override public String call() throws Exception { return "" + this.i; } @@ -102,6 +104,7 @@ private static class HasArrayListConstructor implements Callable { private List list; + @Override public String call() throws Exception { this.list = new ArrayList(); diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutatorTest.java index 5b21817bb..d013723fc 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/IncrementsMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; @@ -37,6 +37,7 @@ public int containsIincInstructions(int i) { return ++i; } + @Override public String call() throws Exception { return "" + containsIincInstructions(1); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutatorTest.java index 813d9ebc9..64ba37dfe 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InlineConstantMutatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,6 +33,7 @@ public void setupEngineToMutateOnlyInlineConstants() { private static class HasBooleanICONST0 implements Callable { + @Override public Boolean call() throws Exception { return false; } @@ -53,6 +54,7 @@ public void shouldReplaceBooleanFalseWithTrue() throws Exception { private static class HasIntegerICONST0 implements Callable { + @Override public Integer call() throws Exception { return 0; } @@ -67,6 +69,7 @@ public void shouldReplaceInteger0With1() throws Exception { private static class HasBooleanICONST1 implements Callable { + @Override public Boolean call() throws Exception { return true; } @@ -81,6 +84,7 @@ public void shouldReplaceBooleanTrueWithFalse() throws Exception { private static class HasIntegerICONST1 implements Callable { + @Override public Integer call() throws Exception { return 1; } @@ -95,6 +99,7 @@ public void shouldReplaceInteger1With0() throws Exception { private static class HasIntegerICONST2 implements Callable { + @Override public Integer call() throws Exception { return 2; } @@ -109,6 +114,7 @@ public void shouldReplaceInteger2With3() throws Exception { private static class HasIntegerICONST3 implements Callable { + @Override public Integer call() throws Exception { return 3; } @@ -123,6 +129,7 @@ public void shouldReplaceInteger3With4() throws Exception { private static class HasIntegerICONST4 implements Callable { + @Override public Integer call() throws Exception { return 4; } @@ -137,6 +144,7 @@ public void shouldReplaceInteger4With5() throws Exception { private static class HasIntegerICONST5 implements Callable { + @Override public Integer call() throws Exception { return 5; } @@ -151,6 +159,7 @@ public void shouldReplaceInteger5With6() throws Exception { private static class HasIntegerLDC implements Callable { + @Override public Integer call() throws Exception { return 987654321; } @@ -166,6 +175,7 @@ public void shouldReplaceLargeIntegerConstantsWithValuePlus1() private static class HasIntegerICONSTM1 implements Callable { + @Override public Integer call() throws Exception { return -1; } @@ -187,6 +197,7 @@ public void shouldReplaceIntegerMinus1With0() throws Exception { private static class HasBIPUSHMinus2 implements Callable { + @Override public Integer call() throws Exception { return -2; } @@ -201,6 +212,7 @@ public void shouldReplaceIntegerMinus2WithMinus1() throws Exception { private static class HasBIPUSH implements Callable { + @Override public Integer call() throws Exception { return 28; } @@ -216,6 +228,7 @@ public void shouldReplaceSmallIntegerConstantsWithValuePlus1() private static class HasSIPUSH implements Callable { + @Override public Integer call() throws Exception { return 32700; } @@ -231,6 +244,7 @@ public void shouldReplaceMediumIntegerConstantsWithValuePlus1() private static class HasTwoMutationPoints implements Callable { + @Override public Boolean call() throws Exception { int i = Short.MAX_VALUE; @@ -253,6 +267,7 @@ public void shouldReplaceFirstMutationPointOnly() throws Exception { private static class HasShortOverflow implements Callable { + @Override public Short call() throws Exception { short s = Short.MAX_VALUE; s = preventSourceFormatingMakingFinal(s); @@ -276,6 +291,7 @@ public void shouldOverflowOnShortMaxValue() throws Exception { private static class HasIntegerAtMaxShortValue implements Callable { + @Override public Integer call() throws Exception { int i = Short.MAX_VALUE; i = preventSourceFormatingMakingFinal(i); @@ -304,6 +320,7 @@ public static short preventSourceFormatingMakingFinal(final short s) { private static class HasByteOverflow implements Callable { + @Override public Byte call() throws Exception { byte b = Byte.MAX_VALUE; b = preventSourceFormatingMakingFinal(b); @@ -333,6 +350,7 @@ public void shouldOverflowOnByteMaxValue() throws Exception { private static class HasIntegerMaxValue implements Callable { + @Override public Integer call() throws Exception { return Integer.MAX_VALUE; } @@ -348,6 +366,7 @@ public void shouldReplaceIntegerMaxWithIntegerMin() throws Exception { private static class HasLongLCONST0 implements Callable { + @Override public Long call() throws Exception { return 0L; } @@ -362,6 +381,7 @@ public void shouldReplaceLong0With1() throws Exception { private static class HasLongLCONST1 implements Callable { + @Override public Long call() throws Exception { return 1L; } @@ -376,6 +396,7 @@ public void shouldReplaceLong1With2() throws Exception { private static class HasLongLDC implements Callable { + @Override public Long call() throws Exception { return 2999999999L; } @@ -390,6 +411,7 @@ public void shouldReplaceLongWithValuePlus1() throws Exception { private static class HasLongLDCMinus1 implements Callable { + @Override public Long call() throws Exception { return -1L; } @@ -408,6 +430,7 @@ public void shouldReplaceLongMinus1With0() throws Exception { private static class HasFloatFCONST0 implements Callable { + @Override public Float call() throws Exception { return 0.0F; } @@ -422,6 +445,7 @@ public void shouldReplaceFloat0With1() throws Exception { private static class HasFloatFCONST1 implements Callable { + @Override public Float call() throws Exception { return 1.0F; } @@ -436,6 +460,7 @@ public void shouldReplaceFloat1With2() throws Exception { private static class HasFloatFCONST2 implements Callable { + @Override public Float call() throws Exception { return 2.0F; } @@ -450,6 +475,7 @@ public void shouldReplaceFloat2With1() throws Exception { private static class HasFloatLDC implements Callable { + @Override public Float call() throws Exception { return 8364.123F; } @@ -464,6 +490,7 @@ public void shouldReplaceFloatWith1() throws Exception { private static class HasFloatMultipleLDC implements Callable { + @Override public Float call() throws Exception { float f = 16.0F; float f2 = 4.0F; @@ -485,6 +512,7 @@ public void shouldReplaceFirstFloatMutationPointOnly() throws Exception { private static class HasDoubleDCONST0 implements Callable { + @Override public Double call() throws Exception { return 0.0D; } @@ -499,6 +527,7 @@ public void shouldReplaceDouble0With1() throws Exception { private static class HasDoubleDCONST1 implements Callable { + @Override public Double call() throws Exception { return 1.0D; } @@ -513,6 +542,7 @@ public void shouldReplaceDouble1With2() throws Exception { private static class HasDoubleLDC implements Callable { + @Override public Double call() throws Exception { return 123456789.123D; } @@ -527,6 +557,7 @@ public void shouldReplaceDoubleWith1() throws Exception { private static class HasDoubleMultipleLDC implements Callable { + @Override public Double call() throws Exception { double d = 4578.1158D; double d2 = 2.0D; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutatorTest.java index b0c15af0d..293f25d37 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/InvertNegsMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; @@ -48,6 +48,7 @@ public int containsINeg(final int i) { return -i; } + @Override public String call() throws Exception { return "" + containsINeg(1); } @@ -67,6 +68,7 @@ public float containsFNeg(final float i) { return -i; } + @Override public String call() throws Exception { return "" + containsFNeg(1f); } @@ -86,6 +88,7 @@ public int containsLNeg(final int i) { return -i; } + @Override public String call() throws Exception { return "" + containsLNeg(1); } @@ -100,11 +103,4 @@ public void shouldInvertLNegs() throws Exception { assertMutantCallableReturns(new HasLNeg(), mutant, "1"); } - @Test - public void shouldRecordCorrectLineNumberForMutations() { - final Collection actual = findMutationsFor(HasLNeg.class); - assertEquals(1, actual.size()); - final MutationDetails first = actual.iterator().next(); - assertEquals(86, first.getLineNumber()); - } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutatorTest.java index d0a10a594..8617b3564 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/MathMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; @@ -35,6 +35,7 @@ private static class HasIAdd implements Callable { this.i = i; } + @Override public String call() { this.i++; return "" + this.i; @@ -55,6 +56,7 @@ private static class HasISub implements Callable { this.i = i; } + @Override public String call() { this.i--; return "" + this.i; @@ -75,6 +77,7 @@ private static class HasIMul implements Callable { this.i = i; } + @Override public String call() { this.i = this.i * 2; return "" + this.i; @@ -95,6 +98,7 @@ private static class HasIDiv implements Callable { this.i = i; } + @Override public String call() { this.i = this.i / 2; return "" + this.i; @@ -115,6 +119,7 @@ private static class HasIOr implements Callable { this.i = i; } + @Override public String call() { this.i = this.i | 2; return "" + this.i; @@ -135,6 +140,7 @@ private static class HasIAnd implements Callable { this.i = i; } + @Override public String call() { this.i = this.i & 2; return "" + this.i; @@ -155,6 +161,7 @@ private static class HasIRem implements Callable { this.i = i; } + @Override public String call() { this.i = this.i % 2; return "" + this.i; @@ -175,6 +182,7 @@ private static class HasIXor implements Callable { this.i = i; } + @Override public String call() { this.i = this.i ^ 2; return "" + this.i; @@ -195,6 +203,7 @@ private static class HasISHL implements Callable { this.i = i; } + @Override public String call() { this.i = this.i << 2; return "" + this.i; @@ -215,6 +224,7 @@ private static class HasISHR implements Callable { this.i = i; } + @Override public String call() { this.i = this.i >> 2; return "" + this.i; @@ -235,6 +245,7 @@ private static class HasIUSHR implements Callable { this.i = i; } + @Override public String call() { this.i = this.i >>> 2; return "" + this.i; @@ -258,6 +269,7 @@ private static class HasLAdd implements Callable { this.i = i; } + @Override public String call() { this.i++; return "" + this.i; @@ -278,6 +290,7 @@ private static class HasLSub implements Callable { this.i = i; } + @Override public String call() { this.i--; return "" + this.i; @@ -298,6 +311,7 @@ private static class HasLMul implements Callable { this.i = i; } + @Override public String call() { this.i = this.i * 2; return "" + this.i; @@ -318,6 +332,7 @@ private static class HasLDiv implements Callable { this.i = i; } + @Override public String call() { this.i = this.i / 2; return "" + this.i; @@ -338,6 +353,7 @@ private static class HasLOr implements Callable { this.i = i; } + @Override public String call() { this.i = this.i | 2; return "" + this.i; @@ -358,6 +374,7 @@ private static class HasLAnd implements Callable { this.i = i; } + @Override public String call() { this.i = this.i & 2; return "" + this.i; @@ -378,6 +395,7 @@ private static class HasLRem implements Callable { this.i = i; } + @Override public String call() { this.i = this.i % 2; return "" + this.i; @@ -398,6 +416,7 @@ private static class HasLXor implements Callable { this.i = i; } + @Override public String call() { this.i = this.i ^ 2; return "" + this.i; @@ -418,6 +437,7 @@ private static class HasLSHL implements Callable { this.i = i; } + @Override public String call() { this.i = this.i << 2; return "" + this.i; @@ -438,6 +458,7 @@ private static class HasLSHR implements Callable { this.i = i; } + @Override public String call() { this.i = this.i >> 2; return "" + this.i; @@ -458,6 +479,7 @@ private static class HasLUSHR implements Callable { this.i = i; } + @Override public String call() { this.i = this.i >>> 2; return "" + this.i; @@ -481,6 +503,7 @@ private static class HasFADD implements Callable { this.i = i; } + @Override public String call() { this.i++; return "" + this.i; @@ -501,6 +524,7 @@ private static class HasFSUB implements Callable { this.i = i; } + @Override public String call() { this.i--; return "" + this.i; @@ -521,6 +545,7 @@ private static class HasFMUL implements Callable { this.i = i; } + @Override public String call() { this.i = this.i * 2; return "" + this.i; @@ -541,6 +566,7 @@ private static class HasFDIV implements Callable { this.i = i; } + @Override public String call() { this.i = this.i / 2; return "" + this.i; @@ -561,6 +587,7 @@ private static class HasFREM implements Callable { this.i = i; } + @Override public String call() { this.i = this.i % 2; return "" + this.i; @@ -583,6 +610,7 @@ private static class HasDADD implements Callable { this.i = i; } + @Override public String call() { this.i++; return "" + this.i; @@ -603,6 +631,7 @@ private static class HasDSUB implements Callable { this.i = i; } + @Override public String call() { this.i--; return "" + this.i; @@ -623,6 +652,7 @@ private static class HasDMUL implements Callable { this.i = i; } + @Override public String call() { this.i = this.i * 2; return "" + this.i; @@ -643,6 +673,7 @@ private static class HasDDIV implements Callable { this.i = i; } + @Override public String call() { this.i = this.i / 2; return "" + this.i; @@ -663,6 +694,7 @@ private static class HasDREM implements Callable { this.i = i; } + @Override public String call() { this.i = this.i % 2; return "" + this.i; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutatorTest.java index 93ede971e..37e01af7d 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NegateConditionalsMutatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,6 +39,7 @@ private static class HasIFEQ implements Callable { this.i = i; } + @Override public String call() { if (this.i != 0) { return "was not zero"; @@ -62,6 +63,7 @@ private static class HasIFNE implements Callable { this.i = i; } + @Override public String call() { if (this.i == 0) { return "was zero"; @@ -85,6 +87,7 @@ private static class HasIFLE implements Callable { this.i = i; } + @Override public String call() { if (this.i > 0) { return "was > zero"; @@ -109,6 +112,7 @@ private static class HasIFGE implements Callable { this.i = i; } + @Override public String call() { if (this.i < 0) { return "was < zero"; @@ -133,6 +137,7 @@ private static class HasIFGT implements Callable { this.i = i; } + @Override public String call() { if (this.i <= 0) { return "was <= zero"; @@ -157,6 +162,7 @@ private static class HasIFLT implements Callable { this.i = i; } + @Override public String call() { if (this.i >= 0) { return "was >= zero"; @@ -181,6 +187,7 @@ private static class HasIFNULL implements Callable { this.i = i; } + @Override public String call() { if (this.i != null) { return "was not null"; @@ -204,6 +211,7 @@ private static class HasIFNONNULL implements Callable { this.i = i; } + @Override public String call() { if (this.i == null) { return "was null"; @@ -227,6 +235,7 @@ private static class HasIF_ICMPNE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i == j) { @@ -251,6 +260,7 @@ private static class HasIF_ICMPEQ implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i != j) { @@ -275,6 +285,7 @@ private static class HasIF_ICMPLE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i > j) { @@ -300,6 +311,7 @@ private static class HasIF_ICMPGE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i < j) { @@ -325,6 +337,7 @@ private static class HasIF_ICMPGT implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i <= j) { @@ -350,6 +363,7 @@ private static class HasIF_ICMPLT implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i >= j) { @@ -375,6 +389,7 @@ private static class HasIF_ACMPNE implements Callable { this.i = i; } + @Override public String call() { final Object integer = Integer.class; if (this.i == integer) { @@ -402,6 +417,7 @@ private static class HasIF_ACMPEQ implements Callable { this.i = i; } + @Override public String call() { final Object integer = Integer.class; if (this.i != integer) { diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutatorTest.java index 451b85ae7..aa272b983 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/NonVoidMethodCallMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; @@ -54,6 +54,7 @@ public void set(final int i) { this.s = this.s + i; } + @Override public String call() throws Exception { set(1); return this.s; @@ -74,6 +75,7 @@ public void shouldNotRemoveConstructorCalls() throws Exception { private static class HasObjectMethodCall implements Callable { + @Override public String call() throws Exception { return this.toString(); } @@ -91,6 +93,7 @@ private boolean booleanMethod() { return true; } + @Override public String call() throws Exception { final boolean result = booleanMethod(); return "" + result; @@ -109,6 +112,7 @@ private double doubleMethod() { return 9123475.3d; } + @Override public String call() throws Exception { final double result = doubleMethod(); return "" + result; @@ -127,6 +131,7 @@ private byte byteMethod() { return 5; } + @Override public String call() throws Exception { final byte result = byteMethod(); return "" + result; @@ -144,6 +149,7 @@ private char charMethod() { return 'g'; } + @Override public String call() throws Exception { final char result = charMethod(); return "" + result; @@ -161,6 +167,7 @@ private short shortMethod() { return 23; } + @Override public String call() throws Exception { final short result = shortMethod(); return "" + result; @@ -179,6 +186,7 @@ private long longMethod() { return 23; } + @Override public String call() throws Exception { final long result = longMethod(); return "" + result; @@ -196,6 +204,7 @@ private float floatMethod() { return 23; } + @Override public String call() throws Exception { final float result = floatMethod(); return "" + result; @@ -210,6 +219,7 @@ public void shouldRemoveNonVoidMethodCallReturningFloatType() } private static class UsesReturnValueOfMethodCall implements Callable { + @Override public String call() throws Exception { return this.toString().toUpperCase(); } @@ -227,6 +237,7 @@ private static class HasLogger implements Callable { @SuppressWarnings("unused") private static Logger log = Logger.getLogger(HasLogger.class.getName()); + @Override public String call() throws Exception { return "ok"; } @@ -249,6 +260,7 @@ public int set(final int newVal) { return i + 42; } + @Override @SuppressWarnings("finally") public String call() throws Exception { int c = 2; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutatorTest.java index a3c3b361d..8a682ace2 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/RemoveConditionalMutatorTest.java @@ -14,10 +14,14 @@ public class RemoveConditionalMutatorTest extends MutatorTestBase { @Test public void shouldProvideAMeaningfulName() { - assertEquals("REMOVE_CONDITIONALS_EQUAL_IF_MUTATOR", new RemoveConditionalMutator(Choice.EQUAL, true).getName()); - assertEquals("REMOVE_CONDITIONALS_EQUAL_ELSE_MUTATOR", new RemoveConditionalMutator(Choice.EQUAL, false).getName()); - assertEquals("REMOVE_CONDITIONALS_ORDER_IF_MUTATOR", new RemoveConditionalMutator(Choice.ORDER, true).getName()); - assertEquals("REMOVE_CONDITIONALS_ORDER_ELSE_MUTATOR", new RemoveConditionalMutator(Choice.ORDER, false).getName()); + assertEquals("REMOVE_CONDITIONALS_EQUAL_IF_MUTATOR", + new RemoveConditionalMutator(Choice.EQUAL, true).getName()); + assertEquals("REMOVE_CONDITIONALS_EQUAL_ELSE_MUTATOR", + new RemoveConditionalMutator(Choice.EQUAL, false).getName()); + assertEquals("REMOVE_CONDITIONALS_ORDER_IF_MUTATOR", + new RemoveConditionalMutator(Choice.ORDER, true).getName()); + assertEquals("REMOVE_CONDITIONALS_ORDER_ELSE_MUTATOR", + new RemoveConditionalMutator(Choice.ORDER, false).getName()); } private static int getZeroButPreventInlining() { @@ -31,6 +35,7 @@ private static class HasIFEQ implements Callable { this.i = i; } + @Override public String call() { if (this.i != 0) { return "was not zero"; @@ -48,21 +53,23 @@ public void shouldReplaceIFEQ_EQUAL_T() throws Exception { assertMutantCallableReturns(new HasIFEQ(1), mutant, expected); assertMutantCallableReturns(new HasIFEQ(0), mutant, expected); } - + @Test public void shouldDescribeReplacementOfEqualityChecksWithTrue() { createTesteeWith(new RemoveConditionalMutator(Choice.EQUAL, true)); final Mutant mutant = getFirstMutant(HasIFEQ.class); - assertThat(mutant.getDetails().getDescription()).contains("equality check with true"); + assertThat(mutant.getDetails().getDescription()).contains( + "equality check with true"); } @Test public void shouldDescribeReplacementOfEqualityChecksWithFalse() { createTesteeWith(new RemoveConditionalMutator(Choice.EQUAL, false)); final Mutant mutant = getFirstMutant(HasIFEQ.class); - assertThat(mutant.getDetails().getDescription()).contains("equality check with false"); + assertThat(mutant.getDetails().getDescription()).contains( + "equality check with false"); } - + @Test public void shouldReplaceIFEQ_EQUAL_F() throws Exception { createTesteeWith(new RemoveConditionalMutator(Choice.EQUAL, false)); @@ -71,7 +78,6 @@ public void shouldReplaceIFEQ_EQUAL_F() throws Exception { assertMutantCallableReturns(new HasIFEQ(1), mutant, expected); assertMutantCallableReturns(new HasIFEQ(0), mutant, expected); } - @Test public void shouldNotReplaceIFEQ_ORDER_T() throws Exception { @@ -92,6 +98,7 @@ private static class HasIFNE implements Callable { this.i = i; } + @Override public String call() { if (this.i == 0) { return "was zero"; @@ -138,6 +145,7 @@ private static class HasIFNULL implements Callable { this.i = i; } + @Override public String call() { if (this.i != null) { return "was not null"; @@ -184,6 +192,7 @@ private static class HasIFNONNULL implements Callable { this.i = i; } + @Override public String call() { if (this.i == null) { return "was null"; @@ -230,6 +239,7 @@ private static class HasIF_ICMPNE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i == j) { @@ -277,6 +287,7 @@ private static class HasIF_ICMPEQ implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i != j) { @@ -317,13 +328,14 @@ public void shouldReplaceIF_ICMPEQ_ORDER_F() throws Exception { assertNoMutants(HasIF_ICMPEQ.class); } - static class HasIF_ACMPEQ implements Callable { + static class HasIF_ACMPEQ implements Callable { private final Object i; HasIF_ACMPEQ(final Object i) { this.i = i; } + @Override public String call() { if (this.i != this) { return "was not zero"; @@ -370,6 +382,7 @@ static class HasIF_ACMPNE implements Callable { this.i = i; } + @Override public String call() { if (this.i == this) { return "was not zero"; @@ -416,6 +429,7 @@ static class HasIFLE implements Callable { this.i = i; } + @Override public String call() { if (this.i > 0) { return "was > zero"; @@ -459,17 +473,18 @@ public void shouldReplaceIFLE_ORDER_F() throws Exception { public void shouldDescribeReplacementOfOrderCheckWithTrue() throws Exception { createTesteeWith(new RemoveConditionalMutator(Choice.ORDER, true)); final Mutant mutant = getFirstMutant(HasIFLE.class); - assertThat(mutant.getDetails().getDescription()).contains(" comparison check with true"); + assertThat(mutant.getDetails().getDescription()).contains( + " comparison check with true"); } - + @Test public void shouldDescribeReplacementOfOrderCheckWithFalse() throws Exception { createTesteeWith(new RemoveConditionalMutator(Choice.ORDER, false)); final Mutant mutant = getFirstMutant(HasIFLE.class); - assertThat(mutant.getDetails().getDescription()).contains(" comparison check with false"); + assertThat(mutant.getDetails().getDescription()).contains( + " comparison check with false"); } - static class HasIFGE implements Callable { private final int i; @@ -477,6 +492,7 @@ static class HasIFGE implements Callable { this.i = i; } + @Override public String call() { if (this.i < 0) { return "was < zero"; @@ -523,6 +539,7 @@ static class HasIFGT implements Callable { this.i = i; } + @Override public String call() { if (this.i <= 0) { return "was <= zero"; @@ -569,6 +586,7 @@ static class HasIFLT implements Callable { this.i = i; } + @Override public String call() { if (this.i >= 0) { return "was >= zero"; @@ -608,7 +626,6 @@ public void shouldReplaceIFLT_ORDER_T_F() throws Exception { assertMutantCallableReturns(new HasIFLT(0), mutant, expected); } - static class HasIF_ICMPLE implements Callable { private final int i; @@ -616,6 +633,7 @@ static class HasIF_ICMPLE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i > j) { @@ -663,6 +681,7 @@ static class HasIF_ICMPGE implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i < j) { @@ -703,7 +722,6 @@ public void shouldReplaceIF_ICMPGE_ORDER_F() throws Exception { assertMutantCallableReturns(new HasIF_ICMPGE(0), mutant, expected); } - static class HasIF_ICMPGT implements Callable { private final int i; @@ -711,6 +729,7 @@ static class HasIF_ICMPGT implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i <= j) { @@ -758,6 +777,7 @@ static class HasIF_ICMPLT implements Callable { this.i = i; } + @Override public String call() { final int j = getZeroButPreventInlining(); if (this.i >= j) { diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutatorTest.java index 3dd5ec134..1bea64a28 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/ReturnValsMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; @@ -41,6 +41,7 @@ public int mutable() { return this.value; } + @Override public String call() throws Exception { return "" + mutable(); } @@ -80,6 +81,7 @@ public long mutable() { return this.value; } + @Override public String call() throws Exception { return "" + mutable(); } @@ -104,6 +106,7 @@ public boolean mutable() { return this.value; } + @Override public String call() throws Exception { return "" + mutable(); } @@ -134,6 +137,7 @@ public float mutable() { return this.value; } + @Override public String call() throws Exception { return "" + mutable(); } @@ -167,6 +171,7 @@ public double mutable() { return this.value; } + @Override public String call() throws Exception { return "" + mutable(); } @@ -201,6 +206,7 @@ public Object mutable() { return this.value; } + @Override public String call() throws Exception { return "" + mutable(); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutatorTest.java index f947f4296..50ccf1d5a 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/VoidMethodCallMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators; @@ -42,6 +42,7 @@ public void set(final int i) { this.i = i; } + @Override public String call() throws Exception { set(1); return "" + this.i; @@ -66,7 +67,7 @@ public void shouldNotRemoveNonVoidMethods() throws Exception { } private static class HasVoidMethodCallWithFinallyBlock implements - Callable { + Callable { private int i = 0; @@ -75,6 +76,7 @@ public void set(final int i, final long k, final double l, this.i = i; } + @Override @SuppressWarnings("finally") public String call() throws Exception { final double a = 1; @@ -104,6 +106,7 @@ public static void set(final int newVal, final long k, final double l, i = newVal; } + @Override @SuppressWarnings("finally") public String call() throws Exception { final double a = 1; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutatorTest.java index e6e4fb896..28f23bf00 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MemberVariableMutatorTest.java @@ -1,17 +1,17 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators.experimental; @@ -28,8 +28,8 @@ import org.pitest.mutationtest.engine.gregor.MutatorTestBase; /** - * - * + * + * * @author Stefan Penndorf */ public class MemberVariableMutatorTest extends MutatorTestBase { @@ -51,6 +51,7 @@ private static class HasMemberVariable implements Callable { private Object member; + @Override public Object call() throws Exception { this.member = TEST_OBJECT; return this.member; @@ -68,6 +69,7 @@ static class HasFinalMemberVariable implements Callable { private final Integer member2 = 5; + @Override public Integer call() throws Exception { return this.member2; } @@ -88,13 +90,14 @@ public HasFinalPrimitiveMemberVariable(final int i) { this.member2 = i; } + @Override public Integer call() throws Exception { return this.member2; } } static class HasFinalPrimitiveMemberVariableStarter extends - MutantStarter { + MutantStarter { @Override protected Callable constructMutee() throws Exception { return new HasFinalPrimitiveMemberVariable(5); @@ -112,6 +115,7 @@ public void shouldRemoveAssignmentToFinalPrimitiveMemberVariable() static class NoInit implements Callable { private int x; + @Override public Integer call() throws Exception { return this.x; } @@ -125,15 +129,16 @@ public void shouldNotCreateMutationForNonInitializedVariable() } static class HasConstantFinalPrimitiveMemberVariable implements - Callable { + Callable { public final int member2 = 42; + @Override public String call() throws Exception { final Class c = getClass(); final Integer i = (Integer) c.getField("member2").get(this); return "" + this.member2 + "-" + i; // will be optimized by compiler to - // "42-" + i; + // "42-" + i; } } @@ -149,10 +154,11 @@ public void isUnableToCreateConsistentMutationForConstantFinalPrimitiveMember() } static class AssignmentAfterSomeValuesOnStack_SingleWord implements - Callable { + Callable { private int member = 1; + @Override public String call() throws Exception { // bipush 100 // aload_0 @@ -178,10 +184,11 @@ public void consumesFromStackTheSameValuesAsPutfieldWouldConsume_SingleWord() } static class AssignmentAfterSomeValuesOnStack_TwoWord implements - Callable { + Callable { private long member = 1; + @Override public String call() throws Exception { // ldc2_w 100 // aload_0 diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarter.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarter.java index f3facf137..edd17a652 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarter.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarter.java @@ -1,17 +1,17 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators.experimental; @@ -30,8 +30,8 @@ * You can subclass this starter and overwrite the constructMutee() * method in order to use your own construction logic. *

- * - * + * + * * @author Stefan Penndorf */ public class MutantStarter implements Callable { @@ -46,7 +46,7 @@ protected MutantStarter() { * Creates a new mutant starter using the default no-arg constructor of the * class supplied. The no-arg constructor and the class itself must have at * least package visibility. - * + * * @param mutantCallableClass * class of mutant callable to create and use in call(). */ @@ -55,6 +55,7 @@ public MutantStarter(final Class> mutantCallableClass) { this.mutantCallableClass = mutantCallableClass; } + @Override public T call() throws Exception { return constructMutee().call(); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarterTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarterTest.java index e6a55f079..67457a913 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/MutantStarterTest.java @@ -1,17 +1,17 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators.experimental; @@ -26,7 +26,7 @@ /** * Unit Test für {@link MutantStarter} helper class. - * + * * @author Stefan Penndorf */ public class MutantStarterTest { @@ -40,6 +40,7 @@ static final class TestMutee implements Callable { TestMutee.muteeCreated = true; } + @Override public TestMutee call() throws Exception { return this; } @@ -77,6 +78,7 @@ public MutantStarterSubclass(final int number) { @Override protected Callable constructMutee() throws Exception { return new Callable() { + @Override public Integer call() throws Exception { return MutantStarterSubclass.this.number; } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutatorTest.java index 5d040e54a..212f7ca6e 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveIncrementsMutatorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.engine.gregor.mutators.experimental; @@ -38,6 +38,7 @@ public int containsIincInstructions(int i) { return ++i; } + @Override public String call() throws Exception { return "" + containsIincInstructions(1); } @@ -49,7 +50,7 @@ public void shouldProvideAMeaningfulName() { assertEquals("REMOVE_INCREMENTS_MUTATOR", RemoveIncrementsMutator.REMOVE_INCREMENTS_MUTATOR.getName()); } - + @Test public void shouldRemoveArgumentsToIInc() throws Exception { final Collection actual = findMutationsFor(HasIncrement.class); @@ -60,6 +61,7 @@ public void shouldRemoveArgumentsToIInc() throws Exception { private static class HasNoIncrements implements Callable { + @Override public String call() throws Exception { return "foo"; } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutatorTest.java index 551dc58bc..49817dba3 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/RemoveSwitchMutatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,8 @@ public void setupEngineToMutateOnlySwitchStatements() { @Test public void shouldProvideAMeaningfulName() { - assertEquals("EXPERIMENTAL_REMOVE_SWITCH_MUTATOR_2", new RemoveSwitchMutator(2).getName()); + assertEquals("EXPERIMENTAL_REMOVE_SWITCH_MUTATOR_2", + new RemoveSwitchMutator(2).getName()); } private static class HasIntSwitchWithDefault implements Callable { @@ -44,6 +45,7 @@ private HasIntSwitchWithDefault(final int value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case 0: @@ -75,6 +77,7 @@ private HasCharSwitchWithDefault(final char value) { this.value = value; } + @Override public Character call() throws Exception { switch (this.value) { case 'a': @@ -110,6 +113,7 @@ private HasEnumSwitchWithDefault(final SwitchEnum value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case FIRST: @@ -127,14 +131,18 @@ public Integer call() throws Exception { @Test public void shouldChangeLabelEnum() throws Exception { final Mutant mutant = getFirstMutant(HasEnumSwitchWithDefault.class); - assertMutantCallableReturns(new HasEnumSwitchWithDefault(SwitchEnum.FIRST), mutant, 1); - assertMutantCallableReturns(new HasEnumSwitchWithDefault(SwitchEnum.SECOND), mutant, 2); - assertMutantCallableReturns(new HasEnumSwitchWithDefault(SwitchEnum.THIRD), mutant, -1); - assertMutantCallableReturns(new HasEnumSwitchWithDefault(SwitchEnum.DEFAULT), mutant, -1); + assertMutantCallableReturns(new HasEnumSwitchWithDefault(SwitchEnum.FIRST), + mutant, 1); + assertMutantCallableReturns( + new HasEnumSwitchWithDefault(SwitchEnum.SECOND), mutant, 2); + assertMutantCallableReturns(new HasEnumSwitchWithDefault(SwitchEnum.THIRD), + mutant, -1); + assertMutantCallableReturns( + new HasEnumSwitchWithDefault(SwitchEnum.DEFAULT), mutant, -1); } private static class HasMultipleArmIntSwitchWithDefault implements - Callable { + Callable { private final int value; @@ -142,6 +150,7 @@ private HasMultipleArmIntSwitchWithDefault(final int value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case 1: @@ -161,15 +170,20 @@ public Integer call() throws Exception { @Test public void shouldReplaceTableLabelsInt() throws Exception { final Mutant mutant = getFirstMutant(HasMultipleArmIntSwitchWithDefault.class); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(0), mutant, 0); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(1), mutant, 1); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(200), mutant, 2); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(4000), mutant, 0); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(800000), mutant, 8); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(0), + mutant, 0); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(1), + mutant, 1); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(200), + mutant, 2); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(4000), + mutant, 0); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithDefault(800000), + mutant, 8); } private static class HasMultipleArmIntSwitchWithoutDefault implements - Callable { + Callable { private final int value; @@ -177,6 +191,7 @@ private HasMultipleArmIntSwitchWithoutDefault(final int value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case 0: @@ -195,15 +210,19 @@ public Integer call() throws Exception { @Test public void shouldReplaceOtherCasesWithoutDefaultForInt() throws Exception { final Mutant mutant = getFirstMutant(HasMultipleArmIntSwitchWithoutDefault.class); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(0), mutant, 0); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(200), mutant, 2); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(4000), mutant, -1); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(800000), mutant, 8); - assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(8), mutant, -1); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(0), + mutant, 0); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(200), + mutant, 2); + assertMutantCallableReturns( + new HasMultipleArmIntSwitchWithoutDefault(4000), mutant, -1); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault( + 800000), mutant, 8); + assertMutantCallableReturns(new HasMultipleArmIntSwitchWithoutDefault(8), + mutant, -1); } - private static class HasFewerLabelsWithDefault implements - Callable { + private static class HasFewerLabelsWithDefault implements Callable { private final int value; @@ -211,6 +230,7 @@ private HasFewerLabelsWithDefault(final int value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case 1: diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutatorTest.java index fa6fb13b0..24fca45ed 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/ReturnValuesMutatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,6 +44,7 @@ private boolean returnPrimitiveBoolean() { return this.value; } + @Override public Boolean call() throws Exception { return returnPrimitiveBoolean(); } @@ -83,6 +84,7 @@ public int returnPrimitiveInteger() { return this.value; } + @Override public Integer call() throws Exception { return returnPrimitiveInteger(); } @@ -119,6 +121,7 @@ public long returnPrimitiveLong() { return this.value; } + @Override public Long call() throws Exception { return returnPrimitiveLong(); } @@ -144,6 +147,7 @@ public float returnPrimitiveFloat() { return this.value; } + @Override public Float call() throws Exception { return returnPrimitiveFloat(); } @@ -177,6 +181,7 @@ public double returnPrimitiveDouble() { return this.value; } + @Override public Double call() throws Exception { return returnPrimitiveDouble(); } @@ -206,6 +211,7 @@ public HasBooleanReturn(final Boolean value) { this.value = value; } + @Override public Boolean call() throws Exception { return this.value; } @@ -246,6 +252,7 @@ public HasIntegerReturn(final Integer value) { this.value = value; } + @Override public Integer call() throws Exception { return this.value; } @@ -280,6 +287,7 @@ public HasLongReturn(final Long value) { this.value = value; } + @Override public Long call() throws Exception { return this.value; } @@ -315,6 +323,7 @@ public HasObjectReturn(final Object value) { this.value = value; } + @Override public Object call() throws Exception { return this.value; } @@ -343,6 +352,7 @@ public HasCustomObjectReturn(final CustomObject value) { this.value = value; } + @Override public CustomObject call() throws Exception { return this.value; } @@ -371,6 +381,7 @@ private HasGenericStuff(final T object) { this.object = object; } + @Override public T call() throws Exception { return this.object; } diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutatorTest.java index b84fa5eba..789cc73f8 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/experimental/SwitchMutatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles and Stefan Penndorf - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,6 +44,7 @@ private HasIntSwitchWithDefault(final int value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case 0: @@ -69,6 +70,7 @@ private HasCharSwitchWithDefault(final char value) { this.value = value; } + @Override public Character call() throws Exception { switch (this.value) { case 'a': @@ -98,6 +100,7 @@ private HasEnumSwitchWithDefault(final SwitchEnum value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case FIRST: @@ -118,7 +121,7 @@ public void shouldSwapFirstCaseWithDefaultForEnum() throws Exception { } private static class HasMultipleArmIntSwitchWithDefault implements - Callable { + Callable { private final int value; @@ -126,6 +129,7 @@ private HasMultipleArmIntSwitchWithDefault(final int value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case 0: @@ -160,7 +164,7 @@ public void shouldReplaceOtherCasesWithDefaultForInt() throws Exception { } private static class HasMultipleArmIntSwitchWithoutDefault implements - Callable { + Callable { private final int value; @@ -168,6 +172,7 @@ private HasMultipleArmIntSwitchWithoutDefault(final int value) { this.value = value; } + @Override public Integer call() throws Exception { switch (this.value) { case 0: @@ -208,6 +213,7 @@ private HasTwoTableSwitchStatements(final int value) { this.value = value; } + @Override public Integer call() throws Exception { int i = 1; switch (this.value) { @@ -232,7 +238,7 @@ public void shouldOnlyCreateRequestedMutationForTableSwitches() } private static class HasTwoLookupSwitchStatements implements - Callable { + Callable { private final int value; @@ -240,6 +246,7 @@ private HasTwoLookupSwitchStatements(final int value) { this.value = value; } + @Override public Integer call() throws Exception { int i = 1; switch (this.value) { diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListenerTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListenerTest.java index 26546d446..e4582346c 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListenerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListenerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,6 @@ import org.pitest.DescriptionMother; import org.pitest.functional.Option; import org.pitest.mutationtest.DetectionStatus; -import org.pitest.mutationtest.execute.CheckTestHasFailedResultListener; import org.pitest.testapi.Description; import org.pitest.testapi.TestResult; @@ -49,7 +48,6 @@ public void shouldReturnDetectionStatusOfKilledWhenEncountersFailure() { assertEquals(DetectionStatus.KILLED, this.testee.status()); } - @Test public void shouldRecordDescriptionOfLastFailingTest() { this.testee.onTestFailure(new TestResult(this.description, null)); diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/DefaultReporterTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/DefaultReporterTest.java index 85ab6469f..0120619f9 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/DefaultReporterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/DefaultReporterTest.java @@ -30,17 +30,18 @@ public void setUp() { @Test public void shouldSendMutationIdentifierToOutputStream() throws IOException { - final MutationIdentifier mi = aMutationId().withIndex(0).withMutator("foo").build(); + final MutationIdentifier mi = aMutationId().withIndex(0).withMutator("foo") + .build(); this.testee.describe(mi); final SafeDataInputStream is = resultToStream(); assertEquals(Id.DESCRIBE, is.readByte()); assertEquals(is.read(MutationIdentifier.class), mi); } - @Test public void shouldSendDetectionStatus() throws IOException { - final MutationIdentifier mi = aMutationId().withIndex(0).withMutator("foo").build(); + final MutationIdentifier mi = aMutationId().withIndex(0).withMutator("foo") + .build(); final MutationStatusTestPair ms = new MutationStatusTestPair(2, DetectionStatus.KILLED, "foo"); this.testee.report(mi, ms); diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestSlaveTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestSlaveTest.java index 2bee1b94a..2423db2a0 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestSlaveTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestSlaveTest.java @@ -63,7 +63,7 @@ public void setup() { when(this.is.read(SlaveArguments.class)).thenReturn(this.args); when(this.engine.createMutator(any(ClassByteArraySource.class))) - .thenReturn(this.mutater); + .thenReturn(this.mutater); this.testee = new MutationTestSlave(this.is, this.reporter); } @@ -76,7 +76,8 @@ public void shouldReportNoErrorWhenNoMutationsSupplied() { @Test public void shouldReportErrorWhenOneOccursDuringAnalysis() { - this.mutations.add(new MutationDetails(aMutationId().withIndex(0).withMutator("foo").build(), null, null, 0, 0)); + this.mutations.add(new MutationDetails(aMutationId().withIndex(0) + .withMutator("foo").build(), null, null, 0, 0)); when(this.mutater.getMutation(any(MutationIdentifier.class))).thenThrow( new PitError("foo")); this.testee.run(); diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java index 4ed3fed3b..419edbc13 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java @@ -33,22 +33,22 @@ public class MutationTestWorkerTest { - private MutationTestWorker testee; + private MutationTestWorker testee; @Mock - private ClassLoader loader; + private ClassLoader loader; @Mock - private Mutater mutater; + private Mutater mutater; @Mock private F3 hotswapper; @Mock - private TimeOutDecoratedTestSource testSource; + private TimeOutDecoratedTestSource testSource; @Mock - private Reporter reporter; + private Reporter reporter; @Before public void setUp() { @@ -133,11 +133,13 @@ public void shouldReportWhenMutationKilledByTest() throws IOException { private TestUnit makeFailingTest() { return new TestUnit() { + @Override public void execute(final ClassLoader loader, final ResultCollector rc) { rc.notifyStart(getDescription()); rc.notifyEnd(getDescription(), new AssertionFailedError()); } + @Override public Description getDescription() { return new Description("atest"); } @@ -148,11 +150,13 @@ public Description getDescription() { private TestUnit makePassingTest() { return new TestUnit() { + @Override public void execute(final ClassLoader loader, final ResultCollector rc) { rc.notifyStart(getDescription()); rc.notifyEnd(getDescription()); } + @Override public Description getDescription() { return new Description("atest"); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java index dc9643ff6..2b85d6d2c 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.execute; @@ -71,6 +71,7 @@ public void shouldApplySideEffectWhenChildRunsForLongerThanAllowedTime() { when(this.timeoutStrategy.getAllowedTime(NORMAL_EXECUTION)).thenReturn(50l); doAnswer(new Answer() { + @Override public Void answer(final InvocationOnMock invocation) throws Throwable { Thread.sleep(100); return null; diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java index 1aac6804b..5afbb787e 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.execute; @@ -29,8 +29,6 @@ import org.pitest.coverage.TestInfo; import org.pitest.functional.Option; import org.pitest.mutationtest.TimeoutLengthStrategy; -import org.pitest.mutationtest.execute.Reporter; -import org.pitest.mutationtest.execute.TimeOutDecoratedTestSource; import org.pitest.testapi.Description; import org.pitest.testapi.ResultCollector; import org.pitest.testapi.TestUnit; @@ -77,9 +75,11 @@ private TestUnit makeTestUnit(final String name) { return new TestUnit() { private final Description description = new Description(name); + @Override public void execute(final ClassLoader loader, final ResultCollector rc) { } + @Override public Description getDescription() { return this.description; } diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java index 9915aa5d5..f2e89a5b4 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java @@ -1,12 +1,12 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilterTest.java b/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilterTest.java index 49278c3d3..067150075 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationPerClassFilterTest.java @@ -1,22 +1,22 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.filter; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; -import static org.pitest.mutationtest.LocationMother.*; +import static org.pitest.mutationtest.LocationMother.aMutationId; import java.util.ArrayList; import java.util.Collection; diff --git a/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactoryTest.java b/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactoryTest.java index 47a51497e..9aa334a27 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactoryTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/filter/LimitNumberOfMutationsPerClassFilterFactoryTest.java @@ -1,25 +1,25 @@ package org.pitest.mutationtest.filter; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; import org.junit.Test; public class LimitNumberOfMutationsPerClassFilterFactoryTest { - - private LimitNumberOfMutationsPerClassFilterFactory testee = new LimitNumberOfMutationsPerClassFilterFactory(); + + private final LimitNumberOfMutationsPerClassFilterFactory testee = new LimitNumberOfMutationsPerClassFilterFactory(); @Test public void shouldFilterWhenNumberOfMutationsPerClassGreaterThanThanZero() { - assertTrue(testee.createFilter(null, null, 1) instanceof LimitNumberOfMutationPerClassFilter); + assertTrue(this.testee.createFilter(null, null, 1) instanceof LimitNumberOfMutationPerClassFilter); } - + @Test public void shouldNotFilterWhenNumberOfMutationsPerClassIsZero() { - assertTrue(testee.createFilter(null, null, 0) instanceof UnfilteredMutationFilter); + assertTrue(this.testee.createFilter(null, null, 0) instanceof UnfilteredMutationFilter); } @Test public void shouldNotFilterWhenNumberOfMutationsPerClassLessThanZero() { - assertTrue(testee.createFilter(null, null, -1) instanceof UnfilteredMutationFilter); + assertTrue(this.testee.createFilter(null, null, -1) instanceof UnfilteredMutationFilter); } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java b/pitest/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java index e5695344a..170a46fed 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java @@ -112,12 +112,12 @@ public void shouldTreatClassesWithSameHashAsUnChanged() { private void setCurrentClassPath(final HierarchicalClassId currentId) { final ClassInfo currentClass = ClassInfoMother.make(currentId.getId()); when(this.classInfoSource.fetchClass(ClassName.fromString("foo"))) - .thenReturn(Option.some(currentClass)); + .thenReturn(Option.some(currentClass)); } private void setCurrentClassPath(final ClassInfo info) { when(this.classInfoSource.fetchClass(ClassName.fromString("foo"))) - .thenReturn(Option.some(info)); + .thenReturn(Option.some(info)); } private ClassHistory makeHistory(final HierarchicalClassId id) { @@ -128,5 +128,4 @@ private ClassHistory makeHistory(final ClassInfo ci) { return makeHistory(ci.getHierarchicalId()); } - } diff --git a/pitest/src/test/java/org/pitest/mutationtest/incremental/FileWriterFactoryTest.java b/pitest/src/test/java/org/pitest/mutationtest/incremental/FileWriterFactoryTest.java index 1da079bee..89e1a9609 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/incremental/FileWriterFactoryTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/incremental/FileWriterFactoryTest.java @@ -19,46 +19,46 @@ public class FileWriterFactoryTest { - @Rule - public TemporaryFolder testFolder = new TemporaryFolder(); + @Rule + public TemporaryFolder testFolder = new TemporaryFolder(); - @Rule - public ExpectedException thrown = ExpectedException.none(); + @Rule + public ExpectedException thrown = ExpectedException.none(); - @Test - public void writeToFile() throws IOException { - File file = testFolder.newFile(); - FileWriterFactory writerFactory = new FileWriterFactory(file); - PrintWriter writer = writerFactory.create(); - writer.write("test"); - writerFactory.close(); + @Test + public void writeToFile() throws IOException { + File file = this.testFolder.newFile(); + FileWriterFactory writerFactory = new FileWriterFactory(file); + PrintWriter writer = writerFactory.create(); + writer.write("test"); + writerFactory.close(); - String content = FileUtil.readToString( new FileInputStream(file) ); - assertThat(content, equalTo("test")); - } + String content = FileUtil.readToString(new FileInputStream(file)); + assertThat(content, equalTo("test")); + } - @Test - public void writeToFolder() throws IOException { - thrown.expect(PitError.class); - Matcher causedBy = instanceOf(IOException.class); - thrown.expectCause(causedBy); + @Test + public void writeToFolder() throws IOException { + this.thrown.expect(PitError.class); + Matcher causedBy = instanceOf(IOException.class); + this.thrown.expectCause(causedBy); - File folder = testFolder.newFolder(); - FileWriterFactory writerFactory = new FileWriterFactory(folder); - writerFactory.create(); - } + File folder = this.testFolder.newFolder(); + FileWriterFactory writerFactory = new FileWriterFactory(folder); + writerFactory.create(); + } - @Test - public void writeToFileWithinFolder() throws IOException { - File folder = testFolder.newFolder(); - File file = new File(folder, "subfolder/file"); - FileWriterFactory writerFactory = new FileWriterFactory(file); - PrintWriter writer = writerFactory.create(); - writer.write("test"); - writerFactory.close(); + @Test + public void writeToFileWithinFolder() throws IOException { + File folder = this.testFolder.newFolder(); + File file = new File(folder, "subfolder/file"); + FileWriterFactory writerFactory = new FileWriterFactory(file); + PrintWriter writer = writerFactory.create(); + writer.write("test"); + writerFactory.close(); + + String content = FileUtil.readToString(new FileInputStream(file)); + assertThat(content, equalTo("test")); + } - String content = FileUtil.readToString( new FileInputStream(file) ); - assertThat(content, equalTo("test")); - } - } diff --git a/pitest/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java b/pitest/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java index 5852b9d74..f250abe21 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java @@ -3,7 +3,8 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Mockito.when; -import static org.pitest.mutationtest.LocationMother.*; +import static org.pitest.mutationtest.LocationMother.aLocation; +import static org.pitest.mutationtest.LocationMother.aMutationId; import java.math.BigInteger; import java.util.Collection; @@ -43,7 +44,7 @@ public void setUp() { public void shouldStartNewMutationsAtAStatusOfNotStarted() { final MutationDetails md = makeMutation("foo"); when(this.history.getPreviousResult(any(MutationIdentifier.class))) - .thenReturn(Option. none()); + .thenReturn(Option. none()); final Collection actual = this.testee.analyse(Collections .singletonList(md)); @@ -110,7 +111,7 @@ public void shouldStartPreviousKilledMutationsAtAStatusOfNotStartedWhenNeitherCl final Collection tests = Collections.singleton(new TestInfo( "TEST_CLASS", killingTest, 0, Option. none(), 0)); when(this.coverage.getTestsForClass(any(ClassName.class))) - .thenReturn(tests); + .thenReturn(tests); when(this.history.hasClassChanged(any(ClassName.class))).thenReturn(false); final MutationResult actual = this.testee .analyse(Collections.singletonList(md)).iterator().next(); @@ -128,11 +129,11 @@ public void shouldStartPreviousKilledMutationsAtAStatusOfKilledWhenNeitherClassO final Collection tests = Collections.singleton(new TestInfo( "TEST_CLASS", killingTest, 0, Option. none(), 0)); when(this.coverage.getTestsForClass(any(ClassName.class))) - .thenReturn(tests); + .thenReturn(tests); when(this.history.hasClassChanged(ClassName.fromString("foo"))).thenReturn( false); when(this.history.hasClassChanged(ClassName.fromString("TEST_CLASS"))) - .thenReturn(true); + .thenReturn(true); final MutationResult actual = this.testee .analyse(Collections.singletonList(md)).iterator().next(); @@ -140,7 +141,8 @@ public void shouldStartPreviousKilledMutationsAtAStatusOfKilledWhenNeitherClassO } private MutationDetails makeMutation(final String method) { - final MutationIdentifier id = aMutationId().withLocation(aLocation().withMethod(method)).build(); + final MutationIdentifier id = aMutationId().withLocation( + aLocation().withMethod(method)).build(); return new MutationDetails(id, "file", "desc", 1, 2); } @@ -151,7 +153,7 @@ private void setHistoryForAllMutationsTo(final DetectionStatus status) { private void setHistoryForAllMutationsTo(final DetectionStatus status, final String test) { when(this.history.getPreviousResult(any(MutationIdentifier.class))) - .thenReturn(Option.some(new MutationStatusTestPair(0, status, test))); + .thenReturn(Option.some(new MutationStatusTestPair(0, status, test))); } } diff --git a/pitest/src/test/java/org/pitest/mutationtest/incremental/NullHistoryStore.java b/pitest/src/test/java/org/pitest/mutationtest/incremental/NullHistoryStore.java index e8d008c29..83b3a265a 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/incremental/NullHistoryStore.java +++ b/pitest/src/test/java/org/pitest/mutationtest/incremental/NullHistoryStore.java @@ -15,22 +15,27 @@ public class NullHistoryStore implements HistoryStore { + @Override public void initialize() { } + @Override public void recordResult(final MutationResult result) { } + @Override public Map getHistoricResults() { return Collections.emptyMap(); } + @Override public Map getHistoricClassPath() { return Collections.emptyMap(); } + @Override public void recordClassPath(final Collection ids, final CoverageDatabase coverageInfo) { diff --git a/pitest/src/test/java/org/pitest/mutationtest/incremental/XStreamHistoryStoreTest.java b/pitest/src/test/java/org/pitest/mutationtest/incremental/XStreamHistoryStoreTest.java index 09b792835..5f1288495 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/incremental/XStreamHistoryStoreTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/incremental/XStreamHistoryStoreTest.java @@ -47,16 +47,18 @@ public class XStreamHistoryStoreTest { private final WriterFactory writerFactory = new WriterFactory() { - public PrintWriter create() { - return new PrintWriter( - XStreamHistoryStoreTest.this.output); - } + @Override + public PrintWriter create() { + return new PrintWriter( + XStreamHistoryStoreTest.this.output); + } - public void close() { + @Override + public void close() { - } + } - }; + }; @Before public void setUp() { diff --git a/pitest/src/test/java/org/pitest/mutationtest/instrument/InstrumentedMutationTestUnitTest.java b/pitest/src/test/java/org/pitest/mutationtest/instrument/InstrumentedMutationTestUnitTest.java index be67220d8..8923c2a3c 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/instrument/InstrumentedMutationTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/instrument/InstrumentedMutationTestUnitTest.java @@ -1,16 +1,16 @@ ///* // * Copyright 2010 Henry Coles -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and limitations under the License. +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and limitations under the License. // */ //package org.pitest.mutationtest.instrument; // diff --git a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java index 38acdbb8f..d56053db1 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java @@ -24,15 +24,18 @@ public void setUp() { @Test public void shouldNotInterceptNormalInvokeInterfaceCalls() { - this.testee.visitMethodInsn(Opcodes.INVOKEINTERFACE, "foo", "bar", "far", false); + this.testee.visitMethodInsn(Opcodes.INVOKEINTERFACE, "foo", "bar", "far", + false); verify(this.mv).visitMethodInsn(Opcodes.INVOKEINTERFACE, "foo", "bar", - "far",false); + "far", false); } @Test public void shouldNotInterceptNormalInvokeStaticCalls() { - this.testee.visitMethodInsn(Opcodes.INVOKESTATIC, "foo", "bar", "far", false); - verify(this.mv).visitMethodInsn(Opcodes.INVOKESTATIC, "foo", "bar", "far", false); + this.testee.visitMethodInsn(Opcodes.INVOKESTATIC, "foo", "bar", "far", + false); + verify(this.mv).visitMethodInsn(Opcodes.INVOKESTATIC, "foo", "bar", "far", + false); } @Test diff --git a/pitest/src/test/java/org/pitest/mutationtest/report/MutationTestResultMother.java b/pitest/src/test/java/org/pitest/mutationtest/report/MutationTestResultMother.java index a39316319..4d640341f 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/report/MutationTestResultMother.java +++ b/pitest/src/test/java/org/pitest/mutationtest/report/MutationTestResultMother.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,10 +36,10 @@ public static MutationDetails createDetails(final String sourceFile) { public static MutationMetaData createMetaData(final MutationResult... mrs) { return new MutationMetaData(Arrays.asList(mrs)); } - - public static ClassMutationResults createClassResults(final MutationResult... mrs) { + + public static ClassMutationResults createClassResults( + final MutationResult... mrs) { return new ClassMutationResults(Arrays.asList(mrs)); } - - + } diff --git a/pitest/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java b/pitest/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java index cdb1f2ea5..a3b57c1d3 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/mutationtest/report/xml/XMLReportListenerTest.java b/pitest/src/test/java/org/pitest/mutationtest/report/xml/XMLReportListenerTest.java index 1fcddecd3..6bfa74553 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/report/xml/XMLReportListenerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/report/xml/XMLReportListenerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsListenerTest.java b/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsListenerTest.java index 4d7b871cc..051109b8c 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsListenerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsListenerTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.statistics; @@ -57,6 +57,7 @@ private boolean hasResultFor(final String mutator) { private F hasResultForMutator(final String mutator) { return new F() { + @Override public Boolean apply(final Score a) { return a.getMutatorName().equals(mutator); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsTest.java b/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsTest.java index c95b9a63e..bc5a6f578 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/statistics/MutationStatisticsTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.statistics; @@ -116,6 +116,7 @@ public void shouldReportTotalNumberOfTestsRun() { private F hasResultForMutator(final String mutator) { return new F() { + @Override public Boolean apply(final Score a) { return a.getMutatorName().equals(mutator); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/statistics/ScoreTest.java b/pitest/src/test/java/org/pitest/mutationtest/statistics/ScoreTest.java index 731060950..864ac4748 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/statistics/ScoreTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/statistics/ScoreTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.mutationtest.statistics; @@ -139,6 +139,7 @@ private F countFor(final DetectionStatus each, final int count) { return new F() { + @Override public Boolean apply(final StatusCount a) { return a.getStatus().equals(each) && (a.getCount() == count); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java index 37efeba48..bc3160d98 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,6 @@ import org.mockito.MockitoAnnotations; import org.pitest.functional.F; import org.pitest.functional.Option; -import org.pitest.mutationtest.tooling.DirectorySourceLocator; public class DirectorySourceLocatorTest { @@ -44,7 +43,7 @@ public void setUp() { this.root = new File("."); this.testee = new DirectorySourceLocator(this.root, this.locator); when(this.locator.apply(any(File.class))) - .thenReturn(Option. none()); + .thenReturn(Option. none()); } @Test @@ -57,7 +56,7 @@ public void shouldLocateSourceForClassesInDefaultPackage() { @Test public void shouldLocateSourceForClassesInNamedPacakges() { this.testee - .locate(Collections.singletonList("com.example.Foo"), "Foo.java"); + .locate(Collections.singletonList("com.example.Foo"), "Foo.java"); final File expected = new File(this.root + File.separator + "com" + File.separator + "example" + File.separator + "Foo.java"); verify(this.locator).apply(expected); diff --git a/pitest/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java b/pitest/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java index 738964afe..53919453e 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,10 +41,10 @@ public class JarCreatingJarFinderTest { - private JarCreatingJarFinder testee; + private JarCreatingJarFinder testee; @Mock - private ClassByteArraySource byteSource; + private ClassByteArraySource byteSource; @Rule public final ExpectedException thrown = ExpectedException.none(); @@ -115,11 +115,12 @@ public void shouldAddPITToTheBootClassPath() throws IOException { @Test public void shouldFailOnUnreadableRessources() throws IOException { - thrown.expect(PitError.class); + this.thrown.expect(PitError.class); - when(this.byteSource.getBytes(anyString())).thenReturn(Option.none()); + when(this.byteSource.getBytes(anyString())).thenReturn( + Option. none()); - this.testee.getJarLocation(); + this.testee.getJarLocation(); } private void assertGeneratedManifestEntryEquals(final String key, diff --git a/pitest/src/test/java/org/pitest/mutationtest/tooling/SpinnerListenerTest.java b/pitest/src/test/java/org/pitest/mutationtest/tooling/SpinnerListenerTest.java index 7eaa2fae4..56e377b90 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/tooling/SpinnerListenerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/tooling/SpinnerListenerTest.java @@ -6,7 +6,6 @@ import java.io.PrintStream; import org.junit.Test; -import org.pitest.mutationtest.tooling.SpinnerListener; public class SpinnerListenerTest { diff --git a/pitest/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java b/pitest/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java index bc6d5a0a8..de213ea9c 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java @@ -1,12 +1,12 @@ /* * Copyright 2012 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/process/KnownLocationJavaExecutableLocatorTest.java b/pitest/src/test/java/org/pitest/process/KnownLocationJavaExecutableLocatorTest.java index 98f111d25..dc589a9d6 100644 --- a/pitest/src/test/java/org/pitest/process/KnownLocationJavaExecutableLocatorTest.java +++ b/pitest/src/test/java/org/pitest/process/KnownLocationJavaExecutableLocatorTest.java @@ -1,6 +1,6 @@ package org.pitest.process; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import org.junit.Test; @@ -8,7 +8,8 @@ public class KnownLocationJavaExecutableLocatorTest { @Test public void shouldReturnWrappedLocation() { - assertEquals("foo", new KnownLocationJavaExecutableLocator("foo").javaExecutable()); + assertEquals("foo", + new KnownLocationJavaExecutableLocator("foo").javaExecutable()); } } diff --git a/pitest/src/test/java/org/pitest/process/WrappingProcessTest.java b/pitest/src/test/java/org/pitest/process/WrappingProcessTest.java index 87238bb87..97c914ea8 100644 --- a/pitest/src/test/java/org/pitest/process/WrappingProcessTest.java +++ b/pitest/src/test/java/org/pitest/process/WrappingProcessTest.java @@ -1,17 +1,17 @@ package org.pitest.process; -import org.junit.Test; -import org.pitest.classpath.ClassPath; -import org.pitest.functional.SideEffect1; -import org.pitest.util.NullJavaAgent; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.HashMap; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.pitest.classpath.ClassPath; +import org.pitest.functional.SideEffect1; +import org.pitest.util.NullJavaAgent; public class WrappingProcessTest { @@ -30,21 +30,20 @@ public static void main(final String[] args) { @Test public void waitToDieShouldReturnProcessExitCode() throws IOException, - InterruptedException { + InterruptedException { - LaunchOptions launchOptions = new LaunchOptions( - NullJavaAgent.instance(), - new DefaultJavaExecutableLocator(), - Collections.emptyList(), + LaunchOptions launchOptions = new LaunchOptions(NullJavaAgent.instance(), + new DefaultJavaExecutableLocator(), Collections. emptyList(), new HashMap()); - ProcessArgs processArgs = ProcessArgs.withClassPath(new ClassPath().getLocalClassPath()) + ProcessArgs processArgs = ProcessArgs + .withClassPath(new ClassPath().getLocalClassPath()) .andBaseDir(new File(System.getProperty("user.dir"))) - .andLaunchOptions(launchOptions) - .andStdout(nullHandler()) + .andLaunchOptions(launchOptions).andStdout(nullHandler()) .andStderr(nullHandler()); - WrappingProcess wrappingProcess = new WrappingProcess(-1,processArgs,getClass()); + WrappingProcess wrappingProcess = new WrappingProcess(-1, processArgs, + getClass()); wrappingProcess.start(); JavaProcess process = wrappingProcess.getProcess(); @@ -54,6 +53,7 @@ public void waitToDieShouldReturnProcessExitCode() throws IOException, private SideEffect1 nullHandler() { return new SideEffect1() { + @Override public void apply(final String a) { } diff --git a/pitest/src/test/java/org/pitest/reflection/ReflectionTest.java b/pitest/src/test/java/org/pitest/reflection/ReflectionTest.java index 85524eed2..762190fb0 100644 --- a/pitest/src/test/java/org/pitest/reflection/ReflectionTest.java +++ b/pitest/src/test/java/org/pitest/reflection/ReflectionTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,13 +26,14 @@ public class ReflectionTest { static class Parent { public int first; + public void foo() { } } static class Child extends Parent { - public int second; + public int second; public static int third; } diff --git a/pitest/src/test/java/org/pitest/simpletest/BasicTestUnitFinder.java b/pitest/src/test/java/org/pitest/simpletest/BasicTestUnitFinder.java index 5157a14cd..69f9ec646 100644 --- a/pitest/src/test/java/org/pitest/simpletest/BasicTestUnitFinder.java +++ b/pitest/src/test/java/org/pitest/simpletest/BasicTestUnitFinder.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,6 +47,7 @@ public BasicTestUnitFinder( this.testMethodFinders.addAll(testMethodFinders); } + @Override public List findTestUnits(final Class testClass) { try { @@ -58,9 +59,9 @@ public List findTestUnits(final Class testClass) { for (final TestMethod m : findTestMethods(testClass)) { final TestStep step = instantiations.get(instantiation); units - .add(createTestUnitForInstantiation(step, - getNamePrefix(instantiations.size(), instantiation), - testClass, m)); + .add(createTestUnitForInstantiation(step, + getNamePrefix(instantiations.size(), instantiation), + testClass, m)); } } @@ -107,6 +108,7 @@ private InstantiationStrategy findInstantiationStrategy(final Class clazz) { private F canInstantiate(final Class clazz) { return new F() { + @Override public Boolean apply(final InstantiationStrategy a) { return a.canInstantiate(clazz); } @@ -119,6 +121,7 @@ private Collection findTestMethods(final Class clazz) { final EqualitySet set = new EqualitySet( new SignatureEqualityStrategy()); final SideEffect1 addToSet = new SideEffect1() { + @Override public void apply(final TestMethod a) { set.add(a); } diff --git a/pitest/src/test/java/org/pitest/simpletest/CanNotCreateTestClassException.java b/pitest/src/test/java/org/pitest/simpletest/CanNotCreateTestClassException.java index caf342e70..decb9eec8 100644 --- a/pitest/src/test/java/org/pitest/simpletest/CanNotCreateTestClassException.java +++ b/pitest/src/test/java/org/pitest/simpletest/CanNotCreateTestClassException.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ /** * @author henry - * + * */ public class CanNotCreateTestClassException extends RuntimeException { diff --git a/pitest/src/test/java/org/pitest/simpletest/ConfigurationForTesting.java b/pitest/src/test/java/org/pitest/simpletest/ConfigurationForTesting.java index 1c2d276b2..94e8698eb 100644 --- a/pitest/src/test/java/org/pitest/simpletest/ConfigurationForTesting.java +++ b/pitest/src/test/java/org/pitest/simpletest/ConfigurationForTesting.java @@ -12,12 +12,17 @@ import org.pitest.functional.Option; import org.pitest.help.PitHelpError; import org.pitest.junit.CompoundTestUnitFinder; -import org.pitest.testapi.*; +import org.pitest.testapi.BaseTestClassIdentifier; +import org.pitest.testapi.Configuration; +import org.pitest.testapi.TestClassIdentifier; +import org.pitest.testapi.TestSuiteFinder; +import org.pitest.testapi.TestUnitFinder; public class ConfigurationForTesting implements Configuration { private static class TestFinder implements MethodFinder { + @Override public Option apply(final Method method) { final TestAnnotationForTesting annotation = method .getAnnotation(TestAnnotationForTesting.class); @@ -25,8 +30,8 @@ public Option apply(final Method method) { if (annotation != null) { final Class expected = !annotation.expected() .getName().equals(TestAnnotationForTesting.NONE.class.getName()) ? annotation - .expected() : null; - return Option.some(new TestMethod(method, expected)); + .expected() : null; + return Option.some(new TestMethod(method, expected)); } else { return Option.none(); } @@ -34,6 +39,7 @@ public Option apply(final Method method) { } + @Override public TestUnitFinder testUnitFinder() { final Set tmfs = new LinkedHashSet(); @@ -41,7 +47,7 @@ public TestUnitFinder testUnitFinder() { final List instantiationStrategies = - Arrays + Arrays . asList(new NoArgsConstructorInstantiationStrategy()); return new CompoundTestUnitFinder( @@ -49,19 +55,23 @@ Collections. singletonList(new BasicTestUnitFinder( instantiationStrategies, tmfs))); } + @Override public TestSuiteFinder testSuiteFinder() { return new NoTestSuiteFinder(); } + @Override public TestClassIdentifier testClassIdentifier() { return new BaseTestClassIdentifier() { + @Override public boolean isATestClass(final ClassInfo a) { return a.hasAnnotation(TestAnnotationForTesting.class); } }; } + @Override public Option verifyEnvironment() { return Option.none(); } diff --git a/pitest/src/test/java/org/pitest/simpletest/EqualitySet.java b/pitest/src/test/java/org/pitest/simpletest/EqualitySet.java index d5eeb806f..66dd33454 100644 --- a/pitest/src/test/java/org/pitest/simpletest/EqualitySet.java +++ b/pitest/src/test/java/org/pitest/simpletest/EqualitySet.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; @@ -21,7 +21,7 @@ /** * @author henry - * + * */ public class EqualitySet implements Iterable { @@ -60,6 +60,7 @@ public boolean isEmpty() { return this.members.isEmpty(); } + @Override public Iterator iterator() { return this.members.iterator(); } diff --git a/pitest/src/test/java/org/pitest/simpletest/EqualitySetTest.java b/pitest/src/test/java/org/pitest/simpletest/EqualitySetTest.java index 9de1b4a10..010560b43 100644 --- a/pitest/src/test/java/org/pitest/simpletest/EqualitySetTest.java +++ b/pitest/src/test/java/org/pitest/simpletest/EqualitySetTest.java @@ -18,6 +18,7 @@ public class EqualitySetTest { @Before public void createTestee() { final EqualityStrategy e = new EqualityStrategy() { + @Override public boolean isEqual(final String lhs, final String rhs) { return lhs.equals(rhs); } diff --git a/pitest/src/test/java/org/pitest/simpletest/EqualityStrategy.java b/pitest/src/test/java/org/pitest/simpletest/EqualityStrategy.java index 3789abea9..ffc9020a8 100644 --- a/pitest/src/test/java/org/pitest/simpletest/EqualityStrategy.java +++ b/pitest/src/test/java/org/pitest/simpletest/EqualityStrategy.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; diff --git a/pitest/src/test/java/org/pitest/simpletest/ExcludedPrefixIsolationStrategy.java b/pitest/src/test/java/org/pitest/simpletest/ExcludedPrefixIsolationStrategy.java index 7abd5877e..e11a81fa9 100644 --- a/pitest/src/test/java/org/pitest/simpletest/ExcludedPrefixIsolationStrategy.java +++ b/pitest/src/test/java/org/pitest/simpletest/ExcludedPrefixIsolationStrategy.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; @@ -32,6 +32,7 @@ public ExcludedPrefixIsolationStrategy( this.excludedPackagePrefixes.addAll(excludedPackagePrefixes); } + @Override public boolean shouldIsolate(final String name) { for (final String s : this.excludedPackagePrefixes) { if (name.startsWith(s)) { diff --git a/pitest/src/test/java/org/pitest/simpletest/InstantiationStrategy.java b/pitest/src/test/java/org/pitest/simpletest/InstantiationStrategy.java index a2effcbc0..bdd47c45e 100644 --- a/pitest/src/test/java/org/pitest/simpletest/InstantiationStrategy.java +++ b/pitest/src/test/java/org/pitest/simpletest/InstantiationStrategy.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; diff --git a/pitest/src/test/java/org/pitest/simpletest/IsolationStrategy.java b/pitest/src/test/java/org/pitest/simpletest/IsolationStrategy.java index d34fa842e..fce4b970b 100644 --- a/pitest/src/test/java/org/pitest/simpletest/IsolationStrategy.java +++ b/pitest/src/test/java/org/pitest/simpletest/IsolationStrategy.java @@ -1,22 +1,22 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; /** * @author henry - * + * */ public interface IsolationStrategy { diff --git a/pitest/src/test/java/org/pitest/simpletest/MethodFinder.java b/pitest/src/test/java/org/pitest/simpletest/MethodFinder.java index b0941ec27..b2ab85e8e 100644 --- a/pitest/src/test/java/org/pitest/simpletest/MethodFinder.java +++ b/pitest/src/test/java/org/pitest/simpletest/MethodFinder.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; diff --git a/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategy.java b/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategy.java index d334f9301..28010a273 100644 --- a/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategy.java +++ b/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategy.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; @@ -20,13 +20,15 @@ import org.pitest.simpletest.steps.NoArgsInstantiateStep; public class NoArgsConstructorInstantiationStrategy implements - InstantiationStrategy { +InstantiationStrategy { + @Override public List instantiations(final Class clazz) { return Collections. singletonList(NoArgsInstantiateStep .instantiate(clazz)); } + @Override public boolean canInstantiate(final Class clazz) { // unwise premature optimization // don't check if a no-args constructor is present diff --git a/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategyTest.java b/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategyTest.java index ee47ecced..8073b3519 100644 --- a/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategyTest.java +++ b/pitest/src/test/java/org/pitest/simpletest/NoArgsConstructorInstantiationStrategyTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; @@ -47,7 +47,7 @@ public void shouldCreateSingleInstantiateTestStep() { .instantiate(NoArgsConstructorInstantiationStrategyTest.class)); assertEquals(expected, this.testee - .instantiations(NoArgsConstructorInstantiationStrategyTest.class)); + .instantiations(NoArgsConstructorInstantiationStrategyTest.class)); } diff --git a/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategy.java b/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategy.java index 3c0882716..96e9863b6 100644 --- a/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategy.java +++ b/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategy.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; @@ -19,6 +19,7 @@ public class SignatureEqualityStrategy implements EqualityStrategy { + @Override public boolean isEqual(final TestMethod lhs, final TestMethod rhs) { final Method m1 = lhs.getMethod(); final Method m2 = rhs.getMethod(); diff --git a/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategyTest.java b/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategyTest.java index a03ae71d8..333cbaf5d 100644 --- a/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategyTest.java +++ b/pitest/src/test/java/org/pitest/simpletest/SignatureEqualityStrategyTest.java @@ -34,12 +34,14 @@ public void shouldConsiderSameMethodEqual() { @Test public void shouldConsiderMethodsWithSameNameButDifferentSignaturesNotEqual() { final Predicate noargs = new Predicate() { + @Override public Boolean apply(final Method a) { return a.getName().equals("foo") && (a.getParameterTypes().length == 0); } }; final Predicate onearg = new Predicate() { + @Override public Boolean apply(final Method a) { return a.getName().equals("foo") && (a.getParameterTypes().length == 1); } @@ -67,6 +69,7 @@ private TestMethod createTestMethod(final Predicate p) { private TestMethod createTestMethod(final String name) { final Predicate p = new Predicate() { + @Override public Boolean apply(final Method a) { return a.getName().equals(name); } diff --git a/pitest/src/test/java/org/pitest/simpletest/SteppedTestUnit.java b/pitest/src/test/java/org/pitest/simpletest/SteppedTestUnit.java index 30deea106..17aa1cef9 100644 --- a/pitest/src/test/java/org/pitest/simpletest/SteppedTestUnit.java +++ b/pitest/src/test/java/org/pitest/simpletest/SteppedTestUnit.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; @@ -24,7 +24,7 @@ /** * @author henry - * + * */ public class SteppedTestUnit extends AbstractTestUnit { diff --git a/pitest/src/test/java/org/pitest/simpletest/TestExecutionException.java b/pitest/src/test/java/org/pitest/simpletest/TestExecutionException.java index 1d19855c2..24bfdf751 100644 --- a/pitest/src/test/java/org/pitest/simpletest/TestExecutionException.java +++ b/pitest/src/test/java/org/pitest/simpletest/TestExecutionException.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; diff --git a/pitest/src/test/java/org/pitest/simpletest/TestMethod.java b/pitest/src/test/java/org/pitest/simpletest/TestMethod.java index 2aaf893c4..45a829a9f 100644 --- a/pitest/src/test/java/org/pitest/simpletest/TestMethod.java +++ b/pitest/src/test/java/org/pitest/simpletest/TestMethod.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; diff --git a/pitest/src/test/java/org/pitest/simpletest/TestStep.java b/pitest/src/test/java/org/pitest/simpletest/TestStep.java index fb451c0ea..0f3128632 100644 --- a/pitest/src/test/java/org/pitest/simpletest/TestStep.java +++ b/pitest/src/test/java/org/pitest/simpletest/TestStep.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; diff --git a/pitest/src/test/java/org/pitest/simpletest/Transformation.java b/pitest/src/test/java/org/pitest/simpletest/Transformation.java index 76b691ba8..3bdb21256 100644 --- a/pitest/src/test/java/org/pitest/simpletest/Transformation.java +++ b/pitest/src/test/java/org/pitest/simpletest/Transformation.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest; diff --git a/pitest/src/test/java/org/pitest/simpletest/TransformingClassLoader.java b/pitest/src/test/java/org/pitest/simpletest/TransformingClassLoader.java index f347017db..74fc41e73 100644 --- a/pitest/src/test/java/org/pitest/simpletest/TransformingClassLoader.java +++ b/pitest/src/test/java/org/pitest/simpletest/TransformingClassLoader.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/simpletest/steps/CallStep.java b/pitest/src/test/java/org/pitest/simpletest/steps/CallStep.java index f7b25cf5c..7bb7739da 100644 --- a/pitest/src/test/java/org/pitest/simpletest/steps/CallStep.java +++ b/pitest/src/test/java/org/pitest/simpletest/steps/CallStep.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest.steps; @@ -24,7 +24,7 @@ /** * @author henry - * + * */ public class CallStep implements TestStep { @@ -34,6 +34,7 @@ public CallStep(final TestMethod m) { this.m = m; } + @Override public Object execute(final ClassLoader loader, final Description testDescription, final Object target) { try { diff --git a/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStep.java b/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStep.java index c5668fc70..de7a75d1d 100644 --- a/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStep.java +++ b/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStep.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.simpletest.steps; @@ -23,7 +23,7 @@ /** * @author henry - * + * */ public final class NoArgsInstantiateStep implements TestStep { @@ -37,6 +37,7 @@ public NoArgsInstantiateStep(final Class clazz) { this.clazz = clazz; } + @Override public Object execute(final ClassLoader loader, final Description testDescription, final Object target) { try { diff --git a/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStepTest.java b/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStepTest.java index 54a61641d..83fea99d5 100644 --- a/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStepTest.java +++ b/pitest/src/test/java/org/pitest/simpletest/steps/NoArgsInstantiateStepTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/testapi/DescriptionTest.java b/pitest/src/test/java/org/pitest/testapi/DescriptionTest.java index b82058c95..1fa342abb 100644 --- a/pitest/src/test/java/org/pitest/testapi/DescriptionTest.java +++ b/pitest/src/test/java/org/pitest/testapi/DescriptionTest.java @@ -6,7 +6,6 @@ import java.io.IOException; import org.junit.Test; -import org.pitest.testapi.Description; import org.pitest.util.IsolationUtils; public class DescriptionTest { diff --git a/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java b/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java index bc7ccc6ff..1d88b048c 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,6 @@ import org.mockito.MockitoAnnotations; import org.pitest.testapi.Description; import org.pitest.testapi.ResultCollector; -import org.pitest.testapi.execute.ExitingResultCollector; public class ExitingResultCollectorTest { diff --git a/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java b/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java index b14b2bdf7..32e186b71 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,7 +30,6 @@ import org.pitest.testapi.Description; import org.pitest.testapi.ResultCollector; import org.pitest.testapi.TestUnit; -import org.pitest.testapi.execute.MultipleTestGroup; import org.pitest.util.IsolationUtils; public class MultipleTestGroupTest { @@ -80,6 +79,6 @@ public void shouldStopExecutingWhenResultCollectorRequestsStop() { @Test public void shouldObeyHashcodeEqualsContract() { EqualsVerifier.forClass(MultipleTestGroup.class).verify(); - } - + } + } diff --git a/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java b/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java index 5d28c5b21..1108b13d4 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testapi.execute; @@ -23,14 +23,13 @@ import org.pitest.testapi.Description; import org.pitest.testapi.TestListener; import org.pitest.testapi.TestResult; -import org.pitest.testapi.execute.ResultType; public class ResultTypeTest { @Mock - private TestListener listener; + private TestListener listener; - private TestResult result = new TestResult(new Description("foo"), null); + private final TestResult result = new TestResult(new Description("foo"), null); @Before public void setUp() { diff --git a/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java b/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java index f9a25ce12..43af864e4 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.pitest.testapi.execute; @@ -22,25 +22,24 @@ /** * @author henry - * + * */ public class TestPitest { - private Pitest testee; - private Container container; + private Pitest testee; + private Container container; @Mock - private TestListener listener; + private TestListener listener; @Mock - private TestListener listener2; - + private TestListener listener2; @Before public void setUp() { MockitoAnnotations.initMocks(this); this.container = new UnContainer(); - this.testee = new Pitest(Arrays.asList(listener,listener2)); + this.testee = new Pitest(Arrays.asList(this.listener, this.listener2)); } public static class PassingTest { @@ -54,28 +53,29 @@ public void shouldPass() { public void shouldNotifyAllListenersOfRunStart() { run(PassingTest.class); verify(this.listener).onRunStart(); - verify(listener2).onRunStart(); + verify(this.listener2).onRunStart(); } @Test public void shouldNotifyAllListenersOfTestStart() { run(PassingTest.class); verify(this.listener).onTestStart(any(Description.class)); - verify(listener2).onTestStart(any(Description.class)); + verify(this.listener2).onTestStart(any(Description.class)); } @Test public void shouldNotifyAllListenersOfTestSuccess() { run(PassingTest.class); verify(this.listener).onTestSuccess(any(TestResult.class)); - verify(listener2).onTestSuccess(any(TestResult.class)); + verify(this.listener2).onTestSuccess(any(TestResult.class)); } @Test - public void shouldNotifyAllListenersOfRunEnd() {; - run(PassingTest.class); - verify(this.listener).onRunEnd(); - verify(listener2).onRunEnd(); + public void shouldNotifyAllListenersOfRunEnd() { + ; + run(PassingTest.class); + verify(this.listener).onRunEnd(); + verify(this.listener2).onRunEnd(); } @Test diff --git a/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java b/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java index c83ecc9a5..2e864b6aa 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; @@ -80,7 +80,7 @@ public void shouldCallStartAndEndForMethodWhenNoError() { this.testee.onTestStart(this.result); this.testee.onTestSuccess(this.result); verify(this.rc, times(1)) - .notifyStart(new Description("method", this.clazz)); + .notifyStart(new Description("method", this.clazz)); verify(this.rc, times(1)).notifyEnd(new Description("method", this.clazz)); } @@ -91,7 +91,7 @@ public void shouldCallStartAndEndForMethodWhenError() { this.testee.onTestStart(this.result); this.testee.onTestFailure(this.result); verify(this.rc, times(1)) - .notifyStart(new Description("method", this.clazz)); + .notifyStart(new Description("method", this.clazz)); verify(this.rc, times(1)).notifyEnd(new Description("method", this.clazz), throwable); } diff --git a/pitest/src/test/java/org/pitest/testng/TestNGConfigurationTest.java b/pitest/src/test/java/org/pitest/testng/TestNGConfigurationTest.java index e607a9c02..4c02cf96e 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGConfigurationTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGConfigurationTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; diff --git a/pitest/src/test/java/org/pitest/testng/TestNGTestClassIdentifierTest.java b/pitest/src/test/java/org/pitest/testng/TestNGTestClassIdentifierTest.java index e231b9a2a..dde221a98 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGTestClassIdentifierTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGTestClassIdentifierTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; diff --git a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitFinderTest.java b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitFinderTest.java index 2a88c56e3..02e59c5f8 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitFinderTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitFinderTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; @@ -20,10 +20,10 @@ import org.junit.Before; import org.junit.Test; +import org.pitest.testapi.TestGroupConfig; import com.example.testng.AnnotatedAtClassLevel; import com.example.testng.AnnotatedAtMethodLevel; -import org.pitest.testapi.TestGroupConfig; public class TestNGTestUnitFinderTest { diff --git a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java index a36c1bbc1..87f061055 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.testng; @@ -28,9 +28,9 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.pitest.testapi.TestGroupConfig; import org.pitest.testapi.Description; import org.pitest.testapi.ResultCollector; +import org.pitest.testapi.TestGroupConfig; import org.pitest.util.ClassLoaderDetectionStrategy; import org.pitest.util.IsolationUtils; @@ -63,14 +63,13 @@ public void shouldReportTestClassStart() { verify(this.rc, times(1)).notifyStart(this.testee.getDescription()); } - @Test public void shouldReportTestClassStartWhenExecutingInForeignClassLoader() { this.testee = new TestNGTestUnit(neverMatch(), Passes.class, this.config); this.testee.execute(this.loader, this.rc); verify(this.rc, times(1)).notifyStart(this.testee.getDescription()); } - + @Test public void shouldReportTestMethodStart() { this.testee = new TestNGTestUnit(Passes.class, this.config); @@ -78,10 +77,10 @@ public void shouldReportTestMethodStart() { verify(this.rc, times(1)).notifyStart( new Description("passes", Passes.class)); } - + @Test public void shouldReportTestMethodStartWhenExecutingInForeignClassLoader() { - this.testee = new TestNGTestUnit(neverMatch(),Passes.class, this.config); + this.testee = new TestNGTestUnit(neverMatch(), Passes.class, this.config); this.testee.execute(this.loader, this.rc); verify(this.rc, times(1)).notifyStart( new Description("passes", Passes.class)); @@ -92,18 +91,17 @@ public void shouldReportTestEndWithoutErorWhenTestRunsSuccessfully() { this.testee = new TestNGTestUnit(Passes.class, this.config); this.testee.execute(this.loader, this.rc); verify(this.rc, times(1)) - .notifyEnd(new Description("passes", Passes.class)); + .notifyEnd(new Description("passes", Passes.class)); } - + @Test public void shouldReportTestEndWithoutErorWhenTestRunsSuccessfullyInForeignClassLoader() { - this.testee = new TestNGTestUnit(neverMatch(),Passes.class, this.config); + this.testee = new TestNGTestUnit(neverMatch(), Passes.class, this.config); this.testee.execute(this.loader, this.rc); verify(this.rc, times(1)) - .notifyEnd(new Description("passes", Passes.class)); + .notifyEnd(new Description("passes", Passes.class)); } - @Test public void shouldReportTestEndWithThrowableWhenTestFails() { this.testee = new TestNGTestUnit(Fails.class, this.config); @@ -112,7 +110,7 @@ public void shouldReportTestEndWithThrowableWhenTestFails() { eq(new Description("fails", Fails.class)), any(AssertionFailedError.class)); } - + @Test public void shouldSkipPassingTestsAfterAFailure() { this.testee = new TestNGTestUnit(Fails.class, this.config); @@ -120,11 +118,10 @@ public void shouldSkipPassingTestsAfterAFailure() { verify(this.rc, times(1)).notifySkipped( eq(new Description("passes", Fails.class))); } - - + @Test public void shouldReportTestEndWithThrowableWhenTestFailsInForeignClassLoader() { - this.testee = new TestNGTestUnit(neverMatch(),Fails.class, this.config); + this.testee = new TestNGTestUnit(neverMatch(), Fails.class, this.config); this.testee.execute(this.loader, this.rc); verify(this.rc, times(1)).notifyEnd( eq(new Description("fails", Fails.class)), @@ -133,7 +130,7 @@ public void shouldReportTestEndWithThrowableWhenTestFailsInForeignClassLoader() @Test public void shouldSkipPassingTestsAfterAFailureInForeignClassLoader() { - this.testee = new TestNGTestUnit(neverMatch(),Fails.class, this.config); + this.testee = new TestNGTestUnit(neverMatch(), Fails.class, this.config); this.testee.execute(this.loader, this.rc); verify(this.rc, times(1)).notifySkipped( eq(new Description("passes", Fails.class))); @@ -162,7 +159,7 @@ public void shouldOnlyRunTestsInIncludedGroups() { verify(this.rc, times(1)).notifyEnd( new Description("includeAndExcludeGroup", HasGroups.class)); } - + @Test public void shouldReportTestSkipped() { this.testee = new TestNGTestUnit(Skips.class, this.config); @@ -178,9 +175,10 @@ public void shouldReportTestSkippedInForeignClassloader() { verify(this.rc, times(1)).notifySkipped( eq(new Description("skip", Skips.class))); } - + private ClassLoaderDetectionStrategy neverMatch() { return new ClassLoaderDetectionStrategy() { + @Override public boolean fromDifferentLoader(final Class clazz, final ClassLoader loader) { return true; diff --git a/pitest/src/test/java/org/pitest/util/FunctionsTest.java b/pitest/src/test/java/org/pitest/util/FunctionsTest.java index 04f93bcc6..40cf24011 100644 --- a/pitest/src/test/java/org/pitest/util/FunctionsTest.java +++ b/pitest/src/test/java/org/pitest/util/FunctionsTest.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/util/InputStreamLineIterableTest.java b/pitest/src/test/java/org/pitest/util/InputStreamLineIterableTest.java index 8d83f9216..6f2648c3b 100644 --- a/pitest/src/test/java/org/pitest/util/InputStreamLineIterableTest.java +++ b/pitest/src/test/java/org/pitest/util/InputStreamLineIterableTest.java @@ -1,16 +1,16 @@ /* * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; @@ -76,6 +76,7 @@ public void shouldReturnFalseWhenContainsCalledAndPredicateDoesNotMatch() { private F> mapIfNotTwo() { return new F>() { + @Override public Option apply(final String a) { if (a.equals("2")) { return Option.none(); diff --git a/pitest/src/test/java/org/pitest/util/IsolationUtilsTest.java b/pitest/src/test/java/org/pitest/util/IsolationUtilsTest.java index feba23cf5..034a8faff 100644 --- a/pitest/src/test/java/org/pitest/util/IsolationUtilsTest.java +++ b/pitest/src/test/java/org/pitest/util/IsolationUtilsTest.java @@ -6,40 +6,50 @@ import org.junit.Test; import org.pitest.classpath.ClassPath; import org.pitest.mutationtest.execute.DefaultPITClassloader; -import org.pitest.util.ClassLoaderDetectionStrategy; -import org.pitest.util.IsolationUtils; public class IsolationUtilsTest { - @Test public void shouldRecogniseClassFromBootClassLoaderAsFromBootLoader() { - ClassLoaderDetectionStrategy testee = IsolationUtils.loaderDetectionStrategy(); - assertFalse(testee.fromDifferentLoader(Integer.class, IsolationUtils.bootClassLoader())); + ClassLoaderDetectionStrategy testee = IsolationUtils + .loaderDetectionStrategy(); + assertFalse(testee.fromDifferentLoader(Integer.class, + IsolationUtils.bootClassLoader())); } - + @Test public void shouldRecogniseClassFromChildOfBootClassLoaderAsFromBootLoader() { - ClassLoaderDetectionStrategy testee = IsolationUtils.loaderDetectionStrategy(); - assertFalse(testee.fromDifferentLoader(IsolationUtilsTest.class, IsolationUtils.bootClassLoader())); + ClassLoaderDetectionStrategy testee = IsolationUtils + .loaderDetectionStrategy(); + assertFalse(testee.fromDifferentLoader(IsolationUtilsTest.class, + IsolationUtils.bootClassLoader())); } - + @Test - public void shouldRecogniseClassFromChildOfChildOfBootClassLoaderAsFromCompatibleLoader() throws ClassNotFoundException { - ClassLoaderDetectionStrategy testee = IsolationUtils.loaderDetectionStrategy(); - DefaultPITClassloader parent = new DefaultPITClassloader(new ClassPath(), IsolationUtils.bootClassLoader()); - DefaultPITClassloader loader = new DefaultPITClassloader(new ClassPath(), parent); - + public void shouldRecogniseClassFromChildOfChildOfBootClassLoaderAsFromCompatibleLoader() + throws ClassNotFoundException { + ClassLoaderDetectionStrategy testee = IsolationUtils + .loaderDetectionStrategy(); + DefaultPITClassloader parent = new DefaultPITClassloader(new ClassPath(), + IsolationUtils.bootClassLoader()); + DefaultPITClassloader loader = new DefaultPITClassloader(new ClassPath(), + parent); + Class child = loader.loadClass(IsolationUtilsTest.class.getName()); - + assertFalse(testee.fromDifferentLoader(child, parent)); } - + @Test - public void shouldNotRecogniseClassFromSiblingLoaderAsFromCompatibleLoader() throws ClassNotFoundException { - ClassLoaderDetectionStrategy testee = IsolationUtils.loaderDetectionStrategy(); - DefaultPITClassloader siblingLoader = new DefaultPITClassloader(new ClassPath(), IsolationUtils.bootClassLoader()); - Class foreign = siblingLoader.loadClass(IsolationUtilsTest.class.getName()); - assertTrue(testee.fromDifferentLoader(foreign, new DefaultPITClassloader(new ClassPath(), IsolationUtils.bootClassLoader()))); + public void shouldNotRecogniseClassFromSiblingLoaderAsFromCompatibleLoader() + throws ClassNotFoundException { + ClassLoaderDetectionStrategy testee = IsolationUtils + .loaderDetectionStrategy(); + DefaultPITClassloader siblingLoader = new DefaultPITClassloader( + new ClassPath(), IsolationUtils.bootClassLoader()); + Class foreign = siblingLoader.loadClass(IsolationUtilsTest.class + .getName()); + assertTrue(testee.fromDifferentLoader(foreign, new DefaultPITClassloader( + new ClassPath(), IsolationUtils.bootClassLoader()))); } } diff --git a/pitest/src/test/java/org/pitest/util/NullJavaAgent.java b/pitest/src/test/java/org/pitest/util/NullJavaAgent.java index 3a2141c28..4a7218fb9 100644 --- a/pitest/src/test/java/org/pitest/util/NullJavaAgent.java +++ b/pitest/src/test/java/org/pitest/util/NullJavaAgent.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,10 +23,12 @@ public static NullJavaAgent instance() { return new NullJavaAgent(); } + @Override public Option getJarLocation() { return Option.none(); } + @Override public void close() { } diff --git a/pitest/src/test/java/org/pitest/util/ResourceFolderByteArraySource.java b/pitest/src/test/java/org/pitest/util/ResourceFolderByteArraySource.java index fcb45a2cb..bbe00f35b 100644 --- a/pitest/src/test/java/org/pitest/util/ResourceFolderByteArraySource.java +++ b/pitest/src/test/java/org/pitest/util/ResourceFolderByteArraySource.java @@ -13,6 +13,7 @@ public class ResourceFolderByteArraySource implements ClassByteArraySource { + @Override public Option getBytes(final String classname) { final ClassPath cp = new ClassPath(new ResourceFolderClassPathroot()); try { @@ -27,20 +28,24 @@ public Option getBytes(final String classname) { class ResourceFolderClassPathroot implements ClassPathRoot { + @Override public URL getResource(final String name) throws MalformedURLException { return null; } + @Override public InputStream getData(final String name) throws IOException { final String path = "sampleClasses/" + name.replace(".", "/") + ".class.bin"; return IsolationUtils.getContextClassLoader().getResourceAsStream(path); } + @Override public Collection classNames() { return null; } + @Override public Option cacheLocation() { return null; } diff --git a/pitest/src/test/java/org/pitest/util/SafeDataInputStreamTest.java b/pitest/src/test/java/org/pitest/util/SafeDataInputStreamTest.java index 9be299ada..88fb3ddf3 100644 --- a/pitest/src/test/java/org/pitest/util/SafeDataInputStreamTest.java +++ b/pitest/src/test/java/org/pitest/util/SafeDataInputStreamTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/util/ServiceLoaderTest.java b/pitest/src/test/java/org/pitest/util/ServiceLoaderTest.java index 1dbf23752..7a9b8a2b6 100644 --- a/pitest/src/test/java/org/pitest/util/ServiceLoaderTest.java +++ b/pitest/src/test/java/org/pitest/util/ServiceLoaderTest.java @@ -23,7 +23,7 @@ public void shouldReturnNoValuesWhenNoServicesFounds() throws Exception { public void shouldReturnValueWhenServiceFound() throws Exception { final Iterable actual = ServiceLoader.load( MutationEngineFactory.class, Thread.currentThread() - .getContextClassLoader()); + .getContextClassLoader()); assertTrue(actual.iterator().hasNext()); } diff --git a/pitest/src/test/java/org/pitest/util/SocketFinderTest.java b/pitest/src/test/java/org/pitest/util/SocketFinderTest.java index e3209b94a..25bc4f089 100644 --- a/pitest/src/test/java/org/pitest/util/SocketFinderTest.java +++ b/pitest/src/test/java/org/pitest/util/SocketFinderTest.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Henry Coles - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pitest/src/test/java/org/pitest/util/StringUtilTest.java b/pitest/src/test/java/org/pitest/util/StringUtilTest.java index 574cec2d3..fa62b82b2 100644 --- a/pitest/src/test/java/org/pitest/util/StringUtilTest.java +++ b/pitest/src/test/java/org/pitest/util/StringUtilTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; @@ -25,19 +25,20 @@ public class StringUtilTest { @Test public void shouldCreateEmptyStringWhenJoiningEmptyList() { - assertEquals("", StringUtil.join(Collections.emptyList(), ",")); + assertEquals("", StringUtil.join(Collections. emptyList(), ",")); } - + @Test public void shouldIncludeNoSeparatorsWhenJoiningSingleItem() { assertEquals("foo", StringUtil.join(Collections.singleton("foo"), ",")); } - + @Test public void shouldJoinStringWithSeparators() { - assertEquals("foo,bar,car", StringUtil.join(Arrays.asList("foo", "bar", "car"), ",")); + assertEquals("foo,bar,car", + StringUtil.join(Arrays.asList("foo", "bar", "car"), ",")); } - + @Test public void repeatShouldRepeatGivenCharacter() { assertEquals("----", StringUtil.repeat('-', 4)); diff --git a/pitest/src/test/java/org/pitest/util/TimeSpanTest.java b/pitest/src/test/java/org/pitest/util/TimeSpanTest.java index f99faa57a..0c3023d8d 100644 --- a/pitest/src/test/java/org/pitest/util/TimeSpanTest.java +++ b/pitest/src/test/java/org/pitest/util/TimeSpanTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package org.pitest.util; diff --git a/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java b/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java index 32e2e69ca..8528d8f94 100644 --- a/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java +++ b/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java @@ -1,16 +1,16 @@ /* * Copyright 2011 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http:www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. */ package sun.pitest; @@ -123,6 +123,7 @@ public void shouldBeSafeToAccessAcrossMultipleThreads() public void shouldReportCorrectCoverageForSpecialisation1() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0]); } @@ -135,6 +136,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation2() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1]); } @@ -147,6 +149,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation3() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2]); @@ -160,6 +163,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation4() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3]); @@ -173,6 +177,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation5() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4]); @@ -186,6 +191,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation6() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5]); @@ -199,6 +205,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation7() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6]); @@ -212,6 +219,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation8() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7]); @@ -225,6 +233,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation9() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7], @@ -239,6 +248,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation10() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7], @@ -253,6 +263,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation11() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7], @@ -267,6 +278,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation12() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7], @@ -281,6 +293,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation13() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7], @@ -295,6 +308,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation14() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7], @@ -310,6 +324,7 @@ public void apply(final Integer classId, final boolean[] probes) { public void shouldReportCorrectCoverageForSpecialisation15() { final SideEffect2 se = new SideEffect2() { + @Override public void apply(final Integer classId, final boolean[] probes) { CodeCoverageStore.visitProbes(classId, 0, probes[0], probes[1], probes[2], probes[3], probes[4], probes[5], probes[6], probes[7], @@ -377,12 +392,14 @@ private void assertHitsLine(final int classId, final int... i) { private void assertDoesNotHitLine(final int classId, final int... i) { final Collection actual = CodeCoverageStore.getHits(); for (final int probe : i) { - assertThat(actual).doesNotContain(CodeCoverageStore.encode(classId, probe)); + assertThat(actual).doesNotContain( + CodeCoverageStore.encode(classId, probe)); } } private Callable makeReader() { final Callable read = new Callable() { + @Override public ConcurrentModificationException call() throws Exception { ConcurrentModificationException error = null; try { @@ -414,6 +431,7 @@ private long pointlesslyIterateCollection() { private static Runnable makeWriter(final int sleepPeriod) { final Runnable write = new Runnable() { + @Override public void run() { for (int i = 0; i != 1000; i++) { try { @@ -429,4 +447,3 @@ public void run() { } } -