[MPMD-369] Make integration tests robust against system encoding (#122)
* MPMD-369 Make integration tests robust against system encoding
* format
diff --git a/src/main/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojo.java b/src/main/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojo.java
index 9fab222..3feab0d 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojo.java
@@ -20,8 +20,9 @@
*/
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
@@ -114,13 +115,12 @@
* {@inheritDoc}
*/
@Override
- protected List<Duplication> getErrorDetails( File cpdFile )
- throws XmlPullParserException, IOException
+ protected List<Duplication> getErrorDetails( File cpdFile ) throws XmlPullParserException, IOException
{
- try ( FileReader fileReader = new FileReader( cpdFile ) )
+ try ( InputStream in = new FileInputStream( cpdFile ) )
{
CpdXpp3Reader reader = new CpdXpp3Reader();
- CpdErrorDetail details = reader.read( fileReader, false );
+ CpdErrorDetail details = reader.read( in, false );
return details.getDuplications();
}
}
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojo.java b/src/main/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojo.java
index 8ff7e62..39cb7ef 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojo.java
@@ -20,8 +20,9 @@
*/
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -124,14 +125,12 @@
}
@Override
- protected List<Violation> getErrorDetails( File pmdFile )
- throws XmlPullParserException, IOException
+ protected List<Violation> getErrorDetails( File pmdFile ) throws XmlPullParserException, IOException
{
- try ( FileReader reader1 = new FileReader( pmdFile ) )
+ try ( InputStream in = new FileInputStream( pmdFile ) )
{
PmdXpp3Reader reader = new PmdXpp3Reader();
- PmdErrorDetail details = reader.read( reader1, false );
-
+ PmdErrorDetail details = reader.read( in, false );
List<Violation> violations = new ArrayList<>();
for ( PmdFile file : details.getFiles() )
{