Wrox Programmer Forums
|
BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2
This is the forum to discuss the Wrox book Beginning Spring Framework 2 by Thomas Van de Velde, Bruce Snyder, Christian Dupuis, Sing Li, Anne Horton, Naveen Balani; ISBN: 9780470101612
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 30th, 2009, 08:04 PM
Authorized User
 
Join Date: Aug 2009
Posts: 10
Thanks: 3
Thanked 3 Times in 3 Posts
Smile Failing DAO Tests

This is a continuation of the problems encountered earlier in Chapter 3. The problem seems to come from Spring not finding the Test classes in the target\test-classes hierarchy. It seems to look in the target\classes hierarchy. Like the "Try It Out" on page 60 - 62, the "Try It Out" on page 69 requires you to copy the AlbumSpringDao$1.class, AlbumSpringDao$UserRowMapper.class, AlbumSpringDao.class, and AlbumSpringDaoTest.class files from test-classes\com\wrox\beginspring\pix\dao\examples to target\classes\com\wrox\beginspring\dao\examples and the springdao-test.xml file from test\resources to target\classes. AlbumSpringDaoTest should run to completion with these changes.
I think that by altering something in the pom.xml file should clear up this problem but I haven't found how to do it yet. If anyone can lead me in the right direction I would appreciate it.
Until next time..............

EverettG.
 
Old September 2nd, 2009, 01:06 AM
Wrox Author
 
Join Date: May 2005
Posts: 4
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Thank you, egoodenuf.

There are two problems to resolve. We need to:
  1. somehow create the initial tables in the hsqldb database
  2. make sure Maven knows where to look for AlbumDaoTest
Create initial tables in the hsqldb database

If you look under wrox-pix-web/src/test/resources, you will find a file named pixhsql.sql This file is an SQL command file. Load it into a text editor to view if you are curious. It basically contains the SQL commands to create the required tables.

In step 3 on Page 61. Just before running the command:
java -cp ./target/pixweb-0.0.1/WEB-INF/lib/hsqldb-1.8.0.7.jar org.hsqldb.util.SqlTool pix-sa
You should first run the following command to create the tables:
java -cp ./target/pixweb-0.0.1/WEB-INF/lib/hsqldb-1.8.0.7.jar org.hsqldb.util.SqlTool pix-sa src/test/resources/pixhsql.sql
The output you will see is:
1 row updated
1 row updated
Make sure Maven knows where to look for AlbumDaoTest

As egoodenuf has kindly pointed out, the Maven exec plugin is simply looking in the wrong places for AlbumDaoTest classes. This appears to be a change in default plugin behavior since publication of the book.

Now, you need to explicitly tell Maven to look under test-classes for AlbumDaoTest. This is the default destination classpath for compiled tests.

On page 62, step 4, the command to execute the AlbumDaoTest needs to be modified slightly:
mvn exec:java -Dexec.classpathScope=test -Dexec.mainClass=com.wrox.beginspring.pix.dao.examp les.AlbumDaoTest
The additional -Dexec.classpathScope=test tells Maven to include the default test classpath when looking for Java classes to execute.

The above changes should enable you to successfully run the JDBC example AlbumDaoTest.

Last edited by SingLi; September 2nd, 2009 at 01:12 AM..
The Following User Says Thank You to SingLi For This Useful Post:
egoodenuf (September 2nd, 2009)
 
Old September 2nd, 2009, 06:25 PM
Authorized User
 
Join Date: Aug 2009
Posts: 10
Thanks: 3
Thanked 3 Times in 3 Posts
Smile Failing DAO Tests

Thanks again for your quick reply. I had already manually created the required tables using the pixhsql.sql file. I manually entered the required SQL statements in SqlTool. What I didn't know was how to execute the .sql file to automatically process the SQL statements contained in the file. Now I do, thank you for that.

The second part of the issue was what I was looking for, How to make Maven properly locate the AlbumDaoTest classes and the AlbumSpringDaoTest classes used in the "Try It Out" on pg. 69. I had completed these by copying the .java files from test-classes\com\wrox\beginspring\pix\dao\examples to target\classes\com\wrox\beginspring\dao\examples [See prior post]. I will go back and try each Test again with the configurations from your post and report the results.

Thanks again for the help.

Until next time...............

EverettG
 
Old September 28th, 2009, 07:13 PM
Authorized User
 
Join Date: Aug 2009
Posts: 10
Thanks: 3
Thanked 3 Times in 3 Posts
Thumbs up Failing DAO Tests

Apologize for the long delay. I am in the process of learning Android and guess what - encountering the exact same problems as here - outdated information in book. All I can say is that it is a learning experience. Any way, back to Spring. Where were we. Oh yes, trying to process the AlbunDAOTest and AlbumSpringDAOTest "Try It Out" from Chapter 3. Problem: Maven was unable to locate the correct .class files for the tests. The updated mvn commands that included the -Dexec.classpathScope=test did the trick for both runs. Thank you SingLi [author] for your help. Hope this helps everyone else.

EverettG.
The Following User Says Thank You to egoodenuf For This Useful Post:
SingLi (September 28th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Where are all the unit tests? Extrakun BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 July 17th, 2007 05:39 PM
Chapter 2 AD HOC Testdriven.net tests? phsarjk BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 May 17th, 2007 04:12 PM
PHP Editor: beta tests Luckasoft Pro PHP 2 March 13th, 2005 09:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.