Search in sources :

Example 1 with HttpConsumerContext

use of org.apache.synapse.commons.emulator.http.dsl.HttpConsumerContext in project wso2-synapse by wso2.

the class HTTPProtocolEmulator method consumer.

@Override
public HttpConsumerContext consumer() {
    consumerContext = new HttpConsumerContext(this);
    setEmulatorType(EmulatorType.HTTP_CONSUMER);
    httpEmulatorConsumerInitializer = new HttpEmulatorConsumerInitializer(consumerContext);
    return consumerContext;
}
Also used : HttpConsumerContext(org.apache.synapse.commons.emulator.http.dsl.HttpConsumerContext) HttpEmulatorConsumerInitializer(org.apache.synapse.commons.emulator.http.consumer.HttpEmulatorConsumerInitializer)

Example 2 with HttpConsumerContext

use of org.apache.synapse.commons.emulator.http.dsl.HttpConsumerContext 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);
    }
}
Also used : HttpConsumerContext(org.apache.synapse.commons.emulator.http.dsl.HttpConsumerContext) HTTPProtocolEmulator(org.apache.synapse.commons.emulator.http.HTTPProtocolEmulator) Emulator(org.apache.synapse.commons.emulator.core.Emulator) HTTPProtocolEmulator(org.apache.synapse.commons.emulator.http.HTTPProtocolEmulator) ServiceResource(org.apache.synapse.unittest.testcase.data.classes.ServiceResource) MalformedURLException(java.net.MalformedURLException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

HttpConsumerContext (org.apache.synapse.commons.emulator.http.dsl.HttpConsumerContext)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 Emulator (org.apache.synapse.commons.emulator.core.Emulator)1 HTTPProtocolEmulator (org.apache.synapse.commons.emulator.http.HTTPProtocolEmulator)1 HttpEmulatorConsumerInitializer (org.apache.synapse.commons.emulator.http.consumer.HttpEmulatorConsumerInitializer)1 ServiceResource (org.apache.synapse.unittest.testcase.data.classes.ServiceResource)1