第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

junit.framework.AssertionFailedError: expected:<true> but was:<false> at junit.framework.Assert.fail(Assert.java:57) at junit.framework.Assert.failNotEquals(Assert.java:329) at junit.framework.Assert.assertEquals(Assert.java:78) at junit.framework.Ass

package?service.impl;

import?java.util.List;

import?org.hibernate.Query;
import?org.hibernate.Session;
import?org.hibernate.Transaction;

import?db.MyHibernateSessionFactory;
import?entity.Users;
import?service.UsersDAO;

public?class?UsersDAOImpl?implements?UsersDAO?{

	@Override
	public?boolean?usersLogin(Users?u)?{

		//?事物對(duì)象
		Transaction?tx?=?null;
		String?hql?=?"";

		try?{
			Session?session?=?MyHibernateSessionFactory.getSessionFactory().getCurrentSession();
			tx?=?session.beginTransaction();
			hql?=?"from?Users?where?username=??and?password=??";
			Query?query?=?session.createQuery(hql);
			query.setParameter(0,?u.getUsername());
			query.setParameter(1,?u.getPassword());
			List<?>?list?=?query.list();
			
			tx.commit();//提交事物
			
			if?(list.size()>0)?{
				return?true;
			}?else?{
				return?false;
			}

		}?catch?(Exception?ex)?{
			ex.printStackTrace();
			return?false;
		}?finally?{
			if?(tx?!=?null)?{
				tx?=?null;

			}
		}
	}

}


package?service.impl;

import?org.junit.Test;

import?entity.Users;
import?junit.framework.Assert;
import?service.UsersDAO;

public?class?TestUsersDAOImpl?{

	@Test
	public?void?testUsersLogin()?{

		Users?u?=?new?Users(1,?"zhangsan",?"123456");
		UsersDAO?udao?=?new?UsersDAOImpl();
		//?udao.usersLogin(u);
		Assert.assertEquals(true,?udao.usersLogin(u));
		//將expected改為false則測(cè)試通過
	}

}

DeBug顯示返回的list的 ?size 0



正在回答

11 回答

在測(cè)試類這里加個(gè)注解吧,

@SuppressWarnings("deprecation")

public class TestUsersDAOImpl {

開始我按提示加了注解,好像就好了

0 回復(fù) 有任何疑惑可以回復(fù)我~
首頁上一頁12下一頁尾頁

舉報(bào)

0/150
提交
取消

junit.framework.AssertionFailedError: expected:<true> but was:<false> at junit.framework.Assert.fail(Assert.java:57) at junit.framework.Assert.failNotEquals(Assert.java:329) at junit.framework.Assert.assertEquals(Assert.java:78) at junit.framework.Ass

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)