use of org.apache.synapse.samples.framework.SampleClientResult in project wso2-synapse by wso2.
the class Sample9 method testDynamicSequences.
public void testDynamicSequences() {
String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
String trpUrl = "http://localhost:8280/";
StockQuoteSampleClient client = getStockQuoteClient();
log.info("Running test: Dynamic Sequences with Registry");
SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM", null);
assertResponseReceived(result);
}
use of org.apache.synapse.samples.framework.SampleClientResult in project wso2-synapse by wso2.
the class Sample657 method testDistributedTransaction.
public void testDistributedTransaction() {
if (System.getProperty("java.naming.factory.initial") == null) {
System.setProperty("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
}
String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
String trpUrl = "http://localhost:8280/";
StockQuoteSampleClient client = getStockQuoteClient();
log.info("Running test: Distributed Transaction Management");
SampleClientResult result = client.requestStandardQuote(addUrl, trpUrl, null, "IBM", null);
assertTrue("Client did not get run successfully ", result.responseReceived());
}
use of org.apache.synapse.samples.framework.SampleClientResult in project wso2-synapse by wso2.
the class IterateSOAPActionTestCase method testSOAPAction.
public void testSOAPAction() throws Exception {
String addUrl = "http://localhost:8280/services/iterateWithSOAPActionTestProxy";
StockQuoteSampleClient client = getStockQuoteClient();
SampleClientResult result = client.requestStandardQuote(addUrl, null, null, "WSO2", null);
assertTrue("Client didn't get response", result.responseReceived());
}
use of org.apache.synapse.samples.framework.SampleClientResult in project wso2-synapse by wso2.
the class LogMediatorAfterSendMediatorTestCase method testLogMediatorAfterSendMediator.
public void testLogMediatorAfterSendMediator() {
StockQuoteSampleClient client = getStockQuoteClient();
SampleClientResult result = client.requestStandardQuote("http://localhost:8280/services/sendMediatorWithLogAfterwardsTestProxy", null, null, "WSO2", null);
assertTrue("Response not received", result.responseReceived());
}
use of org.apache.synapse.samples.framework.SampleClientResult in project wso2-synapse by wso2.
the class MTOMSwASampleClient method sendUsingMTOM.
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);
OMElement image = factory.createOMElement("image", ns);
log.info("Sending file : " + fileName + " as MTOM");
FileDataSource fileDataSource = new FileDataSource(new File(fileName));
DataHandler dataHandler = new DataHandler(fileDataSource);
OMText textData = factory.createOMText(dataHandler, true);
image.addChild(textData);
request.addChild(image);
payload.addChild(request);
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(configuration.getClientRepo(), configuration.getAxis2Xml());
serviceClient = new ServiceClient(configContext, null);
Options options = new Options();
options.setTo(new EndpointReference(targetEPR));
options.setAction("urn:uploadFileUsingMTOM");
options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
serviceClient.setOptions(options);
OMElement response = serviceClient.sendReceive(payload);
OMText binaryNode = (OMText) response.getFirstChildWithName(new QName("http://services.samples", "response")).getFirstChildWithName(new QName("http://services.samples", "image")).getFirstOMChild();
dataHandler = (DataHandler) binaryNode.getDataHandler();
InputStream is = dataHandler.getInputStream();
log.info("temp.dir: " + System.getProperty("java.io.tmpdir"));
File tempFile = File.createTempFile("mtom-", ".gif");
FileOutputStream fos = new FileOutputStream(tempFile);
BufferedOutputStream dest = new BufferedOutputStream(fos, 2048);
byte[] data = new byte[2048];
int count;
while ((count = is.read(data, 0, 2048)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
log.info("Saved response to file : " + tempFile.getAbsolutePath());
clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Error invoking service", e);
clientResult.setException(e);
}
return clientResult;
}
Aggregations