java - 从 SoapUI 项目执行 Java 方法
问题描述
我有一个Java
项目和一个带有方法的测试类,应该Groovy
从SoapUI
. 要执行的方法:
@Test
public void testPkcs12() throws IOException {
try (Pkcs12SignatureToken signatureToken = new Pkcs12SignatureToken("src/test/resources/user_a_rsa.p12",
new PasswordProtection("password".toCharArray()))) {
assertNotNull(signatureToken);
List<DSSPrivateKeyEntry> keys = signatureToken.getKeys();
assertFalse(keys.isEmpty());
KSPrivateKeyEntry dssPrivateKeyEntry = (KSPrivateKeyEntry) keys.get(0);
assertNotNull(dssPrivateKeyEntry);
assertNotNull(dssPrivateKeyEntry.getAlias());
DSSPrivateKeyEntry entry = signatureToken.getKey(dssPrivateKeyEntry.getAlias(), new PasswordProtection("password".toCharArray()));
assertNotNull(entry);
assertNotNull(entry.getCertificate());
assertNotNull(entry.getCertificateChain());
assertNotNull(entry.getEncryptionAlgorithm());
ToBeSigned toBeSigned = new ToBeSigned("Hello world".getBytes("UTF-8"));
SignatureValue signValue = signatureToken.sign(toBeSigned, DigestAlgorithm.SHA256, entry);
assertNotNull(signValue);
assertNotNull(signValue.getAlgorithm());
assertNotNull(signValue.getValue());
System.out.println(DatatypeConverter.printBase64Binary(signValue.getValue()));
}
}
jar
我使用以下插件生成了文件。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
我叫它SoapUI
:
import eu.europa.esig.dss.token.Pkcs12SignatureTokenTest;
log.info Pkcs12SignatureTokenTest.testPkcs12();
我收到以下错误消息:
groovy.lang.MissingMethodException:没有方法签名:静态 eu.europa.esig.dss.token.Pkcs12SignatureTokenTest.testPkcs12() 适用于参数类型:() 值:[] 可能的解决方案:testPkcs12() 行错误:3
解决方案
你试图打电话testPkcs12
,好像它是静态的,但显然不是。试试看嘛:
import eu.europa.esig.dss.token.Pkcs12SignatureTokenTest
new Pkcs12SignatureTokenTest().testPkcs12()
推荐阅读
- javascript - 测试角度绑定
- java - Eclipse RCP 中的动态字段和方法注入
- php - XML 数据到多维数组
- sharepoint-2016 - SP2016 - SP2016 FP2 上的 Spfx Webpart
- intel-pin - Intel-Pin获取的malloc首内存地址的差异
- jstree - Bootstrap Treeview - 按属性值查找节点
- android - 为 Android 构建 Qt 应用程序 - 移动失败
- java - 尝试从 strings.xml 获取字符串数组时出错
- linux - 如何从特定文件夹中生成 PID
- primes - 如何为 a^p 绘制图灵机,其中 p 是质数?