AppFuse JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile
  • AppFuse
  • APF-67

AppGen issues - inheritance & test data generation

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.8.1
  • Fix Version/s: 1.8.2
  • Component/s: Tools - AppGen
  • Labels:
    None

Description

 Two issues addressed that are in AppGen up through 1.8.1 --

(1) It does not find properties/methods that are defined on
superclasses of the model class that is the target of the code
generation. This is typical when using Hibernate's "joined-subclass"
inheritance mapping strategy. if you have for example a BaseCustomer
class that contains common customer attributes, and then
IndividualCustomer and BusinessCustomer classes that inherit from it,
AppGen will not include the properties from BaseCustomer when you
generate code for BusinessCustomer. This was fixed by changing the
Xdoclet java code in appgen to have it look at superclass methods as
well as the methods of the target class. There were also some side
effects that had to be addressed by changing the Xdoclet property used
in the .xdt templates to obtain the "current" class name, making sure
that "current" always meant the class that generation was invoked for,
and not a superclass.

(2) Various issues with the test data generated by AppGen:
- String values that are too long for the field, resulting in
truncation & sometimes a violation of uniqueness constraints. Solved
by generating a string of random letters (alternating upper & lower
case) that is exactly the length specified in the hibernate xdoclet
tag's "length" attribute. If no length attribute is found, defaults to
25. (Not sure if this can happen?)
- Numeric values that aren't appropriate for the property/column type.
Code now generates random numeric values that are specific to the
numeric type of the property - [Ll]ong, [Ii]nt, [Bb]yte, [Ss]hort,
etc.
End results of this:
- No more need to hand-edit sample-data.xml to correct
uniqueness/truncation issues.
- No more need to hand-edit various junit test classes to correct
incorrect numeric datatype assignments.

I also cleaned up a few other small issues I saw, such as code
templates with comments that referred to a "person" or "user" object.
They now refer to the name of the model object being generated.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    appgen-hierarchy.zip
    16/Jun/05 10:18 AM
    34 kB
    David Carter
    1. XML File
      appgen/build.xml 27 kB
    2. File
      appgen/create-tables.sql 2 kB
    3. Text File
      appgen/README.txt 3 kB
    4. File
      appgen/src/action-servlet.xdt 1.0 kB
    5. File
      appgen/src/Constants.xdt 0.5 kB
    6. File
      appgen/src/ControllerTest.xdt 1.0 kB
    7. File
      appgen/src/.../context-hibernate.xdt 0.3 kB
    8. File
      appgen/src/detailed/context-service.xdt 0.4 kB
    9. File
      appgen/src/detailed/Controller.xdt 2 kB
    10. File
      appgen/src/detailed/DAO.xdt 2 kB
    11. File
      appgen/src/detailed/DAOHibernate.xdt 3 kB
    12. File
      appgen/src/detailed/DAOTest.xdt 6 kB
    13. File
      appgen/src/detailed/FormController.xdt 3 kB
    14. File
      appgen/src/detailed/Manager.xdt 2 kB
    15. File
      appgen/src/detailed/ManagerImpl.xdt 2 kB
    16. File
      appgen/src/detailed/ManagerTest.xdt 6 kB
    17. File
      appgen/src/FormControllerTest.xdt 3 kB
    18. File
      appgen/src/FormKeys.xdt 0.9 kB
    19. File
      appgen/src/Form_jsp.xdt 3 kB
    20. File
      appgen/src/generic/Controller.xdt 1 kB
    21. File
      appgen/src/generic/FormController.xdt 3 kB
    22. File
      appgen/src/List_jsp.xdt 2 kB
    23. File
      appgen/src/menu-config.xdt 0.3 kB
    24. File
      appgen/src/menu_jsp.xdt 0.2 kB
    25. Java Source File
      appgen/src/.../xdoclet/FormTagsHandler.java 8 kB
    26. Java Source File
      appgen/src/.../MethodExTagsHandler.java 11 kB
    27. File
      appgen/src/sample-data.xdt 5 kB
    28. File
      appgen/src/url-mappings.xdt 0.4 kB
    29. File
      appgen/src/web-tests.xdt 6 kB
    30. Java Source File
      appgen/test/dao/.../model/Person.java 2 kB
    Showing 30 of 32 items Download Zip
    Show
    Zip Archive
    appgen-hierarchy.zip
    16/Jun/05 10:18 AM
    34 kB
    David Carter
  2. Hide
    Zip Archive
    appgen-testdata-mods.zip
    16/Jun/05 10:18 AM
    39 kB
    David Carter
    1. XML File
      appgen/build.xml 27 kB
    2. File
      appgen/create-tables.sql 2 kB
    3. Text File
      appgen/log.txt 23 kB
    4. Text File
      appgen/README.txt 3 kB
    5. File
      appgen/src/action-servlet.xdt 1.0 kB
    6. File
      appgen/src/Constants.xdt 0.5 kB
    7. File
      appgen/src/ControllerTest.xdt 1.0 kB
    8. File
      appgen/src/.../context-hibernate.xdt 0.3 kB
    9. File
      appgen/src/detailed/context-service.xdt 0.4 kB
    10. File
      appgen/src/detailed/Controller.xdt 2 kB
    11. File
      appgen/src/detailed/DAO.xdt 2 kB
    12. File
      appgen/src/detailed/DAOHibernate.xdt 3 kB
    13. File
      appgen/src/detailed/DAOTest.xdt 5 kB
    14. File
      appgen/src/detailed/FormController.xdt 3 kB
    15. File
      appgen/src/detailed/Manager.xdt 2 kB
    16. File
      appgen/src/detailed/ManagerImpl.xdt 2 kB
    17. File
      appgen/src/detailed/ManagerTest.xdt 5 kB
    18. File
      appgen/src/FormControllerTest.xdt 3 kB
    19. File
      appgen/src/FormKeys.xdt 0.9 kB
    20. File
      appgen/src/Form_jsp.xdt 3 kB
    21. File
      appgen/src/generic/Controller.xdt 1 kB
    22. File
      appgen/src/generic/FormController.xdt 3 kB
    23. File
      appgen/src/List_jsp.xdt 2 kB
    24. File
      appgen/src/menu-config.xdt 0.3 kB
    25. File
      appgen/src/menu_jsp.xdt 0.2 kB
    26. Java Source File
      appgen/src/.../xdoclet/FormTagsHandler.java 8 kB
    27. Java Source File
      appgen/src/.../MethodExTagsHandler.java 15 kB
    28. File
      appgen/src/sample-data.xdt 5 kB
    29. File
      appgen/src/url-mappings.xdt 0.4 kB
    30. File
      appgen/src/web-tests.xdt 6 kB
    Showing 30 of 33 items Download Zip
    Show
    Zip Archive
    appgen-testdata-mods.zip
    16/Jun/05 10:18 AM
    39 kB
    David Carter

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Source
Hide
Permalink
David Carter added a comment - 16/Jun/05 10:16 AM
The inheritance stuff all appears to work with no issues. I did not
get around to adding a test of this feature to the appgen test suite,
but I have run the existing test suites, including the 2-word version.
I re-baselined off of the 1.8.1-RC2 code yesterday, so this should
have any changes from 1.8.1 incorporated already. BeyondCompare is
cool!

I also have changes in here to improve the test data generation, both
in sample-data.xml & in the junit test classes themselves. It now does
a better job of generating numeric data of the appropriate class, and
generating strings that are not too long, based on the
@hibernate.property length="xx" tags. There is an enhanced version of
Person.java in here that has fields of all the supported types.

There is one last issue I'm just too tired to track down at this
point. After my last round of changes related to the test-data
generation, I'm getting an assertion failure on the
PersonFormControllerTest.testSave() method. The report looks like
this:

junit.framework.AssertionFailedError at
org.appfuse.webapp.action.PersonFormControllerTest.testSave(PersonFormControllerTest.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

I can't for the life of me figure out what is causing this. All other
tests pass - dao, service, etc.

I'm including two copies of the appgen directory - one with pretty
much just the hierarchy changes, and another with those plus the test
data stuff. As far as I recall the hierarchy-only version passed all
tests (test-all, test-2word, etc.) completely.
Show
David Carter added a comment - 16/Jun/05 10:16 AM The inheritance stuff all appears to work with no issues. I did not get around to adding a test of this feature to the appgen test suite, but I have run the existing test suites, including the 2-word version. I re-baselined off of the 1.8.1-RC2 code yesterday, so this should have any changes from 1.8.1 incorporated already. BeyondCompare is cool! I also have changes in here to improve the test data generation, both in sample-data.xml & in the junit test classes themselves. It now does a better job of generating numeric data of the appropriate class, and generating strings that are not too long, based on the @hibernate.property length="xx" tags. There is an enhanced version of Person.java in here that has fields of all the supported types. There is one last issue I'm just too tired to track down at this point. After my last round of changes related to the test-data generation, I'm getting an assertion failure on the PersonFormControllerTest.testSave() method. The report looks like this: junit.framework.AssertionFailedError at org.appfuse.webapp.action.PersonFormControllerTest.testSave(PersonFormControllerTest.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) I can't for the life of me figure out what is causing this. All other tests pass - dao, service, etc. I'm including two copies of the appgen directory - one with pretty much just the hierarchy changes, and another with those plus the test data stuff. As far as I recall the hierarchy-only version passed all tests (test-all, test-2word, etc.) completely.
Hide
Permalink
David Carter added a comment - 16/Jun/05 5:38 PM
Doh! I really hate when I do this!

In MethodExTagsHandler.java, method generateStringValue,

change: for (int i = 0; (i <= maxLen); i++) {

to: for (int i = 0; (i < maxLen); i++) {
Show
David Carter added a comment - 16/Jun/05 5:38 PM Doh! I really hate when I do this! In MethodExTagsHandler.java, method generateStringValue, change: for (int i = 0; (i <= maxLen); i++) { to: for (int i = 0; (i < maxLen); i++) {
Hide
Permalink
Matt Raible added a comment - 11/Aug/05 7:13 AM
Patches committed to CVS - please test when you get a chance.
Show
Matt Raible added a comment - 11/Aug/05 7:13 AM Patches committed to CVS - please test when you get a chance.

People

  • Assignee:
    Matt Raible
    Reporter:
    David Carter
Vote (0)
Watch (0)

Dates

  • Created:
    16/Jun/05 10:15 AM
    Updated:
    11/Aug/05 7:13 AM
    Resolved:
    11/Aug/05 7:13 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for AppFuse. Try JIRA - bug tracking software for your team.