use of org.apache.synapse.commons.emulator.core.Emulator in project wso2-synapse by wso2.
the class MockServiceCreator method startMockServiceServer.
/**
* Start service for given parameters using emulator.
*
* @param mockServiceName endpoint name given in descriptor data
* @param host domain of the url
* @param context path of the url
* @param resources resources of the service
*/
static void startMockServiceServer(String mockServiceName, String host, int port, String context, List<ServiceResource> resources) {
try {
HTTPProtocolEmulator httpEmulator = new Emulator().getHttpProtocolEmulator();
emulatorServiceList.add(httpEmulator);
HttpConsumerContext emulator = httpEmulator.consumer().host(host).port(port).context(context);
for (ServiceResource resource : resources) {
routeThroughResourceMethod(resource, emulator);
}
emulator.operations().start();
log.info("Mock service started for " + mockServiceName + " in - http://" + host + ":" + port + context);
} catch (Exception e) {
log.error("Error in initiating mock service named " + mockServiceName, e);
}
}
Aggregations