我有一个包含一些测试用例的 Maven 项目。今天我尝试添加 jarsigner 插件,现在测试失败了:
java.lang.SecurityException:类“types.AccountType”的签名者信息与同一包中其他类的签名者信息不匹配
测试类在同一个包中,可以访问包私有(private)方法等。我相信这个错误正在发生,因为当被测试的类被签名时,junit 测试类没有被签名。
有没有人有关于如何避免这个问题的建议?我有一些想法,但不知道如何实现它们:
最佳答案
我今天遇到了这个问题,问题就像你多年前猜到的那样(签署订单问题)。这对我来说是修复(更改安装阶段):
<plugin>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>${maven-jarsigner-plugin.version}</version>
<executions>
<execution>
<id>sign</id>
<!-- note: this needs to be bound after integration tests or they will fail re: not signed -->
<phase>install</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<tsa>http://sha256timestamp.ws.symantec.com/sha256/timestamp</tsa>
<keystore>${project.basedir}/.conf/Keystore</keystore>
<alias>Alias</alias>
<storepass>{1234}</storepass>
</configuration>
</plugin>
jar 仍然被签名并且集成测试再次工作。
关于Maven + jarsigner + 测试类 = 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21879945/