From: Adam S. <ada...@ja...> - 2006-02-26 16:29:14
|
Tor-Erik N=F8rstrud Larsen wrote: > On the user class the setter takes a set of roles. In excel the roles a= re the role names in a commaseparated list. What I want to do is to confi= gure a Spring based CustomPropertyEditor onto my user so that the commase= parated string of role names, get parsed, and queried, the return a hashs= et of roles (that will be set onto the user). This will make the tests mu= ch cleaner and easier to make. I have read some documentation, but nothin= g gives me a hint how to do it. > =20 Just let me check if I have understood you correctly - you want a custom=20 property editor that can convert from a comma separated string to a=20 hash-set of Role objects, and that should be injected using an property=20 expression (excel header) like "user1.roles"? The way to do this is to write the PropertyEditor you want, and then=20 register it with the JavaBeans standard registry (global): **java.beans.PropertyEditorManager#**registerEditor(...) If you use Java 1.5, you can even make it target only HashSet<Role> or=20 if you use Java 1.4 you will have to settle for HashSet. The best place to put this would be in setupMethod() - a callback in=20 your DDSteps testcase. Then make sure you un-set it in tearDownMethod(),=20 by calling registerEditor(HashSet.class, null). That way it's only used=20 when necessary. In Spring you can add PropertyEditors to the context xml file, but since=20 DDSteps can be used without Spring, we haven't added that feature yet.=20 I'd be very happy if you filed an enhancement request in our bug tracker=20 (so so that it doesn't look like I file all of them myself ;-)! Go to=20 jira.ddsteps.org, create an account if you don't already have one, and=20 fill in a request. Please, let me know if this solved your problem and how it worked out! Regards /Adam Skogman, DDSteps lead -- Adam Skogman, J2EE Consultant Jayway AB Mobile: +46 701 46 92 91 Office: +46 40 12 72 83 Web: www.jayway.se |