• Junit单元测试类


    /*package zxdc.web;
    
    import static org.junit.Assert.*;
    
    import java.io.IOException;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import static org.easymock.EasyMock.*;
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import zyzy.common.util.Common;
    
    public class JunitEx {
            private Common servlet;  
            private HttpServletRequest mockRequest;  
            private HttpServletResponse mockResponse;  
    
        public JunitEx(){
            
        }
        @Before
        public void setUp()throws Exception{
            servlet = new Common();  
            
            mockRequest = createMock(HttpServletRequest.class);          
            mockResponse = createMock(HttpServletResponse.class);  
        }
        @After
        public void tearDown()throws Exception{
            verify(mockRequest);         
            verify(mockResponse);  
        }
        
        
         @Test  
            public void testDoPostHttpServletRequestHttpServletResponse() throws ServletException, IOException {  
                  
                mockRequest.getParameter("id");          
                expectLastCall().andReturn("1");  
                  
               
                replay(mockRequest);                     
                replay(mockResponse);  
                  
                servlet.doPost(mockRequest, mockResponse);   
                          
            }  
          
        @Test
        public void xmlsql(){
            String provinceid="12";
            Common xmlCommon=new Common();
            String resultString=xmlCommon.provinceIdEXprovinceCodeFromXml(provinceid);
            System.out.println(resultString);
            String expResult="0";
            assertEquals(expResult,resultString);
        }
        @Test
        public void getHalfYearId(){
            Common xmlCommon=new Common();
            String resultString=xmlCommon.getHalfYearId();
            String expResult="0";
            System.out.println(resultString);
            //assertEquals(expResult,resultString);
        }
    }
    */
  • 相关阅读:
    java 静态代码块和spring @value等注解注入顺序
    中秋节
    IP切换
    MMF循环队列实现RPC
    Redis 集群方案
    简单Http多线程下载实现
    信息采集
    大四了
    懒懒交流会《前端,架构,框架与库》里面提到的一些问题
    [知识整理] 导数据工具
  • 原文地址:https://www.cnblogs.com/colmeluna/p/3739388.html
Copyright © 2020-2023  润新知