Package org.apache.synapse.samples.framework

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


            subscribeOm.addChild(expiresOm); // Add only if the value provided
        }
        subscribeOm.addChild(filterOm);

        log.info("Subscribing: " + subscribeOm.toString());
        SampleClientResult clientResult = new SampleClientResult();
        try {
            initializeClient(addUrl);
            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe");

            OMElement response = serviceClient.sendReceive(subscribeOm);
            log.info("Subscribed to topic " + topic);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {

            }
            log.info("Response Received: " + response.toString());
            String subId =
                    response.getFirstChildWithName(
                            new QName(eventingNamespace.getNamespaceURI(), "SubscriptionManager"))
                            .getFirstChildWithName(
                                    new QName(addressingNamespace.getNamespaceURI(), "ReferenceParameters"))
                            .getFirstChildWithName(
                                    new QName(eventingNamespace.getNamespaceURI(), "Identifier")).getText();
            log.info("Subscription identifier: " + subId);
            clientResult.addProperty("subId", subId);
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Fault Received : " + e.toString(), e);
            clientResult.setException(e);
        }
        deInitializeClient();
        return clientResult;

    }
View Full Code Here


         (25)   </s12:Body>
         (26) </s12:Envelope>*/
        OMElement subscribeOm = factory.createOMElement("Unsubscribe", eventingNamespace);

        log.info("UnSubscribing: " + subscribeOm.toString());
        SampleClientResult clientResult = new SampleClientResult();
        try {
            initializeClient(addUrl);
            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe");

            OMElement identifierOm = factory.createOMElement("Identifier", eventingNamespace);
            factory.createOMText(identifierOm, identifier);
            serviceClient.addHeader(identifierOm);
            OMElement response = serviceClient.sendReceive(subscribeOm);
            log.info("UnSubscribed to ID " + identifier);
            Thread.sleep(1000);
            log.info("UnSubscribe Response Received: " + response.toString());
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Fault Received : " + e.toString(), e);
            clientResult.setException(e);
        }
        deInitializeClient();
        return clientResult;
    }
View Full Code Here

        factory.createOMText(expiresOm, expires);
        subscribeOm.addChild(expiresOm);


        log.info("SynapseSubscription Renew \n" + subscribeOm.toString());
        SampleClientResult clientResult = new SampleClientResult();
        try {
            initializeClient(addUrl);
            OMElement identifierOm = factory.createOMElement("Identifier", eventingNamespace);
            factory.createOMText(identifierOm, identifier);
            serviceClient.addHeader(identifierOm);
            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew");
            OMElement response = serviceClient.sendReceive(subscribeOm);
            log.info("SynapseSubscription Renew to ID " + identifier);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {

            }
            log.info("SynapseSubscription Renew Response Received: " + response.toString());
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Fault Received : " + e.toString(), e);
            clientResult.setException(e);
        }
        deInitializeClient();
        return clientResult;
    }
View Full Code Here

         (26) </s12:Envelope>
         */
        OMElement subscribeOm = factory.createOMElement("GetStatus", eventingNamespace);

        log.info("GetStatus using: " + subscribeOm.toString());
        SampleClientResult clientResult = new SampleClientResult();
        try {
            initializeClient(addUrl);
            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus");

            OMElement identifierOm = factory.createOMElement("Identifier", eventingNamespace);
            factory.createOMText(identifierOm, identifier);
            serviceClient.addHeader(identifierOm);
            OMElement response = serviceClient.sendReceive(subscribeOm);
            log.info("GetStatus to ID " + identifier);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {

            }
            log.info("GetStatus Response Received: " + response.toString());
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Fault Received : " + e.toString(), e);
            clientResult.setException(e);
        }
        deInitializeClient();
        return clientResult;
    }
View Full Code Here

        return clientResult;
    }

    public SampleClientResult sendEvent(String addUrl, String symbol, String price, String qty,
                                        String topic, String topicns) {
        SampleClientResult clientResult = new SampleClientResult();
        try {
            initializeClient(addUrl);
            OMNamespace aipNamespace = factory.createOMNamespace(topicns, "aip");
            // set the target topic
            OMElement topicOm = factory.createOMElement("Topic", aipNamespace);
            factory.createOMText(topicOm, topic);
            serviceClient.addHeader(topicOm);
            // set for fire and forget
            options.setProperty(MessageContext.CLIENT_API_NON_BLOCKING, Boolean.FALSE);

            OMElement payload =
                    AXIOMUtil.stringToOM("<m:placeOrder xmlns:m=\"http://services.samples\">\n" +
                            "    <m:order>\n" +
                            "        <m:price>" + price + "</m:price>\n" +
                            "        <m:quantity>" + qty + "</m:quantity>\n" +
                            "        <m:symbol>" + symbol + "</m:symbol>\n" +
                            "    </m:order>\n" +
                            "</m:placeOrder>");

            log.info("Sending Event : \n" + payload.toString());
            serviceClient.fireAndForget(payload);
            log.info("Event sent to topic " + topic);
            Thread.sleep(1000);
            clientResult.incrementResponseCount();
        } catch (Exception e) {
            log.error("Fault Received : " + e.toString(), e);
            clientResult.setException(e);
        }
        deInitializeClient();
        return clientResult;
    }
View Full Code Here

    public MTOMSwASampleClient(Axis2ClientConfiguration configuration) {
        this.configuration = configuration;
    }

    public SampleClientResult sendUsingMTOM(String fileName, String targetEPR) {
        clientResult = new SampleClientResult();
        try {
            OMFactory factory = OMAbstractFactory.getOMFactory();
            OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
            payload = factory.createOMElement("uploadFileUsingMTOM", ns);
            OMElement request = factory.createOMElement("request", ns);
View Full Code Here

        return clientResult;

    }

    public SampleClientResult sendUsingSWA(String fileName, String targetEPR) {
        clientResult = new SampleClientResult();
        try {
            Options options = new Options();
            options.setTo(new EndpointReference(targetEPR));
            options.setAction("urn:uploadFileUsingSwA");
            options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
View Full Code Here

    public void testSessionLessLB() {
        String addUrl = "http://localhost:8280/services/LBService1";

        log.info("Running test: Weighted load balancing between 3 endpoints");
        SampleClientResult result = client.sessionlessClient(addUrl, null, 100);
        assertResponseReceived(result);
    }
View Full Code Here

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

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


    public void testRestToPox() {
        String trpUrl = "http://localhost:8280/services/StockQuote";
        log.info("Running test: HTTP REST request ");
        SampleClientResult result = client.requestRestQuote(null, trpUrl, null, "IBM");
        assertResponseReceived(result);
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.samples.framework.SampleClientResult

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.