Re: Re: FormTester and Select component?

2010-03-04 Thread Jan Eriksson
well, since it looks like there's no build-in way of working with the
Select component in FormTester i guess we have to decide on one of the
ideas posted by you guys here. Thanks for you help!

/jan

On Tue, Mar 2, 2010 at 11:39 AM,  leo.erlands...@tyringe.com wrote:
 You could easily extend WicketTester and FormTester to support selecting
 in org.apache.wicket.extensions.markup.html.form.select.Select.

 Take a look at the

 public void select(String formComponentId, int index)

 method in FormTester and

 public FormTester newFormTester(String path, boolean fillBlankString)

 in BaseWicketTester on how to do it.


Thank you for the reply. Unfortunately this is not easier for me since
we already have this function implemented using the Select component.
If there is no way of getting FormTester to work with that component
i'll have a look at your code - i really want to have this test
automated without having to use a heavier test framework.



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Can't get FormTester.submitLink to work (required testfield always missing)

2010-03-04 Thread Jan Eriksson
I'm stuck on something that seems like a very trivial problem.. I have
a form with a RequiredTextField that i want to run some tests on using
FormTester. The form is submitted using a SubmitLink located outside
of the form tags. My problem is that even when i set a value on the
RequiredTextField the form submission is failing - because of that the
required field is missing.


test-code:

tester.startPage(HomePage.class);
tester.assertRenderedPage(HomePage.class);

FormTester formTester = tester.newFormTester(testForm, false);
formTester.setValue(name, a name);

formTester.submitLink(mySubmitLink, true);
tester.assertNoErrorMessage();


java-code:

public class HomePage extends WebPage {

  private static final long serialVersionUID = 1L;
  private final ValueMap properties = new ValueMap();

  public HomePage(final PageParameters parameters) {
  FormObject f = new FormObject(testForm, new
CompoundPropertyModelObject(properties));
  add(f);
  f.add(new RequiredTextFieldString(name)); 
  add(new SubmitLink(mySubmitLink, f));
}
}


markup:

html 
xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd;

body
form wicket:id=testForm
input wicket:id=name/input
/form
a href=# wicket:id=mySubmitLinksubmit/a
/body
/html


stacktrace:

junit.framework.AssertionFailedError: expect no error message, but contains
   Field 'name' is required.
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at 
org.apache.wicket.util.tester.WicketTester.assertNoErrorMessage(WicketTester.java:501)
at 
com.metria.test.atest.TestHomePage.testRenderMyPage(TestHomePage.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:467)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)



Any help would be appreciated! Thanks,
jan

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: FormTester and Select component?

2010-03-02 Thread Jan Eriksson
);
  }

  /**
   * @param tmp
   */
  private void endOptGroup(AppendingStringBuffer tmp) {
    // OptGroup ended
    int start = tmp.lastIndexOf(/option);
    tmp.insert(start + 9, /optgroup);
  }
 }

 **
 Martin

 **
 Martin


 2010/3/2 Jan Eriksson jneriks...@gmail.com:
 We're using a Select component
 (org.apache.wicket.extensions.markup.html.form.select.Select) to
 display two groups of SelectionOptions in a Form. I guess that is the
 correct component to use when you want to group options and render
 them in optgroup's?

 Anyway, we would like to test the form using FormTester but when i try
 to select a value we get the following exception:

 org.apache.wicket.WicketRuntimeException: Selecting on the
 component:'0:paymentFormForm:paymentType' is not supported.
        at org.apache.wicket.util.tester.FormTester.fail(FormTester.java:824)
        at 
 org.apache.wicket.util.tester.FormTester.access$100(FormTester.java:59)
        at 
 org.apache.wicket.util.tester.FormTester$ChoiceSelectorFactory.create(FormTester.java:308)
 ..
 ..

 and the test code:

 FormTester ft = tester.newFormTester(paymentForm, true);
 ft.select(paymentType, 0); // paymentType is the id of the Select component


 Any help would be appreciated!

 thanks,
 jan

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org