paulie wrote:
>
> Having problems getting testSave() and testRemove() methods to work
> properly from my CropActionTest class.
>
> For testSave(), I can see the select statement where the Crop object is
> getting loaded. When I modify the crop name on the object and attempt to
> save, I don't see a subsequent update statement.
>
> For testRemove(), I don't see a delete statement being executed.
>
> Both of the test cases pass, another thing that is disturbing.
>
> The majority of the sql that goes to the console comes from the
> onSetUpBeforeTransaction() and onTearDownAfterTransaction() methods.
>
> I have even put breakpoints before the onTearDownAfterTransaction() method
> is called and cannot see the database activity performed on the affected
> table.
>
> testSave()
> [eseed] DEBUG [main] CropActionTest.onSetUpBeforeTransaction(17)
> [eseed] DEBUG [main] SQL.log(401) | insert into Crop (crop_name,
> species) values (?, ?)
> [eseed] DEBUG [main] CropActionTest.startNewTransaction(392) | Began
> transaction (1):transaction manager
> [org.springframework.orm.hibernate3.hibernatetransactionmana...@c12474];
> rollback [true].
> [eseed] DEBUG [main] CropActionTest.testSave(66) | initialize
> [eseed] DEBUG [main] SQL.log(401) | select this_.cropId as cropId7_0_,
> this_.crop_name as crop2_7_0_, this_.species as species7_0_ from Crop
> crop0_ where crop0_.cropId=?
> [eseed] DEBUG [main] CropActionTest.testSave(72) | cropNameOld = Romaine
> [eseed] DEBUG [main] CropActionTest.testSave(74) | update crop name and
> save
> [eseed] DEBUG [main] CropActionTest.testSave(78) | cropNameNew =
> ActionSaveCrop
> [eseed] DEBUG [main] CropActionTest.endTransaction(360) | Rolled back
> transaction after execution of test [testSearch].
> [eseed] DEBUG [main] CropActionTest.onTearDownAfterTransaction(35)
> [eseed] DEBUG [main] SQL.log(401) | select crop0_.cropId as cropId7_0_,
> crop0_.crop_name as crop2_7_0_, from Crop crop0_ where crop0_.cropId=?
> [eseed] DEBUG [main] SQL.log(401) | delete from Crop where cropId=?
>
> testRemove()
> [eseed] DEBUG [main] CropActionTest.onSetUpBeforeTransaction(17)
> [eseed] DEBUG [main] SQL.log(401) | insert into Crop (crop_name,
> species) values (?, ?)
> [eseed] DEBUG [main] CropActionTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.hibernatetransactionmana...@c713d2];
> rollback [true].
> [eseed] DEBUG [main] CropActionTest.testRemove(85) - initialize
> [eseed] DEBUG [main] CropActionTest.testRemove(100) - delete crop
> [eseed] DEBUG [main] SQL.log(401) | select crop0_.cropId as cropId7_0_,
> crop0_.crop_name as crop2_7_0_, crop0_.species as species7_0_ from Crop
> crop0_ where crop0_.cropId=?
> [eseed] DEBUG [main] CropActionTest.endTransaction(360) | Rolled back
> transaction after execution of test [testRemove].
> [eseed] DEBUG [main] CropActionTest.onTearDownAfterTransaction(35) |
> CropActionTest = onTearDownAfterTransaction
> [eseed] DEBUG [main] SQL.log(401) | select crop0_.cropId as cropId7_0_,
> crop0_.crop_name as crop2_7_0_, crop0_.species as species7_0_ from Crop
> crop0_ where crop0_.cropId=?
> [eseed] DEBUG [main] SQL.log(401) | delete from Crop where cropId=?
>
> Here is the CropActionTest code. I would have expected to see an update
> and select statements for testSave() along with select and remove
> statements with testRemove().
>
> public void testSave() throws Exception {
> log.debug("initialize");
> MockHttpServletRequest request = new MockHttpServletRequest();
> ServletActionContext.setRequest(request);
> action.setCropId(1L);
> assertEquals("success", action.edit());
> assertNotNull(action.getCrop());
> log.debug("cropNameOld = " + action.getCrop().getCropName());
>
> log.debug("update crop name and save");
> action.getCrop().setCropName("ActionSaveCrop");
> assertEquals("input", action.save());
> assertEquals("ActionSaveCrop", action.getCrop().getCropName());
> log.debug("cropNameNew = " + action.getCrop().getCropName());
> assertFalse(action.hasActionErrors());
> assertFalse(action.hasFieldErrors());
> assertNotNull(request.getSession().getAttribute("messages"));
> }
>
> public void testRemove() throws Exception {
> log.debug("initialize");
> MockHttpServletRequest request = new MockHttpServletRequest();
> ServletActionContext.setRequest(request);
>
> log.debug("delete crop");
> action.setDelete("");
> Crop crop = new Crop();
> crop.setCropId(2L);
> action.setCrop(crop);
> assertEquals("success", action.delete());
> assertNotNull(request.getSession().getAttribute("messages"));
> }
>
>
> How come my update and delete queries aren't getting executed. Thanks in
> advance.
>
--
View this message in context:
http://www.nabble.com/ActionTest---Not-executing-sql-queries-on-Action.class-tp23680254s2369p23735723.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net