paquet jnuit.test ;
importer java.util.List ;
importer org.hibernate.SessionFactory ;
importer org.junit.BeforeClass ;
importer org.junit.Test ;
importer org.springframework.context.ApplicationContext ;
importer org.springframework.context.support.ClassPathXmlApplicationContext ;
importer org.springframework.context.support.FileSystemXmlApplicationContext ;
importer com.huawei.bean.Person ;
importer com.huawei.common.dao.CommonDao ;
importer com.huawei.person.PersonAction ;
importer com.huawei.service.PersonService ;
/*************************************************** ******** *
Droit de copie (c) 2005-2008 DROITS RLL RÉSERVÉS PAR SYNICS Ltd.
* Tous droits réservés
* @auteur 吴文来 E-mail :[email protected]
* @version 1.0
* Date de création : 2009-12-22 19:05:43
* Date de mise à jour : 2009-12-22 19:05:43
*
* *** ************************************************** *****/
classe publique MonTest
{ privé statique PersonService personService ; CommonDao statique privé commonDaos ; PersonAction statique privée personAction ; @BeforeClass public static void setUpBeforeClass() lance une exception { //ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml"); Chaîne chaîne = "F:/worspace/ssh2/WebRoot/WEB-INF/conf/";
Chaîne s1 = chaîne+"spring_beans.xml";
Chaîne s2 = chaîne+"test/spring_dao.xml";
Chaîne s3 = chaîne+"test/spring_facade.xml";
Fichiers String[] = {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.
}
@Test
public void testcommondao()
{ List<Person> person =commonDaos.getPageins(0, 1, "from Person"); for(Personne sp:person) System.out.println("sp "+sp.getName()); } // @Test // public void testget() // { // Personne personne = (Personne)personService.getPerson(2); // essayez // { // System.out.println(person.getName()); // System.out.println("???????"); // Thread.sleep(1000*16); // } catch (InterruptedException e) // {
// // TODO Bloc catch généré automatiquement
// e.printStackTrace();
// }
// System.out.println("??????????");
// System.out.println(personne.getName());
// }
//
// @Test
// public void testsave()
// { // Personne personne = new Personne(); // personne.setName("???1"); // personService.add(personne); // } // // @Test // public void testupdate() // { // Personne personne = (Personne)personService.getPerson(1); // personne.setName("ok2!"); // personneService.update(personne);
// }
//
// @Test
// public void testdelete()
// { // personService.delete(1); // } // // @Test // public void testPersonList() // { // List<Person> person = (List<Person>)personService.getPersonList(); // pour (Personne ps:personne) // System.out.println(ps.getName()); // } @Test public void testPersonPageid() { Personne personbean = new Person(); personbean.setName("abc"); List<Person> personne = (List<Person>)personService.getPagein(0,10,personbean);
for(Personne ps:person)
System.out.println(ps.getId());
List<Person> person2 = (List<Person>)personService.getTest("From Person b Where 1=1");
for(Personne ps2:person2)
System.out.println(ps2.getId());
}
}
tests unitaires à ressort
Je suppose que tu aimes
Origine blog.csdn.net/QWERT520/article/details/5327510
conseillé
Classement