@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) {
ClassLoader loader = ManagePriceLinePortTypeImpl.class.getClassLoader();
java.io.InputStream stream = loader.getResourceAsStream("logHandling.properties"); // stream as null
LoggingFramework.initialise(stream);
SearchDataResponse response =new SearchDataResponse();
response.setErrorCode("OK");
return response;
}
public void test();
{
System.out.println("TEST Method");
}
}
在上面的代码片段中,我试图从src位置外部读取属性文件,但由于空流而导致文件未找到异常。
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 {
ManageSearchDataService mockObj ;
@Test
public void doSomething() {
SearchDataRequest searchDataRequest= new SearchDataRequest();
searchDataRequest.setStandardHeader(HeaderClass.getMPLNHeader("ASV"));
SearchDataResponse respose =mockObj.searchData(searchDataRequest);
System.out.println("=== "+respose.getErrorCode());
}
}