0
Spring WebServiceTemplate을 사용하여 SOAP Webservice를 사용하고 있습니다. JUnit을 실행하는 동안 나는 문제에 직면하고있다.JUnit for Spring WebServiceTemplate이 작동하지 않습니다.
내 고객 클래스 :
@Service
public class MyWsClient extends WebServiceGatewaySupport {
@Autowired
private WebServiceTemplate webServiceTemplate;
public String getData(...) throws Exception{
...
SampleResponse response = (SampleResponse) webServiceTemplate.marshalSendAndReceive(request);
...
return response.getData();
}}
내 테스트 클래스 :
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext-junit.xml"})
public class MyWsClientTest {
@Autowired
ApplicationContext applicationContext;
@InjectMocks
MyWsClient myWsClient;
private MockWebServiceServer mockServer;
@Before
public void init() {
MockitoAnnotations.initMocks(this);
mockServer = MockWebServiceServer.createServer(applicationContext);
}
@Test
public void testGetData() throws Exception {
Source expectedRequestPayload = new StringSource(
"<customerCountRequest xmlns=\"http://springframework.org/spring-ws/test\" />");
Source responsePayload = new StringSource(
"<customerCountResponse xmlns='http://springframework.org/spring-ws/test'>"
+ "<customerCount>10</customerCount>" + "</customerCountResponse>");
mockServer.expect(RequestMatchers.payload(expectedRequestPayload)).andRespond(ResponseCreators.withPayload(responsePayload));
String data = myWsClient.getData(...);
assertNotNull(data);
mockServer.verify();
}}
문제 :
난 내 테스트 케이스 나는 라인 NullPointerException이 무엇입니까를 실행 " 내 Clie 내부의 webServiceTemplate.marshalSendAndReceive (요청) " NT 클래스.
webServiceTemplate이 null로 제공됩니다.
내가 뭘 잘못하고 있는지 알기!