spring 元单测试

package jnuit.test;


import java.util.List;

import org.hibernate.SessionFactory;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.huawei.bean.Person;
import com.huawei.common.dao.CommonDao;
import com.huawei.person.PersonAction;
import com.huawei.service.PersonService;

/********************************************************* *  
   Copy right (c) 2005-2008 RLL RIGHTS RESSERVED BY SYNICS Ltd.
 *               All rights reserved
 *  @author 吴文来  E-mail:wenlaixl@163.com
 *  @version 1.0
 *  Create Date: 2009-12-22 19:05:43
 *  Update Date: 2009-12-22 19:05:43
 *
 * **********************************************************/
public class MyTest
{
    private static PersonService personService;
    private static CommonDao commonDaos;
    private static PersonAction personAction;
    @BeforeClass
    public static void setUpBeforeClass() throws Exception
    {
         //ApplicationContext ac  = new ClassPathXmlApplicationContext("beans.xml");
       
         String string = "F:/worspace/ssh2/WebRoot/WEB-INF/conf/";
         String s1 = string+"spring_beans.xml";
         String s2 = string+"test/spring_dao.xml";
         String s3 = string+"test/spring_facade.xml";
         String[] files = {s1,s2,s3};
         ApplicationContext ac = new FileSystemXmlApplicationContext(files);
         personService  = (PersonService)ac.getBean("personService");
         commonDaos     = (CommonDao)ac.getBean("commonDaos");
         personAction   = (PersonAction)ac.getBean("personList");
    }
   
    @Test
    public void testAction()
    {
       String aa= personAction.paginBy();
       System.out.println("aa "+aa);
       System.out.println("cc"+personAction.getPageBar());
      
    }
   
    @Test
    public void testcommondao()
    {
        List<Person> person =commonDaos.getPageins(0, 1, "from Person");
        for(Person sp:person)
                System.out.println("sp  "+sp.getName());
    }
   
//    @Test
//    public void testget()
//    {
//        Person person = (Person)personService.getPerson(2);
//        try
//        {
//            System.out.println(person.getName());
//            System.out.println("???????");
//            Thread.sleep(1000*16);
//        } catch (InterruptedException e)
//        {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
//        System.out.println("????????");
//        System.out.println(person.getName());
//    }
//   
//    @Test
//    public void  testsave()
//    {
//        Person person = new Person();
//        person.setName("???1");
//        personService.add(person);
//    }
//   
//    @Test
//    public void testupdate()
//    {
//        Person person = (Person)personService.getPerson(1);
//        person.setName("ok2!");
//        personService.update(person);
//    }
//   
//    @Test
//    public void testdelete()
//    {
//        personService.delete(1);
//    }
//   
//    @Test
//    public void testPersonList()
//    {
//      List<Person>    person = (List<Person>)personService.getPersonList();
//      for(Person ps:person)
//          System.out.println(ps.getName());
//    }
    @Test
    public void testPersonPageid()
    {
       Person personbean = new Person();
       personbean.setName("abc");
       List<Person>    person = (List<Person>)personService.getPagein(0,10,personbean);
      
       for(Person ps:person)
          System.out.println(ps.getId());
       List<Person>    person2 = (List<Person>)personService.getTest("From Person b where 1=1");
      
       for(Person ps2:person2)
          System.out.println(ps2.getId());
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值