JAVA之我的公共部分测试调用

Posted silencemaker1221

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JAVA之我的公共部分测试调用相关的知识,希望对你有一定的参考价值。

package com.citic.test;

import com.citic.c3p0.*;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.text.*;
import java.util.*;
import java.util.regex.Pattern;

import org.dom4j.*;
import org.dom4j.io.*;
import org.junit.Test;

import com.citic.c3p0.ConnectionManager;
import com.citic.supis.domain.SqlEntityStatment;
import com.citic.util.comm.*;
import com.citic.util.comm.IConstants.LOGLEVEL;
import com.citic.util.DBOperation;
import com.citic.util.MD5Util;
import com.citic.util.OfficeFileOper;
import com.citic.util.ReflectUtil;
import com.citic.util.XMLUtil;
import com.citic.main.constraints.Errors;
import com.citic.msgutil.ProImpl;

public class testObj implements IConstants{

    @Test
    public void parsexml() throws Exception {
        /*
        PrintStream ps=null;
        try {
            FileOutputStream out = new FileOutputStream("systemout" + ".txt",
                    true);
            ps = new PrintStream(out);
            System.setOut(ps);
        } catch (Exception e) {
            System.setErr(ps);
            e.printStackTrace();
        }*/
        CommFun.log();
        ProImpl pil = new ProImpl();
//        pil.parserXml("D:\data\supis\data\20151123\PSIS503_20151123_20151202163714_3R.xml");
        //pil.parserXml("D:/data/supis/data/20151218/receive/PSIS503_20151218_20151218133705745_6R.xml");
        pil.parserXml("D:\data\supis\data\20170418\receive\PSIS150_20170417_201704180907303930122295695_R.xml");
//        pil.parserXml("D:/data/supis/data/PSIS900_20151120_20151129135744.xml");
    }

    @Test
    public void createxml() throws IOException,SQLException {
        ProImpl pil = new ProImpl();
        pil.createXml(20151025, "PSIS802", "0");
    }

    @Test
    public void testEnum(){
        for(int i=0;i<LOGLEVEL.values().length;i++){
            System.out.println(LOGLEVEL.values()[i].name()+":"+i);
        }
    }
    
    
    @Test
    public void testgetlock(){
        boolean lock=FileOperation.getlock();
        if(lock){
            System.out.print("lock ok!");
            try {
                Thread.sleep(100000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            System.out.println("lock failure!");
        }
    }
    
    @Test
    public void testint(){
        Integer num=222222228;
        System.out.println(num==222222228);
    }
    
    @Test
    public void dateformat() {
        SimpleDateFormat ft = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        Date dt = new Date();
        Integer i = (int) (100000000 + Math.random() * 100000000);
        String dts = ft.format(dt) + String.format("%010d", i);
        System.out.println("dts    [" + dts + "]");
    }

    
    @Test
    public void testHash(){
        String[] starr={"1","2"};
        new HashMap<String,String[]>().put("PR00",starr);
    }
    
    @Test
    public void testString() throws Exception{
        String[] strarr={"aaa","bbb-g","ccc-g"};
        
        System.out.println(strarr.toString());
        System.exit(0);
        
        
        String st="ABC   D DDD EE ";
        System.out.println(st.lastIndexOf(‘/‘));
        System.out.println(st.substring(st.lastIndexOf(‘/‘)+1));
        
        FileInputStream in=new FileInputStream("d:\etlpluscfg.txt");
        FileOutputStream out=new FileOutputStream("d:\etlpluscfg.txt1");
        byte[] b=new byte[1024];
        int i=0;
        while((i=in.read(b))>0){
            out.write(b,0,i);
        }
        out.flush();
        out.close();
        in.close();
        System.out.println("over");
    }
    
    
    
    @Test
    public void testlen(){
        String st="y111111111 1212121";
        st=ConfigFileUtil.getValue("sendflag");
        if(st.length()>0 && st.toUpperCase().startsWith("Y")){
            System.out.println(st.toUpperCase());    
        }else{
            System.out.println("111111111111111");
        }
        
    }
    
    @Test
    public void testFile() {
        System.out.println(File.separator);
        String filename = "D:\cd\cd\111.txt\";
        File f=new File(filename);
        System.out.println(f.getAbsolutePath()+","+f.getPath()+","+f.getName());
        String str = filename
                .substring(0, filename.lastIndexOf(File.separator));
        System.out.println("str is [" + str + "]");
    }

    @Test
    public void getproperty() {
        System.out.println("Line separator is["
                + System.getProperty("line.separator") + "]");
        System.out.println("path separator is["
                + System.getProperty("path.separator") + "]");
        System.out.println("file separator is["
                + System.getProperty("file.separator") + "]");
        System.out.println(File.separator);
    }

    @Test
    public void base64encode() {
        String strImg = OfficeFileOper
                .getImageEncodeStr("D:\data\supis\data\20151123\核对意见(支付宝(中国)网络技术有限公司).doc");
        System.out.println(strImg + "..." + strImg.length());
        // generateDecodeImage(strImg);
    }
    
    @Test
    public void testError(){
        String err=Errors.getvalue("PR00");
        CommFun.log(1, err);
    }
    
    @Test
    public void testMap(){
        HashMap<String,String> hm=new HashMap<String, String>();
        hm.put("0b6e42c46824b37eddb5ac917e60c05d","ccc");
        hm.put("99a27d34223327e6d219f9a07facc2e1","dd");
        hm.put("3d681cdd3f0dc3441229d2f7a0eb47e4",null);
        hm.put("6d85d2b217483587fa0f3d688e2f704a","ff");
        hm.put("2191fce653312a90da7f623079c070ec","gg");
        
        try {
            DBOperation.updateMsgHeadSend(hm.values().toArray());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        
        System.exit(1);
        System.out.println(hm.values().toArray());
        
        System.out.println(hm);
        for(String t:hm.keySet()){
            System.out.println("..........."+"["+t+"]");
        }
        
    }
    
    @Test
    public void testsplite(){
        String fline="11:22,33:44,55:66";
        System.out.println(fline.split(",")[1].split(":")[1]);
        
    }
    
    
    @Test
    public void testMd5() throws Exception{
        String str="C:\Users\db2admin\Downloads\1212test.xml";
        str="D:\PSIS503_20170815_201708160903163270153093560_R.xml";
        str="d:\SUPIS201708160900208920102821719.xml";
        String str1="d:\SUPIS201708160900208920102821719_B.xml";
        str1="d:\PSIS900_802_20170816_201708161158540810169190237_R.xml";
        
        File file=new File(str);
        /*差一个字符长度
        FileReader filereader=new FileReader(file);
        System.out.println(file.length());
        BufferedReader bufferedreader=new BufferedReader(filereader);
        String tmpstr;
        int i=0;
        StringBuffer stb=new StringBuffer();
        while((tmpstr=bufferedreader.readLine())!=null){
            stb.append(tmpstr);
        }
        filereader.close();
        bufferedreader.close();
        XMLUtil.xmlCreate(stb.toString(), str1);
        stb=null;
        */
        /*
        FileInputStream fis=new FileInputStream(file);
        byte[] barr=new byte[10240];
        int i=0;
        String tmpstr="";
        while((i=fis.read(barr))>0){
            System.out.println(i);
            tmpstr+=new String(barr, 0, i, "UTF-8");
        }
        fis.close();
        System.out.println(tmpstr.substring(0, 200));
        XMLUtil.xmlCreate(tmpstr, str1);
        tmpstr=null;
        System.exit(0);
        */
        //xmlCreate
        
        
        ConfigFileUtil.setValue("fileflag", "true");
        String md5str2=MD5Util.getMD5String(str1);
        System.out.println("str:"+str+",md5‘s value:"+md5str2);
    }
    
    @Test
    public void testSqlUtil(){
        String[] stra=null;
        
        stra=new String[2];
        stra[0]="1--";
        stra[1]="2--";
        System.out.println(stra.length);
        for(String st:stra){
            System.out.println(st);
        }
        System.exit(0);
        
        
        String sql = " SELECT CUSNO||‘:‘||ACCOUNT||‘:‘||ZFJGH||‘:‘||BANKNAME "
                + "
" + " FROM SUPIS.PUB_CUSTINFO a " + "
"
                + " WHERE a.ZFJGH=‘Z2004031000014‘ ";
        CommFun.log(1, sql);
        try {
            DBOperation.executeSqlReturnData(sql);
            ArrayList[] ar=DBOperation.getDatas();
            System.out.println(ar.length);
            for(int i=0;i<ar.length;i++){
                System.out.println(ar[i].size()+"----");
                String sttmp=(String) ar[i].toArray()[0];
                System.out.println(sttmp);
            }
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    @Test
    public void testDBOperation(){
        CommFun.log();
        String sql="select 1 from SUPIS.PREPAYCARDSTLFLOW";
        try{
            CommFun.log(1, sql);
            DBOperation.executeSqlReturnData(sql);    
        }catch(SQLException se){
            CommFun.log(1, se.toString());
            se.printStackTrace();
        }
        ArrayList[] ar=DBOperation.getDatas();
        String ret=null;
        if(ar.length>0){
            ret=(String)ar[0].toArray()[0];
        }
        System.out.println(ret);
    }
    
    @Test
    public void testArrlist(){
        ArrayList[] ar=new ArrayList[3];
        ar[0]=new ArrayList();
        ar[0].add(1);
        ar[0].add(2);
        ar[0].add(3);
        System.out.println(ar.length);
        for(int i=0;i<ar.length;i++){
            System.out.println(ar[i].get(0));    
        }
    }
    
    @Test
    public void testcparr(){
        String[] ar1=new String[]{"11"};
        String[] ar2=new String[10];
        System.arraycopy(ar1, 0, ar2, 0, 10);
        System.out.println(ar2);
    }
    
    @Test
    public void testHashMap(){
        HashMap<String,String> hm1;
        HashMap<String,String> hm=new HashMap<String, String>();
        hm.put("zmw1", "111");
        hm.put("zmw2", "222");
        hm.put("zmw3", "333");
        hm1=hm;
        hm1.put("zmw444", "444");
        
//        Object[] t1=hm.keySet().toArray();
//        String[] t2=new String[t1.length];
//        for(int i=0;i<t1.length;i++){
//            t2[i]=(String) t1[i];
//            System.out.println(t2[i]+":"+t2[i].getClass());
//        }
        for(String s:hm1.keySet()){
            System.out.println(s+"........");
        }
        
        
        for(String s:hm.keySet()){
            System.out.println(s+"........");
        }
        
        System.out.println(hm.hashCode()+"..."+hm1.hashCode());
        System.exit(0);
        Iterator<String> is=hm.keySet().iterator();
        if(hm.size()>0){
            String[] mqBackFiles = new String[hm.size()];
            for(int i=0;is.hasNext();i++){
                mqBackFiles[i]=is.next();
                System.out.println(mqBackFiles[i]);
            }
        }else{
            System.out.println("hm‘s size is 0");
        }

        
    }
    
    @Test
    public void testURL() throws Exception{
        URL url=new URL("jdbc:db2://21.12.121.116:50000/etlplusl?user=edw&password=edw");
        System.out.println(url.getHost());
        System.out.println(url.getPort());
        System.out.println(url.getProtocol());
    }

    @Test
    public void testNode() throws DocumentException {
//        String filename = "D:\data\supis\data\20151123\PSIS503_20151123_20151202163714_3R.xml";
        String filename="D:\javajars\PSIS150_20170407_201704071710273890113648163_R.xml";
        File xmlFile = new File(filename);
        System.out.println(xmlFile.getName());
        System.out.println(xmlFile.getParent());
        SAXReader sax = new SAXReader();
        //File xmlFile = new File(filename);
        Document doc = sax.read(xmlFile);
        
        Element rootElement = doc.getRootElement();
        String nameURI = rootElement.getNamespaceURI();
        SqlEntityStatment sestmp1;
        SqlEntityStatment[] sestmps1, sestmps2;
        HashMap nsMap = new HashMap();
        nsMap.put("ns", nameURI);
//        String msgid=rootElement.element("MsgHeader").element("MsgID").getTextTrim();
//        String workdate=rootElement.element("MsgHeader").element("Workdate").getTextTrim();
//        
//        System.out.println("workdate:"+workdate);
        sestmp1 = XMLUtil.dispElementshead(doc, nsMap, "MsgHeader");
        CommFun.log(1, ""+sestmp1);
        sestmp1 = XMLUtil.dispElementshead(doc, nsMap, "MsgBody");
        CommFun.log(1, ""+sestmp1);
        sestmps1 = XMLUtil.dispElements1(doc, nsMap, "TxList");
        CommFun.log(1, ""+sestmp1);
        sestmps2 = XMLUtil.mergedata(sestmp1, sestmps1);
        CommFun.log(1, ""+sestmps2);
        // XMLUtil.dispElementsRows(doc, nsMap, "MsgBody");
        // XMLUtil.dispElements(doc, nsMap, "MsgBody");
        //
        /*
         * StringBuffer[] head=XMLUtil.dispElementstail(doc, nsMap, "DiffList");
         * 
         * for(int i=0;i<head.length && !(head[i]==null);i++){
         * System.out.println("head["+i+"] is ["+head[i].toString()+"]"); }
         */
        //

        // StringBuffer[] stb1=XMLUtil.dispElementstail(doc, nsMap, "BankInfo");

        /*
         * List<Node> nodelist = root.selectNodes("//descendant::*"); for (Node
         * node : nodelist) { System.out.println(node.getUniquePath() + ":" +
         * node.getName() + "=" + node.getText().trim() + ":" +
         * node.getNodeTypeName()); }
         */

        // int nodelen=node.getNodeType();

        // System.out.println(node.MAX_NODE_TYPE);
        // XMLUtil.getNodes(root.element("MsgBody"));
        // XMLUtil.getEmptyNodes(root.element("MsgBody"));

    }

    @Test
    public void testc3p0() {
        int debuglevel=1;
        ConnectionManager dbManager = ConnectionManager.getInstance();
        DataSet rs = null;
        String tmpstr = null;
        String appendString="";
        String dataDate="20170418";
        boolean debugFlag=true;
        int rowslimit=100;
        try {
            rs = dbManager
                    .executeQuery("SELECT IDVALUE FROM EDW.V_SUPIS_A_PUB_CONFIG WHERE INTEGER(CURRENT_DATE) BETWEEN STRDATE  AND ENDDATE  AND IDNAME=‘PSIS802‘");
            if (!rs.isEmpty()) {
                
                String sql= rs.getString(0, 0)+" WHERE A.DATA_DT=TO_DATE("
                        + dataDate
                        + ",‘YYYY-MM-DD‘)-1 DAYS "
                        + ("".equals(appendString) ? "" : " and " + appendString)
                        + " ORDER BY 1,2,3 "
                        + ((debugFlag == true && rowslimit > 0) ? " fetch first "
                                + rowslimit + " rows only" : "");
                CommFun.log(debuglevel, sql);
                DataSet rs1 = dbManager.executeQuery(sql);
                System.out.println(rs1.size());

                System.out.println("-------" + rs1.toString() + "-------");

                int len = rs1.size();
                for (int i = 0; i < len; i++) {
                    ArrayList ar = rs1.getRow(i);
                    for (int j = 0; j < ar.size(); j++) {
                        System.out.print(new String(rs1.getString(i, j)
                                .getBytes("gbk")) + "	");
                    }
                    System.out.println();
                }
                // tmpstr=rs.getString(0, 0);
                // CommonFunction.log(tmpstr);
            }
        } catch (Exception e) {

        }
    }

    @Test
    public void testDate() {
        Date date = CommFun.stringToDate("20110701", "yyyyMMdd");
        System.out.println("date is:" + date);
    }

    @Test
    public void testOs() throws IOException,SQLException {
        // System.out.println(System.getProperty("os.name").toLowerCase());
        // ConfigFileUtil cfu = new ConfigFileUtil();
        // int len=cfu.getValues().length;
        // String osName = cfu.getValue("osName");
        // System.out.println("os is [" + osName + "]");
        String str = DBOperation.getValue("SUPIS_CURRWORKDATE");
        String[] strs = DBOperation.getValues();
        int len = strs.length;
        System.out.println("len is [" + len + "]");
        for (int i = 0; i < len; i++) {
            System.out.println(strs[i].toString());
        }
        System.out.println(DBOperation
                .executeSqlReturn("VALUES CURRENT_TIMESTAMP"));
    }

    @Test
    public void testDispValues() throws Exception {
//        ConfigFileUtil cfg = ConfigFileUtil.getInstance();
//        String[] strs = cfg.getValues();
//        int len = strs.length;
//        for (int i = 0; i < len; i++) {
//            System.out.println(strs[i]);
//        }
//        CommFun.log(1,cfg.getValue("FILE_DIR"));
        
        FileOperation.propertity2File1("/config.properties","1212.txt");
        
        //System.out.println(ConfigFileUtil.getValue("name"));
        System.exit(0);
        
        
        boolean fileFlag=false;
        ConfigFileUtil.setValue("fileFlag", "true");
        System.out.println(ConfigFileUtil.getValue("fileFlag"));
        fileFlag=Boolean.parseBoolean(ConfigFileUtil.getValue("fileFlag"));
        System.out.println("FileFlag:"+fileFlag);
    }

    @Test
    public void String2Date() {
        String date = "2015-10-15";
        String patten = "yyyy-MM-dd";
        // Date dt=stringToDate(dateStr,"yyyy-MM-dd");
        DateFormat sf1 = new SimpleDateFormat("yyyyMMdd");
        DateFormat sf2 = new SimpleDateFormat(patten);
        String sfstr = "";
        try {
            sfstr = sf2.format(sf1.parse(date));
            System.out.println("sfstr is :[" + sfstr + "]");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        DateFormat df = new SimpleDateFormat(patten);
        Date d1;
        try {
            d1 = df.parse(sfstr);
            Calendar g = Calendar.getInstance();
            g.setTime(d1);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    @Test
//    public Date stringToDate(String date, String pattan) 
    public void testDate1(){
        String date="20160203";
        String pattan="yyyy-MM-dd";
        DateFormat sf1 = new SimpleDateFormat("yyyyMMdd");
        
        pattan=pattan.replace("-", "");
        DateFormat sf2 = new SimpleDateFormat(pattan);
        
        String sfstr = "";
        try {
//            sfstr = sf2.format(sf1.parse(date));
            sfstr = sf2.format(sf2.parse(date));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("sfstr is"+sfstr+".");
        DateFormat df = new SimpleDateFormat(pattan);
        Date d1;
        try {
            d1 = df.parse(sfstr);
            Calendar g = Calendar.getInstance();
            g.setTime(d1);
            System.out.println(g.getTime());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }
    
    @Test
    public void testLog(){
        
        for(int i=0;i<5000;i++){
            CommFun.log(ALL,"----------------------"+i+"---------------start");
            CommFun.log(0, "NULL NULL NULL NULL NULL");
            CommFun.log(1, "ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ");
            CommFun.log(2, "INFO INFO INFO INFO INFO INFO INFO INFO ");
            CommFun.log(3, "DATA DATA DATA DATA DATA DATA DATA DATA ");
            CommFun.log(4, "DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG ");
            CommFun.log(0, "NULL1 NULL1 NULL1 NULL1 NULL1 NULL1 NULL1 ");
            CommFun.log(1, "ERROR1 ERROR1 ERROR1 ERROR1 ERROR1 ERROR1 ");
            CommFun.log(2, "INFO1 INFO1 INFO1 INFO1 INFO1 INFO1 INFO1 ");
            CommFun.log(3, "DATA1 DATA1 DATA1 DATA1 DATA1 DATA1 DATA1 ");
            
            CommFun.log(5, "NULL2 NULL2 NULL2 NULL2 NULL2 NULL2 NULL2 ");
            CommFun.log(ALL,"----------------------"+i+"---------------end");
        }
        

        
        System.exit(0);
        int debuglevel=1;
        CommFun.log(debuglevel);
        try {
            new Thread().sleep(4000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        CommFun.log(debuglevel);
    }
    
    @Test
    public void sockthread() throws Exception{
        
    }
    
    @Test
    public void fileLists(){
        String fileName="E:\work\zmw_data\20170327";
        File file=new File(fileName);
        for(File f:file.listFiles(new FilenameFilter() {
            private Pattern pattern=Pattern.compile("PSIS(900|802|1.*).*\.xml");
            @Override
            public boolean accept(File dir, String name) {
                return pattern.matcher(name).matches();
            }
        })){
            System.out.println("["+f.getName()+"]");
        }
    }
    
    @Test
    public void testBase64(){
        String filename="D:\software\andriod反编译_新\apktool\com.examexp_itxf\assets\ExamExp_Src.db";
        filename="d:\pdcomment111.txt";
        String desfilename="d:\ExamExp_Src1.db";
        desfilename="d:\pdcomment2222.txt";
        
        //boolean ret=OfficeFileOper.getImage2File(filename, desfilename);
        //System.out.println(ret);
        boolean ret=OfficeFileOper.getImageFromFile(filename, desfilename);
        System.out.println(ret);
    }
    
    @Test
    public void mathCeil(){
        int d=500;
        int cycle = (int) Math.ceil(d*1.0 / 30);
        int remainder = d % 30;
        System.out.println(cycle);
        System.out.println(remainder);
    }
    
    @Test
    public void testThrowException(){
        try{
            throw new Exception("111111");
        }catch(Exception e){
            e.printStackTrace();
        }
        
    }
    
    @Test
    public void exesqlbatch() throws Exception{
        String[] sqlstr=new String[2];
        sqlstr[0] = "INSERT INTO SUPIS.DIFFDATASENDRESP(MSGID,DATADATE,OrgNO,RefOrg,CheckDate,CheckSeqNO,CheckResult,DiffType,DepositOrWithdraw,OrgOriMsgID,OrgAcct,OrgRefAccount,OrgAmount) VALUES (‘201704070007795102‘,‘20170407‘,‘Z2002831000010‘,‘302290031000‘,‘20170326‘,‘20170407134331‘,‘02‘,‘02‘,‘01‘,‘PSIS15220170327112935200044512‘,‘7312410182400000486‘,‘6214830251992276‘,‘2375.00‘)";
        sqlstr[1] = "INSERT INTO SUPIS.DIFFDATASENDRESP(MSGID,DATADATE,OrgNO,RefOrg,CheckDate,CheckSeqNO,CheckResult,DiffType,DepositOrWithdraw,OrgOriMsgID,OrgAcct,OrgRefAccount,OrgAmount) VALUES (‘201704070007795102‘,‘20170407‘,‘Z2002831000010‘,‘302290031000‘,‘20170326‘,‘20170407134331‘,‘02‘,‘02‘,‘01‘,‘PSIS15220170327112935200044500‘,‘7312410182400000486‘,‘6222023006003897380‘,‘230.00‘)";
        CommFun.log(1,"sqlstr:"+sqlstr.length);
        DBOperation.executeBatchSql(sqlstr);
        CommFun.log();
    }
    
    
    @Test
    public void exedbcmd(){
        DBOperation.admincmd("export to d:\11.del of del select * from SUPIS.PUB_CUSTINFO fetch first 10 rows only");
    }
    
    @Test
    public void reflecttest() {
        String xmlOrder = "800";
        String msgid = "PSIS100201704172017111111111111";
        HashMap<String, String[]> hm1 = ReflectUtil.execute((Object) "com.citic.msgutil.xmlback.Create"
                + xmlOrder + "xml",xmlOrder, msgid);
        for(String str:hm1.keySet()){
            System.out.println(str);
        }
    }
    
    @Test
    public void testses(){
        SqlEntityStatment ses=new SqlEntityStatment("11111", "22222222");
        ses.add("3333", "444444444");
        System.out.println(ses.toString());
    }
    
}

 

以上是关于JAVA之我的公共部分测试调用的主要内容,如果未能解决你的问题,请参考以下文章

使用java.lang.Exception的错误:测试类应该只有一个公共构造函数

片段 null 必须是公共静态类才能从实例状态正确重新创建

《大道至简》之我的大学生活(JAVA)

Django项目开发实例之我的博客

vs2003:快速片段工具

java中的单元测试私有和静态方法