@Override
                    public IApiConnector createConnector(ApiRequest request, Api api, RequiredAuthType requiredAuthType, boolean hasDataPolicy, IConnectorConfig connectorConfig) {
                        Assert.assertEquals("test", api.getEndpointType());
                        Assert.assertEquals("test:endpoint", api.getEndpoint());
                        IApiConnector connector = new IApiConnector() {

                            /**
                             * @see io.apiman.gateway.engine.IApiConnector#connect(io.apiman.gateway.engine.beans.ApiRequest, io.apiman.gateway.engine.async.IAsyncResultHandler)
                             */
                            @Override
                            public IApiConnection connect(ApiRequest request,
                                    IAsyncResultHandler<IApiConnectionResponse> handler)
                                    throws ConnectorException {
                                final ApiResponse response = new ApiResponse();
                                response.setCode(200);
                                response.setMessage("OK"); //$NON-NLS-1$

                                mockApiConnectionResponse = new MockApiConnectionResponse() {

                                    @Override
                                    public void write(IApimanBuffer chunk) {
                                        handleBody(chunk);
                                    }

                                    @Override
                                    protected void handleHead(ApiResponse head) {
                                        return;
                                    }

                                    @Override
                                    public ApiResponse getHead() {
                                        return response;
                                    }

                                    @Override
                                    public void end() {
                                        handleEnd();
                                    }

                                    @Override
                                    public void transmit() {
                                        transmitHandler.handle((Void) null);
                                    }

                                    @Override
                                    public void abort(Throwable t) {
                                    }
                                };

                                IAsyncResult<IApiConnectionResponse> mockResponseResultHandler = mock(IAsyncResult.class);
                                given(mockResponseResultHandler.isSuccess()).willReturn(true);
                                given(mockResponseResultHandler.isError()).willReturn(false);
                                given(mockResponseResultHandler.getResult()).willReturn(mockApiConnectionResponse);

                                mockApiConnection = mock(MockApiConnection.class);
                                given(mockApiConnection.getHead()).willReturn(request);

                                // Handle head
                                handler.handle(mockResponseResultHandler);

                                return mockApiConnection;
                            }

                        };
                        return connector;
                    }
Test method for {@link io.apiman.gateway.engine.impl.AbstractEngineFactory#createEngine()}.
@throws ExecutionException
@throws InterruptedException
gateway/engine/core/src/test/java/io/apiman/gateway/engine/impl/DefaultEngineFactoryTest.java