亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? jpaclinictests.java

?? struts+spring 源碼 希望能給大家帶來幫助
?? JAVA
字號:
/*
 * Copyright 2002-2006 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.samples.petclinic.jpa;

import java.util.Collection;
import java.util.Date;

import javax.persistence.EntityManager;

import org.springframework.samples.petclinic.Clinic;
import org.springframework.samples.petclinic.Owner;
import org.springframework.samples.petclinic.Pet;
import org.springframework.samples.petclinic.PetType;
import org.springframework.samples.petclinic.Specialty;
import org.springframework.samples.petclinic.Vet;
import org.springframework.samples.petclinic.Visit;
import org.springframework.samples.petclinic.util.EntityUtils;
import org.springframework.test.annotation.ExpectedException;
import org.springframework.test.jpa.AbstractJpaTests;

/**
 * <p>This class extends AbstractJpaTests,
 * one of the valuable test superclasses provided in the org.springframework.test
 * package. This represents best practice for integration tests with Spring. 
 * The AbstractTransactionalDataSourceSpringContextTests superclass provides the
 * following services:
 * <li>Injects test dependencies, meaning that we don't need to perform application
 * context lookups. See the setClinic() method. Injection uses autowiring by type.
 * <li>Executes each test method in its own transaction, which is automatically
 * rolled back by default. This means that even if tests insert or otherwise
 * change database state, there is no need for a teardown or cleanup script.
 * <li>Provides useful inherited protected fields, such as a JdbcTemplate that can be
 * used to verify database state after test operations, or verify the results of queries
 * performed by application code. An ApplicationContext is also inherited, and can be
 * used for explicit lookup if necessary.
 *
 * <p>The AbstractTransactionalDataSourceSpringContextTests and related classes are shipped
 * in the spring-mock.jar.
 * @see AbstractJpaTests
 * @author Rod Johnson
 */
public abstract class JpaClinicTests extends AbstractJpaTests {
	
	protected Clinic clinic;
	
	@ExpectedException(IllegalArgumentException.class)
	public void testBogusJpql() {
		sharedEntityManager.createQuery("SELECT RUBBISH FROM RUBBISH HEAP").executeUpdate();
	}
	
	public void testApplicationManaged() {
		EntityManager appManaged = entityManagerFactory.createEntityManager();
		appManaged.joinTransaction();
	}


	/**
	 * This method is provided to set the Clinic instance being tested by the Dependency Injection
	 * injection behaviour of the superclass from the <code>org.springframework.test</code> package.
	 * @param clinic clinic to test
	 */
	public void setClinic(Clinic clinic) {
		this.clinic = clinic;
	}


	public void testGetVets() {
		Collection vets = this.clinic.getVets();
		
		// Use the inherited JdbcTemplate (from AbstractTransactionalDataSourceSpringContextTests) 
		// to verify the results of the query
		assertEquals("JDBC query must show the same number of vets",
				jdbcTemplate.queryForInt("SELECT COUNT(0) FROM VETS"), 
				vets.size());
		Vet v1 = (Vet) EntityUtils.getById(vets, Vet.class, 2);
		assertEquals("Leary", v1.getLastName());
		assertEquals(1, v1.getNrOfSpecialties());
		assertEquals("radiology", ((Specialty) v1.getSpecialties().get(0)).getName());
		Vet v2 = (Vet) EntityUtils.getById(vets, Vet.class, 3);
		assertEquals("Douglas", v2.getLastName());
		assertEquals(2, v2.getNrOfSpecialties());
		assertEquals("dentistry", ((Specialty) v2.getSpecialties().get(0)).getName());
		assertEquals("surgery", ((Specialty) v2.getSpecialties().get(1)).getName());
	}

	public void testGetPetTypes() {
		Collection petTypes = this.clinic.getPetTypes();
		assertEquals("JDBC query must show the same number of pet typess",
				jdbcTemplate.queryForInt("SELECT COUNT(0) FROM TYPES"), 
				petTypes.size());
		PetType t1 = (PetType) EntityUtils.getById(petTypes, PetType.class, 1);
		assertEquals("cat", t1.getName());
		PetType t4 = (PetType) EntityUtils.getById(petTypes, PetType.class, 4);
		assertEquals("snake", t4.getName());
	}

	public void testFindOwners() {
		Collection owners = this.clinic.findOwners("Davis");
		assertEquals(2, owners.size());
		owners = this.clinic.findOwners("Daviss");
		assertEquals(0, owners.size());
	}

//	public void testLoadOwner() {
//		Owner o1 = this.clinic.loadOwner(1);
//		assertTrue(o1.getLastName().startsWith("Franklin"));
//		Owner o10 = this.clinic.loadOwner(10);
//		assertEquals("Carlos", o10.getFirstName());
//		
//		// Check lazy loading, by ending the transaction
//		endTransaction();
//		// Now Owners are "disconnected" from the data store.
//		// We might need to touch this collection if we switched to lazy loading
//		// in mapping files, but this test would pick this up.
//		o1.getPets();
//	}

	public void testInsertOwner() {
		Collection owners = this.clinic.findOwners("Schultz");
		int found = owners.size();
		Owner owner = new Owner();
		owner.setLastName("Schultz");
		this.clinic.storeOwner(owner);
		// assertTrue(!owner.isNew());  -- NOT TRUE FOR TOPLINK (before commit)
		owners = this.clinic.findOwners("Schultz");
		assertEquals(found + 1, owners.size());
	}

	public void testUpdateOwner() throws Exception {
		Owner o1 = this.clinic.loadOwner(1);
		String old = o1.getLastName();
		o1.setLastName(old + "X");
		this.clinic.storeOwner(o1);
		o1 = this.clinic.loadOwner(1);
		assertEquals(old + "X", o1.getLastName());
	}

	public void testLoadPet() {
		Collection types = this.clinic.getPetTypes();
		Pet p7 = this.clinic.loadPet(7);
		assertTrue(p7.getName().startsWith("Samantha"));
		assertEquals(EntityUtils.getById(types, PetType.class, 1).getId(), p7.getType().getId());
		assertEquals("Jean", p7.getOwner().getFirstName());
		Pet p6 = this.clinic.loadPet(6);
		assertEquals("George", p6.getName());
		assertEquals(EntityUtils.getById(types, PetType.class, 4).getId(), p6.getType().getId());
		assertEquals("Peter", p6.getOwner().getFirstName());
	}

	public void testInsertPet() {
		Owner o6 = this.clinic.loadOwner(6);
		int found = o6.getPets().size();
		Pet pet = new Pet();
		pet.setName("bowser");
		Collection types = this.clinic.getPetTypes();
		pet.setType((PetType) EntityUtils.getById(types, PetType.class, 2));
		pet.setBirthDate(new Date());
		o6.addPet(pet);
		assertEquals(found + 1, o6.getPets().size());
		// both storePet and storeOwner are necessary to cover all ORM tools
		this.clinic.storePet(pet);
		this.clinic.storeOwner(o6);
		// assertTrue(!pet.isNew());  -- NOT TRUE FOR TOPLINK (before commit)
		o6 = this.clinic.loadOwner(6);
		assertEquals(found + 1, o6.getPets().size());
	}

	public void testUpdatePet() throws Exception {
		Pet p7 = this.clinic.loadPet(7);
		String old = p7.getName();
		p7.setName(old + "X");
		this.clinic.storePet(p7);
		p7 = this.clinic.loadPet(7);
		assertEquals(old + "X", p7.getName());
	}

	public void testInsertVisit() {
		Pet p7 = this.clinic.loadPet(7);
		int found = p7.getVisits().size();
		Visit visit = new Visit();
		p7.addVisit(visit);
		visit.setDescription("test");
		// both storeVisit and storePet are necessary to cover all ORM tools
		this.clinic.storeVisit(visit);
		this.clinic.storePet(p7);
		// assertTrue(!visit.isNew());  -- NOT TRUE FOR TOPLINK (before commit)
		p7 = this.clinic.loadPet(7);
		assertEquals(found + 1, p7.getVisits().size());
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品欧美激情| 亚洲自拍偷拍图区| 欧美色老头old∨ideo| 精品一区二区三区久久| 亚洲欧美日韩国产手机在线| 欧美电影免费观看完整版 | 色综合色狠狠综合色| 开心九九激情九九欧美日韩精美视频电影 | 国产精品主播直播| 香蕉久久夜色精品国产使用方法| 国产日产亚洲精品系列| 欧美色爱综合网| 成人动漫中文字幕| 精品一区二区三区日韩| 五月婷婷激情综合| 亚洲欧洲综合另类在线| 国产欧美日韩久久| 久久久久久亚洲综合影院红桃| 欧美日韩一区二区电影| 97久久精品人人做人人爽| 国产在线一区二区综合免费视频| 五月开心婷婷久久| 夜夜嗨av一区二区三区| 国产精品久久久久永久免费观看 | 色综合一区二区| 国产精品一二三四五| 蜜臀av一区二区| 午夜精品久久久久久久| 亚洲精品精品亚洲| 国产精品久久久久久久岛一牛影视| 久久综合九色综合久久久精品综合| 91精品国产综合久久精品图片 | 91在线视频在线| 成人av动漫在线| 国产精品99久| 国产成人精品一区二| 国产在线麻豆精品观看| 久久99深爱久久99精品| 日韩av网站免费在线| 亚洲电影一区二区| 一区av在线播放| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 久久免费精品国产久精品久久久久 | 日韩高清中文字幕一区| 性感美女久久精品| 亚洲一区在线视频观看| 亚洲成精国产精品女| 亚洲一区二区三区四区五区中文| 亚洲免费观看高清在线观看| 亚洲精品一二三| 亚洲综合自拍偷拍| 亚洲成人激情av| 美国三级日本三级久久99| 日本欧美一区二区在线观看| 日韩高清在线电影| 精品制服美女久久| 国产成人亚洲综合a∨婷婷| 成人晚上爱看视频| 99久久精品情趣| 在线国产电影不卡| 91麻豆精品国产91久久久久久| 欧美一区日本一区韩国一区| 91精品一区二区三区久久久久久 | 亚洲1区2区3区4区| 蜜臀av性久久久久蜜臀av麻豆| 老司机精品视频线观看86| 国产精品一区二区无线| 91小视频在线| 在线播放一区二区三区| 久久这里只有精品视频网| 国产精品福利影院| 视频一区二区欧美| 国产成人av一区| 91久久久免费一区二区| 日韩你懂的电影在线观看| 欧美国产综合色视频| 亚洲一区二区三区在线| 久久精品72免费观看| 成人激情图片网| 91精品国产全国免费观看| 久久久精品人体av艺术| 国产精品不卡视频| 日韩福利电影在线| 床上的激情91.| 欧美精选在线播放| 亚洲国产成人在线| 香蕉成人啪国产精品视频综合网| 国产在线精品一区二区不卡了| av色综合久久天堂av综合| 欧美日本一区二区三区四区| 久久久99久久精品欧美| 亚洲国产成人高清精品| 福利一区二区在线观看| 91精品国产aⅴ一区二区| 国产精品女主播在线观看| 亚洲成人免费av| av电影天堂一区二区在线观看| 欧美日韩不卡在线| 国产精品久久影院| 精品系列免费在线观看| 欧美日韩综合一区| 国产精品污污网站在线观看| 老司机免费视频一区二区| 欧美性感一类影片在线播放| 国产精品每日更新| 久久激情五月激情| 欧美丰满少妇xxxxx高潮对白| 国产精品国产三级国产aⅴ无密码| 九一九一国产精品| 欧美久久久久久久久久| 一区二区三区中文免费| 成人av网站免费观看| 精品久久久久一区二区国产| 午夜视频在线观看一区二区三区| 成人av在线一区二区三区| 国产亚洲美州欧州综合国| 久久99精品久久只有精品| 欧美日韩一区二区三区视频| 亚洲欧洲99久久| 国产成人精品综合在线观看 | 丰满白嫩尤物一区二区| 精品国精品国产| 日韩高清一区二区| 欧美日本在线一区| 亚洲欧美日本韩国| av毛片久久久久**hd| 国产精品天天看| 国产成人在线影院| 国产日韩欧美精品一区| 国产成人一区二区精品非洲| 久久欧美一区二区| 国产精品综合一区二区三区| 久久亚洲欧美国产精品乐播| 老司机免费视频一区二区三区| 日韩一级黄色片| 九一久久久久久| 久久伊人蜜桃av一区二区| 国产一区在线观看视频| 337p粉嫩大胆噜噜噜噜噜91av| 黄网站免费久久| 久久天天做天天爱综合色| 国产在线一区二区| 欧美激情综合五月色丁香 | 欧美一区二区三区免费| 欧美a级理论片| www一区二区| 国产精品中文欧美| 国产精品污www在线观看| 91丝袜美女网| 亚洲影院理伦片| 欧美一区二区三区不卡| 精品无人码麻豆乱码1区2区| 国产欧美一区二区精品忘忧草| 懂色av中文一区二区三区| 亚洲欧美一区二区三区孕妇| 欧美亚洲一区二区在线| 奇米精品一区二区三区四区| 久久综合色天天久久综合图片| 国产精品一区二区黑丝| 亚洲三级在线观看| 91麻豆精品国产自产在线| 国内精品不卡在线| 亚洲欧洲日产国产综合网| 欧美亚洲禁片免费| 久久成人综合网| 国产精品电影院| 欧美日韩高清一区二区不卡| 久久成人麻豆午夜电影| 国产精品久久久久毛片软件| 欧美性生交片4| 久久66热偷产精品| 中文字幕一区二区日韩精品绯色| 欧美日韩一区二区三区四区五区 | 一区二区三区在线观看动漫| 欧美人与性动xxxx| 国产酒店精品激情| 亚洲一区二区三区四区在线观看 | 成人av集中营| 五月婷婷久久丁香| 欧美激情综合网| 欧美日韩不卡在线| 成人开心网精品视频| 午夜电影网亚洲视频| 国产亚洲精品精华液| 欧美日韩在线直播| 91九色02白丝porn| 精品午夜久久福利影院 | 国产毛片精品一区| 亚洲三级理论片| www国产成人免费观看视频 深夜成人网| 成人免费高清在线观看| 日本va欧美va精品| 亚洲男女毛片无遮挡| 久久亚洲欧美国产精品乐播| 欧美人xxxx| 一本到三区不卡视频| 国产原创一区二区| 日韩和欧美一区二区三区| 中文字幕中文字幕在线一区| 欧美变态tickling挠脚心|