Re: Rollback db changes in CFCUnit/CFUnit tests

2007-10-15 Thread Mike Henke
Could someone post Rick's script?  I am very interested in looking @ it.  
Thanks,


~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291150
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Rollback db changes in CFCUnit/CFUnit tests

2007-10-15 Thread Rich
Here is the ant script that I was referring to  the properties file that
powers it.  Also included are the caveats that I gave Janet:

A few caveats:

   1. It is targeted specifically to MSSQL. 
   2. I am using the open source JTDS drivers (
http://jtds.sourceforge.net/) to access our databases.


One problem I ran into when resetting our database was when constraints
existed on existing tables so I use some MSSQL specific SQL to temporarily
detach the constraints during the reset process.  If you are not using
MSSQL, you will need to change the insert operation to CLEAN_INSERT (if i
remember correctly) as it is currently using MSSQL_CLEAN_INSERT in addition
to updating the constraint code.  I hope this helps you with what you are
working on.

Good luck!



HTH,
Rich Kroll



***
Properties file (db-build.properties)
***

db.driver=net.sourceforge.jtds.jdbc.Driver
db.urlprefix=jdbc:jtds:sqlserver://


db.server=RKROLL
db.port=1433
db.instance=
db.database=MYDATABASE
db.username=user
db.password=password
db.exportfile=dataset




***
Build file (build.xml)
***


project name=Build default=menu basedir=.

taskdef name=dbunit classname=org.dbunit.ant.DbUnitTask /
property file=db-build.properties /

target name=menu depends=init
echo
MENU


Available tasks:
export: Exports the database to a flat xml file.
(Should only be done on schema changes)
export-dtd: Exports the database schema DTD
reset:  Reset the database to a last known good
state
disable-constraints:Disable database constraints
enable-constraints: Enable database constraints
/echo

input message=Choose a task: 

validargs=export,export-dtd,reset,disable-constraints,enable-constraints 
defaultvalue=reset 
addproperty=task /
antcall target=${task} inheritAll=true /
/target

!-- = 
  target: INIT  
 = --
target name=init description=-- Initilization
property name=db.server value=RKROLL/
property name=db.port value=1433/
property name=db.instance value=/
property name=db.username value=sa/
property name=db.password value=password/
property name=db.exportfile value=dataset/
/target

!-- = 
  target: reset  
 = --
target name=reset depends=init,disable-constraints description=--
resets the database to a last known good state
echoPerforming database reset on
${db.server}:${db.port}/${db.database};instance=${db.instance}/echo
echoclean insert beginning.../echo
dbunit driver=${db.driver}  

url=${db.urlprefix}${db.server}:${db.port}/${db.database};instance=${db.ins
tance}  
userid=${db.username}  
password=${db.password}
operation type=MSSQL_CLEAN_INSERT
src=${db.exportfile}.xml format=flat /
/dbunit
echoclean insert complete/echo
echoenabling constraints.../echo
antcall target=enable-constraints /
echodatabase reset complete./echo
/target

!-- = 
  target: export
 = --
target name=export depends=init
echoAccessing DB
[jdbc:jtds:sqlserver://${db.server}:${db.port}/${db.database};instance=${db.
instance}]/echo
dbunit driver=${db.driver}  

url=${db.urlprefix}${db.server}:${db.port}/${db.database};instance=${db.ins
tance}  
userid=${db.username}
password=${db.password}
export dest=${db.exportfile}.xml / 
/dbunit
/target

!-- = 
  target: export-dtd  
 = --
target name=export-dtd depends=init description=-- Exports the
database DTD
dbunit driver=${db.driver}  
 
url=${db.urlprefix}${db.server}:${db.port}/${db.database};INSTANCE=${db.ins
tance}  
userid=${db.username}  
password=${db.password}
export dest=${db.exportfile}.dtd format=dtd/
/dbunit
/target

!-- = 
  target: disable-constraints  
 = --
target name=disable-constraints 

Re: Rollback db changes in CFCUnit/CFUnit tests

2007-10-15 Thread Mark Flewellen
http://www.barneyb.com/barneyblog/2007/07/13/schema-tool-update/

This is quite a useful tool for managing database migrations.

Mark F 

~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291155
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Rollback db changes in CFCUnit/CFUnit tests

2007-10-08 Thread Janet MacKay
+1 to dbunit.  You also have the option of wrapping each unit test in a
transaction and then rolling it back at the end.

Jaime Metcher

Yes, that works too.  In this case dbUnit's restore capability is a better fit. 
I got a good quickstart to dbUnit thanks to Rich's script and I'm really liking 
it so far :)  

Thanks for the suggestion guys.

Janet 

~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290609
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Rollback db changes in CFCUnit/CFUnit tests

2007-10-07 Thread Jaime Metcher
Janet,

+1 to dbunit.  You also have the option of wrapping each unit test in a
transaction and then rolling it back at the end.

Jaime Metcher

 -Original Message-
 From: Janet MacKay [mailto:[EMAIL PROTECTED]
 Sent: Friday, 5 October 2007 3:28 AM
 To: CF-Talk
 Subject: SOT: Rollback db changes in CFCUnit/CFUnit tests


 Does anyone know of an article(s) explaining how to work
 rollbacks into unit testing? I want to test a series of DAO's,
 but am not sure how to incorporate this into my tests.

 Janet


 

~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290488
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Rollback db changes in CFCUnit/CFUnit tests

2007-10-05 Thread Rich
 Thanks Rich. That is helpful.  Off to download and review DBUnit.
 
 Thanks,
 Janet

Janet,
If you would like, I have a (work in progress) ant build file that uses
dbunit's ant task to export / reset my database.  I would be happy to email
it to you offlist if you think it might be useful.

HTH,
Rich Kroll


~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290301
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Rollback db changes in CFCUnit/CFUnit tests

2007-10-05 Thread Janet MacKay
Rich, 

That would be great. Thanks.

Janet 

~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290318
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Rollback db changes in CFCUnit/CFUnit tests

2007-10-05 Thread Rich
 Rich,
 
 That would be great. Thanks.
 
 Janet

No problem.  It should be on its way.  Let me know if I can be of any more
help.

Rich Kroll 


~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290350
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Rollback db changes in CFCUnit/CFUnit tests

2007-10-04 Thread Rich
 Does anyone know of an article(s) explaining how to work rollbacks into
 unit testing? I want to test a series of DAO's, but am not sure how to
 incorporate this into my tests.
 
 Janet
 

You can incorporate a tool like DBUnit into your workflow
(http://dbunit.sourceforge.net/).

HTH,
Rich Kroll


~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290213
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Rollback db changes in CFCUnit/CFUnit tests

2007-10-04 Thread Janet MacKay
You can incorporate a tool like DBUnit into your workflow
(http://dbunit.sourceforge.net/).

HTH,
Rich Kroll

Thanks. I'm new to unit testing in general, so sorry if this is a dumb question 
:) .. I think I understand the concept of DBUnit, but I can't visualize where 
it fits into picture. Are DBUnit tests something separate, written in java, or 
do they somehow tie into my CFUnit/CFCUnit tests? Can you give me a high-level 
description of how it hooks into the process?  

Janet



~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290215
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Rollback db changes in CFCUnit/CFUnit tests

2007-10-04 Thread Rich
 Thanks. I'm new to unit testing in general, so sorry if this is a dumb
 question :) .. I think I understand the concept of DBUnit, but I can't
 visualize where it fits into picture. Are DBUnit tests something separate,
 written in java, or do they somehow tie into my CFUnit/CFCUnit tests? Can
 you give me a high-level description of how it hooks into the process?
 
 Janet


-- disclaimer --
I am not a DBUnit expert, and am only using a small portion of its features!
-- end disclaimer --

With that said...I will give you an overview of how I am using DBUnit.  

Step 1:
I start by seeding my database.  Once that is done I use DBUnit to export a
snapshot of the database.

Step 2:
Proceed to develop new features, bug fixes, etc.  

Step 3:
When development is complete and prior to running my unit tests, I use
DBUnit to reset the db back to a last known good state to remove any data
that was inserted during development.

Step 4:
I run my unit tests that test functionality with limited / no data and let
my unit tests populate the db.  This allows for testing of how the system
performs with and without expected data. 

Step 5:
I run a cleanup script that includes a DBUnit reset.

Step 6:
goto step 2 and repeat.


HTH,

Rich Kroll


~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290221
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Rollback db changes in CFCUnit/CFUnit tests

2007-10-04 Thread Janet MacKay
Thanks Rich. That is helpful.  Off to download and review DBUnit.

Thanks,
Janet


~|
Check out the new features and enhancements in the
latest product release - download the What's New PDF now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290226
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4