Examples of SampleClientResult


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

    public SampleClientResult statefulClient(String addUrl, String trpUrl, int iterations) {
        boolean infinite = false;
        String session = null;

        SampleClientResult clientResult = new SampleClientResult();
        try {
            SOAPEnvelope env1 = buildSoapEnvelope("c1", "v1");
            SOAPEnvelope env2 = buildSoapEnvelope("c2", "v1");
            SOAPEnvelope env3 = buildSoapEnvelope("c3", "v1");
            SOAPEnvelope[] envelopes = {env1, env2, env3};

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

            int i = 0;
            int sessionNumber;
            String[] cookies = new String[3];
            boolean httpSession = session != null && "http".equals(session);
            int cookieNumber;
            while (i < iterations || infinite) {
                i++;
                MessageContext messageContext = new MessageContext();
                sessionNumber = getSessionTurn(envelopes.length);

                messageContext.setEnvelope(envelopes[sessionNumber]);
                cookieNumber = getSessionTurn(cookies.length);
                String cookie = cookies[cookieNumber];
                if (httpSession) {
                    setSessionID(messageContext, cookie);
                }
                try {
                    OperationClient op = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
                    op.addMessageContext(messageContext);
                    op.execute(true);

                    MessageContext responseContext =
                            op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                    String receivedCookie = extractSessionID(responseContext);
                    String receivedSetCookie = getSetCookieHeader(responseContext);
                    if (httpSession) {

                        if (receivedSetCookie != null && !"".equals(receivedSetCookie)) {
                            cookies[cookieNumber] = receivedCookie;
                        }
                    }

                    SOAPEnvelope responseEnvelope = responseContext.getEnvelope();
                    OMElement vElement =
                            responseEnvelope.getBody().getFirstChildWithName(new QName("Value"));
                    clientResult.incrementResponseCount();

                    log.info("Request: " + i + " with Session ID: " +
                                    (httpSession ? cookie : sessionNumber) + " ---- " +
                                    "Response : with  " + (httpSession && receivedCookie != null ?
                                    (receivedSetCookie != null ? receivedSetCookie :
                                            receivedCookie) : " ") + " " + vElement.getText());
                } catch (AxisFault axisFault) {
                    log.error("Request with session id " +
                            (httpSession ? cookie : sessionNumber) + " " +
                            "- Get a Fault : " + axisFault.getMessage(), axisFault);
                }
            }
        } 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 void testDynamicStaticKeys() {
        String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
        String trpUrl = "http://localhost:8280/";

        log.info("Running test: Introduction to dynamic and static keys ");
        SampleClientResult result = client.requestCustomQuote(addUrl, trpUrl, null, "IBM");
        assertResponseReceived(result);
    }
View Full Code Here

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

    public void testMessageEnrichment() {
        String trpUrl = "http://localhost:8280/services/StockQuote";

        log.info("Running test: Message Enrichment through Synapse");
        SampleClientResult result = client.requestStandardQuote(null, trpUrl, null, "IBM" ,null);
        assertResponseReceived(result);
    }
View Full Code Here

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

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

        log.info("Running test: Dynamic Sequences with Registry");
        SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM" ,null);
        assertResponseReceived(result);
    }
View Full Code Here

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

        String trpUrl = "http://localhost:8280";
        String expectedError_MSFT = "bogus";
        String expectedError_SUN = "Connection refused";

        log.info("Running test: Creating SOAP fault messages and changing the direction of a message");
        SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "MSFT" ,null);
        assertFalse("Must not get a response", result.responseReceived());
        Exception resultEx = result.getException();
        assertNotNull("Did not receive expected error", resultEx);
        log.info("Got an error as expected: " + resultEx.getMessage());
        assertTrue("Did not receive expected error", resultEx instanceof AxisFault);
        assertTrue("Did not receive expected error", resultEx.getMessage().indexOf(expectedError_MSFT)!=-1);

        result = client.requestStandardQuote(addUrl, trpUrl, null, "SUN" ,null);
        assertFalse("Must not get a response", result.responseReceived());
        resultEx = result.getException();
        assertNotNull("Did not receive expected error", resultEx);
        log.info("Got an error as expected: " + resultEx.getMessage());
        assertTrue("Did not receive expected error", resultEx instanceof AxisFault);
        assertTrue("Did not receive expected error", resultEx.getMessage().indexOf(expectedError_SUN)!=-1);

        result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM" ,null);
        assertFalse("Must not get a response", result.responseReceived());
        resultEx = result.getException();
        assertNotNull("Did not receive expected error", resultEx);
        log.info("Got an error as expected: " + resultEx.getMessage());
        assertTrue("Did not receive expected error", resultEx instanceof AxisFault);
    }
View Full Code Here

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

    public void testFullRegistryBasedConfig() {
        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

        String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
        String trpUrl = "http://localhost:8280";
        String expectedError = "Invalid custom quote request";

        log.info("Running test: Creating SOAP fault messages and changing the direction of a message");
        SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM",null);
        assertFalse("Should not get a response", result.responseReceived());
        Exception resultEx = result.getException();
        assertNotNull("Did not receive expected error", resultEx);
        log.info("Got an error as expected: " + resultEx.getMessage());
        assertTrue("Did not receive expected error", resultEx instanceof AxisFault);
        assertTrue("Did not receive expected error", resultEx.getMessage().indexOf(expectedError)!=-1);
View Full Code Here

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

    public void testDynamicEndPoints() {
        String trpUrl = "http://localhost:8280/";

        log.info("Running test: Dynamic EndPoints with Registry");
        SampleClientResult result = client.requestStandardQuote(null, trpUrl, null, "IBM", null);
        assertResponseReceived(result);
    }
View Full Code Here

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

    public void testCustomSequencesEndpointsWithProxy() {
        String addUrl = "http://localhost:8280/services/StockQuoteProxy1";
        String addUrl2 = "http://localhost:8280/services/StockQuoteProxy2";

        log.info("Running test: Custom sequences and endpoints with proxy services");
        SampleClientResult result1 = client.requestStandardQuote(addUrl, null, null, "IBM" ,null);
        assertTrue("Client did not get run successfully ", result1.responseReceived());
        SampleClientResult result2 = client.requestStandardQuote(addUrl2, null, null, "IBM" ,null);
        assertTrue("Client did not get run successfully ", result2.responseReceived());
    }
View Full Code Here

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


    public void testSessionFullLB() {
        String trpUrl = "http://localhost:8280/services/LBProxy";
        log.info("Running test: Load Balancing with Proxy Services ");
        SampleClientResult result = client.statefulClient(null, trpUrl, 100);
        assertTrue("Client did not run successfully ", result.responseReceived());
    }
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.