Package com.eviware.soapui.model.mock

Examples of com.eviware.soapui.model.mock.MockService


                UISupport.showErrorMessage("No Operations selected..");
                return;
            }

            String mockServiceName = dialog.getValue(Form.MOCKSERVICE);
            MockService mockService = getMockService(iface, project, mockServiceName);
            if (mockService == null) {
                return;
            }

            mockService.setPath(dialog.getValue(Form.PATH));

            try {
                mockService.setPort(Integer.parseInt(dialog.getValue(Form.PORT)));
            } catch (NumberFormatException e1) {
            }

            for (int i = 0; i < iface.getOperationCount(); i++) {
                Operation operation = iface.getOperationAt(i);
                if (!operations.contains(operation.getName())) {
                    continue;
                }

                MockOperation mockOperation = mockService.addNewMockOperation(operation);
                if (mockOperation != null) {
                    mockOperation.addNewMockResponse("Response 1");
                }
            }

            if (dialog.getBooleanValue(Form.ADD_ENDPOINT)) {
                iface.addEndpoint(mockService.getLocalEndpoint());
            }

            if (!atCreation) {
                WsdlMockServiceDesktopPanel desktopPanel = (WsdlMockServiceDesktopPanel) UISupport
                        .showDesktopPanel(mockService);
View Full Code Here


            }
        }
    }

    public MockService getMockService(AbstractInterface modelItem, WsdlProject project, String mockServiceName) {
        MockService mockService = project.getMockServiceByName(mockServiceName);

        if (mockService == null || mockServiceName.equals(CREATE_MOCKSUITE_OPTION)) {
            mockServiceName = UISupport.prompt("Specify name of MockService to create", getName(), modelItem.getName()
                    + " MockService");
            if (mockServiceName != null) {
View Full Code Here

        MockRequest mockRequest = modelItem.getMockResult().getMockRequest();
        requestMessage.addNewMessageContent().setStringValue(mockRequest.getRequestContent());
        requestMessage.setConversationID("1");
        requestMessage.setTimestamp(Calendar.getInstance());
        requestMessage.setID("1");
        MockService mockService = modelItem.getMockOperation().getMockService();
        URL endpoint = new URL("http://127.0.0.1:" + mockService.getPort() + mockService.getPath());
        requestMessage.setSenderHostAndPort("localhost");

        if (endpoint.getPort() > 0) {
            requestMessage.setReceiverHostAndPort(endpoint.getHost() + ":" + endpoint.getPort());
        } else {
View Full Code Here

        String dispatchScript = getMockOperation().getScript();
        if (StringUtils.hasContent(dispatchScript)) {
            SoapUIScriptEngine scriptEngine = scriptEnginePool.getScriptEngine();

            try {
                MockService mockService = getMockOperation().getMockService();
                MockRunner mockRunner = mockService.getMockRunner();
                MockRunContext context = mockRunner == null ? new WsdlMockRunContext(mockService, null) : mockRunner
                        .getMockContext();

                scriptEngine.setVariable("context", context);
                scriptEngine.setVariable("requestContext", request == null ? null : request.getRequestContext());
View Full Code Here

        log.info("Press any key to terminate");

        long startTime = System.nanoTime();

        for (int c = 0; c < project.getMockServiceCount(); c++) {
            MockService mockService = project.getMockServiceAt(c);
            if (this.mockService == null || mockService.getName().equals(this.mockService)) {
                runMockService(mockService);
            }
        }

        for (int c = 0; c < project.getRestMockServiceCount(); c++) {
            MockService mockService = project.getRestMockServiceAt(c);
            if (this.mockService == null || mockService.getName().equals(this.mockService)) {
                runMockService(mockService);
            }
        }

        log.info("Started " + runners.size() + " runner" + ((runners.size() == 1) ? "" : "s"));
View Full Code Here

        TestStep testStep = null;
        TestCase testCase = null;
        TestSuite testSuite = null;
        Project project = null;
        MockService mockService = null;
        AbstractMockResponse mockResponse = null;
        SecurityTest securityTest = null;

        if (modelItem instanceof WsdlTestStep) {
            testStep = (WsdlTestStep) modelItem;
            testCase = testStep.getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlTestCase) {
            testCase = (WsdlTestCase) modelItem;
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlLoadTest) {
            testCase = ((WsdlLoadTest) modelItem).getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlTestSuite) {
            testSuite = (WsdlTestSuite) modelItem;
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlInterface) {
            project = ((WsdlInterface) modelItem).getProject();
        } else if (modelItem instanceof WsdlProject) {
            project = (WsdlProject) modelItem;
        } else if (modelItem instanceof WsdlMockService) {
            mockService = (WsdlMockService) modelItem;
            project = mockService.getProject();
        } else if (modelItem instanceof TestRequest) {
            testStep = ((TestRequest) modelItem).getTestStep();
            testCase = testStep.getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof AbstractHttpRequestInterface<?>) {
            project = ((AbstractHttpRequest<?>) modelItem).getOperation().getInterface().getProject();
        } else if (modelItem instanceof RestResource) {
            project = modelItem.getProject();
        } else if (modelItem instanceof WsdlMockOperation) {
            mockService = ((WsdlMockOperation) modelItem).getMockService();
            project = mockService.getProject();
        } else if (modelItem instanceof AbstractMockResponse) {
            mockResponse = (AbstractMockResponse) modelItem;
            mockService = mockResponse.getMockOperation().getMockService();
            project = mockService.getProject();
        } else if (modelItem instanceof SecurityTest) {
            securityTest = (SecurityTest) modelItem;
            testCase = ((SecurityTest) modelItem).getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
View Full Code Here

        return false;
    }

    public static boolean hasDependingMockOperations(WsdlInterface iface) {
        for (int c = 0; c < iface.getProject().getMockServiceCount(); c++) {
            MockService mockService = iface.getProject().getMockServiceAt(c);
            for (int i = 0; i < mockService.getMockOperationCount(); i++) {
                MockOperation mockOperation = mockService.getMockOperationAt(i);
                if (mockOperation.getOperation().getInterface() == iface) {
                    return true;
                }
            }
        }
View Full Code Here

        if (server == null) {
            initServer();
        }

        synchronized (server) {
            MockService mockService = runner.getMockContext().getMockService();
            int port = mockService.getPort();

            if (SoapUI.getSettings().getBoolean(SSLSettings.ENABLE_MOCK_SSL) && !addedSslConnector) {
                updateSslConnectorSettings();
                server.addConnector(sslConnector);
                addedSslConnector = true;
            } else {
                if (addedSslConnector) {
                    server.removeConnector(sslConnector);
                }

                addedSslConnector = false;
            }

            if (!runners.containsKey(port)) {
                SoapUIConnector connector = new SoapUIConnector();
                PropertySupport.applySystemProperties(connector, "soapui.mock.connector", runner.getMockContext().getMockService());

                connector.setPort(port);
                if (sslConnector != null) {
                    connector.setConfidentialPort(sslConnector.getPort());
                }

                if (mockService.getBindToHostOnly()) {
                    String host = PropertyExpander.expandProperties(mockService, mockService.getHost());
                    if (StringUtils.hasContent(host)) {
                        connector.setHost(host);
                    }
                }

                boolean wasRunning = server.isRunning();

                if (wasRunning) {
                    server.stop();
                }

                server.addConnector(connector);
                try {
                    server.start();
                } catch (RuntimeException e) {
                    UISupport.showErrorMessage(e);

                    server.removeConnector(connector);
                    if (wasRunning) {
                        server.start();
                        return;
                    }
                }

                connectors.put(port, connector);
                runners.put(port, new HashMap<String, List<MockRunner>>());
            }

            Map<String, List<MockRunner>> map = runners.get(port);
            String path = mockService.getPath();
            if (!map.containsKey(path)) {
                map.put(path, new ArrayList<MockRunner>());
            }
            map.get(path).add(runner);
            mockRunners.add(runner);

            log.info("Started mockService [" + mockService.getName() + "] on port [" + port + "] at path [" + path + "]");
        }
    }
View Full Code Here

        sslConnector.setNeedClientAuth(SoapUI.getSettings().getBoolean(SSLSettings.CLIENT_AUTHENTICATION));
    }

    public void stopMockService(MockRunner runner) {
        synchronized (server) {
            MockService mockService = runner.getMockContext().getMockService();
            final Integer port = mockService.getPort();
            Map<String, List<MockRunner>> map = runners.get(port);

            if (map == null || !map.containsKey(mockService.getPath())) {
                return;
            }

            map.get(mockService.getPath()).remove(runner);
            if (map.get(mockService.getPath()).isEmpty()) {
                map.remove(mockService.getPath());
            }

            mockRunners.remove(runner);

            log.info("Stopped MockService [" + mockService.getName() + "] on port [" + port + "]");

            if (map.isEmpty() && !SoapUI.getSettings().getBoolean(HttpSettings.LEAVE_MOCKENGINE)) {
                SoapUIConnector connector = connectors.get(port);
                if (connector == null) {
                    log.warn("Missing connectors on port [" + port + "]");
View Full Code Here

        WsdlTestStep testStep;
        WsdlTestCase testCase = null;
        WsdlTestSuite testSuite = null;
        WsdlProject project = null;
        MockService mockService = null;
        MockResponse mockResponse = null;
        SecurityTest securityTest = null;

        if (modelItem instanceof WsdlTestStep) {
            testStep = (WsdlTestStep) modelItem;
            testCase = testStep.getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlTestCase) {
            testCase = (WsdlTestCase) modelItem;
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlTestSuite) {
            testSuite = (WsdlTestSuite) modelItem;
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlMockService) {
            project = ((WsdlMockService) modelItem).getProject();
        } else if (modelItem instanceof MockResponse) {
            mockResponse = (MockResponse) modelItem;
            mockService = (mockResponse).getMockOperation().getMockService();
            project = mockService.getProject();
        } else if (modelItem instanceof WsdlProject) {
            project = (WsdlProject) modelItem;
        } else if (modelItem instanceof AbstractHttpRequestInterface<?>) {
            project = ((AbstractHttpRequest<?>) modelItem).getOperation().getInterface().getProject();
        } else if (modelItem instanceof Operation) {
            project = (WsdlProject) ((Operation) modelItem).getInterface().getProject();
        } else if (modelItem instanceof SecurityTest) {
            securityTest = (SecurityTest) modelItem;
            testCase = securityTest.getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        }

        TestPropertyHolder globalProperties = PropertyExpansionUtils.getGlobalProperties();
        if (globalProperties.getProperties().size() > 0) {
            targetMenu.add(createPropertyMenu("Global", globalProperties));
        }

        if (project != null) {
            targetMenu.add(createPropertyMenu("Project: [" + project.getName() + "]", project));
        }

        if (testSuite != null) {
            targetMenu.add(createPropertyMenu("TestSuite: [" + testSuite.getName() + "]", testSuite));
        }

        if (mockService != null) {
            targetMenu.add(createPropertyMenu("MockService: [" + mockService.getName() + "]", mockService));
        }

        if (mockResponse != null) {
            targetMenu.add(createPropertyMenu("MockResponse: [" + mockResponse.getName() + "]", mockResponse));
        }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.model.mock.MockService

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.