Package com.gatehill.apibms.core.model

Examples of com.gatehill.apibms.core.model.ExecutionInstance


     * @param port          the port on which to listen for connections
     * @return the return code for the operation, where <code>0</code> indicates success
     */
    public int runApplication(File blueprintFile, MockFactory.BlueprintFormat format, String host, Integer port) {
        // start server from blueprint
        final ExecutionInstance exec =
                executionService.execute(blueprintFile, format, host, port);

        LOGGER.info("Starting server on port {}", exec.getPort());

        // print endpoints
        final StringBuilder sbEndpoints = new StringBuilder();
        sbEndpoints.append("Endpoints:");
        for (ResourceDefinition endpoint : exec.getEndpoints()) {
            sbEndpoints.append(String.format("\r\n(%s) http://%s:%s%s",
                    listRequestMethods(endpoint), exec.getHost(), exec.getPort(), endpoint.getUrl()));
        }
        LOGGER.info(sbEndpoints.toString());
        LOGGER.info("Add ?blueprint to the end of an endpoint to see its documentation");

        try {
View Full Code Here


    public void testReadBlueprintAndStartMock() throws Exception {
        // blueprint file
        final File jsonAst = new File(EndToEndTest.class.getResource("/api1.json").getPath());

        // start server from blueprint
        final ExecutionInstance exec = service.execute(jsonAst, MockFactory.BlueprintFormat.AST_JSON);

        // assert
        Assert.assertNotNull(exec);
        Assert.assertNotNull(exec.getEndpoints());
        Assert.assertEquals(1, exec.getEndpoints().length);

        // test endpoint
        RestAssured
                .get("http://localhost:" + exec.getPort() + "/message")
                .then()
                .assertThat()
                .statusCode(is(StatusCodes.OK))
                .and()
                .body(equalTo("Hello World!\n"));
View Full Code Here

    @Override
    public ExecutionInstance execute(File blueprintFile, MockFactory.BlueprintFormat format, String host, int port) throws ServiceException {
        final MockDefinition definition = mockFactory.createMock(blueprintFile, format);
        final MockServer server = serverService.start(definition, host, port);

        return new ExecutionInstance(server.getHost(), server.getPort(),
                definition.getEndpoints().toArray(new ResourceDefinition[definition.getEndpoints().size()]));
    }
View Full Code Here

        when(serverService.start(mock, ServerService.HOST_LOCALHOST, PORT))
                .thenReturn(server);

        // start server from blueprint
        final ExecutionInstance actual = service.execute(jsonAst, MockFactory.BlueprintFormat.AST_JSON, PORT);

        // assert
        Assert.assertNotNull(actual);
        Assert.assertEquals(PORT, actual.getPort());

        Assert.assertNotNull(actual.getEndpoints());
        Assert.assertEquals(1, actual.getEndpoints().length);

        // verify behaviour
        verify(mockFactory, times(1)).createMock(any(File.class), any(MockFactory.BlueprintFormat.class));
        verify(serverService, times(1)).start(mock, ServerService.HOST_LOCALHOST, PORT);
        verifyNoMoreInteractions(mockFactory, serverService);
View Full Code Here

TOP

Related Classes of com.gatehill.apibms.core.model.ExecutionInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.