首页>代码>java企业考勤系统>/clocksimplejee4/intergrationtest/com/dovesoftware/clocksimplejee3/intergrationtest/LoginTest.java
package com.dovesoftware.clocksimplejee3.intergrationtest;

import junit.framework.Assert;
import junit.framework.TestCase;

import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.SubmitButton;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebForm;
import com.meterware.httpunit.WebLink;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;

public class LoginTest extends TestCase {
	public void testLogin() {
		try {
			long now = System.currentTimeMillis();
			for (int i = 0; i < 100; i++){
				WebConversation wc2 = new WebConversation();
				//获取响应对象
	
				WebResponse   resp = wc2.getResponse( "http://localhost:8080/ClockSimpleJEE3/login/index.jsp" );
				//获得对应的表单对象
				WebForm webForm = resp.getForms()[0];
				SubmitButton submitButton1 = webForm.getSubmitButton("login");
				WebRequest req1 = webForm.getRequest();
				webForm.setParameter("empid","160208");
				webForm.setParameter("password","jerry");
				resp = webForm.submit(submitButton1);
				
				//用getText方法获取相应的全部内容
				//用System.out.println将获取的内容打印在控制台上
				Assert.assertTrue(resp.getText().contains("Welcome to the Clock Online System."));
			}
			long now2 = System.currentTimeMillis();
			System.out.println("In miliseconds:"+ (now2-now));
//			throw new Exception();
		} catch (Exception e) {
			System.err.println("Exception: " + e);
			Assert.assertTrue("Test failed.", false);
		}
	}
}
最近下载更多
balabalawuyu  LV6 2022年11月17日
hu10086  LV1 2022年5月21日
xaiozhu  LV7 2022年4月10日
liugtnb  LV2 2022年3月24日
1819615780  LV1 2021年12月25日
kk1031  LV8 2021年9月6日
LYS_myheart  LV2 2021年7月24日
monkalon  LV14 2021年7月10日
weijiajun  LV1 2021年6月29日
15038811780  LV2 2021年6月2日
最近浏览更多
feizai0101 4月14日
暂无贡献等级
bai fei liu  LV1 3月28日
xiaojie93  LV2 3月1日
1134116035 2月28日
暂无贡献等级
阿卡丽  LV3 2月7日
微笑刺客  LV15 1月20日
123456wadff  LV3 1月15日
ClydeSon  LV5 2023年12月27日
baozhenghua  LV2 2023年12月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友