Search in sources :

Example 71 with StockQuoteSampleClient

use of org.apache.synapse.samples.framework.clients.StockQuoteSampleClient in project wso2-synapse by wso2.

the class Sample5 method testCreateFaultAndChangeDirection.

public void testCreateFaultAndChangeDirection() {
    String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
    String trpUrl = "http://localhost:8280";
    String expectedError_MSFT = "Error connecting to the back end";
    String expectedError_SUN = "Error connecting to the back end";
    StockQuoteSampleClient client = getStockQuoteClient();
    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().contains(expectedError_MSFT));
    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().contains(expectedError_SUN));
    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);
}
Also used : AxisFault(org.apache.axis2.AxisFault) SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 72 with StockQuoteSampleClient

use of org.apache.synapse.samples.framework.clients.StockQuoteSampleClient in project wso2-synapse by wso2.

the class Sample7 method testLocalRegEntriesAndSchemaValidation.

public void testLocalRegEntriesAndSchemaValidation() {
    String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
    String trpUrl = "http://localhost:8280";
    String expectedError = "Invalid custom quote request";
    StockQuoteSampleClient client = getStockQuoteClient();
    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);
}
Also used : AxisFault(org.apache.axis2.AxisFault) SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 73 with StockQuoteSampleClient

use of org.apache.synapse.samples.framework.clients.StockQuoteSampleClient in project wso2-synapse by wso2.

the class Sample151 method testCustomSequencesEndpointsWithProxy.

public void testCustomSequencesEndpointsWithProxy() {
    String addUrl = "http://localhost:8280/services/StockQuoteProxy1";
    String addUrl2 = "http://localhost:8280/services/StockQuoteProxy2";
    StockQuoteSampleClient client = getStockQuoteClient();
    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());
}
Also used : SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 74 with StockQuoteSampleClient

use of org.apache.synapse.samples.framework.clients.StockQuoteSampleClient in project wso2-synapse by wso2.

the class Sample500 method testCallMediator.

public void testCallMediator() throws Exception {
    String addUrl = "http://localhost:8280/services/StockQuoteProxy";
    StockQuoteSampleClient client = getStockQuoteClient();
    log.info("Running test: Call Mediator for Non-Blocking Service Invocation");
    SampleClientResult result = client.requestStandardQuote(addUrl, null, null, "IBM", null);
    assertTrue("Invalid result received", result.responseReceived());
}
Also used : SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 75 with StockQuoteSampleClient

use of org.apache.synapse.samples.framework.clients.StockQuoteSampleClient in project wso2-synapse by wso2.

the class Sample55 method testSessionFullLBFailOver.

public void testSessionFullLBFailOver() {
    final String addUrl = "http://localhost:8280/services/LBService1";
    final StockQuoteSampleClient client = getStockQuoteClient();
    log.info("Running test: Failover sending among 3 endpoints");
    Thread t = new Thread(new Runnable() {

        public void run() {
            result = client.statefulClient(addUrl, null, 200);
        }
    });
    t.start();
    try {
        t.join();
    } catch (InterruptedException e) {
    }
    getBackendServerControllers().get(0).stopProcess();
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
    }
    assertTrue("Did not receive a response", result.responseReceived());
}
Also used : StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Aggregations

StockQuoteSampleClient (org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)99 SampleClientResult (org.apache.synapse.samples.framework.SampleClientResult)45 OMElement (org.apache.axiom.om.OMElement)23 AxisFault (org.apache.axis2.AxisFault)5 QName (javax.xml.namespace.QName)4 Axis2BackEndServerController (org.apache.synapse.samples.framework.Axis2BackEndServerController)1