Java Code Examples for org.apache.wicket.util.tester.WicketTester#startComponentInPage()
The following examples show how to use
org.apache.wicket.util.tester.WicketTester#startComponentInPage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testRenderComponent(){ WicketTester tester = createTester(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { } }; paginator.setTotalResults(Model.of(100)); tester.startComponentInPage(paginator); tester.assertDisabled("paginator:first:link"); tester.assertDisabled("paginator:previous:link"); tester.assertEnabled("paginator:next:link"); tester.assertEnabled("paginator:last:link"); }
Example 2
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testLastButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); paginator.setNumberResultsPerPage(10); tester.startComponentInPage(paginator); tester.clickLink("paginator:last:link"); assertEquals(9, (int) pageBox.value); tester.assertDisabled("paginator:last:link"); tester.assertDisabled("paginator:next:link"); tester.assertEnabled("paginator:previous:link"); tester.assertEnabled("paginator:first:link"); }
Example 3
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testNextButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); tester.startComponentInPage(paginator); tester.clickLink("paginator:next:link"); assertEquals(1, (int) pageBox.value); tester.assertEnabled("paginator:last:link"); tester.assertEnabled("paginator:next:link"); tester.assertEnabled("paginator:previous:link"); tester.assertEnabled("paginator:first:link"); }
Example 4
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testPreviousButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); paginator.setModelObject(2); tester.startComponentInPage(paginator); tester.clickLink("paginator:previous:link"); assertEquals(1, (int) pageBox.value); tester.assertEnabled("paginator:last:link"); tester.assertEnabled("paginator:next:link"); tester.assertEnabled("paginator:previous:link"); tester.assertEnabled("paginator:first:link"); }
Example 5
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testFirstButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); paginator.setModelObject(2); tester.startComponentInPage(paginator); tester.clickLink("paginator:first:link"); assertEquals(0, (int) pageBox.value); tester.assertEnabled("paginator:last:link"); tester.assertEnabled("paginator:next:link"); tester.assertDisabled("paginator:previous:link"); tester.assertDisabled("paginator:first:link"); }
Example 6
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testNumberButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); paginator.setNumberResultsPerPage(10); tester.startComponentInPage(paginator); tester.clickLink("paginator:page:4:link"); assertEquals(4, (int) pageBox.value); tester.assertEnabled("paginator:last:link"); tester.assertEnabled("paginator:next:link"); tester.assertEnabled("paginator:previous:link"); tester.assertEnabled("paginator:first:link"); tester.assertLabel("paginator:page:2:link:label", "5"); }
Example 7
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testShowHiddenComponents(){ WicketTester tester = createTester(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { } }; paginator.setTotalResults(Model.of(100)); paginator.setShowLastButton(false); paginator.setShowFirstButton(false); paginator.setShowNextButton(false); paginator.setShowPreviousButton(false); tester.startComponentInPage(paginator); tester.assertInvisible("paginator:first:link"); tester.assertInvisible("paginator:previous:link"); tester.assertInvisible("paginator:next:link"); tester.assertInvisible("paginator:last:link"); }
Example 8
Source File: TransactionalRequestCycleListenerTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testSuccess(){ PersistenceTransaction transaction = EasyMock.mock(PersistenceTransaction.class); // 2 times because of a redirect transaction.start(); EasyMock.expectLastCall().times(2); transaction.end(); EasyMock.expectLastCall().times(2); EasyMock.replay(transaction); TransactionalRequestCycleListener listener = new TransactionalRequestCycleListener(transaction); WicketTester tester = new WicketTester(); tester.getApplication().getRequestCycleListeners().add(listener); tester.startComponentInPage(new Label("text", new Model<>())); EasyMock.verify(transaction); }
Example 9
Source File: TransactionalRequestCycleListenerTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testOnExceptionRollback(){ PersistenceTransaction transaction = EasyMock.mock(PersistenceTransaction.class); transaction.start(); transaction.setRollbackOnly(); transaction.end(); EasyMock.replay(transaction); TransactionalRequestCycleListener listener = new TransactionalRequestCycleListener(transaction); WicketTester tester = new WicketTester(); tester.getApplication().getRequestCycleListeners().add(listener); try{ tester.startComponentInPage(new TextField<>("text", new Model<>())); }catch (Exception e){ } EasyMock.verify(transaction); }