Re: unit test for dropdownchoice with ajax
On Tue, 23 Dec 2008, tbt wrote: formTester.submit(); If you submit the form with Ajax, you should use WicketTester.executeAjaxEvent in the test instead. Anyway, it seems like there might be a bug. If you can debug some more and/or produce a quickstart that reproduces the problem, it would be good. Otherwise it's difficult to say what's the problem. Best wishes, Timo -- Timo Rantalaiho Reaktor Innovations OyURL: http://www.ri.fi/ - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: unit test for dropdownchoice with ajax
I am having the same issue with multiple drop downs with ajax, when trying to unit test. tbt wrote: Hi I have coded two dropdown boxes similar to the example provided at http://http://www.wicket-library.com/wicket-examples/ajax/choice.1 The hotel dropdown is populated once a country is selected via ajax. This works fine and now i am writing a unit test for it. The code is as follows WicketTester wicketTester = getWicketTester(); wicketTester.startPage(SearchHotelsPage.class); FormTester formTester = wicketTester.newFormTester(searchHotelsForm,false); formTester.select(countryDropDown, 6); DropDownChoice countryDropDownChoice = (DropDownChoice) wicketTester.getComponentFromLastRenderedPage(searchHotelsForm:countryDropDown); assertEquals(countryDropDownChoice.getChoices().size(), 41); wicketTester.executeAjaxEvent(searchHotelsForm:countryDropDown, onchange); wicketTester.assertComponentOnAjaxResponse(searchHotelsForm:hotelDropDown); formTester.select(hotelDropDown, 12); formTester.submit(); wicketTester.assertRenderedPage(EditHotelsPage.class); but the following line fails the unit test wicketTester.assertRenderedPage(EditHotelsPage.class); the stack trace is as follows junit.framework.AssertionFailedError: expected:EditHotelsPage but was:HomePage at org.apache.wicket.util.tester.WicketTester.assertResult(WicketTester.java:575) at org.apache.wicket.util.tester.WicketTester.assertRenderedPage(WicketTester.java:522) at ogn.forms.SearchHotelsFormTest.testAjaxDropdownComponent(SearchHotelsFormTest.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Why does the page get rendered to the HomePage when the form is submitted. Am I testing the ajax dropdown component correctly. Please help. Thanks -- View this message in context: http://www.nabble.com/unit-test-for-dropdownchoice-with-ajax-tp21141772p21509601.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org