📄 usertest.java
字号:
package com.sdi0708.bdifn.bookstore.domain;import java.util.Date;import junit.framework.TestCase;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class UserTest extends TestCase { Session session = null; @Override protected void setUp() throws Exception { super.setUp(); String config = "com/sdi0708/bdifn/bookstore/domain/applicationContext.xml"; ApplicationContext context = new ClassPathXmlApplicationContext(config); SessionFactory sessionFactory = (SessionFactory) context .getBean("sessionFactory"); session = sessionFactory.openSession(); } @Override protected void tearDown() throws Exception { super.tearDown(); session.close(); } public void testSave() { User user = new User(); user.setUid("kgdbdifn"); user.setPassword("123456"); user.setCreateTime(new Date()); user.setName("chengzhi"); user.setEmail("bdifn@163.com"); user.setAddress("bj"); user.setZipcode("1000001"); user.setTelphone("1111111111"); user.setHomephone("22222222"); user.setOfficephone("111122222"); user.setScore(100); session.beginTransaction(); session.save(user); session.getTransaction().commit(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -