Examples of SampleClientResult


Examples of org.apache.synapse.samples.framework.SampleClientResult

    public void testSmartClientMode() {
        String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
        String trpUrl = "http://localhost:8280/";

        log.info("Running test: Smart Client mode");
        SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM" ,null);
        assertResponseReceived(result);
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

    public void testSynapseAsHTTPProxy() {
        String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
        String prxUrl = "http://localhost:8280/";

        log.info("Running test: Using Synapse as a HTTP Proxy");
        SampleClientResult result = client.requestStandardQuote(addUrl, null, prxUrl, "IBM", null);
        assertResponseReceived(result);
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

    public void testFireAndForget() {
        String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
        String trpUrl = "http://localhost:8280/";

        log.info("Running test: One way messaging / fireAndForget through Synapse");
        SampleClientResult result = client.placeOrder(addUrl, trpUrl, null, "IBM");
        assertResponseReceived(result);
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

    public void testLocalEntriesReusableEndPointsSequences() {
        String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
        String trpUrl = "http://localhost:8280";

        log.info("Running test: Local Registry entry definitions, reusable endpoints and sequences");
        SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM" ,null);
        assertResponseReceived(result);
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

     * @return SampleClientResult containing the invocation outcome
     */
    public SampleClientResult requestStandardQuote(String addUrl, String trpUrl, String prxUrl,
                                                   String symbol, String svcPolicy) {
        log.info("sending standard quote request");
        SampleClientResult clientResult = new SampleClientResult();
        try {
            init(addUrl, trpUrl, prxUrl, svcPolicy, 10000);

            payload = StockQuoteHandler.createStandardQuoteRequest(
                    symbol, 1);
            serviceClient.getOptions().setAction("urn:getQuote");
            OMElement resultElement = serviceClient.sendReceive(payload);
            log.info("Standard :: Stock price = $" +
                    StockQuoteHandler.parseStandardQuoteResponse(resultElement));
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Error invoking service", e);
            clientResult.setException(e);
        }
        terminate();
        return clientResult;
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

    }

    public SampleClientResult requestDualQuote(String addUrl, String trpUrl,
                                               String prxUrl, String symbol) {
        log.info("sending dual quote request");
        SampleClientResult clientResult = new SampleClientResult();
        try {
            init(addUrl, trpUrl, prxUrl, null, 10000);

            payload = StockQuoteHandler.createStandardQuoteRequest(
                    symbol, 1);
            serviceClient.getOptions().setAction("urn:getQuote");
            setCompleted(false);
            serviceClient.sendReceiveNonBlocking(payload, new StockQuoteCallback(this));

            while (true) {
                if (isCompleted()) {
                    log.info("Standard dual channel :: Stock price = $" +
                            StockQuoteHandler.parseStandardQuoteResponse(getResponse()));
                    clientResult.incrementResponseCount();
                    break;
                } else {
                    Thread.sleep(100);
                }
            }
        } catch (Exception e) {
            log.error("Error invoking service", e);
            clientResult.setException(e);
        }
        terminate();
        return clientResult;
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

    }

    public SampleClientResult requestCustomQuote(String addUrl, String trpUrl,
                                                 String prxUrl, String symbol) {
        log.info("sending custom quote request");
        SampleClientResult clientResult = new SampleClientResult();
        try {
            init(addUrl, trpUrl, prxUrl, null, 10000);

            payload = StockQuoteHandler.createCustomQuoteRequest(symbol);
            serviceClient.getOptions().setAction("urn:getQuote");
            OMElement resultElement = serviceClient.sendReceive(payload);
            log.info("Custom :: Stock price = $" +
                    StockQuoteHandler.parseCustomQuoteResponse(resultElement));
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Error invoking service", e);
            clientResult.setException(e);
        }
        terminate();
        return clientResult;
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

        return clientResult;
    }

    public SampleClientResult placeOrder(String addUrl, String trpUrl, String prxUrl, String symbol) {
        log.info("sending fire and forget (place order) request");
        SampleClientResult clientResult = new SampleClientResult();
        try {
            init(addUrl, trpUrl, prxUrl, null, 10000);
            double price = getRandom(100, 0.9, true);
            int quantity = (int) getRandom(10000, 1.0, true);
            payload = StockQuoteHandler.createPlaceOrderRequest(price, quantity, symbol);
            serviceClient.getOptions().setAction("urn:placeOrder");

            serviceClient.fireAndForget(payload);
            Thread.sleep(5000);

            log.info("Order placed for " + quantity + " shares of stock " + symbol
                    + " at a price of $ " + price);
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Error invoking service", e);
            clientResult.setException(e);
        }
        terminate();
        return clientResult;
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

    }

    public SampleClientResult requestRestQuote(String addUrl, String trpUrl,
                                               String prxUrl, String symbol) {
        log.info("sending rest request");
        SampleClientResult clientResult = new SampleClientResult();
        try {
            init(addUrl, trpUrl, prxUrl, null, 10000);
            payload = StockQuoteHandler.createStandardQuoteRequest(symbol, 1);
            serviceClient.getOptions().setAction("urn:getQuote");
            serviceClient.getOptions().setProperty(Constants.Configuration.ENABLE_REST,
                    Constants.VALUE_TRUE);
            OMElement resultElement = serviceClient.sendReceive(payload);
            log.info("Standard :: Stock price = $" + StockQuoteHandler.
                    parseStandardQuoteResponse(resultElement));
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Error invoking service", e);
            clientResult.setException(e);
        }
        terminate();
        return clientResult;
    }
View Full Code Here

Examples of org.apache.synapse.samples.framework.SampleClientResult

        return clientResult;
    }


    public SampleClientResult sessionlessClient(String addUrl, String trpUrl, int iterations) {
        SampleClientResult clientResult = new SampleClientResult();
        try {
            boolean infinite = iterations <= 0;
            OMFactory fac = OMAbstractFactory.getOMFactory();
            OMElement value = fac.createOMElement("Value", null);
            value.setText("Sample string");

            init(addUrl, trpUrl, null, null, 10000);
            serviceClient.getOptions().setAction("urn:sampleOperation");

            String testString = "";
            long i = 0;
            while (i < iterations || infinite) {
                serviceClient.getOptions().setManageSession(true);
                OMElement responseElement = serviceClient.sendReceive(value);
                String response = responseElement.getText();
                clientResult.incrementResponseCount();

                i++;
                log.info("Request: " + i + " ==> " + response);
                testString = testString.concat(":" + i + ">" + response + ":");
            }
        } catch (Exception e) {
            log.error("Error invoking service", e);
            clientResult.setException(e);
        }
        terminate();
        return clientResult;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.