Search in sources :

Example 41 with SampleClientResult

use of org.apache.synapse.samples.framework.SampleClientResult 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 42 with SampleClientResult

use of org.apache.synapse.samples.framework.SampleClientResult 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 43 with SampleClientResult

use of org.apache.synapse.samples.framework.SampleClientResult 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 44 with SampleClientResult

use of org.apache.synapse.samples.framework.SampleClientResult 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)

Example 45 with SampleClientResult

use of org.apache.synapse.samples.framework.SampleClientResult 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)

Aggregations

SampleClientResult (org.apache.synapse.samples.framework.SampleClientResult)64 StockQuoteSampleClient (org.apache.synapse.samples.framework.clients.StockQuoteSampleClient)45 OMElement (org.apache.axiom.om.OMElement)5 AxisFault (org.apache.axis2.AxisFault)5 QName (javax.xml.namespace.QName)4 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 DataHandler (javax.activation.DataHandler)2 FileDataSource (javax.activation.FileDataSource)2 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)2 EndpointReference (org.apache.axis2.addressing.EndpointReference)2 OperationClient (org.apache.axis2.client.OperationClient)2 Options (org.apache.axis2.client.Options)2 ServiceClient (org.apache.axis2.client.ServiceClient)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 MessageContext (org.apache.axis2.context.MessageContext)2 MTOMSwASampleClient (org.apache.synapse.samples.framework.clients.MTOMSwASampleClient)2 BufferedOutputStream (java.io.BufferedOutputStream)1 InputStream (java.io.InputStream)1 Attachments (org.apache.axiom.attachments.Attachments)1