⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employeeservicetest.java

📁 是Eclipse web开发从入门到精通的源码
💻 JAVA
字号:
package com.REP.test;

import java.math.BigDecimal;

import junit.framework.TestCase;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.REP.DAO.AccountDAO;
import com.REP.DAO.EmployeeDAO;
import com.REP.ServiceImpl.EmployeeServiceImpl;
import com.REP.bean.Account;
import com.REP.excptions.AccountIsExistException;
import com.REP.excptions.AccountNotExistException;
import com.REP.excptions.OverDrawException;

public class EmployeeServiceTest extends TestCase {
    
    public EmployeeServiceImpl employeeservice ;
    public Account account = new Account();
    public EmployeeDAO employeedao = new EmployeeDAO();
    public AccountDAO accountdao =  new AccountDAO();
   
    protected void setUp() throws Exception {
        super.setUp();
        
        Configuration config = new Configuration().configure("com/REP/hbm/hibernate.cfg.xml");
        SessionFactory sessionfactory = config.buildSessionFactory();
        employeedao.setSessionFactory(sessionfactory);
        accountdao.setSessionFactory(sessionfactory);
        employeeservice = new EmployeeServiceImpl();
        employeeservice.setAccountdao(accountdao);
        employeeservice.setEmployeedao(employeedao);
        account.setLoginName("zs");
        account.setOverdrawNumber(2);
        account.setBalance(new BigDecimal("0"));
        
        
    }

    /*
     * Test method for 'com.REP.ServiceImpl.EmployeeServiceImpl.regist(Employee)'
     */
    public void testRegist() {
        try {
            employeeservice.regist(account);
        } catch (AccountIsExistException e) {
            System.out.println("account is already exist");
        }
        
    }

    /*
     * Test method for 'com.REP.ServiceImpl.EmployeeServiceImpl.repast(String, String)'
     */
    public void testRepast() {
       try {
           employeeservice.repast("zs","10");
       } catch (AccountNotExistException e) {
           System.out.println("the account is not exist");
        
       } catch (OverDrawException e) {
           System.out.println("you are overDraw");
       }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -