List of usage examples for org.apache.wicket.serialize.java JavaSerializer JavaSerializer
public JavaSerializer(final String applicationKey)
From source file:gr.interamerican.wicket.bo2.markup.html.panel.TestSelfDrawnPanel.java
License:Open Source License
/** * Test creation and correct model propagation. *///from w w w .java 2s. c o m @Test public void testSelfDrawnPanel() { tester.startPage(getTestPage()); new JavaSerializer(tester.getApplication().getApplicationKey()).serialize(getTestSubject()); @SuppressWarnings("unchecked") TextField<Long> tf = (TextField<Long>) tester.getComponentFromLastRenderedPage(path("field2")); //$NON-NLS-1$ Long actual = tf.getModel().getObject(); Long expected = model.getObject().getField2(); Assert.assertEquals(expected, actual); /* * Change the model object and assert correct propagation to components. */ model.setObject(new BeanWith1Field(1L)); actual = tf.getModel().getObject(); expected = model.getObject().getField2(); Assert.assertEquals(expected, actual); commonAssertions_noError(); }
From source file:gr.interamerican.wicket.markup.html.panel.crud.picker.TestCrudPickerPanel.java
License:Open Source License
/** * Tests setup./* w w w . j a v a 2 s . co m*/ */ @Before public void setup() { definition = createDef(); panel = new CrudPickerPanel<BeanWithOrderedFields>(definition) { /** * serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected BeanWithOrderedFields newBean() { return new BeanWithOrderedFields(); } }; new JavaSerializer(tester.getApplication().getApplicationKey()).serialize(panel); }
From source file:gr.interamerican.wicket.markup.html.panel.picker.TestPickerPanel.java
License:Open Source License
/** * Tests creation of {@link PickerPanel}. * //from w ww. ja v a 2s . co m * Also tests that pressing the select button, selects the item. */ @Test public void testCreation() { PickerPanelDef<BeanWithOrderedFields> def = createDef(); PickerPanel<BeanWithOrderedFields> panel = new PickerPanel<BeanWithOrderedFields>(def); tester.startPage(getTestPage(panel)); new JavaSerializer(tester.getApplication().getApplicationKey()).serialize(panel); tester.assertComponent(path("tableForm:radioGroup"), RadioGroup.class); tester.assertComponent(path("tableForm:radioGroup:listTable"), DataTable.class); tester.assertComponent(path("tableForm:radioGroup:listTable:body:rows:1:cells:4:cell:radioButton"), Radio.class); String buttonId = path("tableForm:selectButton"); tester.assertComponent(buttonId, AjaxButton.class); AjaxButton button = (AjaxButton) tester.getComponentFromLastRenderedPage(path("tableForm:selectButton")); @SuppressWarnings("unchecked") RadioGroup<BeanWithOrderedFields> radioGroup = (RadioGroup<BeanWithOrderedFields>) tester .getComponentFromLastRenderedPage(path("tableForm:radioGroup")); /* * radio button of first row. Holds the first * BeanWithOrderedFields of the List supplied * to the DataTable. */ @SuppressWarnings("unchecked") Radio<BeanWithOrderedFields> radio = (Radio<BeanWithOrderedFields>) tester.getComponentFromLastRenderedPage( path("tableForm:radioGroup:listTable:body:rows:1:cells:4:cell:radioButton")); assertSame(def.getList().get(0), radio.getModelObject()); /* * Set the first object of the BeanWithOrderedFields List as the * model object of the RadioGroup. This emulates the user actually * clicking the above Radio button. */ BeanWithOrderedFields selection = def.getList().get(0); radioGroup.setModelObject(selection); BeanWithOrderedFields modelOb = radioGroup.getModelObject(); assertSame(selection, modelOb); callback.setExecuted(false); /* * We insert the values in the request parameters manually, because * the formTester.submit() will assign new ids in the path of the * radio buttons and, as a result, the AjaxEvent will fail to locate * the correct radio and retrieve the model. So, normally we would do: * * FormTester formTester = tester.newFormTester(path("tableForm")); * formTester.select("radioGroup", 0); * formTester.submit(); * * TODO: is there a way to have the ajaxevent submit the form maybe? * Having to do this in two steps is a bit counter-intuitive. * * The following line is the equivalent of having clicked the first * row radio. "radio" is the wicket:id of the radio buttons and 0 stands * for the first row. */ Map<String, String[]> map = tester.getRequest().getParameterMap(); map.put("testId:tableForm:radioGroup", new String[] { "radio0" }); tester.executeAjaxEvent(button, "onclick"); BeanWithOrderedFields modelOb2 = radioGroup.getModelObject(); assertSame(modelOb2, modelOb); assertTrue(callback.isExecuted()); assertSame(selection, def.getBeanModel().getObject()); }