@WebService(name = "ManageSearchDataPortType", targetNamespace = "https://abc/searchData", serviceName = "ManageSearchData", portName = "ManageSearchDataPort", wsdlLocation = "/WEB-INF/wsdl/ManageSearchData.wsdl")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
import com.xyz.SearchDataRequest;
import com.xyz.SearchDataResponse;
@XmlSeeAlso({ ObjectFactory.class, com.abc.ObjectFactory.class, com.abc..ObjectFactory.class, com.abc..ObjectFactory.class })
public class ManageSearchDataService {
@WebResult(name = "searchDataResponse", partName = "searchDataResponse", targetNamespace = "https://abc/searchData")
@WebMethod(action = "http://example.com/wsdl/ManageABC/2008/10/22#searchData")
public SearchDataResponse searchData(@WebParam(name = "searchDataRequest", partName = "searchDataRequest", targetNamespace = "https://abc/searchData")
SearchDataRequest searchDataRequest) {
System.out.println(" searchData Methodthod");
}
public void test();
{
System.out.println("TEST Method");
}
}
下面的工作是我的的JUnit的Mockito測試類包含即DoSomething的測試方法。在這裏,我想麥克其上面顯示包含searchData和測試方法ManageSearchDataService類,但SOAP與MockitoJUnit沒有在java中
searchData不會被調用的模擬對象
和正常的測試方法已成功地調用。 searchData是我的WebMethod,您可以看到該方法。
HeaderClass只是包含getMPLNHeader靜態方法的普通調用。
請任何人有任何想法如何做到這一點讓我知道。
package com.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import com.xyz.SearchDataRequest;
import com.aaa.ManageSearchDataService;
@RunWith(MockitoJUnitRunner.class)
public class JunitTestClass {
@Mock ManageSearchDataService mockObj ;
@Test
public void doSomething() {
SearchDataRequest searchDataRequest= new SearchDataRequest();
searchDataRequest.setStandardHeader(HeaderClass.getMPLNHeader("ASV"));
mockObj.searchData(searchDataRequest); // not Working
mockObj.test(); // this working fine printing data
}
}
這是模擬對象的預期行爲。他們不會調用這個方法,但會給你你嘲笑的結果。 'mockobj.when(methodname).then(result)' – Deepak