Search in sources :

Example 66 with StockQuoteSampleClient

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

the class Sample53 method testFailOver.

public void testFailOver() {
    String expectedError = "COULDN'T SEND THE MESSAGE TO THE SERVER";
    String addUrl = "http://localhost:8280/services/LBService1";
    log.info("Running test: Failover sending among 3 endpoints");
    final StockQuoteSampleClient client = getStockQuoteClient();
    // Send some messages and check
    SampleClientResult result = client.sessionlessClient(addUrl, null, 10);
    assertResponseReceived(result);
    // Stop BE server 1
    getBackendServerControllers().get(0).stopProcess();
    sleep(2000);
    // Send another burst of messages and check
    result = client.sessionlessClient(addUrl, null, 10);
    assertResponseReceived(result);
    // Stop BE server 2
    getBackendServerControllers().get(1).stopProcess();
    sleep(2000);
    // Send some more messages and check
    result = client.sessionlessClient(addUrl, null, 10);
    assertResponseReceived(result);
    // Stop BE server 3
    getBackendServerControllers().get(2).stopProcess();
    sleep(2000);
    // Send another message - Should fail
    result = client.sessionlessClient(addUrl, null, 1);
    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));
}
Also used : AxisFault(org.apache.axis2.AxisFault) SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 67 with StockQuoteSampleClient

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

the class Sample54 method testSessionFullLB.

public void testSessionFullLB() {
    String addUrl = "http://localhost:8280/services/LBService1";
    log.info("Running test: Session affinity load balancing between 3 endpoints");
    StockQuoteSampleClient client = getStockQuoteClient();
    SampleClientResult result = client.statefulClient(addUrl, null, 100);
    assertResponseReceived(result);
}
Also used : SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 68 with StockQuoteSampleClient

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

the class Sample56 method testSmartClientMode.

public void testSmartClientMode() {
    String addUrl = "http://localhost:8280";
    StockQuoteSampleClient client = getStockQuoteClient();
    log.info("Running test: Smart Client mode");
    SampleClientResult result = client.requestStandardQuote(addUrl, null, null, "IBM", null);
    assertResponseReceived(result);
}
Also used : SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 69 with StockQuoteSampleClient

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

the class Sample58 method testStaticLB.

public void testStaticLB() {
    final String addUrl = "http://localhost:8280/services/LBService1";
    final StockQuoteSampleClient client = getStockQuoteClient();
    new Thread(new Runnable() {

        public void run() {
            result = client.sessionlessClient(addUrl, null, 200);
        }
    }).start();
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
    }
    getBackendServerControllers().get(0).stopProcess();
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
    }
}
Also used : StockQuoteSampleClient(org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)

Example 70 with StockQuoteSampleClient

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

the class Sample11 method testFullRegistryBasedConfig.

public void testFullRegistryBasedConfig() {
    String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
    String trpUrl = "http://localhost:8280";
    StockQuoteSampleClient client = getStockQuoteClient();
    log.info("Running test: Local Registry entry definitions, reusable endpoints and sequences");
    SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM", null);
    assertResponseReceived(result);
}
Also used : SampleClientResult(org.apache.synapse.samples.framework.SampleClientResult) 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