diff --git a/.gitignore b/.gitignore
index ef79db8f2..3ec532e83 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,14 @@
-*.checkstyle
-*.swp
-.project
-.settings
-target/
-*/.settings
-*/.classpath
-*/.project
-.metadata
-.idea
-*.iml
-.checkstyle
-dependency-reduced-pom.xml
-*/bin
+*.checkstyle
+*.swp
+.project
+.settings
+target/
+*/.settings
+*/.classpath
+*/.project
+.metadata
+.idea
+*.iml
+.checkstyle
+dependency-reduced-pom.xml
+*/bin
diff --git a/.travis.yml b/.travis.yml
index 5fb4b7178..f0b56ceef 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,25 +1,25 @@
-sudo: false
-
-language: java
-
-jdk:
- - oraclejdk8
- - oraclejdk9
-
-env:
- global:
- # taken first download mirror from http://maven.apache.org/
- - BASEURL=http://mirror.softaculous.com/apache/maven/maven-3/VERSION/binaries/apache-maven-VERSION-bin.tar.gz
- - FILE=apache-maven-VERSION-bin.tar.gz
- - DIR=apache-maven-VERSION/bin
- matrix:
- - VERSION=3.3.9
- - VERSION=3.2.5
- - VERSION=3.1.1
- - VERSION=3.0.5
-
-script:
- - wget $(echo -n $BASEURL | sed -e 's#VERSION#'$VERSION'#g')
- - tar -xvzf $(echo -n $FILE | sed -e 's#VERSION#'$VERSION'#')
- - export PATH=$(echo -n $DIR | sed -e 's#VERSION#'$VERSION'#'):$PATH
- - mvn clean verify
+sudo: false
+
+language: java
+
+jdk:
+ - oraclejdk8
+ - oraclejdk9
+
+env:
+ global:
+ # taken first download mirror from http://maven.apache.org/
+ - BASEURL=http://mirror.softaculous.com/apache/maven/maven-3/VERSION/binaries/apache-maven-VERSION-bin.tar.gz
+ - FILE=apache-maven-VERSION-bin.tar.gz
+ - DIR=apache-maven-VERSION/bin
+ matrix:
+ - VERSION=3.3.9
+ - VERSION=3.2.5
+ - VERSION=3.1.1
+ - VERSION=3.0.5
+
+script:
+ - wget $(echo -n $BASEURL | sed -e 's#VERSION#'$VERSION'#g')
+ - tar -xvzf $(echo -n $FILE | sed -e 's#VERSION#'$VERSION'#')
+ - export PATH=$(echo -n $DIR | sed -e 's#VERSION#'$VERSION'#'):$PATH
+ - mvn clean verify
diff --git a/LICENSE.txt b/LICENSE.txt
index d64569567..75b52484e 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,202 +1,202 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/README.md b/README.md
index bc018685f..f57dd26fa 100644
--- a/README.md
+++ b/README.md
@@ -1,376 +1,62 @@
+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.pitest/pitest/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/org.pitest/pitest)
[![Build Status](https://travis-ci.org/hcoles/pitest.png?branch=master)](https://travis-ci.org/hcoles/pitest)
+# CS6367 - Pitest Improvement Project
-Pitest (aka PIT) is a state of the art mutation testing system for Java and the JVM.
-
-Read all about it at http://pitest.org
-
-## Releases
-
-### 1.4.0-SNAPSHOT
-
-* #445 - Raise minimum supported java version to 8
-
-### 1.3.2
-
-* #433 - Aggregate reports via maven (thanks @rchargel)
-* #438 - Filter tests at method level (thanks @ftrautsch)
-* #439 - Primitives return mutator doesn't handle bytes
-* #380 - Remove reliance on xstream for improved java 9 support
-* #414 - Replace xstream history store (thanks @kiftio)
-
-Note when upgrading that history files generated by previous releases are not compatible with 1.3.2 an above.
-
-### 1.3.1
-
-* #434 - XStream security warning
-
-### 1.3.0
-
-* #196 - Raise minimum java version to 7
-* #425 - Broaden for-each detection
-* #428 - Add `excludedTestClasses` parameter
-* #379 - Remove support for mutating static initializers
-* #432 - Add export plugin functionality into pitest
-* #427 - Better return values mutators
-* #429 - Simplify test api
-
-428 changes the existing behaviour of the excludedClasses filter. Previously this excluded classes from both being mutated and run as tests which may require changes for some people when upgrading.
-
-As a result of 429 TestNG tests will no longer be automatically detected - the new `testPlugin` parameter must be explicitly set to "testng".
-
-### 1.2.5
-
-* #407 - SCM goal cannot be run from within module (thanks @sbuisson)
-* #256 - Inline style violate Content Security Policy (thanks @kiftio)
-* #403 - No css in the html report viewed from jenkins (thanks @kiftio)
-* #409 - Mutate based on changes across branched (thanks @sbuisson)
-* #418 - Avoid for loop increments
-* #424 - Avoid for each code
-* #389 - Widen matching of implicit null checks
-
-### 1.2.4
-
-* #397 - Report reasons maven modules skipped
-* #389 - Filter junk getClass null checks in lambdas
-* #400 - Update to ASM 6.0
-
-### 1.2.3
-
-* Update to ASM 6 for Java 9 support
-* #388 - Mark maven plugin as threadsafe
-* #362 - Suppress common equivalent mutant in equals methods
-
-### 1.2.2
-
-* #367 - Static analysis cannot find core classes in some projects
-
-### 1.2.1
-
-* #347 - Avoid autogenerated code (e.g by lombok) anotated with @Generated
-* #285 - Avoid compiler generated conditionals in switch on string. (thanks @Kwaq)
-* #218 - New "naked receiver" / method chain mutator. (thanks @UrsMetz)
-* #354/#356 - New extension point plus changes to reduce cost of random access to bytecode for static analysis
-* #353 - Improved static initializer code detection
-* #364 - Filter infinite loops via static analysis
-* #365 - Configuration system for plugins
-
-(Note #347 will **not** detect `javax.annotaion.Generated` as it has only source retention.)
-
-### 1.2.0
-
-* #318 - Separate main process code from code sharing client classpath
-* #295 - Ignore abstract TestNG tests
-* #215 - Automatic selection of target classes for maven
-* #314 - Do not fail for maven modules without tests or code
-* #306 - Do not fail when only interfaces are in changeset
-* #325 - Anonymous class in Spock test causing error
-* #334 - Compatibility with recent TestNG releases
-* #335 - Incorrect coverage with powermock
-
-Note - as of this release the maven plugin will automatically determine which classes to mutate instead of assuming that the package names match the group id.
-
-### 1.1.11
-
-* #269 - Not possible to break build on 1 mutant
-* #271 - Include method descriptor in line coverage
-* #170 - Exclusion by JUnit runner
-* #291 - Handle empty excludes
-* #287 - Check class hierarchy for annotations
-* #289 - Option to supply classpath from file
-
-
-### 1.1.10
-
-* #260 - Initial support for mutating Kotlin code
-* #264 - Support for yatspec runner (thanks @theangrydev)
-* Break build when more than `maxSurviving` mutants survive
-
-### 1.1.9
-
-* #132 - Allow analysis of only files touched in last commit (thanks Tomasz Luch)
-
-### 1.1.8
-
-* #239 - Provide a shortcut to set history files via maven
-* #240 - Support for regexes (thanks sebi-hgdata)
-* #243 - Use ephemeral ports to communicate with minions
-
-### 1.1.7
-
-* #196 - Raise minimum java version to 1.6
-* #231 - Process hangs
-
-### 1.1.6
-
-* #10 - Add maven report goal (thanks jasonmfehr)
-* #184 - Remove undocumented project file feature
-* #219 - Performance improvement for report generation (thanks tobiasbaum)
-* #190 - Allow custom properties for plugins
-
-Note this release contains a known issue (#231). Please upgrade.
-
-### 1.1.5
-
-* Fix for #148 - Stackoverflow with TestNG data providers when using JMockit
-* Fix for #56 - Not reporting junit incompatibilities
-* Fix for #174 - Invalid linecoverage.xml with static initializers
-* Fix for #183 - Can't run GWTMockito tests
-* Fix for #179 - Broken `includeLaunchClasspath=false` on Windows
-* #173 - Read exclusions and groups from maven surefire config
-
-### 1.1.4
-
-* #157 - Support maven -DskipTests flag (thanks lkwg82)
-* Fix for #163 - Should not include test tree in coverage threshold
-* #166 - Allow classpath exclusions for maven plugin (thanks TomRK1089)
-* #155 - Restore Java 5 compatibility
-* Fix for #148 - Issue with JMockit + TestNG (thanks estekhin and KyleRogers)
-
-### 1.1.3
-
-* Fix for #158 - Tests incorrectly excluded from mutants
-* Fix for #153 - SCM plugin broken for maven 2
-* Fix for #152 - Does not work with IBM jdk
-
-### 1.1.2
-
-* Fix for #150 - line coverage under reported
-
-### 1.1.1
-
-* Block based coverage (fixes 79/131)
-* End support for running on Java 5 (java 5 bytecode still supported)
-* Skip flag for maven modules (#106)
-* Stop declaring TestNG as a dependency
-* New parameter propagation mutator (thanks UrsMetz)
+## Project Summary
-### 1.1.0
+This project aims at adding more mutations to Pitest and use it to help fixing errors. The first phase involves implementing the AOD, ROR and AOR mutations. The second phase will implement even more mutations and add code fixing rules. (treated as mutators)
-* Change scheme for identifying mutants (see https://github.com/hcoles/pitest/issues/125)
-* Support alternate test apis via plugin system
-* Report error when supplied mutator name does not match (thanks artspb)
-* Report exit codes from coverage child process (thanks KyleRogers)
-* Treat JUnit tests with ClassRule annotation as one unit (thanks devmop)
+## How to run
-Please note that any stored history files or sonar results are invalidated by this release.
-
-### 1.0.0
-
-* Switch version numbering scheme
-* Upgrade to ASM 5.0.2
-* Fix for #114 - fails to run for java 8 when -parameters flag is set
-* #99 Support additionalClasspathElements property in maven plugin (thanks artspb)
-* #98 Do not mutate java 7 try with resources (thanks @artspb)
-* #109 extended remove conditional mutator (thanks @vrthra)
-
-
-### 0.33
-
-* Move to Github
-* Upgrade of ASM to support Java 8 bytecode (thanks to "iirekm")
-* Partial support for JUnit categories (thanks to "chrisr")
-* New Remove Increments Mutator (thanks to Rahul Gopinath)
-* Minor logging improvements (thanks to Kyle Rogers aka Stephan Penndorf)
-* Fix for #92 - broken maven 2 support
-* Fix for #75 - incorrectly ignored tests in classes with both @Ignore and @BeforeClass / @AfterClass
-
-### 0.32
-
-* restores java 7 compatibility
-* new remove conditionals mutator
-* support for mutating static initializers with TestNG
-* properly isolate classpaths when running via Ant
-* break builds on coverage threshold
-* allow JVM to be specified
-* support user defined test selection strategies
-* support user defined output format
-* support user defined test prioritisation
-* fix for issue blocking usage with [Robolectric](http://robolectric.org/)
-
-Note, setup for Ant based projects changes in this release. See [ant setup](http://pitest.org/quickstart/ant/) for details on usage.
-
-### 0.31
-
-* Maven 2 compatibility restored
-* Much faster line coverage calculation
-* Fix for #78 - Error when PowerMockito test stores mock as member
-
-This release also changes a number of internal implementation details, some of which may be of interest/importance to those maintaining tools that
-integrate with PIT.
-
-Mutations are now scoped internally as described in [https://groups.google.com/forum/#!topic/pitusers/E0-3QZuMYjE](https://groups.google.com/forum/#!topic/pitusers/E0-3QZuMYjE)
-
-A new class (org.pitest.mutationtest.tooling.EntryPoint) has been introduced that removes some of the duplication that existed in the various ways of launching mutation analysis.
-
-### 0.30
-
-* Support for parametrized [Spock](http://code.google.com/p/spock/) tests
-* Support for [JUnitParams](http://code.google.com/p/junitparams/) tests
-* Fix for #73 - JUnit parameterised tests calling mutee during setup failing during mutation phase
-* Fix to #63 - ant task fails when empty options supplied
-* Ability to override maven options from command line
-* Ability to fail a build if it does not achieve a given mutation score
-* Performance improvement when tests use @BeforeClass or @AfterClass annotations
-* Slightly improved scheduling over multiple threads
-* Improved maven multi project support
-* Integration with source control for maven users
-
-
-### 0.29
-
-* Incremental analysis (--historyInputLocation and --historyOutputLocation)
-* Inlined code detection turned on by default
-* Quieter loggging by default
-* Improved Java 7 support
-* Upgrade of ASM from 3.3 to 4
-* Fix for concurrency issues during coverage collection
-* Fix for #53 - problems with snapshot junit versions
-* Fix for #59 - duplicate dependencies set via maven
-
-
-### 0.28
-
-* Inlined finally block detection (--detectInlinedCode)
-* New experimental switch statement mutator (contributed by Chris Rimmer)
-* Do not mutate Groovy classes
-* Fix for #33 - set user.dir to match surefire
-* Fix for #43 - optionally suppress timestamped folders (--timestampedReports=true/false)
-* Fix for #44 - concurrent modification exception when gathering coverage
-* Fix for #46 - incorrect setting of flags by ant task
-* Smaller memory footprint for main process
-* Faster coverage gathering for large codebases
-* Faster classpath scanning for large codebases
-* Support for JUnit 3 suite methods
-* Fixes for incorrect detection of JUnit 3 tests
-
-**Known issue** - Fix for #33 may not resolve issue for maven 2 users.
-
-Detection of Groovy code has not yet been tested with Groovy 2 which may generate substantially different
-byte code to earlier versions.
-
-### 0.27
-
-* Much prettier reports
-* Now avoids mutating assert statements
-* Removed inScopeClasses option - use targetClasses and targetTests instead
-* Fix for 100% CPU usage when child JVM crashes
-* Fix for #35 #38 - experimental member variable mutator now corrects stack
-* Fix for #39 - order of classpath elements now maintained when running from maven
-
-**Upgrading users may need to modify their build due to removal of the inScopeClasses parameter**
-
-### 0.26
-
-* Ant support
-* New experimental mutator for member variables
-* Fix for #12 #27 - no longer hangs when code under test launches non daemon threads
-* Fix for #26 - now warns when no test library found on classpath
-* Fix for #30 - now errors if mutated classes have no line or source debug
-* Fix for #32 - now correctly handles of JUnit assumptions
-
-**Known issue** - The new member variable mutator may cause errors in synchronized errors. The mutator is
-however disabled by default, and the generated errors are correctly handled by PIT.
-
-### 0.25
-
-* TestNG support (experimental)
-* Fix for issue where mutations in nested classes not isolated from each other
-* Fix for broken classpath isolation for projects using xstream
-* Improved handling of JUnit parametrized tests
-* Ability to limit mutations to specific classpath roots (--mutableCodePaths)
-* Ability to add non launch classpath roots (--classPath) (experimental)
-* Read configuration values from XML (experimental)
-* Option to not throw error when no mutations found
-* Consistent ordering of classes in HTML report
-* Statistics written to console
-* Classes no longer loaded during initial classpath scanning
-* New syntax to easily enable all mutation operations
-
-### 0.24
-
-* JMockit support
-* Option to output results in XML or CSV
-* Fix for #11
-* Improved INLINE_CONSTS mutator
-
-### 0.23
-
-* Fix for issue 7 - source files not located
-
-### 0.22
-
-* Upgrade of Xstream to 1.4.1 to enable OpenJDK 7 support
-* Fix for #5 - corruption of newline character in child processes
-* Ability to set child process launch arguments
-
-### 0.21
-
-* Significant performance improvements
-* Support for powermock via both classloader (requires PowerMockIgnore annotation) and java agent
-* Minor error reporting and usability improvements
-* Fix for major defect around dependency analysis
-* PIT dependencies no longer placed on classpath when running via maven
-* Support for excluding certain classes or tests
-* Support for verbose logging
-
-### 0.20
-
-* Limit number of mutations per class
-* Upgrade xstream to 1.3.1
-* Make available from maven central
-
-### 0.19
-
-* Built in enum methods now excluded from mutation
-* Fixed bug around reporting of untested classes
-* Support for excluding tests greater than a certain distance from class
-* Support for excluding methods from mutation analysis
-* Performance improvements
-* Removed support for launching mutation reports from JUnit runner
-
-### 0.18
-
-* First public release
-
-## Credits
-
-Pitest is mainly the work of [me](https://twitter.com/0hjc) but has benefited from contributions from many others.
-
-Notable contributions not visible [here](https://github.com/hcoles/pitest/graphs/contributors) as they were made before this code was migrated to github include
-
-* Nicolas Rusconi - Ant Task
-* Struan Kerr-Liddell - Improvements to html report
-* Stephan Pendorf - Multiple improvments including improved mutators
+ 1. Please clone our project and compile it in maven: `mvn install -DskipTests` (doing it without -Dskiptests is fine as well.
+ 2. Location of the compiled jar files: `C:\Users\\[User Account Name\]\.m2\repository\org\pitest\pitest\`
+ 3. As of this implementation, the pitest version is 1.4.0-SNAPSHOT.
+ 4. Then add the following section to pom.xml and test using this command:
-Although PIT does not incorporate any code from the Jumble project (http://jumble.sourceforge.net/), the Jumble codebase was used as a guide when developing some aspects of PIT.
-
-## Other stuff
-
-The codebase is checked up on in a few places that give slower feedback than the github hooks.
+ mvn org.pitest:pitest-maven:mutationCoverage
+
+
+
+
+
+ org.pitest
+ pitest-maven
+ 1.4.0-SNAPSHOT
+
+
+ DEFAULTS
+ AOD_FIRST
+ AOD_LAST
+ ARITHMETIC_OPERATOR_REPLACEMENT_MUTATOR
+
+
+
+
+
+
+
+## Members
+ - Joseph LaFreniere
+ - Leeja James
+ - Keith Nguyen
+
+## Progress
+**First Phase**
+ Problem encountered: we have to use different bytecode operation for single-word operator/operands (int, float) compared to double-word operator/operands (long, double).
+
+*AOD mutator*
+ - Replaces two operands and the operator with each of the operands, meaning there are two mutators for each operation.
+ - Example: a + b is replaced with mutant a and mutant b.
-[maven2 on IBM JDK check](https://hjc.ci.cloudbees.com/job/maven2_triangle_example/)
-[Sonarqube analysis](http://nemo.sonarqube.org/dashboard/index/793182)
+*ROR mutator*
+ - Replaces each relational operators with each of the other ones.
+ - Some ROR mutators have already been implemented in the Conditional Boundary Mutator and Negate Conditional Mutator.
+ - Example: < is replaced with >=, <=, !=, ==.
+ *AOR mutator*
+ - Replaces each arithmetic operator with each of the other ones.
+ - Some AOR mutators have been implemented in Math Mutator.
+ - Example: + is replaced with -, *, /, %.
diff --git a/code_cleanup_profile.xml b/code_cleanup_profile.xml
index 9d3a0ee3e..95ec613ff 100644
--- a/code_cleanup_profile.xml
+++ b/code_cleanup_profile.xml
@@ -1,62 +1,62 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/code_format_profile.xml b/code_format_profile.xml
index 40c36cf26..078f04a83 100644
--- a/code_format_profile.xml
+++ b/code_format_profile.xml
@@ -1,269 +1,269 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hackers_guide.txt b/hackers_guide.txt
index 58e0aca83..2a3f321ee 100644
--- a/hackers_guide.txt
+++ b/hackers_guide.txt
@@ -1,42 +1,42 @@
-# General
-
-Pitest supports all version of Java back to Java 6.
-
-As long as the resulting binaries support Java 6 technically the build itself could be tied to higher versions of Java, but testing is currently tied into building so it must build with Java 6.
-
-It is reccomended to use Java 8 while developing, but be aware that it is not possible to use any Java 8 (or 7) features.
-
-## Structure
-
-Pitest is split into several modules
-
-* pitest - Main mutation engine and other code that must share a JVM with the system under test
-* pitest-entry - The main entry point for build tools. Contains code that runs in main controller process.
-* pitest-html-report - Generates the html report
-* pitest-command-line - Command line tool for running pitet
-* pitest-maven - Maven mojo for running pitest
-* pitest-ant - Ant task for running pitest
-* pitest-maven-verification - Integration tests that execute pitest via maven module
-* pitest-java8-verification - Integration tests that validate pitest against java 8 features
-* pitest-groovy-verification - Integration tests that validate pitets behaviour with groovy
-* pitest-build-config - A minimal checkstyle configuration used in other modules.
-
-Care must be taken not to load the code under test into the JVM within the pitest-entry module (e.g by the use of reflection).
-
-Third party dependencies must not be introduced into the pitest module as they may conflict with those of the code under test. Where dependencies are unavoidable (e.g ASM) they must be shaded to avoid conflict.
-
-Dependencies may be introduced into the other modules, but are discouraged so start a discussion before doing so. Any dependencies introduced must be added to the classpath by users of the command-line tool and Ant.
-
-## Eclipse users
-
-Import everything as an existing maven project. If you do not have groovy plugins installed the `pitest-groovy-verification` module will show errors. Unless you are working on something Groovy related it is easiest just to close the module rather than installing the Groovy dependencies into eclipse.
-
-### Code format
-
-The files `code_format_profile.xml` and `code_cleanup_profile.xml` in the root of the repository.
-
-Will create formatting and cleanup profiles named henry. Some aspects of these will be changed in the future (e.g. the use of columns to layout fields) but they should be used while editing pitest to maintain consistency.
-
-## InteliJ
-
-?
+# General
+
+Pitest supports all version of Java back to Java 6.
+
+As long as the resulting binaries support Java 6 technically the build itself could be tied to higher versions of Java, but testing is currently tied into building so it must build with Java 6.
+
+It is reccomended to use Java 8 while developing, but be aware that it is not possible to use any Java 8 (or 7) features.
+
+## Structure
+
+Pitest is split into several modules
+
+* pitest - Main mutation engine and other code that must share a JVM with the system under test
+* pitest-entry - The main entry point for build tools. Contains code that runs in main controller process.
+* pitest-html-report - Generates the html report
+* pitest-command-line - Command line tool for running pitet
+* pitest-maven - Maven mojo for running pitest
+* pitest-ant - Ant task for running pitest
+* pitest-maven-verification - Integration tests that execute pitest via maven module
+* pitest-java8-verification - Integration tests that validate pitest against java 8 features
+* pitest-groovy-verification - Integration tests that validate pitets behaviour with groovy
+* pitest-build-config - A minimal checkstyle configuration used in other modules.
+
+Care must be taken not to load the code under test into the JVM within the pitest-entry module (e.g by the use of reflection).
+
+Third party dependencies must not be introduced into the pitest module as they may conflict with those of the code under test. Where dependencies are unavoidable (e.g ASM) they must be shaded to avoid conflict.
+
+Dependencies may be introduced into the other modules, but are discouraged so start a discussion before doing so. Any dependencies introduced must be added to the classpath by users of the command-line tool and Ant.
+
+## Eclipse users
+
+Import everything as an existing maven project. If you do not have groovy plugins installed the `pitest-groovy-verification` module will show errors. Unless you are working on something Groovy related it is easiest just to close the module rather than installing the Groovy dependencies into eclipse.
+
+### Code format
+
+The files `code_format_profile.xml` and `code_cleanup_profile.xml` in the root of the repository.
+
+Will create formatting and cleanup profiles named henry. Some aspects of these will be changed in the future (e.g. the use of columns to layout fields) but they should be used while editing pitest to maintain consistency.
+
+## InteliJ
+
+?
diff --git a/install.sh b/install.sh
new file mode 100755
index 000000000..5b13be0da
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+mvn -T 4 clean install -DskipTests -e -D"checkstyle.skip"=true -Dmaven.javadoc.skip=true
diff --git a/nohup.out b/nohup.out
new file mode 100644
index 000000000..046858548
--- /dev/null
+++ b/nohup.out
@@ -0,0 +1,14 @@
+WARNING: Using incubator modules: jdk.incubator.httpclient
+org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized. Will retry after the state location is initialized.
+org.eclipse.m2e.logback.configuration: Logback config file: /home/khoa/Documents/work/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.8.3.20180227-2137.xml
+SLF4J: Class path contains multiple SLF4J bindings.
+SLF4J: Found binding in [bundleresource://496.fwk123629835:1/org/slf4j/impl/StaticLoggerBinder.class]
+SLF4J: Found binding in [bundleresource://496.fwk123629835:2/org/slf4j/impl/StaticLoggerBinder.class]
+SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
+SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
+org.eclipse.m2e.logback.configuration: Initializing logback
+WARNING: An illegal reflective access operation has occurred
+WARNING: Illegal reflective access by org.eclipse.emf.ecore.xmi.impl.XMLHandler (file:/home/khoa/.local/share/umake/ide/eclipse/plugins/org.eclipse.emf.ecore.xmi_2.13.0.v20170609-0707.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
+WARNING: Please consider reporting this to the maintainers of org.eclipse.emf.ecore.xmi.impl.XMLHandler
+WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
+WARNING: All illegal access operations will be denied in a future release
diff --git a/perform_release.sh b/perform_release.sh
index 26e37c396..376b735d2 100755
--- a/perform_release.sh
+++ b/perform_release.sh
@@ -1 +1 @@
-mvn -Darguments="-Dcheckstyle.skip=true" release:perform
+mvn -Darguments="-Dcheckstyle.skip=true" release:perform
diff --git a/pitest-aggregator/pom.xml b/pitest-aggregator/pom.xml
index 4b364ca13..f4d4e648b 100644
--- a/pitest-aggregator/pom.xml
+++ b/pitest-aggregator/pom.xml
@@ -1,42 +1,42 @@
-
- 4.0.0
-
- org.pitest
- pitest-parent
- 1.4.0-SNAPSHOT
-
- pitest-aggregator
- Aggregates the output of report XML documents into a new combined HTML report
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
-
-
-
- org.pitest
- pitest-entry
- ${project.version}
-
-
- org.pitest
- pitest-html-report
- ${project.version}
-
-
- junit
- junit
- ${junit.version}
- test
-
-
- org.hamcrest
- hamcrest-library
- 1.3
- test
-
-
+
+ 4.0.0
+
+ org.pitest
+ pitest-parent
+ 1.4.0-SNAPSHOT
+
+ pitest-aggregator
+ Aggregates the output of report XML documents into a new combined HTML report
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+
+
+
+ org.pitest
+ pitest-entry
+ ${project.version}
+
+
+ org.pitest
+ pitest-html-report
+ ${project.version}
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ 1.3
+ test
+
+
\ No newline at end of file
diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/BlockCoverageDataLoader.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/BlockCoverageDataLoader.java
index 1b0d4fb68..697c384e0 100644
--- a/pitest-aggregator/src/main/java/org/pitest/aggregate/BlockCoverageDataLoader.java
+++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/BlockCoverageDataLoader.java
@@ -1,40 +1,40 @@
-package org.pitest.aggregate;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Map;
-
-import org.pitest.classinfo.ClassName;
-import org.pitest.coverage.BlockCoverage;
-import org.pitest.coverage.BlockLocation;
-import org.pitest.mutationtest.engine.Location;
-import org.pitest.mutationtest.engine.MethodName;
-
-class BlockCoverageDataLoader extends DataLoader {
-
- private static final String METHOD = "method";
- private static final String CLASSNAME = "classname";
- private static final String NUMBER = "number";
- private static final String TESTS = "tests";
-
- private static final String OPEN_PAREN = "(";
-
- BlockCoverageDataLoader(final Collection filesToLoad) {
- super(filesToLoad);
- }
-
- @Override
- protected BlockCoverage mapToData(final Map map) {
- final String method = (String) map.get(METHOD);
- final Location location = new Location(ClassName.fromString((String) map.get(CLASSNAME)),
- MethodName.fromString(method.substring(0, method.indexOf(OPEN_PAREN))), method.substring(method.indexOf(OPEN_PAREN)));
-
- final BlockLocation blockLocation = new BlockLocation(location, Integer.parseInt((String) map.get(NUMBER)));
-
- @SuppressWarnings("unchecked")
- final Collection tests = (Collection) map.get(TESTS);
-
- return new BlockCoverage(blockLocation, tests);
- }
-
-}
+package org.pitest.aggregate;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Map;
+
+import org.pitest.classinfo.ClassName;
+import org.pitest.coverage.BlockCoverage;
+import org.pitest.coverage.BlockLocation;
+import org.pitest.mutationtest.engine.Location;
+import org.pitest.mutationtest.engine.MethodName;
+
+class BlockCoverageDataLoader extends DataLoader {
+
+ private static final String METHOD = "method";
+ private static final String CLASSNAME = "classname";
+ private static final String NUMBER = "number";
+ private static final String TESTS = "tests";
+
+ private static final String OPEN_PAREN = "(";
+
+ BlockCoverageDataLoader(final Collection filesToLoad) {
+ super(filesToLoad);
+ }
+
+ @Override
+ protected BlockCoverage mapToData(final Map map) {
+ final String method = (String) map.get(METHOD);
+ final Location location = new Location(ClassName.fromString((String) map.get(CLASSNAME)),
+ MethodName.fromString(method.substring(0, method.indexOf(OPEN_PAREN))), method.substring(method.indexOf(OPEN_PAREN)));
+
+ final BlockLocation blockLocation = new BlockLocation(location, Integer.parseInt((String) map.get(NUMBER)));
+
+ @SuppressWarnings("unchecked")
+ final Collection tests = (Collection) map.get(TESTS);
+
+ return new BlockCoverage(blockLocation, tests);
+ }
+
+}
diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/CodeSourceAggregator.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/CodeSourceAggregator.java
index 3b790df9a..865a5d211 100644
--- a/pitest-aggregator/src/main/java/org/pitest/aggregate/CodeSourceAggregator.java
+++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/CodeSourceAggregator.java
@@ -1,59 +1,59 @@
-package org.pitest.aggregate;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
-import org.pitest.classinfo.ClassName;
-import org.pitest.classpath.ClassFilter;
-import org.pitest.classpath.ClassPath;
-import org.pitest.classpath.ClassPathRoot;
-import org.pitest.classpath.CodeSource;
-import org.pitest.classpath.DirectoryClassPathRoot;
-import org.pitest.classpath.PathFilter;
-import org.pitest.classpath.ProjectClassPaths;
-import org.pitest.functional.FCollection;
-import org.pitest.functional.prelude.Prelude;
-import org.pitest.mutationtest.config.DefaultCodePathPredicate;
-import org.pitest.mutationtest.config.DefaultDependencyPathPredicate;
-import org.pitest.util.Glob;
-
-class CodeSourceAggregator {
-
- private final Collection compiledCodeDirectories;
-
- CodeSourceAggregator(final Collection compiledCodeDirectories) {
- this.compiledCodeDirectories = Collections.unmodifiableCollection(compiledCodeDirectories);
- }
-
- public CodeSource createCodeSource() {
- return new CodeSource(createProjectClassPaths());
- }
-
- private ProjectClassPaths createProjectClassPaths() {
- final ClassPath classPath = new ClassPath(this.compiledCodeDirectories);
- final Predicate classPredicate = createClassPredicate();
- final Predicate pathPredicate = new DefaultCodePathPredicate();
- return new ProjectClassPaths(classPath, new ClassFilter(classPredicate, classPredicate),
- new PathFilter(pathPredicate, Prelude.not(new DefaultDependencyPathPredicate())));
- }
-
- private Predicate createClassPredicate() {
- final Collection classes = new HashSet<>();
- for (final File buildOutputDirectory : this.compiledCodeDirectories) {
- if (buildOutputDirectory.exists()) {
- final DirectoryClassPathRoot dcRoot = new DirectoryClassPathRoot(buildOutputDirectory);
- classes.addAll(FCollection.map(dcRoot.classNames(), toPredicate()));
- }
- }
- return Prelude.or(FCollection.map(classes, Glob.toGlobPredicate()));
- }
-
- private Function toPredicate() {
- return a -> ClassName.fromString(a).getPackage().asJavaName() + ".*";
- }
-
-}
+package org.pitest.aggregate;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+import org.pitest.classinfo.ClassName;
+import org.pitest.classpath.ClassFilter;
+import org.pitest.classpath.ClassPath;
+import org.pitest.classpath.ClassPathRoot;
+import org.pitest.classpath.CodeSource;
+import org.pitest.classpath.DirectoryClassPathRoot;
+import org.pitest.classpath.PathFilter;
+import org.pitest.classpath.ProjectClassPaths;
+import org.pitest.functional.FCollection;
+import org.pitest.functional.prelude.Prelude;
+import org.pitest.mutationtest.config.DefaultCodePathPredicate;
+import org.pitest.mutationtest.config.DefaultDependencyPathPredicate;
+import org.pitest.util.Glob;
+
+class CodeSourceAggregator {
+
+ private final Collection compiledCodeDirectories;
+
+ CodeSourceAggregator(final Collection compiledCodeDirectories) {
+ this.compiledCodeDirectories = Collections.unmodifiableCollection(compiledCodeDirectories);
+ }
+
+ public CodeSource createCodeSource() {
+ return new CodeSource(createProjectClassPaths());
+ }
+
+ private ProjectClassPaths createProjectClassPaths() {
+ final ClassPath classPath = new ClassPath(this.compiledCodeDirectories);
+ final Predicate classPredicate = createClassPredicate();
+ final Predicate pathPredicate = new DefaultCodePathPredicate();
+ return new ProjectClassPaths(classPath, new ClassFilter(classPredicate, classPredicate),
+ new PathFilter(pathPredicate, Prelude.not(new DefaultDependencyPathPredicate())));
+ }
+
+ private Predicate createClassPredicate() {
+ final Collection classes = new HashSet<>();
+ for (final File buildOutputDirectory : this.compiledCodeDirectories) {
+ if (buildOutputDirectory.exists()) {
+ final DirectoryClassPathRoot dcRoot = new DirectoryClassPathRoot(buildOutputDirectory);
+ classes.addAll(FCollection.map(dcRoot.classNames(), toPredicate()));
+ }
+ }
+ return Prelude.or(FCollection.map(classes, Glob.toGlobPredicate()));
+ }
+
+ private Function toPredicate() {
+ return a -> ClassName.fromString(a).getPackage().asJavaName() + ".*";
+ }
+
+}
diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/DataLoader.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/DataLoader.java
index 4ef5e402a..8ddb38792 100644
--- a/pitest-aggregator/src/main/java/org/pitest/aggregate/DataLoader.java
+++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/DataLoader.java
@@ -1,150 +1,150 @@
-package org.pitest.aggregate;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-abstract class DataLoader {
-
- private static final String CANNOT_CLOSE_ERR = "Unable to close input stream";
-
- private final Set filesToLoad;
-
- protected DataLoader(final Collection filesToLoad) {
- if ((filesToLoad == null) || filesToLoad.isEmpty()) {
- throw new IllegalArgumentException("Null or empty filesToLoad");
- }
-
- this.filesToLoad = Collections.unmodifiableSet(new HashSet<>(filesToLoad));
- }
-
- public Set loadData() throws ReportAggregationException {
- final Set data = new HashSet<>();
-
- for (final File file : this.filesToLoad) {
- data.addAll(loadData(file));
- }
- return data;
- }
-
- protected abstract T mapToData(Map map);
-
- Set loadData(final File dataLocation) throws ReportAggregationException {
- if (!dataLocation.exists() || !dataLocation.isFile()) {
- throw new ReportAggregationException(dataLocation.getAbsolutePath() + " does not exist or is not a file");
- }
- final Set data = new HashSet<>();
- try {
- final InputStream inputStream = new BufferedInputStream(new FileInputStream(dataLocation));
-
- final Document doc = readDocument(inputStream);
-
- final Node docNode = doc.getFirstChild();
- final NodeList nodeList = docNode.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- final Node itemNode = nodeList.item(i);
- if (itemNode.getNodeType() == Node.ELEMENT_NODE) {
- data.add(mapToData(nodeMap(itemNode)));
- }
- }
- return data;
- } catch (final IOException e) {
- throw new ReportAggregationException("Could not read file: " + dataLocation.getAbsolutePath(), e);
- }
- }
-
- /**
- * Reads the input stream into a document and closes the input stream when
- * finished.
- */
- static Document readDocument(final InputStream inputStream) throws ReportAggregationException {
- DocumentBuilder docBuilder;
- try {
- docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- return docBuilder.parse(inputStream);
- } catch (final IOException e) {
- throw new ReportAggregationException(e.getMessage(), e);
- } catch (final SAXException e) {
- throw new ReportAggregationException(e.getMessage(), e);
- } catch (final ParserConfigurationException e) {
- throw new ReportAggregationException(e.getMessage(), e);
- } finally {
- try {
- inputStream.close();
- } catch (final IOException e) {
- throw new ReportAggregationException(CANNOT_CLOSE_ERR, e);
- }
- }
- }
-
- // converts the contents of a node into a map
- static Map nodeMap(final Node node) {
- final HashMap map = new HashMap<>();
-
- final NamedNodeMap attrs = node.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- final Node attr = attrs.item(i);
- final String tc = attr.getTextContent().trim();
-
- if (!tc.isEmpty()) {
- map.put(attr.getNodeName(), tc);
- }
- }
-
- final NodeList children = node.getChildNodes();
-
- for (int i = 0; i < children.getLength(); i++) {
- final Node child = children.item(i);
-
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- final String tc = child.getTextContent().trim();
- if (!tc.isEmpty()) {
- map.put(child.getNodeName(), tc);
- } else {
- // may have test nodes
- final List tests = new ArrayList<>();
- final NodeList testNodeList = child.getChildNodes();
- for (int j = 0; j < testNodeList.getLength(); j++) {
- final Node testNode = testNodeList.item(j);
- if (testNode.getNodeType() == Node.ELEMENT_NODE) {
- final NamedNodeMap testAttrs = testNode.getAttributes();
- for (int k = 0; k < testAttrs.getLength(); k++) {
- final Node attr = testAttrs.item(k);
- final String tn = attr.getTextContent().trim();
-
- if (!tn.isEmpty()) {
- tests.add(tn);
- }
- }
- }
- }
- if (!tests.isEmpty()) {
- map.put(child.getNodeName(), tests);
- }
- }
- }
- }
-
- return map;
- }
-}
+package org.pitest.aggregate;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+abstract class DataLoader {
+
+ private static final String CANNOT_CLOSE_ERR = "Unable to close input stream";
+
+ private final Set filesToLoad;
+
+ protected DataLoader(final Collection filesToLoad) {
+ if ((filesToLoad == null) || filesToLoad.isEmpty()) {
+ throw new IllegalArgumentException("Null or empty filesToLoad");
+ }
+
+ this.filesToLoad = Collections.unmodifiableSet(new HashSet<>(filesToLoad));
+ }
+
+ public Set loadData() throws ReportAggregationException {
+ final Set data = new HashSet<>();
+
+ for (final File file : this.filesToLoad) {
+ data.addAll(loadData(file));
+ }
+ return data;
+ }
+
+ protected abstract T mapToData(Map map);
+
+ Set loadData(final File dataLocation) throws ReportAggregationException {
+ if (!dataLocation.exists() || !dataLocation.isFile()) {
+ throw new ReportAggregationException(dataLocation.getAbsolutePath() + " does not exist or is not a file");
+ }
+ final Set data = new HashSet<>();
+ try {
+ final InputStream inputStream = new BufferedInputStream(new FileInputStream(dataLocation));
+
+ final Document doc = readDocument(inputStream);
+
+ final Node docNode = doc.getFirstChild();
+ final NodeList nodeList = docNode.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ final Node itemNode = nodeList.item(i);
+ if (itemNode.getNodeType() == Node.ELEMENT_NODE) {
+ data.add(mapToData(nodeMap(itemNode)));
+ }
+ }
+ return data;
+ } catch (final IOException e) {
+ throw new ReportAggregationException("Could not read file: " + dataLocation.getAbsolutePath(), e);
+ }
+ }
+
+ /**
+ * Reads the input stream into a document and closes the input stream when
+ * finished.
+ */
+ static Document readDocument(final InputStream inputStream) throws ReportAggregationException {
+ DocumentBuilder docBuilder;
+ try {
+ docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ return docBuilder.parse(inputStream);
+ } catch (final IOException e) {
+ throw new ReportAggregationException(e.getMessage(), e);
+ } catch (final SAXException e) {
+ throw new ReportAggregationException(e.getMessage(), e);
+ } catch (final ParserConfigurationException e) {
+ throw new ReportAggregationException(e.getMessage(), e);
+ } finally {
+ try {
+ inputStream.close();
+ } catch (final IOException e) {
+ throw new ReportAggregationException(CANNOT_CLOSE_ERR, e);
+ }
+ }
+ }
+
+ // converts the contents of a node into a map
+ static Map nodeMap(final Node node) {
+ final HashMap map = new HashMap<>();
+
+ final NamedNodeMap attrs = node.getAttributes();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ final Node attr = attrs.item(i);
+ final String tc = attr.getTextContent().trim();
+
+ if (!tc.isEmpty()) {
+ map.put(attr.getNodeName(), tc);
+ }
+ }
+
+ final NodeList children = node.getChildNodes();
+
+ for (int i = 0; i < children.getLength(); i++) {
+ final Node child = children.item(i);
+
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ final String tc = child.getTextContent().trim();
+ if (!tc.isEmpty()) {
+ map.put(child.getNodeName(), tc);
+ } else {
+ // may have test nodes
+ final List tests = new ArrayList<>();
+ final NodeList testNodeList = child.getChildNodes();
+ for (int j = 0; j < testNodeList.getLength(); j++) {
+ final Node testNode = testNodeList.item(j);
+ if (testNode.getNodeType() == Node.ELEMENT_NODE) {
+ final NamedNodeMap testAttrs = testNode.getAttributes();
+ for (int k = 0; k < testAttrs.getLength(); k++) {
+ final Node attr = testAttrs.item(k);
+ final String tn = attr.getTextContent().trim();
+
+ if (!tn.isEmpty()) {
+ tests.add(tn);
+ }
+ }
+ }
+ }
+ if (!tests.isEmpty()) {
+ map.put(child.getNodeName(), tests);
+ }
+ }
+ }
+ }
+
+ return map;
+ }
+}
diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/MutationResultDataLoader.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/MutationResultDataLoader.java
index eea6d1534..159d01c28 100644
--- a/pitest-aggregator/src/main/java/org/pitest/aggregate/MutationResultDataLoader.java
+++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/MutationResultDataLoader.java
@@ -1,52 +1,52 @@
-package org.pitest.aggregate;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-
-import org.pitest.classinfo.ClassName;
-import org.pitest.mutationtest.DetectionStatus;
-import org.pitest.mutationtest.MutationResult;
-import org.pitest.mutationtest.MutationStatusTestPair;
-import org.pitest.mutationtest.engine.Location;
-import org.pitest.mutationtest.engine.MethodName;
-import org.pitest.mutationtest.engine.MutationDetails;
-import org.pitest.mutationtest.engine.MutationIdentifier;
-
-class MutationResultDataLoader extends DataLoader {
-
- private static final String MUTATED_CLASS = "mutatedClass";
- private static final String MUTATED_METHOD = "mutatedMethod";
- private static final String METHOD_DESCRIPTION = "methodDescription";
- private static final String INDEX = "index";
- private static final String MUTATOR = "mutator";
- private static final String SOURCE_FILE = "sourceFile";
- private static final String DESCRIPTION = "description";
- private static final String LINE_NUMBER = "lineNumber";
- private static final String BLOCK = "block";
- private static final String NUMBER_OF_TESTS_RUN = "numberOfTestsRun";
- private static final String STATUS = "status";
- private static final String KILLING_TEST = "killingTest";
-
- MutationResultDataLoader(final Collection filesToLoad) {
- super(filesToLoad);
- }
-
- @Override
- protected MutationResult mapToData(final Map map) {
- final Location location = new Location(ClassName.fromString((String) map.get(MUTATED_CLASS)), MethodName.fromString((String) map.get(MUTATED_METHOD)),
- (String) map.get(METHOD_DESCRIPTION));
-
- final MutationIdentifier id = new MutationIdentifier(location, Arrays.asList(new Integer((String) map.get(INDEX))), (String) map.get(MUTATOR));
-
- final MutationDetails md = new MutationDetails(id, (String) map.get(SOURCE_FILE), (String) map.get(DESCRIPTION),
- Integer.parseInt((String) map.get(LINE_NUMBER)), Integer.parseInt((String) map.get(BLOCK)));
-
- final MutationStatusTestPair status = new MutationStatusTestPair(Integer.parseInt((String) map.get(NUMBER_OF_TESTS_RUN)),
- DetectionStatus.valueOf((String) map.get(STATUS)), (String) map.get(KILLING_TEST));
-
- return new MutationResult(md, status);
- }
-
-}
+package org.pitest.aggregate;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+
+import org.pitest.classinfo.ClassName;
+import org.pitest.mutationtest.DetectionStatus;
+import org.pitest.mutationtest.MutationResult;
+import org.pitest.mutationtest.MutationStatusTestPair;
+import org.pitest.mutationtest.engine.Location;
+import org.pitest.mutationtest.engine.MethodName;
+import org.pitest.mutationtest.engine.MutationDetails;
+import org.pitest.mutationtest.engine.MutationIdentifier;
+
+class MutationResultDataLoader extends DataLoader {
+
+ private static final String MUTATED_CLASS = "mutatedClass";
+ private static final String MUTATED_METHOD = "mutatedMethod";
+ private static final String METHOD_DESCRIPTION = "methodDescription";
+ private static final String INDEX = "index";
+ private static final String MUTATOR = "mutator";
+ private static final String SOURCE_FILE = "sourceFile";
+ private static final String DESCRIPTION = "description";
+ private static final String LINE_NUMBER = "lineNumber";
+ private static final String BLOCK = "block";
+ private static final String NUMBER_OF_TESTS_RUN = "numberOfTestsRun";
+ private static final String STATUS = "status";
+ private static final String KILLING_TEST = "killingTest";
+
+ MutationResultDataLoader(final Collection filesToLoad) {
+ super(filesToLoad);
+ }
+
+ @Override
+ protected MutationResult mapToData(final Map map) {
+ final Location location = new Location(ClassName.fromString((String) map.get(MUTATED_CLASS)), MethodName.fromString((String) map.get(MUTATED_METHOD)),
+ (String) map.get(METHOD_DESCRIPTION));
+
+ final MutationIdentifier id = new MutationIdentifier(location, Arrays.asList(new Integer((String) map.get(INDEX))), (String) map.get(MUTATOR));
+
+ final MutationDetails md = new MutationDetails(id, (String) map.get(SOURCE_FILE), (String) map.get(DESCRIPTION),
+ Integer.parseInt((String) map.get(LINE_NUMBER)), Integer.parseInt((String) map.get(BLOCK)));
+
+ final MutationStatusTestPair status = new MutationStatusTestPair(Integer.parseInt((String) map.get(NUMBER_OF_TESTS_RUN)),
+ DetectionStatus.valueOf((String) map.get(STATUS)), (String) map.get(KILLING_TEST));
+
+ return new MutationResult(md, status);
+ }
+
+}
diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/MutatorUtil.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/MutatorUtil.java
index 660c2df9d..d7368793d 100644
--- a/pitest-aggregator/src/main/java/org/pitest/aggregate/MutatorUtil.java
+++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/MutatorUtil.java
@@ -1,29 +1,29 @@
-package org.pitest.aggregate;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory;
-
-final class MutatorUtil {
-
- private static Map factories = new ConcurrentHashMap<>();
-
- @SuppressWarnings("unchecked")
- static MethodMutatorFactory loadMutator(final String className) {
- if (!factories.containsKey(className)) {
- try {
- final Class clazz = (Class) Class.forName(className);
- final Method values = clazz.getMethod("values");
- final Object valuesArray = values.invoke(null);
- final MethodMutatorFactory mutator = (MethodMutatorFactory) Array.get(valuesArray, 0);
- factories.put(className, mutator);
- } catch (final Exception e) {
- throw new RuntimeException("Unable to load Mutator for class: " + className, e);
- }
- }
- return factories.get(className);
- }
-}
+package org.pitest.aggregate;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory;
+
+final class MutatorUtil {
+
+ private static Map factories = new ConcurrentHashMap<>();
+
+ @SuppressWarnings("unchecked")
+ static MethodMutatorFactory loadMutator(final String className) {
+ if (!factories.containsKey(className)) {
+ try {
+ final Class clazz = (Class) Class.forName(className);
+ final Method values = clazz.getMethod("values");
+ final Object valuesArray = values.invoke(null);
+ final MethodMutatorFactory mutator = (MethodMutatorFactory) Array.get(valuesArray, 0);
+ factories.put(className, mutator);
+ } catch (final Exception e) {
+ throw new RuntimeException("Unable to load Mutator for class: " + className, e);
+ }
+ }
+ return factories.get(className);
+ }
+}
diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregationException.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregationException.java
index 0cc4f3475..ea5772f2f 100644
--- a/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregationException.java
+++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregationException.java
@@ -1,15 +1,15 @@
-package org.pitest.aggregate;
-
-public class ReportAggregationException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public ReportAggregationException(final String message) {
- super(message);
- }
-
- public ReportAggregationException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
+package org.pitest.aggregate;
+
+public class ReportAggregationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public ReportAggregationException(final String message) {
+ super(message);
+ }
+
+ public ReportAggregationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java
index 17337436d..ffe920054 100644
--- a/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java
+++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java
@@ -1,239 +1,239 @@
-package org.pitest.aggregate;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.Function;
-
-import org.pitest.classpath.CodeSource;
-import org.pitest.coverage.BlockCoverage;
-import org.pitest.coverage.BlockLocation;
-import org.pitest.coverage.CoverageData;
-import org.pitest.coverage.CoverageDatabase;
-import org.pitest.coverage.TestInfo;
-import org.pitest.coverage.analysis.LineMapper;
-import org.pitest.functional.FCollection;
-import java.util.Optional;
-import org.pitest.mutationtest.ClassMutationResults;
-import org.pitest.mutationtest.MutationMetaData;
-import org.pitest.mutationtest.MutationResult;
-import org.pitest.mutationtest.MutationResultListener;
-import org.pitest.mutationtest.SourceLocator;
-import org.pitest.mutationtest.report.html.MutationHtmlReportListener;
-import org.pitest.mutationtest.tooling.SmartSourceLocator;
-import org.pitest.util.ResultOutputStrategy;
-
-public final class ReportAggregator {
- private final ResultOutputStrategy resultOutputStrategy;
- private final DataLoader blockCoverageLoader;
- private final DataLoader mutationLoader;
-
- private final Collection sourceCodeDirectories;
- private final CodeSourceAggregator codeSourceAggregator;
-
- private ReportAggregator(final ResultOutputStrategy resultOutputStrategy, final Set lineCoverageFiles, final Set mutationFiles,
- final Set sourceCodeDirs, final Set compiledCodeDirs) {
- this.resultOutputStrategy = resultOutputStrategy;
- this.blockCoverageLoader = new BlockCoverageDataLoader(lineCoverageFiles);
- this.mutationLoader = new MutationResultDataLoader(mutationFiles);
- this.sourceCodeDirectories = Collections.unmodifiableCollection(new HashSet<>(sourceCodeDirs));
- this.codeSourceAggregator = new CodeSourceAggregator(new HashSet<>(compiledCodeDirs));
- }
-
- public void aggregateReport() throws ReportAggregationException {
- final MutationMetaData mutationMetaData = new MutationMetaData(new ArrayList<>(this.mutationLoader.loadData()));
-
- final MutationResultListener mutationResultListener = createResultListener(mutationMetaData);
-
- mutationResultListener.runStart();
-
- for (final ClassMutationResults mutationResults : mutationMetaData.toClassResults()) {
- mutationResultListener.handleMutationResult(mutationResults);
- }
- mutationResultListener.runEnd();
- }
-
- private MutationResultListener createResultListener(final MutationMetaData mutationMetaData) throws ReportAggregationException {
- final SourceLocator sourceLocator = new SmartSourceLocator(this.sourceCodeDirectories);
-
- final CodeSource codeSource = this.codeSourceAggregator.createCodeSource();
- final CoverageDatabase coverageDatabase = calculateCoverage(codeSource, mutationMetaData);
- final Collection mutatorNames = new HashSet<>(FCollection.flatMap(mutationMetaData.getMutations(), resultToMutatorName()));
-
- return new MutationHtmlReportListener(coverageDatabase, this.resultOutputStrategy, mutatorNames, sourceLocator);
- }
-
- private static Function> resultToMutatorName() {
- return a -> {
- try {
- final String mutatorName = MutatorUtil.loadMutator(a.getDetails().getMutator()).getName();
- return Collections.singletonList(mutatorName);
- } catch (final Exception e) {
- throw new RuntimeException("Cannot convert to mutator: " + a.getDetails().getMutator(), e);
- }
- };
- }
-
- private CoverageData calculateCoverage(final CodeSource codeSource, final MutationMetaData metadata) throws ReportAggregationException {
- final Collection coverageData = this.blockCoverageLoader.loadData();
- try {
- final Map> blockCoverageMap = blocksToMap(coverageData);
- return new CoverageData(codeSource, new LineMapper(codeSource),blockCoverageMap);
- } catch (final Exception e) {
- throw new ReportAggregationException(e.getMessage(), e);
- }
- }
-
- private Map> blocksToMap(
- final Collection coverageData) {
- final Map> blockCoverageMap = new HashMap<>();
-
- for (final BlockCoverage blockData : coverageData) {
- blockCoverageMap.put(blockData.getBlock(), new HashSet<>(FCollection.map(blockData.getTests(), toTestInfo(blockData))));
- }
- return blockCoverageMap;
- }
-
- private Function toTestInfo(final BlockCoverage blockData) {
- return a -> new TestInfo(null, a, 0, Optional.ofNullable(blockData.getBlock().getLocation().getClassName()), blockData.getBlock().getBlock());
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private ResultOutputStrategy resultOutputStrategy;
- private final Set lineCoverageFiles = new HashSet<>();
- private final Set mutationResultsFiles = new HashSet<>();
- private final Set sourceCodeDirectories = new HashSet<>();
- private final Set compiledCodeDirectories = new HashSet<>();
-
- public Builder resultOutputStrategy(final ResultOutputStrategy resultOutputStrategy) {
- this.resultOutputStrategy = resultOutputStrategy;
- return this;
- }
-
- public Builder lineCoverageFiles(final List lineCoverageFiles) {
- this.lineCoverageFiles.clear();
- for (final File file : lineCoverageFiles) {
- addLineCoverageFile(file);
- }
- return this;
- }
-
- public Builder addLineCoverageFile(final File lineCoverageFile) {
- validateFile(lineCoverageFile);
- this.lineCoverageFiles.add(lineCoverageFile);
- return this;
- }
-
- public Builder mutationResultsFiles(final List mutationResultsFiles) {
- this.mutationResultsFiles.clear();
- for (final File file : mutationResultsFiles) {
- addMutationResultsFile(file);
- }
- return this;
- }
-
- public Builder addMutationResultsFile(final File mutationResultsFile) {
- validateFile(mutationResultsFile);
- this.mutationResultsFiles.add(mutationResultsFile);
- return this;
- }
-
- public Builder sourceCodeDirectories(final List sourceCodeDirectories) {
- this.sourceCodeDirectories.clear();
- for (final File file : sourceCodeDirectories) {
- addSourceCodeDirectory(file);
- }
- return this;
- }
-
- public Builder addSourceCodeDirectory(final File sourceCodeDirectory) {
- validateDirectory(sourceCodeDirectory);
- this.sourceCodeDirectories.add(sourceCodeDirectory);
- return this;
- }
-
- public Builder compiledCodeDirectories(final List compiledCodeDirectories) {
- this.compiledCodeDirectories.clear();
- for (final File file : compiledCodeDirectories) {
- addCompiledCodeDirectory(file);
- }
- return this;
- }
-
- public Builder addCompiledCodeDirectory(final File compiledCodeDirectory) {
- validateDirectory(compiledCodeDirectory);
- this.compiledCodeDirectories.add(compiledCodeDirectory);
- return this;
- }
-
- public Set getCompiledCodeDirectories() {
- return this.compiledCodeDirectories;
- }
-
- public Set getLineCoverageFiles() {
- return this.lineCoverageFiles;
- }
-
- public Set getMutationResultsFiles() {
- return this.mutationResultsFiles;
- }
-
- public Set getSourceCodeDirectories() {
- return this.sourceCodeDirectories;
- }
-
- public ReportAggregator build() {
- validateState();
- return new ReportAggregator(this.resultOutputStrategy, this.lineCoverageFiles, this.mutationResultsFiles, this.sourceCodeDirectories, this.compiledCodeDirectories);
- }
-
- /*
- * Validators
- */
- private void validateState() {
- if (this.resultOutputStrategy == null) {
- throw new IllegalStateException("Failed to build: the resultOutputStrategy has not been set");
- }
- if (this.lineCoverageFiles.isEmpty()) {
- throw new IllegalStateException("Failed to build: no lineCoverageFiles have been set");
- }
- if (this.mutationResultsFiles.isEmpty()) {
- throw new IllegalStateException("Failed to build: no mutationResultsFiles have been set");
- }
- if (this.sourceCodeDirectories.isEmpty()) {
- throw new IllegalStateException("Failed to build: no sourceCodeDirectories have been set");
- }
- if (this.compiledCodeDirectories.isEmpty()) {
- throw new IllegalStateException("Failed to build: no compiledCodeDirectories have been set");
- }
- }
-
- private void validateFile(final File file) {
- if (file == null) {
- throw new IllegalArgumentException("file is null");
- }
- if (!file.exists() || !file.isFile()) {
- throw new IllegalArgumentException(file.getAbsolutePath() + " does not exist or is not a file");
- }
- }
-
- private void validateDirectory(final File directory) {
- if (directory == null) {
- throw new IllegalArgumentException("directory is null");
- }
- if (!directory.exists() || !directory.isDirectory()) {
- throw new IllegalArgumentException(directory.getAbsolutePath() + " does not exist or is not a directory");
- }
- }
- }
-}
+package org.pitest.aggregate;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+
+import org.pitest.classpath.CodeSource;
+import org.pitest.coverage.BlockCoverage;
+import org.pitest.coverage.BlockLocation;
+import org.pitest.coverage.CoverageData;
+import org.pitest.coverage.CoverageDatabase;
+import org.pitest.coverage.TestInfo;
+import org.pitest.coverage.analysis.LineMapper;
+import org.pitest.functional.FCollection;
+import java.util.Optional;
+import org.pitest.mutationtest.ClassMutationResults;
+import org.pitest.mutationtest.MutationMetaData;
+import org.pitest.mutationtest.MutationResult;
+import org.pitest.mutationtest.MutationResultListener;
+import org.pitest.mutationtest.SourceLocator;
+import org.pitest.mutationtest.report.html.MutationHtmlReportListener;
+import org.pitest.mutationtest.tooling.SmartSourceLocator;
+import org.pitest.util.ResultOutputStrategy;
+
+public final class ReportAggregator {
+ private final ResultOutputStrategy resultOutputStrategy;
+ private final DataLoader blockCoverageLoader;
+ private final DataLoader mutationLoader;
+
+ private final Collection sourceCodeDirectories;
+ private final CodeSourceAggregator codeSourceAggregator;
+
+ private ReportAggregator(final ResultOutputStrategy resultOutputStrategy, final Set lineCoverageFiles, final Set mutationFiles,
+ final Set sourceCodeDirs, final Set compiledCodeDirs) {
+ this.resultOutputStrategy = resultOutputStrategy;
+ this.blockCoverageLoader = new BlockCoverageDataLoader(lineCoverageFiles);
+ this.mutationLoader = new MutationResultDataLoader(mutationFiles);
+ this.sourceCodeDirectories = Collections.unmodifiableCollection(new HashSet<>(sourceCodeDirs));
+ this.codeSourceAggregator = new CodeSourceAggregator(new HashSet<>(compiledCodeDirs));
+ }
+
+ public void aggregateReport() throws ReportAggregationException {
+ final MutationMetaData mutationMetaData = new MutationMetaData(new ArrayList<>(this.mutationLoader.loadData()));
+
+ final MutationResultListener mutationResultListener = createResultListener(mutationMetaData);
+
+ mutationResultListener.runStart();
+
+ for (final ClassMutationResults mutationResults : mutationMetaData.toClassResults()) {
+ mutationResultListener.handleMutationResult(mutationResults);
+ }
+ mutationResultListener.runEnd();
+ }
+
+ private MutationResultListener createResultListener(final MutationMetaData mutationMetaData) throws ReportAggregationException {
+ final SourceLocator sourceLocator = new SmartSourceLocator(this.sourceCodeDirectories);
+
+ final CodeSource codeSource = this.codeSourceAggregator.createCodeSource();
+ final CoverageDatabase coverageDatabase = calculateCoverage(codeSource, mutationMetaData);
+ final Collection mutatorNames = new HashSet<>(FCollection.flatMap(mutationMetaData.getMutations(), resultToMutatorName()));
+
+ return new MutationHtmlReportListener(coverageDatabase, this.resultOutputStrategy, mutatorNames, sourceLocator);
+ }
+
+ private static Function> resultToMutatorName() {
+ return a -> {
+ try {
+ final String mutatorName = MutatorUtil.loadMutator(a.getDetails().getMutator()).getName();
+ return Collections.singletonList(mutatorName);
+ } catch (final Exception e) {
+ throw new RuntimeException("Cannot convert to mutator: " + a.getDetails().getMutator(), e);
+ }
+ };
+ }
+
+ private CoverageData calculateCoverage(final CodeSource codeSource, final MutationMetaData metadata) throws ReportAggregationException {
+ final Collection coverageData = this.blockCoverageLoader.loadData();
+ try {
+ final Map> blockCoverageMap = blocksToMap(coverageData);
+ return new CoverageData(codeSource, new LineMapper(codeSource),blockCoverageMap);
+ } catch (final Exception e) {
+ throw new ReportAggregationException(e.getMessage(), e);
+ }
+ }
+
+ private Map> blocksToMap(
+ final Collection coverageData) {
+ final Map> blockCoverageMap = new HashMap<>();
+
+ for (final BlockCoverage blockData : coverageData) {
+ blockCoverageMap.put(blockData.getBlock(), new HashSet<>(FCollection.map(blockData.getTests(), toTestInfo(blockData))));
+ }
+ return blockCoverageMap;
+ }
+
+ private Function toTestInfo(final BlockCoverage blockData) {
+ return a -> new TestInfo(null, a, 0, Optional.ofNullable(blockData.getBlock().getLocation().getClassName()), blockData.getBlock().getBlock());
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private ResultOutputStrategy resultOutputStrategy;
+ private final Set lineCoverageFiles = new HashSet<>();
+ private final Set mutationResultsFiles = new HashSet<>();
+ private final Set sourceCodeDirectories = new HashSet<>();
+ private final Set compiledCodeDirectories = new HashSet<>();
+
+ public Builder resultOutputStrategy(final ResultOutputStrategy resultOutputStrategy) {
+ this.resultOutputStrategy = resultOutputStrategy;
+ return this;
+ }
+
+ public Builder lineCoverageFiles(final List lineCoverageFiles) {
+ this.lineCoverageFiles.clear();
+ for (final File file : lineCoverageFiles) {
+ addLineCoverageFile(file);
+ }
+ return this;
+ }
+
+ public Builder addLineCoverageFile(final File lineCoverageFile) {
+ validateFile(lineCoverageFile);
+ this.lineCoverageFiles.add(lineCoverageFile);
+ return this;
+ }
+
+ public Builder mutationResultsFiles(final List mutationResultsFiles) {
+ this.mutationResultsFiles.clear();
+ for (final File file : mutationResultsFiles) {
+ addMutationResultsFile(file);
+ }
+ return this;
+ }
+
+ public Builder addMutationResultsFile(final File mutationResultsFile) {
+ validateFile(mutationResultsFile);
+ this.mutationResultsFiles.add(mutationResultsFile);
+ return this;
+ }
+
+ public Builder sourceCodeDirectories(final List sourceCodeDirectories) {
+ this.sourceCodeDirectories.clear();
+ for (final File file : sourceCodeDirectories) {
+ addSourceCodeDirectory(file);
+ }
+ return this;
+ }
+
+ public Builder addSourceCodeDirectory(final File sourceCodeDirectory) {
+ validateDirectory(sourceCodeDirectory);
+ this.sourceCodeDirectories.add(sourceCodeDirectory);
+ return this;
+ }
+
+ public Builder compiledCodeDirectories(final List compiledCodeDirectories) {
+ this.compiledCodeDirectories.clear();
+ for (final File file : compiledCodeDirectories) {
+ addCompiledCodeDirectory(file);
+ }
+ return this;
+ }
+
+ public Builder addCompiledCodeDirectory(final File compiledCodeDirectory) {
+ validateDirectory(compiledCodeDirectory);
+ this.compiledCodeDirectories.add(compiledCodeDirectory);
+ return this;
+ }
+
+ public Set getCompiledCodeDirectories() {
+ return this.compiledCodeDirectories;
+ }
+
+ public Set getLineCoverageFiles() {
+ return this.lineCoverageFiles;
+ }
+
+ public Set getMutationResultsFiles() {
+ return this.mutationResultsFiles;
+ }
+
+ public Set getSourceCodeDirectories() {
+ return this.sourceCodeDirectories;
+ }
+
+ public ReportAggregator build() {
+ validateState();
+ return new ReportAggregator(this.resultOutputStrategy, this.lineCoverageFiles, this.mutationResultsFiles, this.sourceCodeDirectories, this.compiledCodeDirectories);
+ }
+
+ /*
+ * Validators
+ */
+ private void validateState() {
+ if (this.resultOutputStrategy == null) {
+ throw new IllegalStateException("Failed to build: the resultOutputStrategy has not been set");
+ }
+ if (this.lineCoverageFiles.isEmpty()) {
+ throw new IllegalStateException("Failed to build: no lineCoverageFiles have been set");
+ }
+ if (this.mutationResultsFiles.isEmpty()) {
+ throw new IllegalStateException("Failed to build: no mutationResultsFiles have been set");
+ }
+ if (this.sourceCodeDirectories.isEmpty()) {
+ throw new IllegalStateException("Failed to build: no sourceCodeDirectories have been set");
+ }
+ if (this.compiledCodeDirectories.isEmpty()) {
+ throw new IllegalStateException("Failed to build: no compiledCodeDirectories have been set");
+ }
+ }
+
+ private void validateFile(final File file) {
+ if (file == null) {
+ throw new IllegalArgumentException("file is null");
+ }
+ if (!file.exists() || !file.isFile()) {
+ throw new IllegalArgumentException(file.getAbsolutePath() + " does not exist or is not a file");
+ }
+ }
+
+ private void validateDirectory(final File directory) {
+ if (directory == null) {
+ throw new IllegalArgumentException("directory is null");
+ }
+ if (!directory.exists() || !directory.isDirectory()) {
+ throw new IllegalArgumentException(directory.getAbsolutePath() + " does not exist or is not a directory");
+ }
+ }
+ }
+}
diff --git a/pitest-aggregator/src/test/java/org/pitest/aggregate/BlockCoverageDataLoaderTest.java b/pitest-aggregator/src/test/java/org/pitest/aggregate/BlockCoverageDataLoaderTest.java
index 70a87ea2f..f0d4e63c5 100644
--- a/pitest-aggregator/src/test/java/org/pitest/aggregate/BlockCoverageDataLoaderTest.java
+++ b/pitest-aggregator/src/test/java/org/pitest/aggregate/BlockCoverageDataLoaderTest.java
@@ -1,41 +1,41 @@
-package org.pitest.aggregate;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.pitest.coverage.BlockCoverage;
-
-public class BlockCoverageDataLoaderTest {
-
- private BlockCoverageDataLoader underTest;
-
- @Before
- public void setup() throws Exception {
- final URL url = MutationResultDataLoaderTest.class.getResource("/full-data/linecoverage.xml");
- final File file = new File(url.toURI());
-
- this.underTest = new BlockCoverageDataLoader(Arrays.asList(file));
- }
-
- @Test
- public void testLoadData() throws Exception {
- final Collection results = this.underTest.loadData();
-
- assertNotNull(results);
- assertEquals(5, results.size());
- for (final BlockCoverage block : results) {
- assertNotNull(block.getTests());
- assertEquals(1, block.getTests().size());
-
- assertEquals("com.example.DividerTest.testDivide(com.example.DividerTest)", block.getTests().iterator().next());
- }
- }
-
-}
+package org.pitest.aggregate;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.pitest.coverage.BlockCoverage;
+
+public class BlockCoverageDataLoaderTest {
+
+ private BlockCoverageDataLoader underTest;
+
+ @Before
+ public void setup() throws Exception {
+ final URL url = MutationResultDataLoaderTest.class.getResource("/full-data/linecoverage.xml");
+ final File file = new File(url.toURI());
+
+ this.underTest = new BlockCoverageDataLoader(Arrays.asList(file));
+ }
+
+ @Test
+ public void testLoadData() throws Exception {
+ final Collection results = this.underTest.loadData();
+
+ assertNotNull(results);
+ assertEquals(5, results.size());
+ for (final BlockCoverage block : results) {
+ assertNotNull(block.getTests());
+ assertEquals(1, block.getTests().size());
+
+ assertEquals("com.example.DividerTest.testDivide(com.example.DividerTest)", block.getTests().iterator().next());
+ }
+ }
+
+}
diff --git a/pitest-aggregator/src/test/java/org/pitest/aggregate/CodeSourceAggregatorTest.java b/pitest-aggregator/src/test/java/org/pitest/aggregate/CodeSourceAggregatorTest.java
index d0fe4f308..7f1726ef6 100644
--- a/pitest-aggregator/src/test/java/org/pitest/aggregate/CodeSourceAggregatorTest.java
+++ b/pitest-aggregator/src/test/java/org/pitest/aggregate/CodeSourceAggregatorTest.java
@@ -1,38 +1,38 @@
-package org.pitest.aggregate;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.Arrays;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.pitest.classinfo.ClassName;
-import org.pitest.classpath.CodeSource;
-
-public class CodeSourceAggregatorTest {
-
- private CodeSourceAggregator underTest;
-
- @Before
- public void setup() throws Exception {
- final File testDir = new File(CodeSourceAggregatorTest.class.getResource("/").toURI());
- final File mainDir = new File(CodeSourceAggregatorTest.class.getResource("/org/pitest/aggregate/DataLoader.class").toURI()).getParentFile() // aggregate
- .getParentFile() // pitest
- .getParentFile() // org
- .getParentFile(); // classes
- this.underTest = new CodeSourceAggregator(Arrays.asList(testDir, mainDir));
- }
-
- @Test
- public void testCreateCodeSource() {
- final CodeSource source = this.underTest.createCodeSource();
- assertNotNull(source);
-
- assertTrue(source.fetchClass(ClassName.fromClass(CodeSourceAggregator.class)).isPresent());
- assertFalse(source.fetchClass(ClassName.fromString("com.doesnt.exist.Type")).isPresent());
- }
-
-}
+package org.pitest.aggregate;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.pitest.classinfo.ClassName;
+import org.pitest.classpath.CodeSource;
+
+public class CodeSourceAggregatorTest {
+
+ private CodeSourceAggregator underTest;
+
+ @Before
+ public void setup() throws Exception {
+ final File testDir = new File(CodeSourceAggregatorTest.class.getResource("/").toURI());
+ final File mainDir = new File(CodeSourceAggregatorTest.class.getResource("/org/pitest/aggregate/DataLoader.class").toURI()).getParentFile() // aggregate
+ .getParentFile() // pitest
+ .getParentFile() // org
+ .getParentFile(); // classes
+ this.underTest = new CodeSourceAggregator(Arrays.asList(testDir, mainDir));
+ }
+
+ @Test
+ public void testCreateCodeSource() {
+ final CodeSource source = this.underTest.createCodeSource();
+ assertNotNull(source);
+
+ assertTrue(source.fetchClass(ClassName.fromClass(CodeSourceAggregator.class)).isPresent());
+ assertFalse(source.fetchClass(ClassName.fromString("com.doesnt.exist.Type")).isPresent());
+ }
+
+}
diff --git a/pitest-aggregator/src/test/java/org/pitest/aggregate/DataLoaderTest.java b/pitest-aggregator/src/test/java/org/pitest/aggregate/DataLoaderTest.java
index 8ee10136e..4c7bcd8bd 100644
--- a/pitest-aggregator/src/test/java/org/pitest/aggregate/DataLoaderTest.java
+++ b/pitest-aggregator/src/test/java/org/pitest/aggregate/DataLoaderTest.java
@@ -1,53 +1,53 @@
-package org.pitest.aggregate;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.Map;
-
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-public class DataLoaderTest {
-
- @Test
- public void testLoadMutationSnippet() throws Exception {
- final Document doc = DataLoader.readDocument(DataLoaderTest.class.getResourceAsStream("/snippets/mutation.xml"));
- final Node node = doc.getFirstChild();
-
- final Map map = DataLoader.nodeMap(node);
-
- assertEquals(13, map.size());
- assertEquals("true", map.get("detected"));
- assertEquals("KILLED", map.get("status"));
- assertEquals("1", map.get("numberOfTestsRun"));
- assertEquals("OrderedWeightedValueSampler.java", map.get("sourceFile"));
- assertEquals("com.mycompany.OrderedWeightedValueSampler", map.get("mutatedClass"));
- assertEquals("", map.get("mutatedMethod"));
- assertEquals("(JLjava/util/function/Consumer;Ljava/util/function/BiFunction;I)V", map.get("methodDescription"));
- assertEquals("77", map.get("lineNumber"));
- assertEquals("org.pitest.mutationtest.engine.gregor.mutators.MathMutator", map.get("mutator"));
- assertEquals("61", map.get("index"));
- assertEquals(
- "com.mycompany.SmallScaleOrderedWeightedValueSamplerTest.shouldSucceedWithVariousGapTimestamps(com.mycompany.SmallScaleOrderedWeightedValueSamplerTest)",
- map.get("killingTest"));
- assertEquals("Replaced long multiplication with division", map.get("description"));
- assertEquals("27", map.get("block"));
- }
-
- @Test
- public void testLoadCoverageSnippet() throws Exception {
- final Document doc = DataLoader.readDocument(DataLoaderTest.class.getResourceAsStream("/snippets/linecoverage.xml"));
- final Node node = doc.getFirstChild();
-
- final Map map = DataLoader.nodeMap(node);
-
- assertEquals(4, map.size());
- assertEquals("com.example.DividerTest", map.get("classname"));
- assertEquals("testDivide()V", map.get("method"));
- assertEquals("0", map.get("number"));
- assertEquals(Arrays.asList("com.example.DividerTest.testDivide(com.example.DividerTest)"), map.get("tests"));
- }
-
-}
+package org.pitest.aggregate;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public class DataLoaderTest {
+
+ @Test
+ public void testLoadMutationSnippet() throws Exception {
+ final Document doc = DataLoader.readDocument(DataLoaderTest.class.getResourceAsStream("/snippets/mutation.xml"));
+ final Node node = doc.getFirstChild();
+
+ final Map map = DataLoader.nodeMap(node);
+
+ assertEquals(13, map.size());
+ assertEquals("true", map.get("detected"));
+ assertEquals("KILLED", map.get("status"));
+ assertEquals("1", map.get("numberOfTestsRun"));
+ assertEquals("OrderedWeightedValueSampler.java", map.get("sourceFile"));
+ assertEquals("com.mycompany.OrderedWeightedValueSampler", map.get("mutatedClass"));
+ assertEquals("", map.get("mutatedMethod"));
+ assertEquals("(JLjava/util/function/Consumer;Ljava/util/function/BiFunction;I)V", map.get("methodDescription"));
+ assertEquals("77", map.get("lineNumber"));
+ assertEquals("org.pitest.mutationtest.engine.gregor.mutators.MathMutator", map.get("mutator"));
+ assertEquals("61", map.get("index"));
+ assertEquals(
+ "com.mycompany.SmallScaleOrderedWeightedValueSamplerTest.shouldSucceedWithVariousGapTimestamps(com.mycompany.SmallScaleOrderedWeightedValueSamplerTest)",
+ map.get("killingTest"));
+ assertEquals("Replaced long multiplication with division", map.get("description"));
+ assertEquals("27", map.get("block"));
+ }
+
+ @Test
+ public void testLoadCoverageSnippet() throws Exception {
+ final Document doc = DataLoader.readDocument(DataLoaderTest.class.getResourceAsStream("/snippets/linecoverage.xml"));
+ final Node node = doc.getFirstChild();
+
+ final Map map = DataLoader.nodeMap(node);
+
+ assertEquals(4, map.size());
+ assertEquals("com.example.DividerTest", map.get("classname"));
+ assertEquals("testDivide()V", map.get("method"));
+ assertEquals("0", map.get("number"));
+ assertEquals(Arrays.asList("com.example.DividerTest.testDivide(com.example.DividerTest)"), map.get("tests"));
+ }
+
+}
diff --git a/pitest-aggregator/src/test/java/org/pitest/aggregate/MutationResultDataLoaderTest.java b/pitest-aggregator/src/test/java/org/pitest/aggregate/MutationResultDataLoaderTest.java
index 021b63c62..e9b6e74db 100644
--- a/pitest-aggregator/src/test/java/org/pitest/aggregate/MutationResultDataLoaderTest.java
+++ b/pitest-aggregator/src/test/java/org/pitest/aggregate/MutationResultDataLoaderTest.java
@@ -1,54 +1,54 @@
-package org.pitest.aggregate;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.pitest.mutationtest.DetectionStatus;
-import org.pitest.mutationtest.MutationResult;
-
-public class MutationResultDataLoaderTest {
-
- private MutationResultDataLoader underTest;
-
- @Before
- public void setup() throws Exception {
- final URL url = MutationResultDataLoaderTest.class.getResource("/full-data/mutations.xml");
- final File file = new File(url.toURI());
-
- this.underTest = new MutationResultDataLoader(Arrays.asList(file));
- }
-
- @Test
- public void testLoadData() throws Exception {
- final Collection results = this.underTest.loadData();
-
- assertNotNull(results);
- assertEquals(2, results.size());
-
- for (final MutationResult result : results) {
- if (result.getDetails().getFirstIndex() == 5) {
- assertEquals(38, result.getDetails().getBlock());
- assertEquals("com.mycompany.OrderedWeightedValueSampler", result.getDetails().getId().getClassName().asJavaName());
- assertEquals(202, result.getDetails().getLineNumber());
- assertFalse(result.getStatus().isDetected());
- assertEquals(DetectionStatus.NO_COVERAGE, result.getStatus());
- } else {
- assertEquals(27, result.getDetails().getBlock());
- assertEquals("com.mycompany.OrderedWeightedValueSampler", result.getDetails().getId().getClassName().asJavaName());
- assertEquals(77, result.getDetails().getLineNumber());
- assertTrue(result.getStatus().isDetected());
- assertEquals(DetectionStatus.KILLED, result.getStatus());
- }
- }
- }
-
-}
+package org.pitest.aggregate;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.pitest.mutationtest.DetectionStatus;
+import org.pitest.mutationtest.MutationResult;
+
+public class MutationResultDataLoaderTest {
+
+ private MutationResultDataLoader underTest;
+
+ @Before
+ public void setup() throws Exception {
+ final URL url = MutationResultDataLoaderTest.class.getResource("/full-data/mutations.xml");
+ final File file = new File(url.toURI());
+
+ this.underTest = new MutationResultDataLoader(Arrays.asList(file));
+ }
+
+ @Test
+ public void testLoadData() throws Exception {
+ final Collection results = this.underTest.loadData();
+
+ assertNotNull(results);
+ assertEquals(2, results.size());
+
+ for (final MutationResult result : results) {
+ if (result.getDetails().getFirstIndex() == 5) {
+ assertEquals(38, result.getDetails().getBlock());
+ assertEquals("com.mycompany.OrderedWeightedValueSampler", result.getDetails().getId().getClassName().asJavaName());
+ assertEquals(202, result.getDetails().getLineNumber());
+ assertFalse(result.getStatus().isDetected());
+ assertEquals(DetectionStatus.NO_COVERAGE, result.getStatus());
+ } else {
+ assertEquals(27, result.getDetails().getBlock());
+ assertEquals("com.mycompany.OrderedWeightedValueSampler", result.getDetails().getId().getClassName().asJavaName());
+ assertEquals(77, result.getDetails().getLineNumber());
+ assertTrue(result.getStatus().isDetected());
+ assertEquals(DetectionStatus.KILLED, result.getStatus());
+ }
+ }
+ }
+
+}
diff --git a/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java b/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java
index aaf186e1a..a4c40a379 100644
--- a/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java
+++ b/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java
@@ -1,195 +1,195 @@
-package org.pitest.aggregate;
-
-import static org.junit.Assert.assertNotNull;
-import static org.pitest.aggregate.TestInvocationHelper.getCompiledDirectory;
-import static org.pitest.aggregate.TestInvocationHelper.getCoverageFile;
-import static org.pitest.aggregate.TestInvocationHelper.getMutationFile;
-import static org.pitest.aggregate.TestInvocationHelper.getResultOutputStrategy;
-import static org.pitest.aggregate.TestInvocationHelper.getSourceDirectory;
-import static org.pitest.aggregate.TestInvocationHelper.getTestCompiledDirectory;
-import static org.pitest.aggregate.TestInvocationHelper.getTestSourceDirectory;
-
-import java.io.File;
-import java.util.Arrays;
-
-import org.hamcrest.Matchers;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-public class ReportAggregatorBuilderTest {
-
- private static final String NOT_A_FILE = "does not exist or is not a file";
- private static final String NOT_A_DIR = "does not exist or is not a directory";
- private static final String IS_NULL = "is null";
- @Rule
- public ExpectedException expected = ExpectedException.none();
-
- @Test
- public void testLineCoverageFiles_withNull() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(IS_NULL));
-
- ReportAggregator.builder().lineCoverageFiles(Arrays.asList(getCoverageFile(), null, getCoverageFile()));
- }
-
- @Test
- public void testLineCoverageFiles_withFake() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
-
- ReportAggregator.builder().lineCoverageFiles(Arrays.asList(new File("doesnotexist.xml")));
- }
-
- @Test
- public void testLineCoverageFiles_withDir() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
-
- ReportAggregator.builder().lineCoverageFiles(Arrays.asList(getSourceDirectory()));
- }
-
- @Test
- public void testMutationResultsFiles_withNull() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(IS_NULL));
-
- ReportAggregator.builder().mutationResultsFiles(Arrays.asList(getMutationFile(), null, getMutationFile()));
- }
-
- @Test
- public void testMutationResultsFiles_withFake() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
-
- ReportAggregator.builder().mutationResultsFiles(Arrays.asList(new File("doesnotexist.xml")));
- }
-
- @Test
- public void testMutationResultsFiles_withDir() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
-
- ReportAggregator.builder().mutationResultsFiles(Arrays.asList(getTestSourceDirectory()));
- }
-
- @Test
- public void testSourceCodeDirectories_withNull() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(IS_NULL));
-
- ReportAggregator.builder().sourceCodeDirectories(Arrays.asList(getSourceDirectory(), null, getTestSourceDirectory()));
- }
-
- @Test
- public void testSourceCodeDirectories_withFake() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
-
- ReportAggregator.builder().sourceCodeDirectories(Arrays.asList(new File("fakedirectory")));
- }
-
- @Test
- public void testSourceCodeDirectories_withFile() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
-
- ReportAggregator.builder().sourceCodeDirectories(Arrays.asList(getCoverageFile()));
- }
-
- @Test
- public void testCompiledCodeDirectories_withNull() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(IS_NULL));
-
- ReportAggregator.builder().compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), null, getTestCompiledDirectory()));
- }
-
- @Test
- public void testCompiledCodeDirectories_withFake() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
-
- ReportAggregator.builder().compiledCodeDirectories(Arrays.asList(new File("fakedirectory")));
- }
-
- @Test
- public void testCompiledCodeDirectories_withFile() {
- this.expected.expect(IllegalArgumentException.class);
- this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
-
- ReportAggregator.builder().compiledCodeDirectories(Arrays.asList(getMutationFile()));
- }
-
- @Test
- public void testBuild() {
- assertNotNull(ReportAggregator.builder() // create builder
- .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
- .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
- .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
- .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
- .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
- .build());
- }
-
- @Test
- public void testBuild_missingOutputStrategy() {
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage(Matchers.containsString("resultOutputStrategy"));
- ReportAggregator.builder() // create builder
- .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
- .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
- .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
- .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
- .build();
- }
-
- @Test
- public void testBuild_missingCoverageFiles() {
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage(Matchers.containsString("lineCoverageFiles"));
- ReportAggregator.builder() // create builder
- .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
- .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
- .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
- .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
- .build();
- }
-
- @Test
- public void testBuild_missingMutationResultsFiles() {
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage(Matchers.containsString("mutationResultsFiles"));
- ReportAggregator.builder() // create builder
- .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
- .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
- .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
- .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
- .build();
- }
-
- @Test
- public void testBuild_missingCompiledCodeDirectories() {
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage(Matchers.containsString("compiledCodeDirectories"));
- ReportAggregator.builder() // create builder
- .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
- .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
- .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
- .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
- .build();
- }
-
- @Test
- public void testBuild_missingSourceCodeDirectories() {
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage(Matchers.containsString("sourceCodeDirectories"));
- ReportAggregator.builder() // create builder
- .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
- .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
- .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
- .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
- .build();
- }
-
-}
+package org.pitest.aggregate;
+
+import static org.junit.Assert.assertNotNull;
+import static org.pitest.aggregate.TestInvocationHelper.getCompiledDirectory;
+import static org.pitest.aggregate.TestInvocationHelper.getCoverageFile;
+import static org.pitest.aggregate.TestInvocationHelper.getMutationFile;
+import static org.pitest.aggregate.TestInvocationHelper.getResultOutputStrategy;
+import static org.pitest.aggregate.TestInvocationHelper.getSourceDirectory;
+import static org.pitest.aggregate.TestInvocationHelper.getTestCompiledDirectory;
+import static org.pitest.aggregate.TestInvocationHelper.getTestSourceDirectory;
+
+import java.io.File;
+import java.util.Arrays;
+
+import org.hamcrest.Matchers;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class ReportAggregatorBuilderTest {
+
+ private static final String NOT_A_FILE = "does not exist or is not a file";
+ private static final String NOT_A_DIR = "does not exist or is not a directory";
+ private static final String IS_NULL = "is null";
+ @Rule
+ public ExpectedException expected = ExpectedException.none();
+
+ @Test
+ public void testLineCoverageFiles_withNull() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(IS_NULL));
+
+ ReportAggregator.builder().lineCoverageFiles(Arrays.asList(getCoverageFile(), null, getCoverageFile()));
+ }
+
+ @Test
+ public void testLineCoverageFiles_withFake() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
+
+ ReportAggregator.builder().lineCoverageFiles(Arrays.asList(new File("doesnotexist.xml")));
+ }
+
+ @Test
+ public void testLineCoverageFiles_withDir() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
+
+ ReportAggregator.builder().lineCoverageFiles(Arrays.asList(getSourceDirectory()));
+ }
+
+ @Test
+ public void testMutationResultsFiles_withNull() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(IS_NULL));
+
+ ReportAggregator.builder().mutationResultsFiles(Arrays.asList(getMutationFile(), null, getMutationFile()));
+ }
+
+ @Test
+ public void testMutationResultsFiles_withFake() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
+
+ ReportAggregator.builder().mutationResultsFiles(Arrays.asList(new File("doesnotexist.xml")));
+ }
+
+ @Test
+ public void testMutationResultsFiles_withDir() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_FILE));
+
+ ReportAggregator.builder().mutationResultsFiles(Arrays.asList(getTestSourceDirectory()));
+ }
+
+ @Test
+ public void testSourceCodeDirectories_withNull() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(IS_NULL));
+
+ ReportAggregator.builder().sourceCodeDirectories(Arrays.asList(getSourceDirectory(), null, getTestSourceDirectory()));
+ }
+
+ @Test
+ public void testSourceCodeDirectories_withFake() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
+
+ ReportAggregator.builder().sourceCodeDirectories(Arrays.asList(new File("fakedirectory")));
+ }
+
+ @Test
+ public void testSourceCodeDirectories_withFile() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
+
+ ReportAggregator.builder().sourceCodeDirectories(Arrays.asList(getCoverageFile()));
+ }
+
+ @Test
+ public void testCompiledCodeDirectories_withNull() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(IS_NULL));
+
+ ReportAggregator.builder().compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), null, getTestCompiledDirectory()));
+ }
+
+ @Test
+ public void testCompiledCodeDirectories_withFake() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
+
+ ReportAggregator.builder().compiledCodeDirectories(Arrays.asList(new File("fakedirectory")));
+ }
+
+ @Test
+ public void testCompiledCodeDirectories_withFile() {
+ this.expected.expect(IllegalArgumentException.class);
+ this.expected.expectMessage(Matchers.containsString(NOT_A_DIR));
+
+ ReportAggregator.builder().compiledCodeDirectories(Arrays.asList(getMutationFile()));
+ }
+
+ @Test
+ public void testBuild() {
+ assertNotNull(ReportAggregator.builder() // create builder
+ .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
+ .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
+ .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
+ .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
+ .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
+ .build());
+ }
+
+ @Test
+ public void testBuild_missingOutputStrategy() {
+ this.expected.expect(IllegalStateException.class);
+ this.expected.expectMessage(Matchers.containsString("resultOutputStrategy"));
+ ReportAggregator.builder() // create builder
+ .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
+ .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
+ .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
+ .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
+ .build();
+ }
+
+ @Test
+ public void testBuild_missingCoverageFiles() {
+ this.expected.expect(IllegalStateException.class);
+ this.expected.expectMessage(Matchers.containsString("lineCoverageFiles"));
+ ReportAggregator.builder() // create builder
+ .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
+ .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
+ .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
+ .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
+ .build();
+ }
+
+ @Test
+ public void testBuild_missingMutationResultsFiles() {
+ this.expected.expect(IllegalStateException.class);
+ this.expected.expectMessage(Matchers.containsString("mutationResultsFiles"));
+ ReportAggregator.builder() // create builder
+ .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
+ .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
+ .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
+ .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
+ .build();
+ }
+
+ @Test
+ public void testBuild_missingCompiledCodeDirectories() {
+ this.expected.expect(IllegalStateException.class);
+ this.expected.expectMessage(Matchers.containsString("compiledCodeDirectories"));
+ ReportAggregator.builder() // create builder
+ .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
+ .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
+ .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
+ .sourceCodeDirectories(Arrays.asList(getSourceDirectory(), getTestSourceDirectory())) // sourceCodeDirectories
+ .build();
+ }
+
+ @Test
+ public void testBuild_missingSourceCodeDirectories() {
+ this.expected.expect(IllegalStateException.class);
+ this.expected.expectMessage(Matchers.containsString("sourceCodeDirectories"));
+ ReportAggregator.builder() // create builder
+ .resultOutputStrategy(getResultOutputStrategy()) // resultOutputStrategy
+ .lineCoverageFiles(Arrays.asList(getCoverageFile())) // lineCoverageFiles
+ .mutationResultsFiles(Arrays.asList(getMutationFile())) // mutationResultsFiles
+ .compiledCodeDirectories(Arrays.asList(getCompiledDirectory(), getTestCompiledDirectory())) // compiledCodeDirectories
+ .build();
+ }
+
+}
diff --git a/pitest-aggregator/src/test/java/org/pitest/aggregate/TestInvocationHelper.java b/pitest-aggregator/src/test/java/org/pitest/aggregate/TestInvocationHelper.java
index e2cc06256..4952ec89e 100644
--- a/pitest-aggregator/src/test/java/org/pitest/aggregate/TestInvocationHelper.java
+++ b/pitest-aggregator/src/test/java/org/pitest/aggregate/TestInvocationHelper.java
@@ -1,75 +1,75 @@
-package org.pitest.aggregate;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-
-import org.pitest.util.ResultOutputStrategy;
-import org.pitest.util.Unchecked;
-
-public class TestInvocationHelper {
-
- public static ResultOutputStrategy getResultOutputStrategy() {
- return sourceFile -> new Writer() {
-
- @Override
- public void write(final char[] cbuf, final int off, final int len) throws IOException {
- // ignore
- }
-
- @Override
- public void flush() throws IOException {
- // ignore
- }
-
- @Override
- public void close() throws IOException {
- // ignore
- }
- };
- }
-
- public static File getMutationFile() {
- try {
- return new File(ReportAggregatorBuilderTest.class.getResource("/full-data/mutations.xml").toURI());
- } catch (final Exception e) {
- throw Unchecked.translateCheckedException(e);
- }
- }
-
- public static File getCoverageFile() {
- try {
- return new File(ReportAggregatorBuilderTest.class.getResource("/full-data/linecoverage.xml").toURI());
- } catch (final Exception e) {
- throw Unchecked.translateCheckedException(e);
- }
- }
-
- public static File getSourceDirectory() {
- return new File("src" + File.separator + "main" + File.separator + "java");
- }
-
- public static File getTestSourceDirectory() {
- return new File("src" + File.separator + "test" + File.separator + "java");
- }
-
- public static File getCompiledDirectory() {
- try {
- return new File(ReportAggregatorBuilderTest.class.getResource("/org/pitest/aggregate/DataLoader.class").toURI()).getParentFile() // aggregate
- .getParentFile() // pitest
- .getParentFile() // org
- .getParentFile(); // classes
- } catch (final Exception e) {
- throw Unchecked.translateCheckedException(e);
- }
- }
-
- public static File getTestCompiledDirectory() {
- try {
- return new File(ReportAggregatorBuilderTest.class.getResource("/").toURI());
- } catch (final Exception e) {
- throw Unchecked.translateCheckedException(e);
- }
- }
-
-}
+package org.pitest.aggregate;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+
+import org.pitest.util.ResultOutputStrategy;
+import org.pitest.util.Unchecked;
+
+public class TestInvocationHelper {
+
+ public static ResultOutputStrategy getResultOutputStrategy() {
+ return sourceFile -> new Writer() {
+
+ @Override
+ public void write(final char[] cbuf, final int off, final int len) throws IOException {
+ // ignore
+ }
+
+ @Override
+ public void flush() throws IOException {
+ // ignore
+ }
+
+ @Override
+ public void close() throws IOException {
+ // ignore
+ }
+ };
+ }
+
+ public static File getMutationFile() {
+ try {
+ return new File(ReportAggregatorBuilderTest.class.getResource("/full-data/mutations.xml").toURI());
+ } catch (final Exception e) {
+ throw Unchecked.translateCheckedException(e);
+ }
+ }
+
+ public static File getCoverageFile() {
+ try {
+ return new File(ReportAggregatorBuilderTest.class.getResource("/full-data/linecoverage.xml").toURI());
+ } catch (final Exception e) {
+ throw Unchecked.translateCheckedException(e);
+ }
+ }
+
+ public static File getSourceDirectory() {
+ return new File("src" + File.separator + "main" + File.separator + "java");
+ }
+
+ public static File getTestSourceDirectory() {
+ return new File("src" + File.separator + "test" + File.separator + "java");
+ }
+
+ public static File getCompiledDirectory() {
+ try {
+ return new File(ReportAggregatorBuilderTest.class.getResource("/org/pitest/aggregate/DataLoader.class").toURI()).getParentFile() // aggregate
+ .getParentFile() // pitest
+ .getParentFile() // org
+ .getParentFile(); // classes
+ } catch (final Exception e) {
+ throw Unchecked.translateCheckedException(e);
+ }
+ }
+
+ public static File getTestCompiledDirectory() {
+ try {
+ return new File(ReportAggregatorBuilderTest.class.getResource("/").toURI());
+ } catch (final Exception e) {
+ throw Unchecked.translateCheckedException(e);
+ }
+ }
+
+}
diff --git a/pitest-aggregator/src/test/resources/full-data/linecoverage.xml b/pitest-aggregator/src/test/resources/full-data/linecoverage.xml
index 3100c0721..db8fe5b17 100644
--- a/pitest-aggregator/src/test/resources/full-data/linecoverage.xml
+++ b/pitest-aggregator/src/test/resources/full-data/linecoverage.xml
@@ -1,28 +1,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pitest-aggregator/src/test/resources/full-data/mutations.xml b/pitest-aggregator/src/test/resources/full-data/mutations.xml
index 6e16aaef0..f90137254 100644
--- a/pitest-aggregator/src/test/resources/full-data/mutations.xml
+++ b/pitest-aggregator/src/test/resources/full-data/mutations.xml
@@ -1,27 +1,27 @@
-
-
-
- OrderedWeightedValueSampler.java
- com.mycompany.OrderedWeightedValueSampler
- <init>
- (JLjava/util/function/Consumer;Ljava/util/function/BiFunction;I)V
- 77
- org.pitest.mutationtest.engine.gregor.mutators.MathMutator
- 61
- com.mycompany.SmallScaleOrderedWeightedValueSamplerTest.shouldSucceedWithVariousGapTimestamps(com.mycompany.SmallScaleOrderedWeightedValueSamplerTest)
- Replaced long multiplication with division
- 27
-
-
- OrderedWeightedValueSampler.java
- com.mycompany.OrderedWeightedValueSampler
- close
- ()I
- 202
- org.pitest.mutationtest.engine.gregor.mutators.ReturnValsMutator
- 5
-
- replaced return of integer sized value with (x == 0 ? 1 : 0)
- 38
-
+
+
+
+ OrderedWeightedValueSampler.java
+ com.mycompany.OrderedWeightedValueSampler
+ <init>
+ (JLjava/util/function/Consumer;Ljava/util/function/BiFunction;I)V
+ 77
+ org.pitest.mutationtest.engine.gregor.mutators.MathMutator
+ 61
+ com.mycompany.SmallScaleOrderedWeightedValueSamplerTest.shouldSucceedWithVariousGapTimestamps(com.mycompany.SmallScaleOrderedWeightedValueSamplerTest)
+ Replaced long multiplication with division
+ 27
+
+
+ OrderedWeightedValueSampler.java
+ com.mycompany.OrderedWeightedValueSampler
+ close
+ ()I
+ 202
+ org.pitest.mutationtest.engine.gregor.mutators.ReturnValsMutator
+ 5
+
+ replaced return of integer sized value with (x == 0 ? 1 : 0)
+ 38
+
\ No newline at end of file
diff --git a/pitest-aggregator/src/test/resources/snippets/linecoverage.xml b/pitest-aggregator/src/test/resources/snippets/linecoverage.xml
index 35b203288..39c12a716 100644
--- a/pitest-aggregator/src/test/resources/snippets/linecoverage.xml
+++ b/pitest-aggregator/src/test/resources/snippets/linecoverage.xml
@@ -1,5 +1,5 @@
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/pitest-aggregator/src/test/resources/snippets/mutation.xml b/pitest-aggregator/src/test/resources/snippets/mutation.xml
index 48413a089..75d015b5d 100644
--- a/pitest-aggregator/src/test/resources/snippets/mutation.xml
+++ b/pitest-aggregator/src/test/resources/snippets/mutation.xml
@@ -1,12 +1,12 @@
-
- OrderedWeightedValueSampler.java
- com.mycompany.OrderedWeightedValueSampler
- <init>
- (JLjava/util/function/Consumer;Ljava/util/function/BiFunction;I)V
- 77
- org.pitest.mutationtest.engine.gregor.mutators.MathMutator
- 61
- com.mycompany.SmallScaleOrderedWeightedValueSamplerTest.shouldSucceedWithVariousGapTimestamps(com.mycompany.SmallScaleOrderedWeightedValueSamplerTest)
- Replaced long multiplication with division
- 27
+
+ OrderedWeightedValueSampler.java
+ com.mycompany.OrderedWeightedValueSampler
+ <init>
+ (JLjava/util/function/Consumer;Ljava/util/function/BiFunction;I)V
+ 77
+ org.pitest.mutationtest.engine.gregor.mutators.MathMutator
+ 61
+ com.mycompany.SmallScaleOrderedWeightedValueSamplerTest.shouldSucceedWithVariousGapTimestamps(com.mycompany.SmallScaleOrderedWeightedValueSamplerTest)
+ Replaced long multiplication with division
+ 27
\ No newline at end of file
diff --git a/pitest-ant/pom.xml b/pitest-ant/pom.xml
index dbaf4e853..da6b272c5 100644
--- a/pitest-ant/pom.xml
+++ b/pitest-ant/pom.xml
@@ -1,84 +1,84 @@
-
-
- 4.0.0
-
- pitest-parent
- org.pitest
- 1.4.0-SNAPSHOT
-
- pitest-ant
- pitest-ant
- http://pitest.org
- Pitest Ant task.
-
-
-
- org.pitest
- pitest-command-line
- ${project.version}
-
-
-
- org.apache.ant
- ant
- ${ant.version}
- provided
-
-
-
-
- xmlunit
- xmlunit
- 1.6
- jar
- test
-
-
- org.apache.ant
- ant-testutil
- ${ant.version}
- jar
- test
-
-
- org.apache.maven
- maven-ant-tasks
- 2.1.3
- jar
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
-
-
-
- org.pitest:pitest-command-line
-
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ pitest-parent
+ org.pitest
+ 1.4.0-SNAPSHOT
+
+ pitest-ant
+ pitest-ant
+ http://pitest.org
+ Pitest Ant task.
+
+
+
+ org.pitest
+ pitest-command-line
+ ${project.version}
+
+
+
+ org.apache.ant
+ ant
+ ${ant.version}
+ provided
+
+
+
+
+ xmlunit
+ xmlunit
+ 1.6
+ jar
+ test
+
+
+ org.apache.ant
+ ant-testutil
+ ${ant.version}
+ jar
+ test
+
+
+ org.apache.maven
+ maven-ant-tasks
+ 2.1.3
+ jar
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+ org.pitest:pitest-command-line
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pitest-ant/src/test/java/com/example/PartCovered.java b/pitest-ant/src/test/java/com/example/PartCovered.java
index 5026e7b0f..e0234011c 100644
--- a/pitest-ant/src/test/java/com/example/PartCovered.java
+++ b/pitest-ant/src/test/java/com/example/PartCovered.java
@@ -1,17 +1,17 @@
-package com.example;
-
-public class PartCovered {
-
- public int returnsOneProperlytestedByTest() {
- return 1;
- }
-
- public int returnsTwoNotCoveredByTest() {
- return 2;
- }
-
- public int returnsThreeCoveredButNotTestedByTest() {
- return 3;
- }
-
-}
+package com.example;
+
+public class PartCovered {
+
+ public int returnsOneProperlytestedByTest() {
+ return 1;
+ }
+
+ public int returnsTwoNotCoveredByTest() {
+ return 2;
+ }
+
+ public int returnsThreeCoveredButNotTestedByTest() {
+ return 3;
+ }
+
+}
diff --git a/pitest-ant/src/test/java/com/example/PartCoveredTest.java b/pitest-ant/src/test/java/com/example/PartCoveredTest.java
index e78ea0374..2419efe77 100644
--- a/pitest-ant/src/test/java/com/example/PartCoveredTest.java
+++ b/pitest-ant/src/test/java/com/example/PartCoveredTest.java
@@ -1,27 +1,27 @@
-package com.example;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class PartCoveredTest {
-
- private PartCovered testee;
-
- @Before
- public void setUp() {
- this.testee = new PartCovered();
- }
-
- @Test
- public void fullyTestReturnsOne() {
- assertEquals(1, this.testee.returnsOneProperlytestedByTest());
- }
-
- @Test
- public void coverButDoNotTestReturnsThree() {
- this.testee.returnsThreeCoveredButNotTestedByTest();
- }
-
-}
+package com.example;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class PartCoveredTest {
+
+ private PartCovered testee;
+
+ @Before
+ public void setUp() {
+ this.testee = new PartCovered();
+ }
+
+ @Test
+ public void fullyTestReturnsOne() {
+ assertEquals(1, this.testee.returnsOneProperlytestedByTest());
+ }
+
+ @Test
+ public void coverButDoNotTestReturnsThree() {
+ this.testee.returnsThreeCoveredButNotTestedByTest();
+ }
+
+}
diff --git a/pitest-build-config/pom.xml b/pitest-build-config/pom.xml
index 0167397b1..c09eff4e0 100644
--- a/pitest-build-config/pom.xml
+++ b/pitest-build-config/pom.xml
@@ -1,11 +1,11 @@
-
- 4.0.0
- pitest-build-config
- Build Config
-
- pitest-parent
- org.pitest
- 1.4.0-SNAPSHOT
-
-
-
+
+ 4.0.0
+ pitest-build-config
+ Build Config
+
+ pitest-parent
+ org.pitest
+ 1.4.0-SNAPSHOT
+
+
+
diff --git a/pitest-command-line/pom.xml b/pitest-command-line/pom.xml
index 5d190b601..b59e8eaf7 100644
--- a/pitest-command-line/pom.xml
+++ b/pitest-command-line/pom.xml
@@ -1,84 +1,84 @@
-
-
-
- 4.0.0
-
- pitest-parent
- org.pitest
- 1.4.0-SNAPSHOT
-
- pitest-command-line
- pitest-command-line
- http://pitest.org
- Pitest command line tool.
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- org.pitest.mutationtest.commandline.MutationCoverageReport
- true
-
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- net.sf.jopt-simple:*
- org.pitest:pitest-html-report
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.pitest
- pitest-entry
- ${project.version}
-
-
- org.pitest
- pitest-html-report
- ${project.version}
-
-
- net.sf.jopt-simple
- jopt-simple
- 4.9
-
-
-
-
-
-
+
+
+
+ 4.0.0
+
+ pitest-parent
+ org.pitest
+ 1.4.0-SNAPSHOT
+
+ pitest-command-line
+ pitest-command-line
+ http://pitest.org
+ Pitest command line tool.
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ org.pitest.mutationtest.commandline.MutationCoverageReport
+ true
+
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+ package
+
+ shade
+
+
+
+
+ net.sf.jopt-simple:*
+ org.pitest:pitest-html-report
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.pitest
+ pitest-entry
+ ${project.version}
+
+
+ org.pitest
+ pitest-html-report
+ ${project.version}
+
+
+ net.sf.jopt-simple
+ jopt-simple
+ 4.9
+
+
+
+
+
+
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 1b91d45c1..890edd602 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
@@ -1,96 +1,96 @@
-/*
- * 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.
- */
-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;
-import org.pitest.mutationtest.statistics.MutationStatistics;
-import org.pitest.mutationtest.tooling.AnalysisResult;
-import org.pitest.mutationtest.tooling.CombinedStatistics;
-import org.pitest.mutationtest.tooling.EntryPoint;
-import org.pitest.util.Unchecked;
-
-/**
- * Entry point for command line interface
- */
-public class MutationCoverageReport {
-
- public static void main(final String[] args) {
-
- final PluginServices plugins = PluginServices.makeForContextLoader();
- final OptionsParser parser = new OptionsParser(new PluginFilter(plugins));
- final ParseResult pr = parser.parse(args);
-
- if (!pr.isOk()) {
- parser.printHelp();
- System.out.println(">>>> " + pr.getErrorMessage().get());
- } else {
- final ReportOptions data = pr.getOptions();
-
- final CombinedStatistics stats = runReport(data, plugins);
-
- throwErrorIfScoreBelowCoverageThreshold(stats.getCoverageSummary(),
- data.getCoverageThreshold());
- throwErrorIfScoreBelowMutationThreshold(stats.getMutationStatistics(),
- data.getMutationThreshold());
- throwErrorIfMoreThanMaxSuvivingMutants(stats.getMutationStatistics(), data.getMaximumAllowedSurvivors());
- }
-
- }
-
- 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);
- }
- }
-
- private static void throwErrorIfScoreBelowMutationThreshold(
- final MutationStatistics stats, final int threshold) {
- if ((threshold != 0) && (stats.getPercentageDetected() < threshold)) {
- throw new RuntimeException("Mutation score of "
- + stats.getPercentageDetected() + " is below threshold of "
- + threshold);
- }
- }
-
- private static void throwErrorIfMoreThanMaxSuvivingMutants(
- final MutationStatistics stats, final long threshold) {
- if ((threshold > 0)
- && (stats.getTotalSurvivingMutations() > threshold)) {
- throw new RuntimeException("Had "
- + stats.getTotalSurvivingMutations() + " surviving mutants, but only "
- + threshold + " survivors allowed");
- }
- }
-
- private static CombinedStatistics runReport(ReportOptions data,
- PluginServices plugins) {
-
- final EntryPoint e = new EntryPoint();
- final AnalysisResult result = e.execute(null, data, plugins,
- new HashMap());
- if (result.getError().isPresent()) {
- throw Unchecked.translateCheckedException(result.getError().get());
- }
- return result.getStatistics().get();
-
- }
-
-}
+/*
+ * 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.
+ */
+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;
+import org.pitest.mutationtest.statistics.MutationStatistics;
+import org.pitest.mutationtest.tooling.AnalysisResult;
+import org.pitest.mutationtest.tooling.CombinedStatistics;
+import org.pitest.mutationtest.tooling.EntryPoint;
+import org.pitest.util.Unchecked;
+
+/**
+ * Entry point for command line interface
+ */
+public class MutationCoverageReport {
+
+ public static void main(final String[] args) {
+
+ final PluginServices plugins = PluginServices.makeForContextLoader();
+ final OptionsParser parser = new OptionsParser(new PluginFilter(plugins));
+ final ParseResult pr = parser.parse(args);
+
+ if (!pr.isOk()) {
+ parser.printHelp();
+ System.out.println(">>>> " + pr.getErrorMessage().get());
+ } else {
+ final ReportOptions data = pr.getOptions();
+
+ final CombinedStatistics stats = runReport(data, plugins);
+
+ throwErrorIfScoreBelowCoverageThreshold(stats.getCoverageSummary(),
+ data.getCoverageThreshold());
+ throwErrorIfScoreBelowMutationThreshold(stats.getMutationStatistics(),
+ data.getMutationThreshold());
+ throwErrorIfMoreThanMaxSuvivingMutants(stats.getMutationStatistics(), data.getMaximumAllowedSurvivors());
+ }
+
+ }
+
+ 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);
+ }
+ }
+
+ private static void throwErrorIfScoreBelowMutationThreshold(
+ final MutationStatistics stats, final int threshold) {
+ if ((threshold != 0) && (stats.getPercentageDetected() < threshold)) {
+ throw new RuntimeException("Mutation score of "
+ + stats.getPercentageDetected() + " is below threshold of "
+ + threshold);
+ }
+ }
+
+ private static void throwErrorIfMoreThanMaxSuvivingMutants(
+ final MutationStatistics stats, final long threshold) {
+ if ((threshold > 0)
+ && (stats.getTotalSurvivingMutations() > threshold)) {
+ throw new RuntimeException("Had "
+ + stats.getTotalSurvivingMutations() + " surviving mutants, but only "
+ + threshold + " survivors allowed");
+ }
+ }
+
+ private static CombinedStatistics runReport(ReportOptions data,
+ PluginServices plugins) {
+
+ final EntryPoint e = new EntryPoint();
+ final AnalysisResult result = e.execute(null, data, plugins,
+ new HashMap());
+ if (result.getError().isPresent()) {
+ throw Unchecked.translateCheckedException(result.getError().get());
+ }
+ return result.getStatistics().get();
+
+ }
+
+}
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 abbc1603d..7455cf923 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,475 +1,475 @@
-/*
- * 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.
- */
-package org.pitest.mutationtest.commandline;
-
-import static org.pitest.mutationtest.config.ConfigOption.AVOID_CALLS;
-import static org.pitest.mutationtest.config.ConfigOption.CHILD_JVM;
-import static org.pitest.mutationtest.config.ConfigOption.CLASSPATH;
-import static org.pitest.mutationtest.config.ConfigOption.CLASSPATH_FILE;
-import static org.pitest.mutationtest.config.ConfigOption.CODE_PATHS;
-import static org.pitest.mutationtest.config.ConfigOption.COVERAGE_THRESHOLD;
-import static org.pitest.mutationtest.config.ConfigOption.DEPENDENCY_DISTANCE;
-import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_CLASSES;
-import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_GROUPS;
-import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_METHOD;
-import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_TEST_CLASSES;
-import static org.pitest.mutationtest.config.ConfigOption.EXPORT_LINE_COVERAGE;
-import static org.pitest.mutationtest.config.ConfigOption.FAIL_WHEN_NOT_MUTATIONS;
-import static org.pitest.mutationtest.config.ConfigOption.FEATURES;
-import static org.pitest.mutationtest.config.ConfigOption.HISTORY_INPUT_LOCATION;
-import static org.pitest.mutationtest.config.ConfigOption.HISTORY_OUTPUT_LOCATION;
-import static org.pitest.mutationtest.config.ConfigOption.INCLUDED_GROUPS;
-import static org.pitest.mutationtest.config.ConfigOption.INCLUDED_TEST_METHODS;
-import static org.pitest.mutationtest.config.ConfigOption.INCLUDE_LAUNCH_CLASSPATH;
-import static org.pitest.mutationtest.config.ConfigOption.JVM_PATH;
-import static org.pitest.mutationtest.config.ConfigOption.MAX_MUTATIONS_PER_CLASS;
-import static org.pitest.mutationtest.config.ConfigOption.MAX_SURVIVING;
-import static org.pitest.mutationtest.config.ConfigOption.MUTATIONS;
-import static org.pitest.mutationtest.config.ConfigOption.MUTATION_ENGINE;
-import static org.pitest.mutationtest.config.ConfigOption.MUTATION_THRESHOLD;
-import static org.pitest.mutationtest.config.ConfigOption.MUTATION_UNIT_SIZE;
-import static org.pitest.mutationtest.config.ConfigOption.OUTPUT_FORMATS;
-import static org.pitest.mutationtest.config.ConfigOption.PLUGIN_CONFIGURATION;
-import static org.pitest.mutationtest.config.ConfigOption.REPORT_DIR;
-import static org.pitest.mutationtest.config.ConfigOption.SOURCE_DIR;
-import static org.pitest.mutationtest.config.ConfigOption.TARGET_CLASSES;
-import static org.pitest.mutationtest.config.ConfigOption.TEST_FILTER;
-import static org.pitest.mutationtest.config.ConfigOption.TEST_PLUGIN;
-import static org.pitest.mutationtest.config.ConfigOption.THREADS;
-import static org.pitest.mutationtest.config.ConfigOption.TIMEOUT_CONST;
-import static org.pitest.mutationtest.config.ConfigOption.TIMEOUT_FACTOR;
-import static org.pitest.mutationtest.config.ConfigOption.TIME_STAMPED_REPORTS;
-import static org.pitest.mutationtest.config.ConfigOption.USE_INLINED_CODE_DETECTION;
-import static org.pitest.mutationtest.config.ConfigOption.VERBOSE;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.function.Predicate;
-import java.util.logging.Logger;
-
-import org.pitest.classpath.ClassPath;
-import org.pitest.functional.FCollection;
-import org.pitest.mutationtest.config.ConfigOption;
-import org.pitest.mutationtest.config.ReportOptions;
-import org.pitest.testapi.TestGroupConfig;
-import org.pitest.util.Glob;
-import org.pitest.util.Log;
-import org.pitest.util.Unchecked;
-
-import joptsimple.ArgumentAcceptingOptionSpec;
-import joptsimple.OptionException;
-import joptsimple.OptionParser;
-import joptsimple.OptionSet;
-import joptsimple.OptionSpec;
-import joptsimple.OptionSpecBuilder;
-import joptsimple.util.KeyValuePair;
-
-public class OptionsParser {
-
- private final Predicate dependencyFilter;
-
- private static final Logger LOG = Log.getLogger();
-
- private final OptionParser parser;
- private final ArgumentAcceptingOptionSpec reportDirSpec;
- private final OptionSpec targetClassesSpec;
- private final OptionSpec targetTestsSpec;
- private final OptionSpec avoidCallsSpec;
- private final OptionSpec depth;
- private final OptionSpec threadsSpec;
- private final OptionSpec sourceDirSpec;
- private final OptionSpec historyOutputSpec;
- private final OptionSpec historyInputSpec;
- private final OptionSpec mutators;
- private final OptionSpec features;
- private final OptionSpec jvmArgs;
- private final OptionSpec timeoutFactorSpec;
- private final OptionSpec timeoutConstSpec;
- private final OptionSpec excludedMethodsSpec;
- private final ArgumentAcceptingOptionSpec verboseSpec;
- private final OptionSpec excludedClassesSpec;
- private final OptionSpec excludedTestClassesSpec;
- private final OptionSpec outputFormatSpec;
- private final OptionSpec additionalClassPathSpec;
- private final OptionSpec classPathFile;
- private final ArgumentAcceptingOptionSpec failWhenNoMutations;
- private final ArgumentAcceptingOptionSpec codePaths;
- private final OptionSpec excludedGroupsSpec;
- private final OptionSpec includedGroupsSpec;
- private final OptionSpec includedTestMethodsSpec;
- private final OptionSpec mutationUnitSizeSpec;
- private final ArgumentAcceptingOptionSpec timestampedReportsSpec;
- private final ArgumentAcceptingOptionSpec detectInlinedCode;
- private final ArgumentAcceptingOptionSpec mutationThreshHoldSpec;
- private final ArgumentAcceptingOptionSpec coverageThreshHoldSpec;
- private final ArgumentAcceptingOptionSpec maxSurvivingSpec;
- private final OptionSpec mutationEngine;
- private final ArgumentAcceptingOptionSpec exportLineCoverageSpec;
- private final OptionSpec javaExecutable;
- private final OptionSpec pluginPropertiesSpec;
- private final OptionSpec testPluginSpec;
-
- private final ArgumentAcceptingOptionSpec includeLaunchClasspathSpec;
-
- public OptionsParser(Predicate dependencyFilter) {
-
- this.dependencyFilter = dependencyFilter;
-
- this.parser = new OptionParser();
- this.parser.acceptsAll(Arrays.asList("h", "?"), "show help");
-
- this.testPluginSpec = parserAccepts(TEST_PLUGIN)
- .withRequiredArg()
- .ofType(String.class)
- .defaultsTo("junit")
- .describedAs("test plugin to use");
-
- 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();
-
- this.avoidCallsSpec = parserAccepts(AVOID_CALLS)
- .withRequiredArg()
- .ofType(String.class)
- .withValuesSeparatedBy(',')
- .describedAs(
- "comma separated list of packages to consider as untouchable logging calls");
-
- this.targetTestsSpec = parserAccepts(TEST_FILTER)
- .withRequiredArg()
- .ofType(String.class)
- .withValuesSeparatedBy(',')
- .describedAs(
- "comma separated list of filters to match against tests to run");
-
- this.depth = parserAccepts(DEPENDENCY_DISTANCE).withRequiredArg()
- .ofType(Integer.class)
- .defaultsTo(DEPENDENCY_DISTANCE.getDefault(Integer.class))
- .describedAs("maximum distance to look from test for covered classes");
-
- this.threadsSpec = parserAccepts(THREADS).withRequiredArg()
- .ofType(Integer.class).defaultsTo(THREADS.getDefault(Integer.class))
- .describedAs("number of threads to use for testing");
-
- parserAccepts(MAX_MUTATIONS_PER_CLASS)
- .withRequiredArg().ofType(Integer.class)
- .defaultsTo(MAX_MUTATIONS_PER_CLASS.getDefault(Integer.class))
- .describedAs("No longer supported. Use CLASSLIMIT(limit[42]) feature instead");
-
- this.sourceDirSpec = parserAccepts(SOURCE_DIR).withRequiredArg()
- .ofType(File.class).withValuesSeparatedBy(',')
- .describedAs("comma separated list of source directories").required();
-
- this.mutators = parserAccepts(MUTATIONS).withRequiredArg()
- .ofType(String.class).withValuesSeparatedBy(',')
- .describedAs("comma separated list of mutation operators");
-
- this.features = parserAccepts(FEATURES).withRequiredArg()
- .ofType(String.class).withValuesSeparatedBy(',')
- .describedAs("comma separated list of features to enable/disable.");
-
- this.jvmArgs = parserAccepts(CHILD_JVM).withRequiredArg()
- .withValuesSeparatedBy(',')
- .describedAs("comma separated list of child JVM args");
-
- this.detectInlinedCode = parserAccepts(USE_INLINED_CODE_DETECTION)
- .withOptionalArg()
- .ofType(Boolean.class)
- .defaultsTo(true)
- .describedAs(
- "whether or not to try and detect code inlined from finally blocks");
-
- this.timestampedReportsSpec = parserAccepts(TIME_STAMPED_REPORTS)
- .withOptionalArg().ofType(Boolean.class).defaultsTo(true)
- .describedAs("whether or not to generated timestamped directories");
-
- this.timeoutFactorSpec = parserAccepts(TIMEOUT_FACTOR).withOptionalArg()
- .ofType(Float.class)
- .describedAs("factor to apply to calculate maximum test duration")
- .defaultsTo(TIMEOUT_FACTOR.getDefault(Float.class));
-
- this.timeoutConstSpec = parserAccepts(TIMEOUT_CONST).withOptionalArg()
- .ofType(Long.class)
- .describedAs("constant to apply to calculate maximum test duration")
- .defaultsTo(TIMEOUT_CONST.getDefault(Long.class));
-
- this.excludedMethodsSpec = parserAccepts(EXCLUDED_METHOD)
- .withRequiredArg()
- .ofType(String.class)
- .withValuesSeparatedBy(',')
- .describedAs(
- "comma separated list of filters to match against methods to exclude from mutation analysis");
-
- this.excludedClassesSpec = parserAccepts(EXCLUDED_CLASSES)
- .withRequiredArg()
- .ofType(String.class)
- .withValuesSeparatedBy(',')
- .describedAs(
- "comma separated list of globs for classes to exclude when mutating");
-
- this.excludedTestClassesSpec = parserAccepts(EXCLUDED_TEST_CLASSES)
- .withRequiredArg()
- .ofType(String.class)
- .withValuesSeparatedBy(',')
- .describedAs(
- "comma separated list of globs of test classes to exclude");
-
- this.verboseSpec = parserAccepts(VERBOSE).withOptionalArg()
- .ofType(Boolean.class).defaultsTo(true)
- .describedAs("whether or not to generate verbose output");
-
- this.exportLineCoverageSpec = parserAccepts(EXPORT_LINE_COVERAGE)
- .withOptionalArg()
- .ofType(Boolean.class)
- .defaultsTo(true)
- .describedAs(
- "whether or not to dump per test line coverage data to disk");
-
- this.includeLaunchClasspathSpec = parserAccepts(INCLUDE_LAUNCH_CLASSPATH)
- .withOptionalArg().ofType(Boolean.class).defaultsTo(true)
- .describedAs("whether or not to analyse launch classpath");
-
- this.outputFormatSpec = parserAccepts(OUTPUT_FORMATS)
- .withRequiredArg()
- .ofType(String.class)
- .withValuesSeparatedBy(',')
- .describedAs(
- "comma separated list of listeners to receive mutation results")
- .defaultsTo("HTML");
-
- this.additionalClassPathSpec = parserAccepts(CLASSPATH).withRequiredArg()
- .ofType(String.class).withValuesSeparatedBy(',')
- .describedAs("coma separated list of additional classpath elements");
-
- this.classPathFile = this.parserAccepts(CLASSPATH_FILE).withRequiredArg()
- .ofType(File.class).describedAs("File with a list of additional classpath elements (one per line)");
-
- this.failWhenNoMutations = parserAccepts(FAIL_WHEN_NOT_MUTATIONS)
- .withOptionalArg().ofType(Boolean.class).defaultsTo(true)
- .describedAs("whether to throw error if no mutations found");
-
- this.codePaths = parserAccepts(CODE_PATHS)
- .withRequiredArg()
- .ofType(String.class)
- .withValuesSeparatedBy(',')
- .describedAs(
- "Globs identifying classpath roots containing mutable code");
-
- this.includedGroupsSpec = parserAccepts(INCLUDED_GROUPS).withRequiredArg()
- .ofType(String.class).withValuesSeparatedBy(',')
- .describedAs("TestNG groups/JUnit categories to include");
-
- this.includedTestMethodsSpec = parserAccepts(INCLUDED_TEST_METHODS).withRequiredArg()
- .ofType(String.class).withValuesSeparatedBy(',')
- .describedAs("Test methods that should be included for challenging the mutants");
-
- this.excludedGroupsSpec = parserAccepts(EXCLUDED_GROUPS).withRequiredArg()
- .ofType(String.class).withValuesSeparatedBy(',')
- .describedAs("TestNG groups/JUnit categories to include");
-
- this.mutationUnitSizeSpec = parserAccepts(MUTATION_UNIT_SIZE)
- .withRequiredArg()
- .ofType(Integer.class)
- .describedAs(
- "Maximum number of mutations to include within a single unit of analysis")
- .defaultsTo(MUTATION_UNIT_SIZE.getDefault(Integer.class));
-
- this.historyInputSpec = parserAccepts(HISTORY_INPUT_LOCATION)
- .withRequiredArg().ofType(File.class)
- .describedAs("File to read history from for incremental analysis");
-
- this.historyOutputSpec = parserAccepts(HISTORY_OUTPUT_LOCATION)
- .withRequiredArg().ofType(File.class)
- .describedAs("File to write history to for incremental analysis");
-
- this.mutationThreshHoldSpec = parserAccepts(MUTATION_THRESHOLD)
- .withRequiredArg().ofType(Integer.class)
- .describedAs("Mutation score below which to throw an error")
- .defaultsTo(MUTATION_THRESHOLD.getDefault(Integer.class));
-
- this.maxSurvivingSpec = parserAccepts(MAX_SURVIVING)
- .withRequiredArg().ofType(Integer.class)
- .describedAs("Maximum number of surviving mutants to allow without throwing an error")
- .defaultsTo(MAX_SURVIVING.getDefault(Integer.class));
-
- this.coverageThreshHoldSpec = parserAccepts(COVERAGE_THRESHOLD)
- .withRequiredArg().ofType(Integer.class)
- .describedAs("Line coverage below which to throw an error")
- .defaultsTo(COVERAGE_THRESHOLD.getDefault(Integer.class));
-
- this.mutationEngine = parserAccepts(MUTATION_ENGINE).withRequiredArg()
- .ofType(String.class).describedAs("mutation engine to use")
- .defaultsTo(MUTATION_ENGINE.getDefault(String.class));
-
- this.javaExecutable = parserAccepts(JVM_PATH).withRequiredArg()
- .ofType(String.class).describedAs("path to java executable");
-
- this.pluginPropertiesSpec = parserAccepts(PLUGIN_CONFIGURATION)
- .withRequiredArg().ofType(KeyValuePair.class)
- .describedAs("custom plugin properties");
-
- }
-
- private OptionSpecBuilder parserAccepts(final ConfigOption option) {
- return this.parser.accepts(option.getParamName());
- }
-
- public ParseResult parse(final String[] args) {
- final ReportOptions data = new ReportOptions();
- try {
- final OptionSet userArgs = this.parser.parse(args);
- return parseCommandLine(data, userArgs);
-
- } catch (final OptionException uoe) {
- return new ParseResult(data, uoe.getLocalizedMessage());
- }
- }
-
- /**
- * Creates a new ParseResult object using the command line arguments.
- *
- * @param data
- * the ReportOptions to populate.
- * @param userArgs
- * the OptionSet which contains the command line arguments.
- * @return a new ParseResult, correctly configured using the command line
- * arguments.
- */
- private ParseResult parseCommandLine(final ReportOptions data,
- final OptionSet userArgs) {
- data.setTestPlugin(userArgs.valueOf(this.testPluginSpec));
- data.setReportDir(userArgs.valueOf(this.reportDirSpec));
- data.setTargetClasses(this.targetClassesSpec.values(userArgs));
- data.setTargetTests(FCollection.map(this.targetTestsSpec.values(userArgs),
- Glob.toGlobPredicate()));
- data.setSourceDirs(this.sourceDirSpec.values(userArgs));
- data.setMutators(this.mutators.values(userArgs));
- data.setFeatures(this.features.values(userArgs));
- data.setDependencyAnalysisMaxDistance(this.depth.value(userArgs));
- data.addChildJVMArgs(this.jvmArgs.values(userArgs));
-
-
- data.setDetectInlinedCode(userArgs.has(this.detectInlinedCode)
- && userArgs.valueOf(this.detectInlinedCode));
-
- data.setIncludeLaunchClasspath(userArgs
- .valueOf(this.includeLaunchClasspathSpec));
-
- data.setShouldCreateTimestampedReports(userArgs
- .valueOf(this.timestampedReportsSpec));
- data.setNumberOfThreads(this.threadsSpec.value(userArgs));
- data.setTimeoutFactor(this.timeoutFactorSpec.value(userArgs));
- data.setTimeoutConstant(this.timeoutConstSpec.value(userArgs));
- data.setLoggingClasses(this.avoidCallsSpec.values(userArgs));
- data.setExcludedMethods(this.excludedMethodsSpec.values(userArgs));
- data.setExcludedClasses(this.excludedClassesSpec.values(userArgs));
- data.setExcludedTestClasses(FCollection.map(
- this.excludedTestClassesSpec.values(userArgs), Glob.toGlobPredicate()));
- data.setVerbose(userArgs.has(this.verboseSpec)
- && userArgs.valueOf(this.verboseSpec));
-
- data.addOutputFormats(this.outputFormatSpec.values(userArgs));
- data.setFailWhenNoMutations(this.failWhenNoMutations.value(userArgs));
- data.setCodePaths(this.codePaths.values(userArgs));
- data.setMutationUnitSize(this.mutationUnitSizeSpec.value(userArgs));
-
- data.setHistoryInputLocation(this.historyInputSpec.value(userArgs));
- data.setHistoryOutputLocation(this.historyOutputSpec.value(userArgs));
- data.setMutationThreshold(this.mutationThreshHoldSpec.value(userArgs));
- data.setMaximumAllowedSurvivors(this.maxSurvivingSpec.value(userArgs));
- data.setCoverageThreshold(this.coverageThreshHoldSpec.value(userArgs));
- data.setMutationEngine(this.mutationEngine.value(userArgs));
- data.setFreeFormProperties(listToProperties(this.pluginPropertiesSpec
- .values(userArgs)));
-
- data.setExportLineCoverage(userArgs.has(this.exportLineCoverageSpec)
- && userArgs.valueOf(this.exportLineCoverageSpec));
-
- setClassPath(userArgs, data);
-
- setTestGroups(userArgs, data);
-
- data.setIncludedTestMethods(this.includedTestMethodsSpec.values(userArgs));
- data.setJavaExecutable(this.javaExecutable.value(userArgs));
-
- if (userArgs.has("?")) {
- return new ParseResult(data, "See above for supported parameters.");
- } else {
- return new ParseResult(data, null);
- }
- }
-
- private void setClassPath(final OptionSet userArgs, final ReportOptions data) {
-
- final List elements = new ArrayList<>();
- if (data.isIncludeLaunchClasspath()) {
- elements.addAll(ClassPath.getClassPathElementsAsPaths());
- } else {
- elements.addAll(FCollection.filter(
- ClassPath.getClassPathElementsAsPaths(), this.dependencyFilter));
- }
- if (userArgs.has(this.classPathFile)) {
- try (BufferedReader classPathFileBR = new BufferedReader(new FileReader(userArgs.valueOf(this.classPathFile).getAbsoluteFile()))) {
- String element;
- while ((element = classPathFileBR.readLine()) != null) {
- elements.add(element);
- }
- } catch (final IOException ioe) {
- LOG.warning("Unable to read class path file:" + userArgs.valueOf(this.classPathFile).getAbsolutePath() + " - "
- + ioe.getMessage());
- }
- }
- elements.addAll(userArgs.valuesOf(this.additionalClassPathSpec));
- data.setClassPathElements(elements);
- }
-
- 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) {
- final Properties p = new Properties();
- for (final KeyValuePair kvp : kvps) {
- p.put(kvp.key, kvp.value);
- }
- return p;
- }
-
- public void printHelp() {
- try {
- this.parser.printHelpOn(System.out);
- } catch (final IOException ex) {
- throw Unchecked.translateCheckedException(ex);
- }
- }
-
-}
+/*
+ * 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.
+ */
+package org.pitest.mutationtest.commandline;
+
+import static org.pitest.mutationtest.config.ConfigOption.AVOID_CALLS;
+import static org.pitest.mutationtest.config.ConfigOption.CHILD_JVM;
+import static org.pitest.mutationtest.config.ConfigOption.CLASSPATH;
+import static org.pitest.mutationtest.config.ConfigOption.CLASSPATH_FILE;
+import static org.pitest.mutationtest.config.ConfigOption.CODE_PATHS;
+import static org.pitest.mutationtest.config.ConfigOption.COVERAGE_THRESHOLD;
+import static org.pitest.mutationtest.config.ConfigOption.DEPENDENCY_DISTANCE;
+import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_CLASSES;
+import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_GROUPS;
+import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_METHOD;
+import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_TEST_CLASSES;
+import static org.pitest.mutationtest.config.ConfigOption.EXPORT_LINE_COVERAGE;
+import static org.pitest.mutationtest.config.ConfigOption.FAIL_WHEN_NOT_MUTATIONS;
+import static org.pitest.mutationtest.config.ConfigOption.FEATURES;
+import static org.pitest.mutationtest.config.ConfigOption.HISTORY_INPUT_LOCATION;
+import static org.pitest.mutationtest.config.ConfigOption.HISTORY_OUTPUT_LOCATION;
+import static org.pitest.mutationtest.config.ConfigOption.INCLUDED_GROUPS;
+import static org.pitest.mutationtest.config.ConfigOption.INCLUDED_TEST_METHODS;
+import static org.pitest.mutationtest.config.ConfigOption.INCLUDE_LAUNCH_CLASSPATH;
+import static org.pitest.mutationtest.config.ConfigOption.JVM_PATH;
+import static org.pitest.mutationtest.config.ConfigOption.MAX_MUTATIONS_PER_CLASS;
+import static org.pitest.mutationtest.config.ConfigOption.MAX_SURVIVING;
+import static org.pitest.mutationtest.config.ConfigOption.MUTATIONS;
+import static org.pitest.mutationtest.config.ConfigOption.MUTATION_ENGINE;
+import static org.pitest.mutationtest.config.ConfigOption.MUTATION_THRESHOLD;
+import static org.pitest.mutationtest.config.ConfigOption.MUTATION_UNIT_SIZE;
+import static org.pitest.mutationtest.config.ConfigOption.OUTPUT_FORMATS;
+import static org.pitest.mutationtest.config.ConfigOption.PLUGIN_CONFIGURATION;
+import static org.pitest.mutationtest.config.ConfigOption.REPORT_DIR;
+import static org.pitest.mutationtest.config.ConfigOption.SOURCE_DIR;
+import static org.pitest.mutationtest.config.ConfigOption.TARGET_CLASSES;
+import static org.pitest.mutationtest.config.ConfigOption.TEST_FILTER;
+import static org.pitest.mutationtest.config.ConfigOption.TEST_PLUGIN;
+import static org.pitest.mutationtest.config.ConfigOption.THREADS;
+import static org.pitest.mutationtest.config.ConfigOption.TIMEOUT_CONST;
+import static org.pitest.mutationtest.config.ConfigOption.TIMEOUT_FACTOR;
+import static org.pitest.mutationtest.config.ConfigOption.TIME_STAMPED_REPORTS;
+import static org.pitest.mutationtest.config.ConfigOption.USE_INLINED_CODE_DETECTION;
+import static org.pitest.mutationtest.config.ConfigOption.VERBOSE;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+import java.util.function.Predicate;
+import java.util.logging.Logger;
+
+import org.pitest.classpath.ClassPath;
+import org.pitest.functional.FCollection;
+import org.pitest.mutationtest.config.ConfigOption;
+import org.pitest.mutationtest.config.ReportOptions;
+import org.pitest.testapi.TestGroupConfig;
+import org.pitest.util.Glob;
+import org.pitest.util.Log;
+import org.pitest.util.Unchecked;
+
+import joptsimple.ArgumentAcceptingOptionSpec;
+import joptsimple.OptionException;
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import joptsimple.OptionSpec;
+import joptsimple.OptionSpecBuilder;
+import joptsimple.util.KeyValuePair;
+
+public class OptionsParser {
+
+ private final Predicate dependencyFilter;
+
+ private static final Logger LOG = Log.getLogger();
+
+ private final OptionParser parser;
+ private final ArgumentAcceptingOptionSpec reportDirSpec;
+ private final OptionSpec targetClassesSpec;
+ private final OptionSpec targetTestsSpec;
+ private final OptionSpec avoidCallsSpec;
+ private final OptionSpec depth;
+ private final OptionSpec threadsSpec;
+ private final OptionSpec sourceDirSpec;
+ private final OptionSpec historyOutputSpec;
+ private final OptionSpec historyInputSpec;
+ private final OptionSpec mutators;
+ private final OptionSpec features;
+ private final OptionSpec jvmArgs;
+ private final OptionSpec timeoutFactorSpec;
+ private final OptionSpec timeoutConstSpec;
+ private final OptionSpec excludedMethodsSpec;
+ private final ArgumentAcceptingOptionSpec verboseSpec;
+ private final OptionSpec excludedClassesSpec;
+ private final OptionSpec excludedTestClassesSpec;
+ private final OptionSpec outputFormatSpec;
+ private final OptionSpec additionalClassPathSpec;
+ private final OptionSpec classPathFile;
+ private final ArgumentAcceptingOptionSpec failWhenNoMutations;
+ private final ArgumentAcceptingOptionSpec codePaths;
+ private final OptionSpec excludedGroupsSpec;
+ private final OptionSpec includedGroupsSpec;
+ private final OptionSpec includedTestMethodsSpec;
+ private final OptionSpec mutationUnitSizeSpec;
+ private final ArgumentAcceptingOptionSpec timestampedReportsSpec;
+ private final ArgumentAcceptingOptionSpec detectInlinedCode;
+ private final ArgumentAcceptingOptionSpec mutationThreshHoldSpec;
+ private final ArgumentAcceptingOptionSpec coverageThreshHoldSpec;
+ private final ArgumentAcceptingOptionSpec maxSurvivingSpec;
+ private final OptionSpec mutationEngine;
+ private final ArgumentAcceptingOptionSpec exportLineCoverageSpec;
+ private final OptionSpec javaExecutable;
+ private final OptionSpec pluginPropertiesSpec;
+ private final OptionSpec testPluginSpec;
+
+ private final ArgumentAcceptingOptionSpec includeLaunchClasspathSpec;
+
+ public OptionsParser(Predicate dependencyFilter) {
+
+ this.dependencyFilter = dependencyFilter;
+
+ this.parser = new OptionParser();
+ this.parser.acceptsAll(Arrays.asList("h", "?"), "show help");
+
+ this.testPluginSpec = parserAccepts(TEST_PLUGIN)
+ .withRequiredArg()
+ .ofType(String.class)
+ .defaultsTo("junit")
+ .describedAs("test plugin to use");
+
+ 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();
+
+ this.avoidCallsSpec = parserAccepts(AVOID_CALLS)
+ .withRequiredArg()
+ .ofType(String.class)
+ .withValuesSeparatedBy(',')
+ .describedAs(
+ "comma separated list of packages to consider as untouchable logging calls");
+
+ this.targetTestsSpec = parserAccepts(TEST_FILTER)
+ .withRequiredArg()
+ .ofType(String.class)
+ .withValuesSeparatedBy(',')
+ .describedAs(
+ "comma separated list of filters to match against tests to run");
+
+ this.depth = parserAccepts(DEPENDENCY_DISTANCE).withRequiredArg()
+ .ofType(Integer.class)
+ .defaultsTo(DEPENDENCY_DISTANCE.getDefault(Integer.class))
+ .describedAs("maximum distance to look from test for covered classes");
+
+ this.threadsSpec = parserAccepts(THREADS).withRequiredArg()
+ .ofType(Integer.class).defaultsTo(THREADS.getDefault(Integer.class))
+ .describedAs("number of threads to use for testing");
+
+ parserAccepts(MAX_MUTATIONS_PER_CLASS)
+ .withRequiredArg().ofType(Integer.class)
+ .defaultsTo(MAX_MUTATIONS_PER_CLASS.getDefault(Integer.class))
+ .describedAs("No longer supported. Use CLASSLIMIT(limit[42]) feature instead");
+
+ this.sourceDirSpec = parserAccepts(SOURCE_DIR).withRequiredArg()
+ .ofType(File.class).withValuesSeparatedBy(',')
+ .describedAs("comma separated list of source directories").required();
+
+ this.mutators = parserAccepts(MUTATIONS).withRequiredArg()
+ .ofType(String.class).withValuesSeparatedBy(',')
+ .describedAs("comma separated list of mutation operators");
+
+ this.features = parserAccepts(FEATURES).withRequiredArg()
+ .ofType(String.class).withValuesSeparatedBy(',')
+ .describedAs("comma separated list of features to enable/disable.");
+
+ this.jvmArgs = parserAccepts(CHILD_JVM).withRequiredArg()
+ .withValuesSeparatedBy(',')
+ .describedAs("comma separated list of child JVM args");
+
+ this.detectInlinedCode = parserAccepts(USE_INLINED_CODE_DETECTION)
+ .withOptionalArg()
+ .ofType(Boolean.class)
+ .defaultsTo(true)
+ .describedAs(
+ "whether or not to try and detect code inlined from finally blocks");
+
+ this.timestampedReportsSpec = parserAccepts(TIME_STAMPED_REPORTS)
+ .withOptionalArg().ofType(Boolean.class).defaultsTo(true)
+ .describedAs("whether or not to generated timestamped directories");
+
+ this.timeoutFactorSpec = parserAccepts(TIMEOUT_FACTOR).withOptionalArg()
+ .ofType(Float.class)
+ .describedAs("factor to apply to calculate maximum test duration")
+ .defaultsTo(TIMEOUT_FACTOR.getDefault(Float.class));
+
+ this.timeoutConstSpec = parserAccepts(TIMEOUT_CONST).withOptionalArg()
+ .ofType(Long.class)
+ .describedAs("constant to apply to calculate maximum test duration")
+ .defaultsTo(TIMEOUT_CONST.getDefault(Long.class));
+
+ this.excludedMethodsSpec = parserAccepts(EXCLUDED_METHOD)
+ .withRequiredArg()
+ .ofType(String.class)
+ .withValuesSeparatedBy(',')
+ .describedAs(
+ "comma separated list of filters to match against methods to exclude from mutation analysis");
+
+ this.excludedClassesSpec = parserAccepts(EXCLUDED_CLASSES)
+ .withRequiredArg()
+ .ofType(String.class)
+ .withValuesSeparatedBy(',')
+ .describedAs(
+ "comma separated list of globs for classes to exclude when mutating");
+
+ this.excludedTestClassesSpec = parserAccepts(EXCLUDED_TEST_CLASSES)
+ .withRequiredArg()
+ .ofType(String.class)
+ .withValuesSeparatedBy(',')
+ .describedAs(
+ "comma separated list of globs of test classes to exclude");
+
+ this.verboseSpec = parserAccepts(VERBOSE).withOptionalArg()
+ .ofType(Boolean.class).defaultsTo(true)
+ .describedAs("whether or not to generate verbose output");
+
+ this.exportLineCoverageSpec = parserAccepts(EXPORT_LINE_COVERAGE)
+ .withOptionalArg()
+ .ofType(Boolean.class)
+ .defaultsTo(true)
+ .describedAs(
+ "whether or not to dump per test line coverage data to disk");
+
+ this.includeLaunchClasspathSpec = parserAccepts(INCLUDE_LAUNCH_CLASSPATH)
+ .withOptionalArg().ofType(Boolean.class).defaultsTo(true)
+ .describedAs("whether or not to analyse launch classpath");
+
+ this.outputFormatSpec = parserAccepts(OUTPUT_FORMATS)
+ .withRequiredArg()
+ .ofType(String.class)
+ .withValuesSeparatedBy(',')
+ .describedAs(
+ "comma separated list of listeners to receive mutation results")
+ .defaultsTo("HTML");
+
+ this.additionalClassPathSpec = parserAccepts(CLASSPATH).withRequiredArg()
+ .ofType(String.class).withValuesSeparatedBy(',')
+ .describedAs("coma separated list of additional classpath elements");
+
+ this.classPathFile = this.parserAccepts(CLASSPATH_FILE).withRequiredArg()
+ .ofType(File.class).describedAs("File with a list of additional classpath elements (one per line)");
+
+ this.failWhenNoMutations = parserAccepts(FAIL_WHEN_NOT_MUTATIONS)
+ .withOptionalArg().ofType(Boolean.class).defaultsTo(true)
+ .describedAs("whether to throw error if no mutations found");
+
+ this.codePaths = parserAccepts(CODE_PATHS)
+ .withRequiredArg()
+ .ofType(String.class)
+ .withValuesSeparatedBy(',')
+ .describedAs(
+ "Globs identifying classpath roots containing mutable code");
+
+ this.includedGroupsSpec = parserAccepts(INCLUDED_GROUPS).withRequiredArg()
+ .ofType(String.class).withValuesSeparatedBy(',')
+ .describedAs("TestNG groups/JUnit categories to include");
+
+ this.includedTestMethodsSpec = parserAccepts(INCLUDED_TEST_METHODS).withRequiredArg()
+ .ofType(String.class).withValuesSeparatedBy(',')
+ .describedAs("Test methods that should be included for challenging the mutants");
+
+ this.excludedGroupsSpec = parserAccepts(EXCLUDED_GROUPS).withRequiredArg()
+ .ofType(String.class).withValuesSeparatedBy(',')
+ .describedAs("TestNG groups/JUnit categories to include");
+
+ this.mutationUnitSizeSpec = parserAccepts(MUTATION_UNIT_SIZE)
+ .withRequiredArg()
+ .ofType(Integer.class)
+ .describedAs(
+ "Maximum number of mutations to include within a single unit of analysis")
+ .defaultsTo(MUTATION_UNIT_SIZE.getDefault(Integer.class));
+
+ this.historyInputSpec = parserAccepts(HISTORY_INPUT_LOCATION)
+ .withRequiredArg().ofType(File.class)
+ .describedAs("File to read history from for incremental analysis");
+
+ this.historyOutputSpec = parserAccepts(HISTORY_OUTPUT_LOCATION)
+ .withRequiredArg().ofType(File.class)
+ .describedAs("File to write history to for incremental analysis");
+
+ this.mutationThreshHoldSpec = parserAccepts(MUTATION_THRESHOLD)
+ .withRequiredArg().ofType(Integer.class)
+ .describedAs("Mutation score below which to throw an error")
+ .defaultsTo(MUTATION_THRESHOLD.getDefault(Integer.class));
+
+ this.maxSurvivingSpec = parserAccepts(MAX_SURVIVING)
+ .withRequiredArg().ofType(Integer.class)
+ .describedAs("Maximum number of surviving mutants to allow without throwing an error")
+ .defaultsTo(MAX_SURVIVING.getDefault(Integer.class));
+
+ this.coverageThreshHoldSpec = parserAccepts(COVERAGE_THRESHOLD)
+ .withRequiredArg().ofType(Integer.class)
+ .describedAs("Line coverage below which to throw an error")
+ .defaultsTo(COVERAGE_THRESHOLD.getDefault(Integer.class));
+
+ this.mutationEngine = parserAccepts(MUTATION_ENGINE).withRequiredArg()
+ .ofType(String.class).describedAs("mutation engine to use")
+ .defaultsTo(MUTATION_ENGINE.getDefault(String.class));
+
+ this.javaExecutable = parserAccepts(JVM_PATH).withRequiredArg()
+ .ofType(String.class).describedAs("path to java executable");
+
+ this.pluginPropertiesSpec = parserAccepts(PLUGIN_CONFIGURATION)
+ .withRequiredArg().ofType(KeyValuePair.class)
+ .describedAs("custom plugin properties");
+
+ }
+
+ private OptionSpecBuilder parserAccepts(final ConfigOption option) {
+ return this.parser.accepts(option.getParamName());
+ }
+
+ public ParseResult parse(final String[] args) {
+ final ReportOptions data = new ReportOptions();
+ try {
+ final OptionSet userArgs = this.parser.parse(args);
+ return parseCommandLine(data, userArgs);
+
+ } catch (final OptionException uoe) {
+ return new ParseResult(data, uoe.getLocalizedMessage());
+ }
+ }
+
+ /**
+ * Creates a new ParseResult object using the command line arguments.
+ *
+ * @param data
+ * the ReportOptions to populate.
+ * @param userArgs
+ * the OptionSet which contains the command line arguments.
+ * @return a new ParseResult, correctly configured using the command line
+ * arguments.
+ */
+ private ParseResult parseCommandLine(final ReportOptions data,
+ final OptionSet userArgs) {
+ data.setTestPlugin(userArgs.valueOf(this.testPluginSpec));
+ data.setReportDir(userArgs.valueOf(this.reportDirSpec));
+ data.setTargetClasses(this.targetClassesSpec.values(userArgs));
+ data.setTargetTests(FCollection.map(this.targetTestsSpec.values(userArgs),
+ Glob.toGlobPredicate()));
+ data.setSourceDirs(this.sourceDirSpec.values(userArgs));
+ data.setMutators(this.mutators.values(userArgs));
+ data.setFeatures(this.features.values(userArgs));
+ data.setDependencyAnalysisMaxDistance(this.depth.value(userArgs));
+ data.addChildJVMArgs(this.jvmArgs.values(userArgs));
+
+
+ data.setDetectInlinedCode(userArgs.has(this.detectInlinedCode)
+ && userArgs.valueOf(this.detectInlinedCode));
+
+ data.setIncludeLaunchClasspath(userArgs
+ .valueOf(this.includeLaunchClasspathSpec));
+
+ data.setShouldCreateTimestampedReports(userArgs
+ .valueOf(this.timestampedReportsSpec));
+ data.setNumberOfThreads(this.threadsSpec.value(userArgs));
+ data.setTimeoutFactor(this.timeoutFactorSpec.value(userArgs));
+ data.setTimeoutConstant(this.timeoutConstSpec.value(userArgs));
+ data.setLoggingClasses(this.avoidCallsSpec.values(userArgs));
+ data.setExcludedMethods(this.excludedMethodsSpec.values(userArgs));
+ data.setExcludedClasses(this.excludedClassesSpec.values(userArgs));
+ data.setExcludedTestClasses(FCollection.map(
+ this.excludedTestClassesSpec.values(userArgs), Glob.toGlobPredicate()));
+ data.setVerbose(userArgs.has(this.verboseSpec)
+ && userArgs.valueOf(this.verboseSpec));
+
+ data.addOutputFormats(this.outputFormatSpec.values(userArgs));
+ data.setFailWhenNoMutations(this.failWhenNoMutations.value(userArgs));
+ data.setCodePaths(this.codePaths.values(userArgs));
+ data.setMutationUnitSize(this.mutationUnitSizeSpec.value(userArgs));
+
+ data.setHistoryInputLocation(this.historyInputSpec.value(userArgs));
+ data.setHistoryOutputLocation(this.historyOutputSpec.value(userArgs));
+ data.setMutationThreshold(this.mutationThreshHoldSpec.value(userArgs));
+ data.setMaximumAllowedSurvivors(this.maxSurvivingSpec.value(userArgs));
+ data.setCoverageThreshold(this.coverageThreshHoldSpec.value(userArgs));
+ data.setMutationEngine(this.mutationEngine.value(userArgs));
+ data.setFreeFormProperties(listToProperties(this.pluginPropertiesSpec
+ .values(userArgs)));
+
+ data.setExportLineCoverage(userArgs.has(this.exportLineCoverageSpec)
+ && userArgs.valueOf(this.exportLineCoverageSpec));
+
+ setClassPath(userArgs, data);
+
+ setTestGroups(userArgs, data);
+
+ data.setIncludedTestMethods(this.includedTestMethodsSpec.values(userArgs));
+ data.setJavaExecutable(this.javaExecutable.value(userArgs));
+
+ if (userArgs.has("?")) {
+ return new ParseResult(data, "See above for supported parameters.");
+ } else {
+ return new ParseResult(data, null);
+ }
+ }
+
+ private void setClassPath(final OptionSet userArgs, final ReportOptions data) {
+
+ final List elements = new ArrayList<>();
+ if (data.isIncludeLaunchClasspath()) {
+ elements.addAll(ClassPath.getClassPathElementsAsPaths());
+ } else {
+ elements.addAll(FCollection.filter(
+ ClassPath.getClassPathElementsAsPaths(), this.dependencyFilter));
+ }
+ if (userArgs.has(this.classPathFile)) {
+ try (BufferedReader classPathFileBR = new BufferedReader(new FileReader(userArgs.valueOf(this.classPathFile).getAbsoluteFile()))) {
+ String element;
+ while ((element = classPathFileBR.readLine()) != null) {
+ elements.add(element);
+ }
+ } catch (final IOException ioe) {
+ LOG.warning("Unable to read class path file:" + userArgs.valueOf(this.classPathFile).getAbsolutePath() + " - "
+ + ioe.getMessage());
+ }
+ }
+ elements.addAll(userArgs.valuesOf(this.additionalClassPathSpec));
+ data.setClassPathElements(elements);
+ }
+
+ 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) {
+ final Properties p = new Properties();
+ for (final KeyValuePair kvp : kvps) {
+ p.put(kvp.key, kvp.value);
+ }
+ return p;
+ }
+
+ public void printHelp() {
+ try {
+ this.parser.printHelpOn(System.out);
+ } catch (final IOException ex) {
+ throw Unchecked.translateCheckedException(ex);
+ }
+ }
+
+}
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 eab29e2e1..4dcdb412f 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,42 +1,42 @@
-/*
- * 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.
- */
-package org.pitest.mutationtest.commandline;
-
-import java.util.Optional;
-import org.pitest.mutationtest.config.ReportOptions;
-
-public class ParseResult {
-
- private final ReportOptions options;
- private final Optional errorMessage;
-
- public ParseResult(final ReportOptions options, final String errorMessage) {
- this.options = options;
- this.errorMessage = Optional.ofNullable(errorMessage);
- }
-
- public boolean isOk() {
- return !this.errorMessage.isPresent();
- }
-
- public ReportOptions getOptions() {
- return this.options;
- }
-
- public Optional getErrorMessage() {
- return this.errorMessage;
- }
-
-}
+/*
+ * 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.
+ */
+package org.pitest.mutationtest.commandline;
+
+import java.util.Optional;
+import org.pitest.mutationtest.config.ReportOptions;
+
+public class ParseResult {
+
+ private final ReportOptions options;
+ private final Optional errorMessage;
+
+ public ParseResult(final ReportOptions options, final String errorMessage) {
+ this.options = options;
+ this.errorMessage = Optional.ofNullable(errorMessage);
+ }
+
+ public boolean isOk() {
+ return !this.errorMessage.isPresent();
+ }
+
+ public ReportOptions getOptions() {
+ return this.options;
+ }
+
+ public Optional getErrorMessage() {
+ return this.errorMessage;
+ }
+
+}
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 7aed7d443..db2da0dea 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
@@ -1,51 +1,51 @@
-package org.pitest.mutationtest.commandline;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
-import org.pitest.functional.FCollection;
-import org.pitest.mutationtest.config.PluginServices;
-import org.pitest.plugin.ClientClasspathPlugin;
-import org.pitest.util.PitError;
-
-public class PluginFilter implements Predicate {
-
- private final Set includedClassPathElement = new HashSet<>();
-
- public PluginFilter(final PluginServices plugin) {
- FCollection.mapTo(plugin.findClientClasspathPlugins(), classToLocation(),
- this.includedClassPathElement);
- }
-
- private static Function classToLocation() {
- return new Function() {
- @Override
- public String apply(final ClientClasspathPlugin a) {
- try {
- return new File(a.getClass().getProtectionDomain().getCodeSource()
- .getLocation().toURI()).getCanonicalPath();
- } catch (final IOException ex) {
- throw createPitErrorForExceptionOnClass(ex, a);
- } catch (final URISyntaxException ex) {
- throw createPitErrorForExceptionOnClass(ex, a);
- }
- }
-
- private PitError createPitErrorForExceptionOnClass(final Exception ex,
- final ClientClasspathPlugin clazz) {
- return new PitError("Error getting location of class " + clazz, ex);
- }
- };
- }
-
- @Override
- public boolean test(final String a) {
- return this.includedClassPathElement.contains(a);
- }
-
-}
+package org.pitest.mutationtest.commandline;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+import org.pitest.functional.FCollection;
+import org.pitest.mutationtest.config.PluginServices;
+import org.pitest.plugin.ClientClasspathPlugin;
+import org.pitest.util.PitError;
+
+public class PluginFilter implements Predicate {
+
+ private final Set includedClassPathElement = new HashSet<>();
+
+ public PluginFilter(final PluginServices plugin) {
+ FCollection.mapTo(plugin.findClientClasspathPlugins(), classToLocation(),
+ this.includedClassPathElement);
+ }
+
+ private static Function classToLocation() {
+ return new Function() {
+ @Override
+ public String apply(final ClientClasspathPlugin a) {
+ try {
+ return new File(a.getClass().getProtectionDomain().getCodeSource()
+ .getLocation().toURI()).getCanonicalPath();
+ } catch (final IOException ex) {
+ throw createPitErrorForExceptionOnClass(ex, a);
+ } catch (final URISyntaxException ex) {
+ throw createPitErrorForExceptionOnClass(ex, a);
+ }
+ }
+
+ private PitError createPitErrorForExceptionOnClass(final Exception ex,
+ final ClientClasspathPlugin clazz) {
+ return new PitError("Error getting location of class " + clazz, ex);
+ }
+ };
+ }
+
+ @Override
+ public boolean test(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 05b90a56f..a7cb70837 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,525 +1,525 @@
-/*
- * 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.
- */
-package org.pitest.mutationtest.commandline;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.function.Predicate;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.pitest.mutationtest.config.ConfigOption;
-import org.pitest.mutationtest.config.PluginServices;
-import org.pitest.mutationtest.config.ReportOptions;
-import org.pitest.mutationtest.engine.gregor.GregorMutationEngine;
-import org.pitest.mutationtest.engine.gregor.mutators.ConditionalsBoundaryMutator;
-import org.pitest.mutationtest.engine.gregor.mutators.MathMutator;
-
-public class OptionsParserTest {
-
- 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;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(this.filter.test(any(String.class))).thenReturn(true);
- this.testee = new OptionsParser(this.filter);
- }
-
- @Test
- public void shouldParseTestPlugin() {
- final String value = "foo";
- final ReportOptions actual = parseAddingRequiredArgs("--testPlugin", value);
- assertEquals(value, actual.getTestPlugin());
- }
-
- @Test
- public void shouldParseReportDir() {
- final String value = "foo";
- final ReportOptions actual = parseAddingRequiredArgs("--reportDir", value);
- assertEquals(value, actual.getReportDir());
- }
-
- @Test
- public void shouldCreatePredicateFromCommaSeparatedListOfTargetClassGlobs() {
- final ReportOptions actual = parseAddingRequiredArgs("--targetClasses",
- "foo*,bar*");
- final Predicate actualPredicate = actual.getTargetClassesFilter();
- assertTrue(actualPredicate.test("foo_anything"));
- assertTrue(actualPredicate.test("bar_anything"));
- assertFalse(actualPredicate.test("notfoobar"));
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfSourceDirectories() {
- final ReportOptions actual = parseAddingRequiredArgs("--sourceDirs",
- "foo/bar,bar/far");
- assertEquals(Arrays.asList(new File("foo/bar"), new File("bar/far")), actual.getSourceDirs());
- }
-
- @Test
- public void shouldParseMaxDepenencyDistance() {
- final ReportOptions actual = parseAddingRequiredArgs(
- "--dependencyDistance", "42");
- assertEquals(42, actual.getDependencyAnalysisMaxDistance());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfJVMArgs() {
- final ReportOptions actual = parseAddingRequiredArgs("--jvmArgs", "foo,bar");
- assertEquals(Arrays.asList("foo", "bar"), actual.getJvmArgs());
- }
-
- @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(),
- MathMutator.MATH_MUTATOR.name()), actual.getMutators());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfFeatures() {
- final ReportOptions actual = parseAddingRequiredArgs("--features", "+FOO(),-BAR(value=1 & value=2)");
- assertThat(actual.getFeatures()).contains("+FOO()", "-BAR(value=1 & value=2)");
- }
-
- @Test
- public void shouldNotDetectInlinedCodeByDefault() {
- final ReportOptions actual = parseAddingRequiredArgs("");
- assertFalse(actual.isDetectInlinedCode());
- }
-
- @Test
- public void shouldDetermineIfInlinedCodeFlagIsSet() {
- final ReportOptions actual = parseAddingRequiredArgs("--detectInlinedCode");
- assertTrue(actual.isDetectInlinedCode());
- }
-
- @Test
- public void shouldDetermineIfInlinedCodeFlagIsSetWhenFalseSupplied() {
- final ReportOptions actual = parseAddingRequiredArgs("--detectInlinedCode=false");
- assertFalse(actual.isDetectInlinedCode());
- }
-
- @Test
- public void shouldCreateTimestampedReportsByDefault() {
- final ReportOptions actual = parseAddingRequiredArgs();
- assertTrue(actual.shouldCreateTimeStampedReports());
- }
-
- @Test
- public void shouldDetermineIfSuppressTimestampedReportsFlagIsSet() {
- final ReportOptions actual = parseAddingRequiredArgs("--timestampedReports");
- assertTrue(actual.shouldCreateTimeStampedReports());
- }
-
- @Test
- public void shouldDetermineIfSuppressTimestampedReportsFlagIsSetWhenFalseSupplied() {
- final ReportOptions actual = parseAddingRequiredArgs("--timestampedReports=false");
- assertFalse(actual.shouldCreateTimeStampedReports());
- }
-
- @Test
- public void shouldParseNumberOfThreads() {
- final ReportOptions actual = parseAddingRequiredArgs("--threads", "42");
- assertEquals(42, actual.getNumberOfThreads());
- }
-
- @Test
- public void shouldParseTimeOutFactor() {
- final ReportOptions actual = parseAddingRequiredArgs("--timeoutFactor",
- "1.32");
- assertEquals(1.32f, actual.getTimeoutFactor(), 0.1);
- }
-
- @Test
- public void shouldParseTimeOutConstant() {
- final ReportOptions actual = parseAddingRequiredArgs("--timeoutConst", "42");
- assertEquals(42, actual.getTimeoutConstant());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfTargetTestClassGlobs() {
- final ReportOptions actual = parseAddingRequiredArgs("--targetTest",
- "foo*,bar*");
- final Predicate actualPredicate = actual.getTargetTestsFilter();
- assertTrue(actualPredicate.test("foo_anything"));
- assertTrue(actualPredicate.test("bar_anything"));
- assertFalse(actualPredicate.test("notfoobar"));
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfTargetTestClassGlobAsRegex() {
- ReportOptions actual = parseAddingRequiredArgs("--targetTest",
- "~foo\\w*,~bar.*");
- Predicate actualPredicate = actual.getTargetTestsFilter();
- assertTrue(actualPredicate.test("foo_anything"));
- assertTrue(actualPredicate.test("bar_anything"));
- assertFalse(actualPredicate.test("notfoobar"));
- actual = parseAddingRequiredArgs("--targetTest",
- "~.*?foo\\w*,~bar.*");
- actualPredicate = actual.getTargetTestsFilter();
- assertTrue(actualPredicate.test("notfoobar"));
- }
-
- @Test
- public void shouldUseTargetClassesFilterForTestsWhenNoTargetTestsFilterSupplied() {
- final ReportOptions actual = parseAddingRequiredArgs("--targetClasses",
- "foo*,bar*");
- final Predicate actualPredicate = actual.getTargetTestsFilter();
- assertTrue(actualPredicate.test("foo_anything"));
- assertTrue(actualPredicate.test("bar_anything"));
- assertFalse(actualPredicate.test("notfoobar"));
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfExcludedTestClassGlobs() {
- final ReportOptions actual = parseAddingRequiredArgs("--excludedTestClasses",
- "foo*", "--targetTests", "foo*,bar*", "--targetClasses", "foo*,bar*");
- final Predicate testPredicate = actual.getTargetTestsFilter();
- assertFalse(testPredicate.test("foo_anything"));
- assertTrue(testPredicate.test("bar_anything"));
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfExcludedClassGlobsAndApplyTheseToTargets() {
- final ReportOptions actual = parseAddingRequiredArgs("--excludedClasses",
- "foo*", "--targetTests", "foo*,bar*", "--targetClasses", "foo*,bar*");
-
- final Predicate targetPredicate = actual.getTargetClassesFilter();
- assertFalse(targetPredicate.test("foo_anything"));
- assertTrue(targetPredicate.test("bar_anything"));
- }
-
- @Test
- public void shouldDefaultLoggingPackagesToDefaultsDefinedByDefaultMutationConfigFactory() {
- final ReportOptions actual = parseAddingRequiredArgs();
- assertEquals(ReportOptions.LOGGING_CLASSES, actual.getLoggingClasses());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfClassesToAvoidCallTo() {
- final ReportOptions actual = parseAddingRequiredArgs("--avoidCallsTo",
- "foo,bar,foo.bar");
- assertEquals(Arrays.asList("foo", "bar", "foo.bar"),
- actual.getLoggingClasses());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfExcludedMethods() {
- final ReportOptions actual = parseAddingRequiredArgs("--excludedMethods",
- "foo*,bar*,car");
- final Collection actualPredicate = actual
- .getExcludedMethods();
- assertThat(actualPredicate).containsExactlyInAnyOrder("foo*", "bar*", "car");
- }
-
- @Test
- public void shouldParseVerboseFlag() {
- final ReportOptions actual = parseAddingRequiredArgs("--verbose");
- assertTrue(actual.isVerbose());
- }
-
- @Test
- public void shouldDefaultToHtmlReportWhenNoOutputFormatsSpecified() {
- final ReportOptions actual = parseAddingRequiredArgs();
- assertEquals(new HashSet<>(Arrays.asList("HTML")),
- actual.getOutputFormats());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfOutputFormatsWhenSupplied() {
- final ReportOptions actual = parseAddingRequiredArgs("--outputFormats",
- "HTML,CSV");
- assertEquals(new HashSet<>(Arrays.asList("HTML", "CSV")),
- actual.getOutputFormats());
- }
-
- @Test
- public void shouldAcceptCommaSeparatedListOfAdditionalClassPathElements() {
- final ReportOptions ro = parseAddingRequiredArgs("--classPath",
- "/foo/bar,./boo");
- final Collection actual = ro.getClassPathElements();
- assertTrue(actual.contains("/foo/bar"));
- assertTrue(actual.contains("./boo"));
- }
-
- @Test
- public void shouldAcceptFileWithListOfAdditionalClassPathElements() {
- final ClassLoader classLoader = getClass().getClassLoader();
- final File classPathFile = new File(classLoader.getResource("testClassPathFile.txt").getFile());
- final ReportOptions ro = parseAddingRequiredArgs("--classPathFile",
- classPathFile.getAbsolutePath());
- final Collection actual = ro.getClassPathElements();
- assertTrue(actual.contains("C:/foo"));
- assertTrue(actual.contains("/etc/bar"));
- }
-
- @Test
- public void shouldDetermineIfFailWhenNoMutationsFlagIsSet() {
- assertTrue(parseAddingRequiredArgs("--failWhenNoMutations", "true")
- .shouldFailWhenNoMutations());
- assertFalse(parseAddingRequiredArgs("--failWhenNoMutations", "false")
- .shouldFailWhenNoMutations());
- }
-
- @Test
- public void shouldFailWhenNoMutationsSetByDefault() {
- assertTrue(parseAddingRequiredArgs("").shouldFailWhenNoMutations());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfMutableCodePaths() {
- final ReportOptions actual = parseAddingRequiredArgs("--mutableCodePaths",
- "foo,bar");
- assertEquals(Arrays.asList("foo", "bar"), actual.getCodePaths());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfExcludedTestGroups() {
- 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");
- assertEquals(Arrays.asList("foo", "bar"), actual.getGroupConfig()
- .getIncludedGroups());
- }
-
- @Test
- public void shouldParseCommaSeparatedListOfIncludedTestMethods() {
- final ReportOptions actual = parseAddingRequiredArgs("--includedTestMethods",
- "foo,bar");
- assertEquals(Arrays.asList("foo", "bar"), actual
- .getIncludedTestMethods());
- }
-
- @Test
- public void shouldParseMutationUnitSize() {
- final ReportOptions actual = parseAddingRequiredArgs("--mutationUnitSize",
- "50");
- assertEquals(50, actual.getMutationUnitSize());
- }
-
- @Test
- public void shouldDefaultMutationUnitSizeToCorrectValue() {
- final ReportOptions actual = parseAddingRequiredArgs("");
- assertEquals(
- (int) ConfigOption.MUTATION_UNIT_SIZE.getDefault(Integer.class),
- actual.getMutationUnitSize());
- }
-
- @Test
- public void shouldDefaultToNoHistory() {
- final ReportOptions actual = parseAddingRequiredArgs("");
- assertNull(actual.getHistoryInputLocation());
- assertNull(actual.getHistoryOutputLocation());
- }
-
- @Test
- public void shouldParseHistoryInputLocation() {
- final ReportOptions actual = parseAddingRequiredArgs(
- "--historyInputLocation", "foo");
- assertEquals(new File("foo"), actual.getHistoryInputLocation());
- }
-
- @Test
- public void shouldParseHistoryOutputLocation() {
- final ReportOptions actual = parseAddingRequiredArgs(
- "--historyOutputLocation", "foo");
- assertEquals(new File("foo"), actual.getHistoryOutputLocation());
- }
-
- @Test
- public void shouldParseMutationThreshold() {
- final ReportOptions actual = parseAddingRequiredArgs("--mutationThreshold",
- "42");
- assertEquals(42, actual.getMutationThreshold());
- }
-
- @Test
- public void shouldParseMaximumAllowedSurvivingMutants() {
- final ReportOptions actual = parseAddingRequiredArgs("--maxSurviving",
- "42");
- assertEquals(42, actual.getMaximumAllowedSurvivors());
- }
-
- @Test
- public void shouldParseCoverageThreshold() {
- final ReportOptions actual = parseAddingRequiredArgs("--coverageThreshold",
- "42");
- assertEquals(42, actual.getCoverageThreshold());
- }
-
- @Test
- public void shouldDefaultToGregorEngineWhenNoOptionSupplied() {
- final ReportOptions actual = parseAddingRequiredArgs();
- 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");
- assertEquals("foo", actual.getJavaExecutable());
- }
-
- @Test
- public void shouldParseExportLineCoverageFlag() {
- final ReportOptions actual = parseAddingRequiredArgs("--exportLineCoverage");
- assertTrue(actual.shouldExportLineCoverage());
- }
-
- @Test
- 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");
- assertTrue(actual.isIncludeLaunchClasspath());
- }
-
- @Test
- public void shouldHandleNotCanonicalLaunchClasspathElements() {
- final String oldClasspath = System.getProperty(JAVA_CLASS_PATH_PROPERTY);
- try {
- // given
- final PluginServices plugins = PluginServices.makeForContextLoader();
- this.testee = new OptionsParser(new PluginFilter(plugins));
- // and
- System.setProperty(JAVA_CLASS_PATH_PROPERTY,
- getNonCanonicalGregorEngineClassPath());
- // when
- final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=false");
- // 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"));
- }
-
- @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"));
- }
-
- 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();
- }
-
- private Predicate gregorClass() {
- return s -> GregorMutationEngine.class.getName().equals(s);
- }
-
- private ReportOptions parseAddingRequiredArgs(final String... args) {
-
- final List a = new ArrayList<>();
- a.addAll(Arrays.asList(args));
- addIfNotPresent(a, "--targetClasses");
- addIfNotPresent(a, "--reportDir");
- addIfNotPresent(a, "--sourceDirs");
- return parse(a.toArray(new String[a.size()]));
- }
-
- private void addIfNotPresent(final List uniqueArgs, final String value) {
- if (!uniqueArgs.contains(value)) {
- uniqueArgs.add(value);
- uniqueArgs.add("ignore");
- }
- }
-
- private ReportOptions parse(final String... args) {
- return this.testee.parse(args).getOptions();
- }
-
-}
+/*
+ * 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.
+ */
+package org.pitest.mutationtest.commandline;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.function.Predicate;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.pitest.mutationtest.config.ConfigOption;
+import org.pitest.mutationtest.config.PluginServices;
+import org.pitest.mutationtest.config.ReportOptions;
+import org.pitest.mutationtest.engine.gregor.GregorMutationEngine;
+import org.pitest.mutationtest.engine.gregor.mutators.ConditionalsBoundaryMutator;
+import org.pitest.mutationtest.engine.gregor.mutators.MathMutator;
+
+public class OptionsParserTest {
+
+ 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;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(this.filter.test(any(String.class))).thenReturn(true);
+ this.testee = new OptionsParser(this.filter);
+ }
+
+ @Test
+ public void shouldParseTestPlugin() {
+ final String value = "foo";
+ final ReportOptions actual = parseAddingRequiredArgs("--testPlugin", value);
+ assertEquals(value, actual.getTestPlugin());
+ }
+
+ @Test
+ public void shouldParseReportDir() {
+ final String value = "foo";
+ final ReportOptions actual = parseAddingRequiredArgs("--reportDir", value);
+ assertEquals(value, actual.getReportDir());
+ }
+
+ @Test
+ public void shouldCreatePredicateFromCommaSeparatedListOfTargetClassGlobs() {
+ final ReportOptions actual = parseAddingRequiredArgs("--targetClasses",
+ "foo*,bar*");
+ final Predicate actualPredicate = actual.getTargetClassesFilter();
+ assertTrue(actualPredicate.test("foo_anything"));
+ assertTrue(actualPredicate.test("bar_anything"));
+ assertFalse(actualPredicate.test("notfoobar"));
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfSourceDirectories() {
+ final ReportOptions actual = parseAddingRequiredArgs("--sourceDirs",
+ "foo/bar,bar/far");
+ assertEquals(Arrays.asList(new File("foo/bar"), new File("bar/far")), actual.getSourceDirs());
+ }
+
+ @Test
+ public void shouldParseMaxDepenencyDistance() {
+ final ReportOptions actual = parseAddingRequiredArgs(
+ "--dependencyDistance", "42");
+ assertEquals(42, actual.getDependencyAnalysisMaxDistance());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfJVMArgs() {
+ final ReportOptions actual = parseAddingRequiredArgs("--jvmArgs", "foo,bar");
+ assertEquals(Arrays.asList("foo", "bar"), actual.getJvmArgs());
+ }
+
+ @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(),
+ MathMutator.MATH_MUTATOR.name()), actual.getMutators());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfFeatures() {
+ final ReportOptions actual = parseAddingRequiredArgs("--features", "+FOO(),-BAR(value=1 & value=2)");
+ assertThat(actual.getFeatures()).contains("+FOO()", "-BAR(value=1 & value=2)");
+ }
+
+ @Test
+ public void shouldNotDetectInlinedCodeByDefault() {
+ final ReportOptions actual = parseAddingRequiredArgs("");
+ assertFalse(actual.isDetectInlinedCode());
+ }
+
+ @Test
+ public void shouldDetermineIfInlinedCodeFlagIsSet() {
+ final ReportOptions actual = parseAddingRequiredArgs("--detectInlinedCode");
+ assertTrue(actual.isDetectInlinedCode());
+ }
+
+ @Test
+ public void shouldDetermineIfInlinedCodeFlagIsSetWhenFalseSupplied() {
+ final ReportOptions actual = parseAddingRequiredArgs("--detectInlinedCode=false");
+ assertFalse(actual.isDetectInlinedCode());
+ }
+
+ @Test
+ public void shouldCreateTimestampedReportsByDefault() {
+ final ReportOptions actual = parseAddingRequiredArgs();
+ assertTrue(actual.shouldCreateTimeStampedReports());
+ }
+
+ @Test
+ public void shouldDetermineIfSuppressTimestampedReportsFlagIsSet() {
+ final ReportOptions actual = parseAddingRequiredArgs("--timestampedReports");
+ assertTrue(actual.shouldCreateTimeStampedReports());
+ }
+
+ @Test
+ public void shouldDetermineIfSuppressTimestampedReportsFlagIsSetWhenFalseSupplied() {
+ final ReportOptions actual = parseAddingRequiredArgs("--timestampedReports=false");
+ assertFalse(actual.shouldCreateTimeStampedReports());
+ }
+
+ @Test
+ public void shouldParseNumberOfThreads() {
+ final ReportOptions actual = parseAddingRequiredArgs("--threads", "42");
+ assertEquals(42, actual.getNumberOfThreads());
+ }
+
+ @Test
+ public void shouldParseTimeOutFactor() {
+ final ReportOptions actual = parseAddingRequiredArgs("--timeoutFactor",
+ "1.32");
+ assertEquals(1.32f, actual.getTimeoutFactor(), 0.1);
+ }
+
+ @Test
+ public void shouldParseTimeOutConstant() {
+ final ReportOptions actual = parseAddingRequiredArgs("--timeoutConst", "42");
+ assertEquals(42, actual.getTimeoutConstant());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfTargetTestClassGlobs() {
+ final ReportOptions actual = parseAddingRequiredArgs("--targetTest",
+ "foo*,bar*");
+ final Predicate actualPredicate = actual.getTargetTestsFilter();
+ assertTrue(actualPredicate.test("foo_anything"));
+ assertTrue(actualPredicate.test("bar_anything"));
+ assertFalse(actualPredicate.test("notfoobar"));
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfTargetTestClassGlobAsRegex() {
+ ReportOptions actual = parseAddingRequiredArgs("--targetTest",
+ "~foo\\w*,~bar.*");
+ Predicate actualPredicate = actual.getTargetTestsFilter();
+ assertTrue(actualPredicate.test("foo_anything"));
+ assertTrue(actualPredicate.test("bar_anything"));
+ assertFalse(actualPredicate.test("notfoobar"));
+ actual = parseAddingRequiredArgs("--targetTest",
+ "~.*?foo\\w*,~bar.*");
+ actualPredicate = actual.getTargetTestsFilter();
+ assertTrue(actualPredicate.test("notfoobar"));
+ }
+
+ @Test
+ public void shouldUseTargetClassesFilterForTestsWhenNoTargetTestsFilterSupplied() {
+ final ReportOptions actual = parseAddingRequiredArgs("--targetClasses",
+ "foo*,bar*");
+ final Predicate actualPredicate = actual.getTargetTestsFilter();
+ assertTrue(actualPredicate.test("foo_anything"));
+ assertTrue(actualPredicate.test("bar_anything"));
+ assertFalse(actualPredicate.test("notfoobar"));
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfExcludedTestClassGlobs() {
+ final ReportOptions actual = parseAddingRequiredArgs("--excludedTestClasses",
+ "foo*", "--targetTests", "foo*,bar*", "--targetClasses", "foo*,bar*");
+ final Predicate testPredicate = actual.getTargetTestsFilter();
+ assertFalse(testPredicate.test("foo_anything"));
+ assertTrue(testPredicate.test("bar_anything"));
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfExcludedClassGlobsAndApplyTheseToTargets() {
+ final ReportOptions actual = parseAddingRequiredArgs("--excludedClasses",
+ "foo*", "--targetTests", "foo*,bar*", "--targetClasses", "foo*,bar*");
+
+ final Predicate targetPredicate = actual.getTargetClassesFilter();
+ assertFalse(targetPredicate.test("foo_anything"));
+ assertTrue(targetPredicate.test("bar_anything"));
+ }
+
+ @Test
+ public void shouldDefaultLoggingPackagesToDefaultsDefinedByDefaultMutationConfigFactory() {
+ final ReportOptions actual = parseAddingRequiredArgs();
+ assertEquals(ReportOptions.LOGGING_CLASSES, actual.getLoggingClasses());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfClassesToAvoidCallTo() {
+ final ReportOptions actual = parseAddingRequiredArgs("--avoidCallsTo",
+ "foo,bar,foo.bar");
+ assertEquals(Arrays.asList("foo", "bar", "foo.bar"),
+ actual.getLoggingClasses());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfExcludedMethods() {
+ final ReportOptions actual = parseAddingRequiredArgs("--excludedMethods",
+ "foo*,bar*,car");
+ final Collection actualPredicate = actual
+ .getExcludedMethods();
+ assertThat(actualPredicate).containsExactlyInAnyOrder("foo*", "bar*", "car");
+ }
+
+ @Test
+ public void shouldParseVerboseFlag() {
+ final ReportOptions actual = parseAddingRequiredArgs("--verbose");
+ assertTrue(actual.isVerbose());
+ }
+
+ @Test
+ public void shouldDefaultToHtmlReportWhenNoOutputFormatsSpecified() {
+ final ReportOptions actual = parseAddingRequiredArgs();
+ assertEquals(new HashSet<>(Arrays.asList("HTML")),
+ actual.getOutputFormats());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfOutputFormatsWhenSupplied() {
+ final ReportOptions actual = parseAddingRequiredArgs("--outputFormats",
+ "HTML,CSV");
+ assertEquals(new HashSet<>(Arrays.asList("HTML", "CSV")),
+ actual.getOutputFormats());
+ }
+
+ @Test
+ public void shouldAcceptCommaSeparatedListOfAdditionalClassPathElements() {
+ final ReportOptions ro = parseAddingRequiredArgs("--classPath",
+ "/foo/bar,./boo");
+ final Collection actual = ro.getClassPathElements();
+ assertTrue(actual.contains("/foo/bar"));
+ assertTrue(actual.contains("./boo"));
+ }
+
+ @Test
+ public void shouldAcceptFileWithListOfAdditionalClassPathElements() {
+ final ClassLoader classLoader = getClass().getClassLoader();
+ final File classPathFile = new File(classLoader.getResource("testClassPathFile.txt").getFile());
+ final ReportOptions ro = parseAddingRequiredArgs("--classPathFile",
+ classPathFile.getAbsolutePath());
+ final Collection actual = ro.getClassPathElements();
+ assertTrue(actual.contains("C:/foo"));
+ assertTrue(actual.contains("/etc/bar"));
+ }
+
+ @Test
+ public void shouldDetermineIfFailWhenNoMutationsFlagIsSet() {
+ assertTrue(parseAddingRequiredArgs("--failWhenNoMutations", "true")
+ .shouldFailWhenNoMutations());
+ assertFalse(parseAddingRequiredArgs("--failWhenNoMutations", "false")
+ .shouldFailWhenNoMutations());
+ }
+
+ @Test
+ public void shouldFailWhenNoMutationsSetByDefault() {
+ assertTrue(parseAddingRequiredArgs("").shouldFailWhenNoMutations());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfMutableCodePaths() {
+ final ReportOptions actual = parseAddingRequiredArgs("--mutableCodePaths",
+ "foo,bar");
+ assertEquals(Arrays.asList("foo", "bar"), actual.getCodePaths());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfExcludedTestGroups() {
+ 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");
+ assertEquals(Arrays.asList("foo", "bar"), actual.getGroupConfig()
+ .getIncludedGroups());
+ }
+
+ @Test
+ public void shouldParseCommaSeparatedListOfIncludedTestMethods() {
+ final ReportOptions actual = parseAddingRequiredArgs("--includedTestMethods",
+ "foo,bar");
+ assertEquals(Arrays.asList("foo", "bar"), actual
+ .getIncludedTestMethods());
+ }
+
+ @Test
+ public void shouldParseMutationUnitSize() {
+ final ReportOptions actual = parseAddingRequiredArgs("--mutationUnitSize",
+ "50");
+ assertEquals(50, actual.getMutationUnitSize());
+ }
+
+ @Test
+ public void shouldDefaultMutationUnitSizeToCorrectValue() {
+ final ReportOptions actual = parseAddingRequiredArgs("");
+ assertEquals(
+ (int) ConfigOption.MUTATION_UNIT_SIZE.getDefault(Integer.class),
+ actual.getMutationUnitSize());
+ }
+
+ @Test
+ public void shouldDefaultToNoHistory() {
+ final ReportOptions actual = parseAddingRequiredArgs("");
+ assertNull(actual.getHistoryInputLocation());
+ assertNull(actual.getHistoryOutputLocation());
+ }
+
+ @Test
+ public void shouldParseHistoryInputLocation() {
+ final ReportOptions actual = parseAddingRequiredArgs(
+ "--historyInputLocation", "foo");
+ assertEquals(new File("foo"), actual.getHistoryInputLocation());
+ }
+
+ @Test
+ public void shouldParseHistoryOutputLocation() {
+ final ReportOptions actual = parseAddingRequiredArgs(
+ "--historyOutputLocation", "foo");
+ assertEquals(new File("foo"), actual.getHistoryOutputLocation());
+ }
+
+ @Test
+ public void shouldParseMutationThreshold() {
+ final ReportOptions actual = parseAddingRequiredArgs("--mutationThreshold",
+ "42");
+ assertEquals(42, actual.getMutationThreshold());
+ }
+
+ @Test
+ public void shouldParseMaximumAllowedSurvivingMutants() {
+ final ReportOptions actual = parseAddingRequiredArgs("--maxSurviving",
+ "42");
+ assertEquals(42, actual.getMaximumAllowedSurvivors());
+ }
+
+ @Test
+ public void shouldParseCoverageThreshold() {
+ final ReportOptions actual = parseAddingRequiredArgs("--coverageThreshold",
+ "42");
+ assertEquals(42, actual.getCoverageThreshold());
+ }
+
+ @Test
+ public void shouldDefaultToGregorEngineWhenNoOptionSupplied() {
+ final ReportOptions actual = parseAddingRequiredArgs();
+ 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");
+ assertEquals("foo", actual.getJavaExecutable());
+ }
+
+ @Test
+ public void shouldParseExportLineCoverageFlag() {
+ final ReportOptions actual = parseAddingRequiredArgs("--exportLineCoverage");
+ assertTrue(actual.shouldExportLineCoverage());
+ }
+
+ @Test
+ 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");
+ assertTrue(actual.isIncludeLaunchClasspath());
+ }
+
+ @Test
+ public void shouldHandleNotCanonicalLaunchClasspathElements() {
+ final String oldClasspath = System.getProperty(JAVA_CLASS_PATH_PROPERTY);
+ try {
+ // given
+ final PluginServices plugins = PluginServices.makeForContextLoader();
+ this.testee = new OptionsParser(new PluginFilter(plugins));
+ // and
+ System.setProperty(JAVA_CLASS_PATH_PROPERTY,
+ getNonCanonicalGregorEngineClassPath());
+ // when
+ final ReportOptions actual = parseAddingRequiredArgs("--includeLaunchClasspath=false");
+ // 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"));
+ }
+
+ @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"));
+ }
+
+ 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();
+ }
+
+ private Predicate gregorClass() {
+ return s -> GregorMutationEngine.class.getName().equals(s);
+ }
+
+ private ReportOptions parseAddingRequiredArgs(final String... args) {
+
+ final List a = new ArrayList<>();
+ a.addAll(Arrays.asList(args));
+ addIfNotPresent(a, "--targetClasses");
+ addIfNotPresent(a, "--reportDir");
+ addIfNotPresent(a, "--sourceDirs");
+ return parse(a.toArray(new String[a.size()]));
+ }
+
+ private void addIfNotPresent(final List uniqueArgs, final String value) {
+ if (!uniqueArgs.contains(value)) {
+ uniqueArgs.add(value);
+ uniqueArgs.add("ignore");
+ }
+ }
+
+ private ReportOptions parse(final String... args) {
+ return this.testee.parse(args).getOptions();
+ }
+
+}
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 e92c2a1f7..1a5dd3a67 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
@@ -1,38 +1,38 @@
-package org.pitest.mutationtest.commandline;
-
-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;
-
-public class PluginFilterTest {
-
- private final PluginFilter testee = new PluginFilter(new PluginServices(
- IsolationUtils.getContextClassLoader()));
-
- @Test
- public void shouldExcludeHtmlReportPlugin() throws Exception {
- final String pluginLocation = getClassLocationAsCanonicalPath(HtmlReportFactory.class);
- assertFalse(this.testee.test(pluginLocation));
- }
-
- @Test
- public void shouldIncludeMutationEngine() throws Exception {
- final String pluginLocation = getClassLocationAsCanonicalPath(GregorMutationEngine.class);
- assertTrue(this.testee.test(pluginLocation));
- }
-
- private String getClassLocationAsCanonicalPath(Class> clazz)
- throws URISyntaxException, IOException {
- return new File(clazz.getProtectionDomain().getCodeSource().getLocation()
- .toURI()).getCanonicalPath();
- }
-}
+package org.pitest.mutationtest.commandline;
+
+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;
+
+public class PluginFilterTest {
+
+ private final PluginFilter testee = new PluginFilter(new PluginServices(
+ IsolationUtils.getContextClassLoader()));
+
+ @Test
+ public void shouldExcludeHtmlReportPlugin() throws Exception {
+ final String pluginLocation = getClassLocationAsCanonicalPath(HtmlReportFactory.class);
+ assertFalse(this.testee.test(pluginLocation));
+ }
+
+ @Test
+ public void shouldIncludeMutationEngine() throws Exception {
+ final String pluginLocation = getClassLocationAsCanonicalPath(GregorMutationEngine.class);
+ assertTrue(this.testee.test(pluginLocation));
+ }
+
+ private String getClassLocationAsCanonicalPath(Class> clazz)
+ throws URISyntaxException, IOException {
+ return new File(clazz.getProtectionDomain().getCodeSource().getLocation()
+ .toURI()).getCanonicalPath();
+ }
+}
diff --git a/pitest-command-line/src/test/resources/testClassPathFile.txt b/pitest-command-line/src/test/resources/testClassPathFile.txt
index bd64cc8e4..44adeb876 100644
--- a/pitest-command-line/src/test/resources/testClassPathFile.txt
+++ b/pitest-command-line/src/test/resources/testClassPathFile.txt
@@ -1,2 +1,2 @@
-C:/foo
+C:/foo
/etc/bar
\ No newline at end of file
diff --git a/pitest-entry/pom.xml b/pitest-entry/pom.xml
index e04efc337..da8cbca28 100644
--- a/pitest-entry/pom.xml
+++ b/pitest-entry/pom.xml
@@ -1,181 +1,181 @@
-
-
-
- 4.0.0
-
- pitest-parent
- org.pitest
- 1.4.0-SNAPSHOT
-
- pitest-entry
- pitest-entry
- http://pitest.org
- Pitest entry point
-
-
-
-
-