Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ under the License.
<properties>
<mavenVersion>3.0</mavenVersion>
<javaVersion>7</javaVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
* under the License.
*/

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -122,7 +123,7 @@ private VerificationResult verify()
{
VerificationResult results = new VerificationResult();

try ( Reader reader = new FileReader( verificationFile ) )
try ( BufferedReader reader = Files.newBufferedReader( verificationFile.toPath(), StandardCharsets.UTF_8 ) )
{
VerificationsXpp3Reader xppReader = new VerificationsXpp3Reader();
Verifications verifications = xppReader.read( reader );
Expand Down Expand Up @@ -176,7 +177,8 @@ private boolean verifyFileContent( org.apache.maven.plugins.verifier.model.File

// Note: Very inefficient way as we load the whole file in memory. If you have a better
// idea, please submit it!
Matcher matcher = pattern.matcher( FileUtils.fileRead( new File( fileCheck.getLocation() ) ) );
Matcher matcher = pattern.matcher(
FileUtils.fileRead( new File( fileCheck.getLocation() ), StandardCharsets.UTF_8.toString() ) );

if ( matcher.find() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,25 @@ public void print( VerificationResult result )
}
}

@Test
public void testCheckKoi8FileForContent()
throws Exception
{
VerifierMojo mojo = new VerifierMojo();
File file = getResourceFile("/FileExistsIncorrectEncoding.xml");
mojo.setBaseDir( file.getParentFile() );
mojo.setVerificationFile( file );
mojo.setVerificationResultPrinter( new VerificationResultPrinter()
{
public void print( VerificationResult result )
{
assertEquals( 0, result.getExistenceFailures().size() );
assertEquals( 0, result.getNonExistenceFailures().size() );
assertEquals( 1, result.getContentFailures().size() );
}
} );

mojo.execute();
}

}
27 changes: 27 additions & 0 deletions src/test/resources/FileExistsIncorrectEncoding.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<verifications>
<files>
<file>
<location>textInKOI-8-encoding.txt</location>
<contains>кодировке</contains>
</file>
</files>
</verifications>
1 change: 1 addition & 0 deletions src/test/resources/textInKOI-8-encoding.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��������� � ��������� �� UTF-8