I am currently trying to write a test that is run via Maven that specifically addresses strings containing UTF-8 characters. If I run said test in IntelliJ everything is fine and the results are as expected. If i run the test using mvn test, then (only) the test that is testing UTF-8 characters is failing.
This is my test:
@Test public void testWithUTF8() throws InvalidKeyException, NoSuchAlgorithmException { String signature = NFLAuth.sign("Contains UTF-8: äüöööÕßÍÑð"); Assert.assertEquals("Signature=BSY4prbinpAgzJLv6ffGm+XJb1NTIbGY6gTj8RA3lsA=", signature); } First of all, yes, I read the question about encoding in Maven and I did everything. Theres the property, its added to the compiler plugin, I have even set JAVA_TOOL_OPTIONS with file.encoding but still no luck. I also dont know what encoding it is using, if I try windows-1252 in IntelliJ the test also fails, but the signature is not the same as maven gets.
Here is the POM:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>***</groupId> <artifactId>***</artifactId> <version>1.0</version> <name>***</name> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.4</version> </dependency> <dependency> <groupId>com.apigee.edge.4g</groupId> <artifactId>expressions</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>com.apigee.edge.4g</groupId> <artifactId>message-flow</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>com.apigee.edge.4g</groupId> <artifactId>kernel</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/kernel-api-1.0.0.jar</systemPath> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.10.19</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.21</version> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.9.2</version> </dependency> </dependencies> </project>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>? If not, try to do this"\u00E4\u00F6\u00FC..."(äöü...). Especially as Windows-1252 would cover the letters too.NFLAuth.sign("\u00E4\u00F6\u00FC");and within that method I printed thegetBytes()of the input variable. IntelliJ:C3 A4 C3 B6 C3 BCMaven:E4 F6 FCSo apparently it is not using UTF-8 encoding in Maven...