Added: shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/CategoryTest.java URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/CategoryTest.java?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/CategoryTest.java (added) +++ shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/CategoryTest.java Mon Jul 31 09:31:56 2006 @@ -0,0 +1,57 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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.apache.shale.petstore.domain; + +import junit.framework.TestCase; +import org.apache.shale.petstore.domain.Pet; +import org.apache.shale.petstore.domain.Category; + +/** + * @author Sean Schofield + */ +public class CategoryTest extends TestCase { + + Pet pet; + private Category fooCategory; + private Category barCategory; + + protected void setUp() throws Exception { + pet = new Pet(); + pet.setProductId("003201233"); + fooCategory = new Category("foo category"); + barCategory = new Category("bar category"); + } + + public void testAddPet() { + fooCategory.addPet(pet); + assertEquals("pet.category", fooCategory, pet.getCategory()); + assertTrue("category pet set should contain the pet", fooCategory.getPets().contains(pet)); + } + +// public void testEquals() { +// assertFalse("fooCategory.equals(barCategory)", fooCategory.equals(barCategory)); +// Category buzzCategory = new Category("buzz category"); +// +// // categoryId should be sufficient to satisfy equals +// assertTrue("fooCategory.equals(buzzCategory)", fooCategory.equals(buzzCategory)); +// +// // equals method should also be checking the categoryId of the parent when present +// buzzCategory.setParentCategory(fooCategory); +// assertFalse("! buzzCategory.equals(barCategory)", buzzCategory.equals(barCategory)); +// barCategory.setParentCategory(fooCategory); +// assertTrue("buzzCategory.equals(barCategory)", buzzCategory.equals(barCategory)); +// } +}
Added: shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/PetTest.java URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/PetTest.java?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/PetTest.java (added) +++ shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/domain/PetTest.java Mon Jul 31 09:31:56 2006 @@ -0,0 +1,64 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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.apache.shale.petstore.domain; + +import junit.framework.TestCase; + +import java.util.Set; + +import org.apache.shale.petstore.domain.Pet; +import org.apache.shale.petstore.domain.Category; + +/** + * @author Sean Schofield + */ +public class PetTest extends TestCase { + + Pet pet; + Category dogs; + Category cats; + private static final String DOGS = "DOGS"; + private static final String CATS = "CATS"; + + + protected void setUp() throws Exception { + super.setUp(); + + dogs = new Category(DOGS); + cats = new Category(CATS); + + pet = new Pet(cats, "0403220", "cat description"); + cats.addPet(pet); + } + + /** + * A pet can have at most one category so the setter method should enforce this. The domain model is + * responsible for enforcing these relationship rules so they need to be tested here. + * @throws Exception + */ + public void testSetCategory() throws Exception { + assertEquals("pet.category.description", CATS, pet.getCategory().getDescription()); + Set petSet = cats.getPets(); + assertTrue("category pet set should contain the pet", petSet.contains(pet)); + + pet.changeCategory(dogs); + petSet = cats.getPets(); + assertFalse("old category should no longer contain pet", petSet.contains(pet)); + petSet = dogs.getPets(); + assertTrue("new category should contain pet", petSet.contains(pet)); + } + +} Added: shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/AbstractHibernateDaoTestCase.java URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/AbstractHibernateDaoTestCase.java?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/AbstractHibernateDaoTestCase.java (added) +++ shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/AbstractHibernateDaoTestCase.java Mon Jul 31 09:31:56 2006 @@ -0,0 +1,82 @@ +package org.apache.shale.petstore.persistence.impl; + +import org.springframework.transaction.support.TransactionSynchronizationManager; +import org.springframework.orm.hibernate3.SessionFactoryUtils; +import org.springframework.orm.hibernate3.SessionHolder; +import org.springframework.orm.hibernate3.HibernateTemplate; +import org.hibernate.SessionFactory; +import org.hibernate.Session; +import org.hibernate.dialect.HSQLDialect; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import junit.framework.TestCase; + +import java.io.File; + +/** + * Base test case for all test cases of Hibernate DAO implementations. Perform basic session and + * transaction setup and teardown here. + * @author Sean Schofield + */ +public class AbstractHibernateDaoTestCase extends TestCase { + + protected PetDaoHibernate petDao; + protected CategoryDaoHibernate categoryDao; + private SessionFactory sessionFactory; + private Session session; + + public void setUp() throws Exception { + Configuration configuration = new Configuration(); + configuration.setProperty(Environment.DRIVER, "org.hsqldb.jdbcDriver"); + configuration.setProperty(Environment.URL, "jdbc:hsqldb:mem:ProductDAOTest"); + configuration.setProperty(Environment.USER, "sa"); + configuration.setProperty(Environment.DIALECT, HSQLDialect.class.getName()); + configuration.setProperty(Environment.SHOW_SQL, "true"); + configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); + + // add all hibernate mappings in the domain dir + String dir = (getClass().getClassLoader().getResource("org/apache/shale/petstore/domain")).getFile(); + configuration.addDirectory(new File(dir)); + + // create the hibernate template to inject into the DAOs + sessionFactory = configuration.buildSessionFactory(); + HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory); + + // create convenient DAO instances for subclasses to use + petDao = new PetDaoHibernate(); + categoryDao = new CategoryDaoHibernate(); + + // configure the DAO instances + petDao.setHibernateTemplate(hibernateTemplate); + categoryDao.setHibernateTemplate(hibernateTemplate); + + openSession(); +// session = SessionFactoryUtils.getSession(sessionFactory, true); +// TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); + } + + public void tearDown() throws Exception { + TransactionSynchronizationManager.unbindResource(sessionFactory); + SessionFactoryUtils.releaseSession(session, sessionFactory); + } + + protected void closeSession() throws Exception { + session.close(); + } + + protected void openSession() throws Exception { + session = SessionFactoryUtils.getSession(sessionFactory, true); + TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); + } + + /** + * Convenience method for flushing and clearing all of the templates. This allows tests of persistence + * as opposed to just testing that the cache is working. + */ + protected void flushAndClear() { + categoryDao.getHibernateTemplate().flush(); + categoryDao.getHibernateTemplate().clear(); + petDao.getHibernateTemplate().flush(); + petDao.getHibernateTemplate().clear(); + } +} Added: shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/CategoryDaoHibernateTest.java URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/CategoryDaoHibernateTest.java?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/CategoryDaoHibernateTest.java (added) +++ shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/CategoryDaoHibernateTest.java Mon Jul 31 09:31:56 2006 @@ -0,0 +1,165 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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.apache.shale.petstore.persistence.impl; + +import org.apache.shale.petstore.domain.Category; +import org.apache.shale.petstore.domain.Pet; + +import java.util.List; +import java.util.Set; + +/** + * @author Sean Schofield + */ +public class CategoryDaoHibernateTest extends AbstractHibernateDaoTestCase { + + private Category category; + + public void setUp() throws Exception { + super.setUp(); + category = new Category("foo category description"); + } + + public void testStoreAndRetrieveBusinessKeyEquality() throws Exception { + //long id = categoryDao.store(category); + + long id = categoryDao.store(category); + + // flush and clear so we can test that the pet was actually stored + flushAndClear(); + + Category retrievedCategory = categoryDao.get(id); + + assertEquals(category, retrievedCategory); + assertNotSame(category, retrievedCategory); + } + + /** + * Verify that a category's set of pets is stored and retrieved properly. Also verifies that + * transient pets are stored in the database through cascade-save. + * @throws Exception + */ + public void testStoreAndRetrieveSet() throws Exception { + // create a couple of pets + Pet pet1 = new Pet("12345", "Pet1"); + Pet pet2 = new Pet("78901", "Pet2"); + category.addPet(pet1); + category.addPet(pet2); + + // persist the category + long id = categoryDao.store(category); + + flushAndClear(); + + Category retrievedCategory = categoryDao.get(id); + + // category should have been persisted and have a pet set with size 2 + assertNotNull("retrievedCategory", retrievedCategory); + assertEquals("retrievedCategory.pets.size", 2, retrievedCategory.getPets().size()); + + // the pets should also have been persisted due to cascade-save + assertNotNull("pet1.id", pet1.getId()); + assertNotNull("pet2.id", pet2.getId()); + } + + public void testRemoveCategory() throws Exception { + // create a couple of pets + Pet pet1 = new Pet("12345", "Pet1"); + Pet pet2 = new Pet("78901", "Pet2"); + category.addPet(pet1); + category.addPet(pet2); + + // persist the category + long id = categoryDao.store(category); + + flushAndClear(); + + Category retrievedCategory = categoryDao.get(id); + categoryDao.remove(retrievedCategory); + + flushAndClear(); + + retrievedCategory = categoryDao.get(id); + assertNull("retrievedCategory", retrievedCategory); + + flushAndClear(); + + // pets should also have been deleted + Pet retrievedPet1 = petDao.get(pet1.getId()); + Pet retrievedPet2 = petDao.get(pet2.getId()); + assertNull("retrievedPet1", retrievedPet1); + assertNull("retrievedPet2", retrievedPet2); + } + + public void testGetCategories() throws Exception { + // create a few categories and store them + Category category1 = new Category("category1"); + Category category2 = new Category("category2"); + Category category3 = new Category("category3"); + + categoryDao.store(category1); + categoryDao.store(category2); + categoryDao.store(category3); + + flushAndClear(); + + List categoryList = categoryDao.getCategories(); + assertEquals("categorySet.size", 3, categoryList.size()); + + Category category4 = new Category("category4"); + category3.addChildCategory(category4); + } + + public void testCategoryDirtyCheckingUpdate() throws Exception { + Category category1 = new Category("category1"); + categoryDao.store(category1); + + // create a new transient category + Category category2 = new Category("category2"); + + // associate transient category with a persistent category + category1.addChildCategory(category2); + flushAndClear(); + + // verify that dirty check cascaded to child category and that it was persisted + assertNotNull("category2.id", category2.getId()); + } + + public void testCategoryDirtyCheckingNew() throws Exception { + Category category1 = new Category("category1"); + Category category2 = new Category("category2"); + + category1.addChildCategory(category2); + categoryDao.store(category1); + + // verify that dirty check cascaded to child category and that it was persisted + assertNotNull("category2.id", category2.getId()); + } + + public void testCategoryDirtyCheckingDeleteParent() throws Exception { + Category category1 = new Category("category1"); + Category category2 = new Category("category2"); + + category1.addChildCategory(category2); + categoryDao.store(category1); + flushAndClear(); + categoryDao.remove(category1); + flushAndClear(); + + // verify that dirty check cascaded to child category and that it was persisted + assertTrue("size() == 0", categoryDao.getCategories().size() == 0); + } +} Added: shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/PetDaoHibernateTest.java URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/PetDaoHibernateTest.java?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/PetDaoHibernateTest.java (added) +++ shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/persistence/impl/PetDaoHibernateTest.java Mon Jul 31 09:31:56 2006 @@ -0,0 +1,72 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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.apache.shale.petstore.persistence.impl; + +import org.apache.shale.petstore.domain.Pet; +import org.apache.shale.petstore.domain.Category; + +/** + * @author Sean Schofield + */ +public class PetDaoHibernateTest extends AbstractHibernateDaoTestCase { + + private Pet fooPet; + + public void setUp() throws Exception { + super.setUp(); + // setup reusable pet and category objects + Category fooCategory = new Category("foo category"); + categoryDao.store(fooCategory); + + fooPet = new Pet(fooCategory, "12345", "foo pet"); + fooPet.setPrice(100.30); + fooPet.setQuantity(33); + } + + public void testStoreAndRetrieveBusinessKeyEquality() throws Exception { + long id = petDao.store(fooPet); + + // flush and clear so we can test that the pet was actually stored + flushAndClear(); + + Pet retrievedPet = (Pet)petDao.get(id); + + assertEquals(fooPet, retrievedPet); + assertNotSame(fooPet, retrievedPet); + } + + /** + * Since Hibernate recommends using only the so-called business key in your + * equality statement, we should also check that the rest of the values are + * identical once stored and retrieved. Each property needs to be checked + * manually since we are not able to rely on the equals() method. + * @throws Exception + */ + public void testStoreAndRetrieveValueEquality() throws Exception { + long id = petDao.store(fooPet); + + flushAndClear(); + + Pet retrievedPet = petDao.get(id); + + assertEquals("retrievedPet.getProductId()", fooPet.getProductId(), retrievedPet.getProductId()); + assertEquals("retrievedPet.getDescription()", fooPet.getDescription(), retrievedPet.getDescription()); + assertEquals("retrievedPet.getPrice()", fooPet.getPrice(), retrievedPet.getPrice()); + assertEquals("retrievedPet.getQuantity()", fooPet.getQuantity(), retrievedPet.getQuantity()); + assertEquals("retrievedPet.getCategory()", fooPet.getCategory(), retrievedPet.getCategory()); + } + +} Added: shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/service/impl/InventoryServiceImplTest.java URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/service/impl/InventoryServiceImplTest.java?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/service/impl/InventoryServiceImplTest.java (added) +++ shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/service/impl/InventoryServiceImplTest.java Mon Jul 31 09:31:56 2006 @@ -0,0 +1,49 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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.apache.shale.petstore.service.impl; + +import org.jmock.Mock; +import org.jmock.cglib.MockObjectTestCase; +import org.apache.shale.petstore.persistence.CategoryDao; + +/** + * @author Sean Schofield + */ +public class InventoryServiceImplTest extends MockObjectTestCase { + + private InventoryServiceImpl inventoryService; + private Mock mockDao; + + public void setUp() throws Exception { + super.setUp(); + inventoryService = new InventoryServiceImpl(); + // setup mock + mockDao = mock(CategoryDao.class); + // inject mock + inventoryService.setCategoryDao((CategoryDao)mockDao.proxy()); + } + + public void testGetInventory() { + mockDao.expects(once()).method("getCategories"); + inventoryService.getInventory(); + } + + public void testCreateTestData() { + mockDao.expects(atLeastOnce()).method("store"); + inventoryService.createTestData(); + } +} Added: shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/view/backing/TreeBackerTest.java URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/view/backing/TreeBackerTest.java?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/view/backing/TreeBackerTest.java (added) +++ shale/sandbox/shale-petstore/src/test/java/org/apache/shale/petstore/view/backing/TreeBackerTest.java Mon Jul 31 09:31:56 2006 @@ -0,0 +1,119 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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.apache.shale.petstore.view.backing; + +import org.jmock.cglib.MockObjectTestCase; +import org.jmock.Mock; +import org.apache.shale.petstore.service.impl.InventoryServiceImpl; +import org.apache.shale.petstore.service.InventoryService; +import org.apache.shale.petstore.persistence.CategoryDao; +import org.apache.shale.petstore.persistence.PetDao; +import org.apache.shale.petstore.domain.Category; +import org.apache.shale.petstore.domain.Pet; +import org.apache.myfaces.custom.tree2.*; + +import java.util.List; +import java.util.ArrayList; + +/** + * @author Sean Schofield + */ +public class TreeBackerTest extends MockObjectTestCase { + + private static final Category DOGS = new Category("dogs"); + private static final Category TERRIERS = new Category("terriers"); + private static final Pet BOSTON_TERRIER = new Pet("1001", "boton terrier"); + private static final Pet WHEATON_TERRIER = new Pet("1002", "wheaton terrier"); + private static final Category RETRIEVERS = new Category("retrievers"); + private static final Category CATS = new Category("cats"); + private static final Category FISH = new Category("fish"); + + private TreeBacker treeBacker; + //private Mock mockDao; + + public void setUp() throws Exception { + super.setUp(); + + TERRIERS.addPet(BOSTON_TERRIER); + TERRIERS.addPet(WHEATON_TERRIER); + DOGS.addChildCategory(TERRIERS); + DOGS.addChildCategory(RETRIEVERS); + + treeBacker = new TreeBacker(); + + // inject custom mock + treeBacker.setInventoryService(new MockInventoryService()); + } + + /** + * Verify that the Tree + */ + public void testGetTreeModel() { + /** + * We're assuming the TreeModel is using the default node id scheme of 0, 0:1, etc. + * Technically there is nothing about TreeModel that requires this but we happen to know + * that TreeBacker is using TreeModelBase so we're cheating a little here. That's ok + * b/c what we're really trying to test is that the mapping from the service data to + * the view data (ie. TreeNode conversion) is working properly and that its preserving + * the original order of the data. + */ + TreeModel model = (TreeModelBase)treeBacker.getTreeModel(); + + TreeNode treeNode = model.getNodeById("0:0"); + assertEquals("0:0", DOGS.getDescription(), treeNode.getDescription()); + + treeNode = model.getNodeById("0:0:0"); + assertEquals("0:0:0", TERRIERS.getDescription(), treeNode.getDescription()); + + treeNode = model.getNodeById("0:0:1"); + assertEquals("0:0:1", RETRIEVERS.getDescription(), treeNode.getDescription()); + + treeNode = model.getNodeById("0:1"); + assertEquals("0:1", CATS.getDescription(), treeNode.getDescription()); + + treeNode = model.getNodeById("0:2"); + assertEquals("0:2", FISH.getDescription(), treeNode.getDescription()); + } + + /** + * Mock class used to generate sample data. + */ + private static final class MockInventoryService implements InventoryService { + + public List<Category> getInventory() { + List categoryList = new ArrayList(); + + categoryList.add(DOGS); + categoryList.add(CATS); + categoryList.add(FISH); + + return categoryList; + } + + public void setCategoryDao(CategoryDao categoryDao) { + throw new UnsupportedOperationException("method should not be called from test case"); + } + + public void setPetDao(PetDao petDao) { + throw new UnsupportedOperationException("method should not be called from test case"); + } + + public void createTestData() { + throw new UnsupportedOperationException("method should not be called from test case"); + } + } +} Added: shale/sandbox/shale-petstore/src/test/resources/spring-persistence.xml URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/test/resources/spring-persistence.xml?rev=427158&view=auto ============================================================================== --- shale/sandbox/shale-petstore/src/test/resources/spring-persistence.xml (added) +++ shale/sandbox/shale-petstore/src/test/resources/spring-persistence.xml Mon Jul 31 09:31:56 2006 @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> + + <!-- + Spring configuration for UNIT TESTS. Not to be used in deployed application. + --> +<beans> + + <bean id="dataSource" + class="org.springframework.jdbc.datasource.DriverManagerDataSource"> + <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> + <property name="url" value="jdbc:hsqldb:mem:ProductDAOTest"/> + <property name="username" value="sa"/> + <!-- + <property name="password" value="${db.password}"/> + --> + </bean> + <bean id="sessionFactory" + class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> + <property name="dataSource" ref="dataSource"/> + <property name="hibernateProperties"> + <props> + <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> + <prop key="hibernate.show_sql">true</prop> + <prop key="hibernate.hbm2ddl.auto">create-drop</prop> + </props> + </property> + <property name="mappingDirectoryLocations"> + <list> + <value>classpath:/org/apache/myfaces/petstore/domain</value> + </list> + </property> + </bean> + <bean id ="hibernateTemplate" + class="org.springframework.orm.hibernate3.HibernateTemplate"> + <property name="sessionFactory" ref="sessionFactory"/> + </bean> + <bean id="petDao" + class="org.apache.shale.petstore.persistence.impl.PetDaoHibernate"> + <property name="hibernateTemplate" ref="hibernateTemplate"/> + </bean> + <bean id="categoryDao" + class="org.apache.shale.petstore.persistence.impl.CategoryDaoHibernate"> + <property name="hibernateTemplate" ref="hibernateTemplate"/> + </bean> + +</beans> \ No newline at end of file
