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

📄 hibernateclinictestsforaroundtest.java

📁 随书光盘:精通Sping 2.0 的随书源代码
💻 JAVA
字号:
package org.springframework.samples.petclinic.hibernate;

import java.util.Collection;

import org.springframework.samples.petclinic.Clinic;
import org.springframework.samples.petclinic.Owner;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

/**
 * 
 * @author worldheart
 *
 */
public class HibernateClinicTestsForAroundTest extends AbstractTransactionalDataSourceSpringContextTests {

	protected Clinic clinic;

	public void setClinic(Clinic clinic) {
		this.clinic = clinic;
	}

	public void testInsertOwnerVerson1() {
		Collection owners = this.clinic.findOwners("Schultz");
		int found = owners.size();
		Owner owner = new Owner();
		owner.setLastName("Schultz");
		this.clinic.storeOwnerSave(owner);
		//借助于findOwners查找Owner
		owners = this.clinic.findOwners("Schultz");
		assertEquals(found + 1, owners.size());
	}
	
	public void testInsertOwnerVersion2() {
		this.deleteFromTables(new String[]{"visits","pets","owners"});
		Owner owner = new Owner();
		owner.setLastName("Schultz1");
		this.clinic.storeOwnerSave(owner);
		assertEquals(1, this.jdbcTemplate.queryForInt("select count(*) from owners where city = 'gz'"));
		owner = new Owner();
		owner.setLastName("Schultz2");
		this.clinic.storeOwnerSave(owner);
		assertEquals(2, this.jdbcTemplate.queryForInt("select count(*) from owners where city = 'gz'"));
		owner = new Owner();
		owner.setLastName("Schultz3");
		this.clinic.storeOwnerSave(owner);
		assertEquals(3, this.jdbcTemplate.queryForInt("select count(*) from owners where city = 'gz'"));
	}

	protected String[] getConfigLocations() {
		return new String[] { "/org/springframework/samples/petclinic/hibernate/applicationContext-hibernate-around.xml" };
	}

}

⌨️ 快捷键说明

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