teste de unidade de mola

pacote jnuit.test;


importar java.util.List;

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

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

/********************************************** ******** *  
   Direito de cópia (c) 2005-2008 RLL DIREITOS RESERVADOS PELA SYNICS Ltd.
 * Todos os direitos reservados
 * @author 吴文来 E-mail:[email protected]
 * @versão 1.0
 * Data de criação: 22/12/2009 19:05:43
 * Data de atualização: 22/12/2009 19:05:43
 *
 * *** ************************************************** *****/
public class MeuTeste
{     private static PersonService personService;     private static CommonDao commonDaos;     private static PersonAction personAction;     @BeforeClass     public static void setUpBeforeClass() lança 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+"teste/spring_dao.xml";
         String s3 = string+"test/spring_facade.xml";
         String[] arquivos = {s1,s2,s3};
         ApplicationContext ac = novo FileSystemXmlApplicationContext(arquivos);
         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);        Sistema.fora.



      
    }
   
    @Test
    public void testcommondao()
    {         List<Person> person =commonDaos.getPageins(0, 1, "from Person");         for(Pessoa sp:pessoa)                 System.out.println("sp "+sp.getName());     } // @Test // public void testget() // { // Pessoa person = (Person)personService.getPerson(2); // tente // { // System.out.println(person.getName()); //System.out.println("???????"); //Thread.sleep(1000*16); // } catch (InterruptedException e) // {




   











// // TODO Bloco catch gerado automaticamente
// e.printStackTrace();
// }
// System.out.println("??????????");
// System.out.println(person.getName());
// }
//   
// @Test
// public void testave()
// { // Pessoa pessoa = new Pessoa(); // pessoa.setName("???1"); // pessoaService.add(pessoa); // } //    // @Test // public void testupdate() // { // Pessoa pessoa = (Person)personService.getPerson(1); // pessoa.setName("ok2!"); // personService.update(pessoa);











// }
//   
// @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<Pessoa> pessoa = (List<Pessoa>)personService.getPagein(0,10,personbean);
















      
       for(Pessoa ps:pessoa)
          System.out.println(ps.getId());
       List<Pessoa> person2 = (List<Person>)personService.getTest("Da Pessoa b onde 1=1");
      
       for(Pessoa ps2:pessoa2)
          System.out.println(ps2.getId());
    }
}

おすすめ

転載: blog.csdn.net/QWERT520/article/details/5327510