/*
* TestCases.java
*
* Created on 21 February 2007, 17:43
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.metidator.client;
import com.mediator.mediator_Elite.Globals;
import com.mediator.mediator_Elite.Med_Elite_SOAPPort;
import com.mediator.mediator_Elite.SOAP_Proc;
import com.mediator.mediator_Elite.XMLParser;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Vector;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
import org.w3c.dom.Document;
/**
*
* @author Yuhui (Jeff) Chen
*/
public class TestCases {
private Med_Elite_SOAPPort mesp = new Med_Elite_SOAPPort();
private SOAP_Proc soapProc = new SOAP_Proc();
private Vector results = new Vector();
private XMLParser xmlp = new XMLParser();
private Globals globals = new Globals();
/** Creates a new instance of TestCases */
public TestCases() {
}
public static void main(String[] args) {
TestCases tcs = new TestCases();
int doLoop = 1;
for(int i= 0; i < doLoop; i++){
long t1 = System.currentTimeMillis();
tcs.execute();
long t2 = System.currentTimeMillis();
long responseTime = t2-t1;
tcs.printResults();
System.out.println("***********************");
System.out.println("* Response Time (ms) : " + responseTime);
System.out.println("***********************");
tcs.wrtFile(responseTime);
}
}
private void execute(){
ws1();
ws2();
ws3();
//set the metadata file name here
globals.setMetadataFile("E:\\project\\extra\\ws-metadata.xml");
//set the global policy
String globalPolicy= "3dependability803001000";
mesp.setGlobalPolicy(globalPolicy);
results = mesp.execute();
}
private void ws1(){
QName serviceQName = new QName("http://xml.nig.ac.jp:80/xddbj/Blast", "Blast");
QName portQName = new QName("http://tempuri.org/Blast", "Blast");
String smRequest = "blastnddbjhumccccacatca ccactttgga taacgccaaa tacaccttca acgggctagg atacttcctg ctggttcagg cccaggacag aaattcttcc ttcctgctgg agggccgcac tgcccagact gattctgcca atgccacgaa cttcattgcc tttgcggccc aatacaacac cagcagcctg aagtctccca tcacagttca gtggtttctt gagcccaatg acacaatccg agttgtacac aataaccaaa cggtggcctt taacaccagc gacactgaag acttgcccgt attcaatgcc actggtgtcc tactgatcca aaatggctcc caagtctcag ccaactttga tgggacagtg accatctctg tgattgctct ctccaacatc cttcacgcct cctccagcct gtcagaggag taccgcaacc acacaaaggg ccttctggga gtctggaatg acaatccaga agatgacttc agaatgccca atggctccac catcccctcc aacacgtccg aggagactct tttccactat ggaatgacat cggaaactaa cgggataggc ctccttgggg tgaggacaga ccctctgcct tctgagttta ctcccatctt cttgtcccaa ctgtggaaca agagcggcgc cggtgaagac ttgatctctg ggtgcaacga ggacgcacag tgcaagtttg acatcctggc cacaggaaac agagacatcg gacaaagcac caactcaatc cttagaacat tccggcacgt gaatggcacg ctcaaccagt acccaccccc tatccactac agcagcaaga ttcaagccta caaggggcga gaacagtggc cattgagatc accagcaact ctaaggatgt cgtattcagc ctctccaaca agtgcagtgg cctttgagct ctttgaaaac gggagtttgc acgtggacac caacatcccc agaagaacgt acctggagat tctagcaagg gatgtcaaga ctaacttgtc atcggtactc cagcctgaga cggtggcttg cttctgtagt aaggaggaac agtgtttgta caacgagacc agcaaagagg gcaactcttc cactgaggtg accagctgca agtgcgatgg gaactccttc ggccgcttgt gtgaacactc taaggacctc tgcactgagc catgcttccc taatgtggac tgcattcctg ggaagggctg tcaggcctgc cctccaaaca tgactggaga tgggcgtcat tgtgtagctg tggagatctc tgaattctgc cagaaccatt cctgtcctgt gaattactgc tataaccatg gccattgcga catctctggg cctccagact gccagcccac ttgcacctgc gcccctgcct tcactggtaa ccgctgcttc ctggccggga acaatttcac tcccatcatc tataaagagc ttcccttgag gaccatcacg ctctctctca gggaggacga aaacgcctct aacgctgacg tcaatgcctc ggtggcaaac gtactagaga acttggacat gcgggctttt ctctccaaca gcttagtgga gctgatacga acctctcccg gagcaccagt ccttggcaag cccattcatc actggaaggt cgtctcccac ttcaagtacc gtcccagggg acccctcatc cactatctga acaaccaact gataagcgcc gtgatggagg ccttcctcct ccaggctcgg caggagaggc ggaagaggag tggagaagcc aggaagaacg tccgcttctt ccccatctcg agggcagacg tccaggacgg gatggccctg aacctaagta tgctggacga gtacttcacg tgcgatggct acaaaggcta ccacttggtc tacagccccc aggatggcgt cacctgtgtg tccccatgta gtgagggcta ctgtcacaat ggaggccaat gcaagcacct gccagatggg ccccagtgca cgtgcgcaac cttcagcatc tacacatcct ggggcgaacg ctgtgagcat ctaagcgtga aacttggggc attcttcggg atcctctttg gagccctggg tgccctcttg ctactggcca tcttagcatg tgtggtcttt cacttctgcg gctgctccat gaacaagttc tcctaccctc tggactcaga actgtga";
//set the individual policy
String xmlPolicy= "SOAP11HTTPSync60000average 3300no2";
String endpointAddress = "http://xml.nig.ac.jp:80/xddbj/Blast";
SOAPMessage message = soapProc.bindingSOAP(smRequest);
mesp.insertWS(endpointAddress, serviceQName,portQName,message,xmlPolicy);
}
private void ws2(){
String smRequest = "AB000050";
QName serviceQName = new QName("http://xml.nig.ac.jp/xddbj/DDBJ", "DDBJ");
QName portQName = new QName("http://xml.nig.ac.jp/xddbj/DDBJ", "DDBJ");
String xmlPolicy= "SOAP11HTTPSync60000average 3300no2";
String endpointAddress = "http://xml.nig.ac.jp/xddbj/DDBJ";
SOAPMessage message = soapProc.bindingSOAP(smRequest);
mesp.insertWS(endpointAddress, serviceQName,portQName,message,xmlPolicy);
}
private void ws3(){
String smRequest = "AB000050";
QName serviceQName = new QName("http://xml.nig.ac.jp/xddbj/BlastDemo", "BlastDemo");
QName portQName = new QName("http://xml.nig.ac.jp/xddbj/BlastDemo", "BlastDemo");
String xmlPolicy= "SOAP11HTTPSync60000average 3300no2";
String endpointAddress = "http://xml.nig.ac.jp/xddbj/BlastDemo";
SOAPMessage message = soapProc.bindingSOAP(smRequest);
mesp.insertWS(endpointAddress, serviceQName,portQName,message,xmlPolicy);
}
private void printResults(){
//System.out.println("number of results :" + results.size());
for(int i=0; i < results.size(); i++ ){
Object obj = (Object) results.get(i);
if (obj instanceof SOAPMessage){
System.out.println();
System.out.println("=============================");
System.out.println("* Final result: *");
System.out.println(soapProc.SOAPToXMLString((SOAPMessage)results.get(i)));
System.out.println("=============================");
}
if (obj instanceof Document){
System.out.println("=============================");
System.out.println("* Final report: *");
try {
xmlp.printNodeToConsole((Document)obj);
System.out.println();
//xmlp.printXML((Document)obj);
} catch (Exception ex) {
ex.printStackTrace();
}
//System.out.println();
System.out.println("=============================");
}
}
}
private void wrtFile(long rst){
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
try
{
// Create a new file output stream
out = new FileOutputStream("E:\\Projects\\extra\\testCase.txt");
// Connect print stream to the output stream
p = new PrintStream( out );
p.append(String.valueOf(rst));
}
catch (Exception e)
{
System.err.println ("Error writing to file");
}
}
}