不一样的思想~~ http://shop34712791.taobao.com MSN:wins0910@hotmail.com

发布新日志

  • httpunit

    2008-08-28 22:08:13

    1\直接获取页面内容
    package onlyfun.caterpillar.test;

    import java.io.IOException;
    import java.net.MalformedURLException;

    import org.xml.sax.SAXException;

    import com.meterware.httpunit.GetMethodWebRequest;
    import com.meterware.httpunit.WebConversation;
    import com.meterware.httpunit.WebRequest;
    import com.meterware.httpunit.WebResponse;

    import junit.framework.TestCase;

    public class FirstHttpUnitTest extends TestCase {

    public void testCaterpillarOnlyfun()
    throws MalformedURLException,
    IOException,
    SAXException {
    WebConversation webConversation =
    new WebConversation();
    WebRequest request =
    new GetMethodWebRequest(
    "http://caterpillar.onlyfun.net/phpBB2/");
    WebResponse response =
    webConversation.getResponse(request);
    assertTrue(response.getTitle().startsWith(
    "caterpillar.onlyfun.net"));
    }

    public static void main(String[] args) {
    junit.swingui.TestRunner.run(
    FirstHttpUnitTest.class);
    }
    }
    2\通过Get方法访问页面并且加入参数 
    System.out.println("向服务器发送数据,然后获取网页内容:");   //建立一个WebConversation实例   WebConversation wc = new WebConversation();   //向指定的URL发出请求   WebRequest req = new GetMethodWebRequest( " http://localhost:6888/HelloWorld.jsp " );   //给请求加上参数   req.setParameter("username","姓名");   //获取响应对象   WebResponse resp = wc.getResponse( req );   //用getText方法获取相应的全部内容   //用System.out.println将获取的内容打印在控制台上   System.out.println( resp.getText() );
    3\通过Post方法访问页面并且加入参数
    //建立一个WebConversation实例   WebConversation wc = new WebConversation();   //向指定的URL发出请求   WebRequest req = new PostMethodWebRequest( " http://localhost:6888/HelloWorld.jsp " );   //给请求加上参数   req.setParameter("username","姓名");   //获取响应对象   WebResponse resp = wc.getResponse( req );   //用getText方法获取相应的全部内容   //用System.out.println将获取的内容打印在控制台上   System.out.println( resp.getText() );




    4\处理页面中的链接

    这里的演示是找到页面中的某一个链接,然后模拟用户的单机行为,获得它指向文件的内容。比如在我的页面HelloWorld.html中有一个链接,它显示的内容是TestLink,它指向我另一个页面TestLink.htm. TestLink.htm里面只显示TestLink.html几个字符
    System.out.println("获取页面中链接指向页面的内容:");   //建立一个WebConversation实例   WebConversation wc = new WebConversation();   //获取响应对象   WebResponse resp = wc.getResponse( " http://localhost:6888/HelloWorld.html " );   //获得页面链接对象   WebLink link = resp.getLinkWith( "TestLink" );   //模拟用户单击事件   link.click();   //获得当前的响应对象   WebResponse nextLink = wc.getCurrentPage();   //用getText方法获取相应的全部内容   //用System.out.println将获取的内容打印在控制台上   System.out.println( nextLink.getText() );

    5\处理页面中的表格
    表格是用来控制页面显示的常规对象,在HttpUnit中使用数组来处理页面中的多个表格,你可以用resp.getTables()方法获取页面所有的表格对象。他们依照出现在页面中的顺序保存在一个数组里面。
      [注意] Java中数组下标是从0开始的,所以取第一个表格应该是resp.getTables()[0],其他以此类推。
    下面的例子演示如何从页面中取出第一个表格的内容并且将他们循环显示出来:

    //建立一个WebConversation实例   WebConversation wc = new WebConversation();   //获取响应对象  WebResponse resp = wc.getResponse( " http://localhost:6888/HelloWorld.html " );   //获得对应的表格对象   WebTable webTable = resp.getTables()[0];   //将表格对象的内容传递给字符串数组   String[][] datas = webTable.asText();   //循环显示表格内容   int i = 0 ,j = 0;   int m = datas[0].length;   int n = datas.length;   while (i<n){   j=0;   while(j<m){   System.out.println("表格中第"+(i+1)+"行第"+(j+1)+"列的内容是:"+datas[j]);   ++j;   }   ++i;   }
    6\处理页面中的表单
    表单是用来接受用户输入,也可以向用户显示用户已输入信息(如需要用户修改数据时,通常会显示他以前输入过的信息),在HttpUnit中使用数组来处理页面中的多个表单,你可以用resp.getForms()方法获取页面所有的表单对象。他们依照出现在页面中的顺序保存在一个数组里面。
      [注意] Java中数组下标是从0开始的,所以取第一个表单应该是resp.getForms()[0],其他以此类推。
      下面的例子演示如何从页面中取出第一个表单的内容并且将他们循环显示出来
    System.out.println("获取页面中表单的内容:");   //建立一个WebConversation实例   WebConversation wc = new WebConversation();   //获取响应对象   WebResponse resp = wc.getResponse( " http://localhost:6888/HelloWorld.html " );   //获得对应的表单对象   WebForm webForm = resp.getForms()[0];   //获得表单中所有控件的名字   String[] pNames = webForm.getParameterNames();   int i = 0;   int m = pNames.length;   //循环显示表单中所有控件的内容   while(i<m){   System.out.println("第"+(i+1)+"个控件的名字是"+pNames+",里面的内容是"+
    webForm.getParameterValue(pNames));   ++i;   }
  • mocktest

    2007-09-16 20:22:55

    mocktest

    src/junitbook.fine.tasting

    Account.java

    AccountManager.java

    AccountService.java

    MockAccountManager.java

    testAccountService.java

    --Account.java

    package junitbook.fine.tasting;
    public class Account{
     private long balance;
     public Account(String accountId,long initialBalance){
      this.balance = initialBalance;
      System.out.println("-------Account balance initialBalance:-----"+balance);
     }
     public void debit(long amount){
      this.balance -= amount;
      System.out.println("-------debit balance-amount:------"+balance);
     }
     public void credit(long amount){
      this.balance +=amount;
      System.out.println("-------credit balance+amount:------"+balance);
     }
     public long getBalance(){
      return this.balance;
     }
    }

    -----AccountManager.java

    package junitbook.fine.tasting;

    public interface AccountManager{
     Account findAccountForUser(String userId);
     void updateAccount(Account account);
     }

    -----AccountService.java

    package junitbook.fine.tasting;
    public class AccountService{
     private AccountManager accountManager;
     
     private long amount;
     
     public void setAccountManager(MockAccountManager mockAccountManager, AccountManager manager){
      this.accountManager = manager;
     }
     
     public void transfer(String senderId,String beneficiaryId,long account){
      Account sender = this.accountManager.findAccountForUser(senderId);
      Account beneficiary =this.accountManager.findAccountForUser(beneficiaryId);
      sender.debit(amount);
      beneficiary.credit(amount);
      this.accountManager.updateAccount(sender);
      this.accountManager.updateAccount(beneficiary);
     }
    }

    ----MockAccountManager.java

    package junitbook.fine.tasting;
    import java.util.Hashtable;
    public class MockAccountManager implements AccountManager{
     private Hashtable accounts = new Hashtable();
     
     public void addAccount(String userId,Account account){
     this.accounts.put(userId,account);
     }
     
     public Account findAccountForUser(String userId){
      return (Account)this.accounts.get(userId);
     }
     
     public void updateAccount(Account account){
     }

    }

    ----testAccountService.java

    package junitbook.fine.tasting;
    import junit.framework.*;
    public class testAccountService extends TestCase{

     public void testTransferOk(){
      MockAccountManager mockAccountManager = new MockAccountManager();
      Account senderAccount = new Account("1",200);
      System.out.println("-------senderAccount:------"+senderAccount);
      Account beneficiaryAccount = new Account("2",100);
      System.out.println("-------senderAccount:-----"+beneficiaryAccount);
      mockAccountManager.addAccount("1",senderAccount);
      mockAccountManager.addAccount("2",beneficiaryAccount);
      System.out.println("-------mockAccountManager:------"+mockAccountManager);
        
      AccountService accountService = new AccountService();
      System.out.println("-------accountService1:------"+accountService);
      accountService.setAccountManager(mockAccountManager, mockAccountManager);
      accountService.transfer("1","2",50);
      System.out.println("-------accountService2:-------"+accountService);
      
      assertEquals(200,senderAccount.getBalance());
      assertEquals(100,beneficiaryAccount.getBalance());
     }

    }

     

     

  • md5加密程序

    2007-08-28 17:22:08

    create project:md5

    jdk:1.4.2

    create package:src/com.eshore.eca.util

    hashcode.java and MD5Crypter.java

    create webroot:WebRoot/WEB-INF/web.xml (null)

    1、hashcode.java:

    package com.eshore.eca.util;

    public class hashcode{
     
     public String getHashCode(String hashCodeString){
      String inputValue = null;
      if (hashCodeString != null) {
       //System.out.println(hashCodeString);
       inputValue = MD5Crypter.encode(hashCodeString);
       System.out.println("gethashCodeValue:"+inputValue);
      }
      return hashCodeString;
     }
    public static void main(String[] args){
     String inputValue = "1TEST3TEST3075576510001020310072772147483647123456789012345678123456aB";
     System.out.println("hashCodeValue:"+inputValue);
     hashcode mySend = new hashcode();
     mySend.getHashCode(inputValue);
     }
    }

    2、MD5Crypter.java

    package com.eshore.eca.util;
    import java.security.MessageDigest;
    import java.security.Security;
    import cryptix.util.core.Hex;

    public class MD5Crypter {

        private static boolean isInit = false;

        public MD5Crypter() {
        }

        public static String encode(String originalString) {
            if (originalString == null)
                return null;
            if (!isInit)
                init();
            try {
                MessageDigest messagedigest = MessageDigest.getInstance("MD5");
                messagedigest.reset();
                messagedigest.update(originalString.getBytes("utf8"));
    //            for(int i = 0; i < originalString.length(); i++)
    //                messagedigest.update((byte)originalString.charAt(i));
                byte abyte0[] = messagedigest.digest();
                return Hex.toString(abyte0);
            }
            catch (Exception exception) {
                System.err.println(exception.getMessage());
                return null;
            }

        }

        public static byte[] encodeByte(String originalString) {
            if (originalString == null)
                return null;
            if (!isInit)
                init();
            try {
                MessageDigest messagedigest = MessageDigest.getInstance("MD5");
                messagedigest.reset();
                messagedigest.update(originalString.getBytes("utf8"));
    //            for(int i = 0; i < originalString.length(); i++)
    //                messagedigest.update((byte)originalString.charAt(i));
                byte abyte0[] = messagedigest.digest();
                return abyte0;
            }
            catch (Exception exception) {
                System.err.println(exception.getMessage());
                return null;
            }

        }

        private static void init() {
    //        Security.addProvider(new Cryptix());
            isInit = true;
        }

     

  • jsp/servlet/javaBean 小程序

    2007-08-28 16:21:26

    create a tomcat project:test

    package:WEB-INF/src/test

    test.java and TestBean.java

    1、test.java:

    package test;
    import java.io.IOException;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class test extends HttpServlet{

     protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
      // TODO Auto-generated method stub
      System.out.println("asdfasdfasdf");
      //arg1.sendRedirect("index.jsp");
      arg1.sendRedirect("TestBean.jsp");
     }

     protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
      // TODO Auto-generated method stub
      System.out.println("asdfasdfasdf");
      //arg1.sendRedirect("index.jsp");
      arg1.sendRedirect("TestBean.jsp");
     }

    }

    2、TestBean.java:

    package test;
    public class TestBean{
      private String name = null;
      public TestBean(String strName_p){
       this.name=strName_p;
      }
    public String setName(String strName_p){
     return this.name=strName_p;
    }
    public String getName(){
     return this.name;
            }
    }

    project test 下:index.jsp and TestBean.jsp

    3、index.jsp

    <html>
    <body>
    <center>
    now time is :<%=new java.util.Date()%>
    </center>
    </body>
    </html>

    4、TestBean.jsp

    <%@ page import = "test.TestBean"%>
    <html>
    <body>
    <center>
    <%
     TestBean myBean = new TestBean("This is java bean");
    %>
    this is java bean name :<%=myBean.getName()%>
    </center>
    </body>
    </html>

    5、WEB-INF/web.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
      <display-name>Welcome to Tomcat</display-name>
      <descrīption>
         Welcome to Tomcat
      </descrīption>
      <servlet>
            <servlet-name>test</servlet-name>
            <servlet-class>test.test</servlet-class>
      </servlet>
      <servlet-mapping>
            <servlet-name>test</servlet-name>
            <url-pattern>/index.do</url-pattern>
      </servlet-mapping>
    </web-app>

    6、http://localhost/test/index.do

    7、jsp/servlet/javaBean test example

  • 客户端生成多线程(一)~

    2007-08-02 09:07:00

    package autotest;

    import java.io.BufferedOutputStream;
    import java.io.IOException;

    public class PPPThread extends Thread{
         static ReadXml rx = new ReadXml("config/interface.xml");
         int threadId = -1;
         BufferedOutputStream ōut = null;
        
         public PPPThread(int threadId,BufferedOutputStream tmpOut) {
             this.threadId = threadId;
             this.out=tmpOut;
         }

         public void run() {
             System.out.println("threadId:"+threadId);
          //String tmp="GZ_HWSCP:1234@218.190.14.158:8088";
          String tmp="buddyv20:buddyv20@218.190.14.158:8088";
          //String tmp="buddyv20:buddyv20@10.17.42.96:8088";
             byte[] strByteArray;

       //----------
       String[] int_tmp;
          String test_type=rx.getItem("project","test_type");
          System.out.println("test_type:"+test_type);
          int_tmp=test_type.split(",");
          String xml_dir=null;
          String url=null;
          String files;
          String[] file_list;
               
          XmlSendClient mySend = new XmlSendClient();
          //openlog();
          for(int i=0;i<int_tmp.length;i++){
           url=rx.getItem("project/interface"+int_tmp[i],"url");
           System.out.println("url:"+url);
           xml_dir=rx.getItem("project/interface"+int_tmp[i],"xml_dir");
           System.out.println("xml_dir:"+xml_dir);
           files=rx.getItem("project/interface"+int_tmp[i],"files");
           System.out.println("files:"+files);
           file_list=files.split(",");
           XmlSendClient.setbnetID(rx.getItem("project/interface"+int_tmp[i],"bnetID"));
           XmlSendClient.setbnetAccount(rx.getItem("project/interface"+int_tmp[i],"bnetAccount"));
           XmlSendClient.setproductSpecID(rx.getItem("project/interface"+int_tmp[i],"productSpecID"));
           XmlSendClient.setproductInfo1(rx.getItem("project/interface"+int_tmp[i],"productInfo1"));
           XmlSendClient.setproductInfo2(rx.getItem("project/interface"+int_tmp[i],"productInfo2"));
           XmlSendClient.settimeStamp(rx.getItem("project/interface"+int_tmp[i],"timestamp"));
           XmlSendClient.setshareKey(rx.getItem("project/interface"+int_tmp[i],"shareKey"));
           for(int j=0;j<file_list.length;j++){
            System.out.println("Process the file : "+xml_dir+"/"+file_list[j]+".xml"); 
            mySend.SendXmlFile(url,xml_dir,file_list[j]+".xml",int_tmp[i]);
            System.out.println(" ------------SendXmlFile:"+file_list[j]+" over------------");
           }
           System.out.println(" ------------test_type:"+int_tmp[i]+" over------------");
          }
          System.out.println("Program over!");
          //closelog();
          System.exit(0);      
          
          //------------
          
          strByteArray = tmp.getBytes();
          
          try {
    //       Thread.sleep(100000);
                 this.out.write(strByteArray, 0, strByteArray.length);
                 this.out.flush();
             } catch (Exception ex) {
              ex.printStackTrace();
             }
         }
    }

  • 利用http协议走soap请求ws服务(二)~

    2007-08-02 09:05:37

    package autotest;

    import com.gsta.neva2.config.*;
    import java.lang.*;
    import java.util.Properties;

    public class ReadXml {

     public Configure myConfigure = new Configure();
     String filepath=null;

     public ReadXml(String path){
      this.filepath =path;
            System.out.println("filepath:"+filepath);
      
            try{
       myConfigure.parse(filepath);
      }catch(ConfigException ex){
       System.out.println(ex.getMessage());
      }
      
     }
     
     public String getItem(String tPath,String tNodeName){
      
      
      String tReturn="";
      
      try{
       tReturn = myConfigure.getItemValue(tPath, tNodeName);
      }catch(ConfigException ex){
       System.out.println(ex.getMessage());
      }
      return tReturn;
     }
     public String getItemprop(String tfieldNode,String tfieldValue){
      
      
      String tReturn="";
      
      try{
       tReturn = myConfigure.getItemProp(tfieldNode,tfieldValue);
      }catch(ConfigException ex){
       System.out.println(ex.getMessage());
      }
      return tReturn;
     }

    }

  • 利用http协议走soap请求ws服务(一)~

    2007-08-02 09:03:54

    package autotest;

    import java.io.*;
    import java.net.*;
    import java.io.BufferedReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import autotest.*;


    // 系统主要函数,功能:发送xml文件到接口,然后接收接口返回消息,并打印消息中的相关信息
    public class XmlSendClient {
     
     static FileWriter fw=null;
     static PrintWriter ōutlog=null;
     static ReadXml rx = new ReadXml("config/interface.xml");
     ReadProxy myProxy = new ReadProxy();
     static String productSpecID=null;
     static String bnetId=null;
     static String timestamp=null;
     static String bnetAccount=null;
     static String productInfo1=null;
     static String productInfo2=null;
     static String shareKey=null;
     
     @SuppressWarnings("static-access")
     public void SendXmlFile(String url_wsdl,String xml_path,String xml_file,String interface_index){

            String SOAPUrl=url_wsdl;
            String xmlFile2Send=xml_path+"/"+xml_file;
            //System.out.println("xmlFile2Send:"+xmlFile2Send);
      String SOAPAction = "";

      try{
    //   设置IE代理:
    //   System.getProperties().put("proxySet", "true");
    //   System.getProperties().put("proxyHost", "xx.xx.xx.xx");
    //         System.getProperties().put("proxyPort", "8080");
    //         String authString="xxxxxxxx:xxxxxxxx";
    //   String auth="Basic"+new sun.misc.BASE64Encoder().encode(authString.getBytes()); 
       // 建立同接口之间的连接,以备发送接口文件。
             URL url = new URL(SOAPUrl);
            
             URLConnection connection = url.openConnection();
    //         connection.setRequestProperty("Proxy-Authorization",auth);
             System.out.println("urlconnetction:"+connection);
             HttpURLConnection httpConn = (HttpURLConnection) connection;
             System.out.println("httpurlconnection:"+httpConn);
             httpConn.setFollowRedirects(true);
             httpConn.setInstanceFollowRedirects(true);
             httpConn.usingProxy();
            
            
             // 打开输入的接口xml文件
             FileInputStream fin = new FileInputStream(xmlFile2Send);
             // 初始一个空的字节输出流
             ByteArrayOutputStream bout = new ByteArrayOutputStream();
             copy(fin,bout);
             fin.close();
            
             byte[] b =null;
             // 进行模板的参数替换
             b=getReplace(bout,interface_index,xml_file);
            
             // 设置HTTP参数

             httpConn.setRequestProperty("Content-Length",String.valueOf(b.length));
             httpConn.setRequestProperty("Content-Type","text/xml; charset=UTF-8");
       httpConn.setRequestProperty("SOAPAction",SOAPAction);
             httpConn.setRequestMethod( "POST" );
             httpConn.setDoOutput(true);
             httpConn.setDoInput(true);
             // 发送接口文件,发送完毕后关闭输出流
             OutputStream ōut = httpConn.getOutputStream();
             out.write(b);   
             out.close();
            
             // 从对话通道中读取接口返回信息。
             System.out.println("xml_file:"+xml_file);
             //outlog.println("------"+xml_path+"------");
             InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
             BufferedReader in = new BufferedReader(isr);
             String inputLine;
            
             int int_start;
             int int_end;
             int int_start_info;
             int int_end_info;
             String str_inputLine="";
            
             // 不断循环从通道中读取返回信息,直至读取为空
       while ((inputLine = in.readLine()) != null){
        str_inputLine=str_inputLine+inputLine;
        System.out.println("inputLine:"+inputLine);
        System.out.println("str_inputLine:"+str_inputLine);
       }
       
       // 打印resultNo节点的信息
       int_start=str_inputLine.indexOf("ns2:result");
       int_end=str_inputLine.indexOf("/ns2:result");
       if(str_inputLine.indexOf("ns2:result")>=0){
        //outlog.println("xml_file:"+xml_file);
        System.out.println("result: "+str_inputLine.substring(int_start+50,int_end-1));
       }
     
       // 当resultNo的值不为0时,还需打印resultInfo信息,以供查问题
       int_start_info=str_inputLine.indexOf("ns3:info");
       int_end_info=str_inputLine.indexOf("/ns3:info");
       if(str_inputLine.indexOf("ns2:result")>=0){
        if(str_inputLine.indexOf(">0<")<0){
         System.out.println("info:"+str_inputLine.substring(int_start_info+48,int_end_info-1));
        }
       }
       //outlog.println();
      }catch(Exception ex){
             ex.printStackTrace();
             outlog.println(xml_file+" : this file is failed!");
             outlog.println();
            }
        }
     
        private boolean hasProxy() {
      // TODO Auto-generated method stub
      return false;
     }

     // 同步拷贝文件流到字节输出流,并保证在拷贝过程中,这两个流不受其他线程影响
        public void copy(InputStream in, OutputStream out) throws IOException {
           synchronized (in) {
           synchronized (out) {
             byte[] buffer = new byte[256];
             while (true) {
               int bytesRead = in.read(buffer);
               if (bytesRead == -1) break;
               out.write(buffer, 0, bytesRead);
             }
           }
         }
        }
       
        // 打开写日志的文件
        static void openlog(){
         try {
          fw = new FileWriter("interface_test.log");
          outlog = new PrintWriter(fw);
      } catch (IOException e) {
       e.printStackTrace();
      }
        }
       
        // 关闭写日志文件的句柄
        static void closelog(){
         
         try {
          outlog.println("Program has executed successfully!");
          outlog.close();
          fw.close();
      } catch (IOException e) {
       e.printStackTrace();
      }
        }

       
        // 更换接口文件模板中,需要更换的节点值
        public byte[] getReplace(ByteArrayOutputStream b,String inter_index,String xml_file){
         String tmp1=b.toString();
         String inputValue1=null;
         
          tmp1=tmp1.replace("bnetid_String",getbnetID());
             tmp1=tmp1.replace("bnetAccount_String",getbnetAccount());
             tmp1=tmp1.replace("productSpecID_String",getproductSpecID());
             tmp1=tmp1.replace("productInfo_String",getproductInfo1());
             tmp1=tmp1.replace("timestamp_String",gettimeStamp());
          if (xml_file.endsWith("order.xml")){
    //       System.out.println(getbnetID());
    //       System.out.println(getbnetAccount());
    //       System.out.println(getproductSpecID());
    //       System.out.println(getproductInfo1());
    //       System.out.println(gettimeStamp());
    //       System.out.println("getshareKey:"+getshareKey());
           inputValue1 = MD5Crypter.encode(getbnetID()+getbnetAccount()+getproductSpecID()+getproductInfo1()+gettimeStamp()+getshareKey());
           System.out.println("order hashcode:"+inputValue1);
           tmp1=tmp1.replace("hashCode_String",inputValue1);
           tmp1.trim();
           System.out.println("order tmp1:"+tmp1);
           return tmp1.getBytes();
          }else if(xml_file.endsWith("modify.xml")){
                 tmp1=tmp1.replace("productInfo_String",getproductInfo2());
           inputValue1 = MD5Crypter.encode(getbnetID()+getproductSpecID()+getproductInfo2()+gettimeStamp()+getshareKey());
           System.out.println("modify hashcode:"+inputValue1);
           tmp1=tmp1.replace("hashCode_String",inputValue1);
           return tmp1.getBytes();
          }else if(xml_file.endsWith("cancel.xml")){
           inputValue1 = MD5Crypter.encode(getbnetID()+getproductSpecID()+gettimeStamp()+getshareKey());
           System.out.println("cancel hashcode:"+inputValue1);
           tmp1=tmp1.replace("hashCode_String",inputValue1);
           return tmp1.getBytes();
          }
      //};
     return null;
    }

     //获得bnetID
        static String getbnetID(){
         //System.out.println("getbnetId:"+bnetId);
         return bnetId;
        }
        static void setbnetID(String tmp_bnetId){
         bnetId=tmp_bnetId;
         //System.out.println("setbnetid:"+bnetid);
        }
        static String getbnetAccount(){
         //System.out.println("getbnetAccount:"+bnetAccount);
         return bnetAccount;
        }
       
        // 当前接口循环中,给外部公用的帐号名称变量赋值,以供取值使用
        static void setbnetAccount(String tmp_bnetAccount){
         bnetAccount=tmp_bnetAccount;
         //System.out.println("setbnetAccount:"+bnetAccount);
        }
       
        static String getproductInfo1(){
         //System.out.println("getproductInfo1:"+productInfo1);
         return productInfo1;
        }
       
        //当前接口循环中,给外部公用的帐号名称变量赋值,以供取值使用
        static void setproductInfo1(String tmp_productInfo1){
         productInfo1=tmp_productInfo1;
         //System.out.println("setproductInfo1:"+productInfo1);
        }
       
        static String getproductInfo2(){
         //System.out.println("getproductInfo2:"+productInfo2);
         return productInfo2;
        }
       
        //当前接口循环中,给外部公用的帐号名称变量赋值,以供取值使用
        static void setproductInfo2(String tmp_productInfo2){
         productInfo2=tmp_productInfo2;
         //System.out.println("setproductInfo2:"+productInfo2);
        }
           
        // 取得当前接口循环中,外部公用的帐号名称
        static String getproductSpecID(){
         //System.out.println("getproductSpecID:"+productSpecID);
         return productSpecID;
        }
           
        // 当前接口循环中,给外部公用的帐号名称变量赋值,以供取值使用
        static void setproductSpecID(String tmp_productSpecID){
         productSpecID=tmp_productSpecID;
         //System.out.println("setproductSpecID:"+productSpecID);
        }
        static String gettimeStamp(){
         //System.out.println("gettimestamp:"+timestamp);
         return timestamp;
        }
          
        static void settimeStamp(String tmp_timestamp){
         timestamp=tmp_timestamp;
         //System.out.println("settimeStamp:"+timestamp);
        }
        static String getshareKey(){
         //System.out.println("getshareKey:"+shareKey);
         return shareKey;
        }
          
        static void setshareKey(String tmp_shareKey){
         shareKey=tmp_shareKey;
         //System.out.println("setshareKey:"+shareKey);
        }
       
        // 主程序入口
        public static void main(String[] args){
         String[] int_tmp;
         String test_type=rx.getItem("project","test_type");
         System.out.println("test_type:"+test_type);
         int_tmp=test_type.split(",");
         String xml_dir=null;
         String url=null;
         String files;
         String[] file_list;

         XmlSendClient mySend = new XmlSendClient();
         //openlog();
         for(int i=0;i<int_tmp.length;i++){
          url=rx.getItem("project/interface"+int_tmp[i],"url");
          System.out.println("url:"+url);
          xml_dir=rx.getItem("project/interface"+int_tmp[i],"xml_dir");
          System.out.println("xml_dir:"+xml_dir);
          files=rx.getItem("project/interface"+int_tmp[i],"files");
          System.out.println("files:"+files);
          file_list=files.split(",");
          mySend.setbnetID(rx.getItem("project/interface"+int_tmp[i],"bnetID"));
          mySend.setbnetAccount(rx.getItem("project/interface"+int_tmp[i],"bnetAccount"));
          mySend.setproductSpecID(rx.getItem("project/interface"+int_tmp[i],"productSpecID"));
          mySend.setproductInfo1(rx.getItem("project/interface"+int_tmp[i],"productInfo1"));
          mySend.setproductInfo2(rx.getItem("project/interface"+int_tmp[i],"productInfo2"));
          mySend.settimeStamp(rx.getItem("project/interface"+int_tmp[i],"timestamp"));
          mySend.setshareKey(rx.getItem("project/interface"+int_tmp[i],"shareKey"));
          for(int j=0;j<file_list.length;j++){
           System.out.println("Process the file : "+xml_dir+"/"+file_list[j]+".xml"); 
           mySend.SendXmlFile(url,xml_dir,file_list[j]+".xml",int_tmp[i]);
           System.out.println(" ------------SendXmlFile:"+file_list[j]+" over------------");
          }
          System.out.println(" ------------test_type:"+int_tmp[i]+" over------------");
         }
         System.out.println("Program over!");
         //closelog();
         System.exit(0);
         
        }
    }

Open Toolbar