You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2014/06/16 09:41:01 UTC
[jira] [Commented] (WICKET-5618) Wicket or WicketTester is
constructing my page twice
[ https://issues.apache.org/jira/browse/WICKET-5618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14032198#comment-14032198 ]
Martin Grigorov commented on WICKET-5618:
-----------------------------------------
It is not clear what could be the issue.
Please try with 1.5.8, 9, 10 and then consult with their changelogs to see what causes this issue.
> Wicket or WicketTester is constructing my page twice
> ----------------------------------------------------
>
> Key: WICKET-5618
> URL: https://issues.apache.org/jira/browse/WICKET-5618
> Project: Wicket
> Issue Type: Bug
> Affects Versions: 1.5.11, 6.15.0
> Reporter: Trejkaz
>
> I tried to update to v6.15.0 and all our tests started failing because all expectations are now being called twice. I tested that the issue also occurs in v1.5.11.
> We were previously on v1.5.7 which does not have this issue. Did something change between v1.5.7 and v1.5.11 which could be responsible for this?
> This isn't just occurring on one or two tests - every non-trivial test (certainly any test which posts a form) is failing.
> Navigating to the start page (called at the start of the test)
> {code}
> @Override
> protected void navigateToStartPage()
> {
> fakeLoginAsAdmin();
> mockery.checking(new Expectations() {{
> oneOf(serverGroupStore).getAllGroups(); will(returnValue(Arrays.asList(
> new DefaultServerGroup(3, "my-group", EnumSet.noneOf(Permission.class)),
> new DefaultServerGroup(1, "nuix-admins", EnumSet.allOf(Permission.class)),
> new DefaultServerGroup(2, "nuix-users", EnumSet.of(Permission.ACCESS_SERVER))
> )));
> }});
> tester.startPage(GroupsPage.class);
> tester.assertRenderedPage(GroupsPage.class);
> newGroupForm = tester.newFormTester("newGroupForm");
> mockery.assertIsSatisfied();
> }
> {code}
> The actual test:
> {code}
> @Test
> public void testCreateGroup_OK()
> {
> mockery.checking(new Expectations() {{
> // Submitting the form...
> expectationsForGroupsPage();
> oneOf(serverGroupStore).findByName("my-new-group"); will(returnValue(null));
> ServerGroup newlyCreatedGroup = new DefaultServerGroup(4, "my-new-group", EnumSet.noneOf(Permission.class));
> oneOf(serverGroupStore).create("my-new-group"); will(returnValue(newlyCreatedGroup));
> // XXX: I'm not sure why this occurs but it happens when sending the instruction to redirect.
> oneOf(serverGroupStore).findById(4); will(returnValue(newlyCreatedGroup));
> // After the redirect...
> oneOf(serverGroupStore).findById(4); will(returnValue(newlyCreatedGroup));
> }});
> newGroupForm.setValue("name", "my-new-group");
> newGroupForm.submit(); // ** FAILS HERE **
> tester.assertNoErrorMessage();
> tester.assertInfoMessages("Group my-new-group created.");
> tester.assertRenderedPage(ShowGroupPage.class);
> tester.assertContains("<title>my-new-group");
> mockery.assertIsSatisfied();
> }
> {code}
> The setup of the tester itself:
> {code}
> @Before
> public final void setUp() throws Exception
> {
> mockery = MockeryFactory.createMockery();
> MutablePicoContainer container = new DefaultPicoContainer();
> populateContainer(container);
> tester = new WicketTester(new ServerWebUIApplication(container));
> //tester.setFollowRedirects(false);
> // Mock out checking for settings otherwise you have to mock ServerContext and ServerPreferences -
> // but various tests rely on mocking those already, to test the main functionality.
> serverPreferencesWatcher = mockery.mock(ServerPreferencesWatcher.class);
> container.addComponent(ServerPreferencesWatcher.class, serverPreferencesWatcher);
> mockery.checking(new Expectations() {{
> allowing(serverPreferencesWatcher).isRestartRequired(); will(returnValue(false));
> }});
> navigateToStartPage();
> }
> {code}
> I found that this occurs even if I tell WicketTester not to follow redirects.
--
This message was sent by Atlassian JIRA
(v6.2#6252)