如何解决测试肥皂消费者 'uri' 不能为空
我有一个方法可以在通过 Soap 发送消息时调用“marshalSendAndReceive”方法。
class SoapConnector : WebServiceGatewaySupport() {
fun getClient(documentId: String): Person {
val request = getSearchRequest(documentId)
val response = webservicetemplate.marshalSendAndReceive(request) as SearchResponse
return getPerson(response)
}
@Configuration
class SearchClientConfig {
@Bean
fun marshaller(): Jaxb2Marshaller? {
return Jaxb2Marshaller().apply {
contextpath = "wsdl" //here path to generated java classes from wsdl
}
}
@Bean
fun searchCilent(marshallerJaxb: Jaxb2Marshaller): SoapConnector {
return SoapConnector().apply {
defaultUri = "http://20.40.59.1:8080/cdi/soap/services/ServiceWS"
marshaller = marshallerJaxb
unmarshaller = marshallerJaxb
}
}
}
我想模拟这个方法。
@RunWith(springrunner::class)
@SpringBoottest(webEnvironment = SpringBoottest.WebEnvironment.RANDOM_PORT)
@sql(scripts = ["classpath:db/init.sql"])
@AutoConfigureEmbeddedDatabase(
beanName = "dataSource",provider = AutoConfigureEmbeddedDatabase.DatabaseProvider.DOCKER
)
class SoapTest : WebServiceGatewaySupport(){
private lateinit var webServiceGatewaySupport: WebServiceGatewaySupport
private lateinit var connector: SoapConnector
@BeforeEach
fun setUp() {
webServiceGatewaySupport = Mockito.mock(WebServiceGatewaySupport::class.java)
}
@Test
fun getClienttest() {
Mockito.`when`(webservicetemplate.marshalSendAndReceive(ArgumentMatchers.anyObject())).thenReturn(SearchResponse())
connector.getClient(RandomStringUtils.randomAlphabetic(7))
}
}
java.lang.IllegalArgumentException: 'uri' must not be empty
我不明白问题出在哪里,也不知道如何制作此方法的有效 Mock。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。