Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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.
(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.
-
Hide
- appgen-hierarchy.zip
- 16/Jun/05 10:18 AM
- 34 kB
- David Carter
-
- appgen/build.xml 27 kB
- appgen/create-tables.sql 2 kB
- appgen/README.txt 3 kB
- appgen/src/action-servlet.xdt 1.0 kB
- appgen/src/Constants.xdt 0.5 kB
- appgen/src/ControllerTest.xdt 1.0 kB
- appgen/src/.../context-hibernate.xdt 0.3 kB
- appgen/src/detailed/context-service.xdt 0.4 kB
- appgen/src/detailed/Controller.xdt 2 kB
- appgen/src/detailed/DAO.xdt 2 kB
- appgen/src/detailed/DAOHibernate.xdt 3 kB
- appgen/src/detailed/DAOTest.xdt 6 kB
- appgen/src/detailed/FormController.xdt 3 kB
- appgen/src/detailed/Manager.xdt 2 kB
- appgen/src/detailed/ManagerImpl.xdt 2 kB
- appgen/src/detailed/ManagerTest.xdt 6 kB
- appgen/src/FormControllerTest.xdt 3 kB
- appgen/src/FormKeys.xdt 0.9 kB
- appgen/src/Form_jsp.xdt 3 kB
- appgen/src/generic/Controller.xdt 1 kB
- appgen/src/generic/FormController.xdt 3 kB
- appgen/src/List_jsp.xdt 2 kB
- appgen/src/menu-config.xdt 0.3 kB
- appgen/src/menu_jsp.xdt 0.2 kB
- appgen/src/.../xdoclet/FormTagsHandler.java 8 kB
- appgen/src/.../MethodExTagsHandler.java 11 kB
- appgen/src/sample-data.xdt 5 kB
- appgen/src/url-mappings.xdt 0.4 kB
- appgen/src/web-tests.xdt 6 kB
- appgen/test/dao/.../model/Person.java 2 kB
-
Hide
- appgen-testdata-mods.zip
- 16/Jun/05 10:18 AM
- 39 kB
- David Carter
-
- appgen/build.xml 27 kB
- appgen/create-tables.sql 2 kB
- appgen/log.txt 23 kB
- appgen/README.txt 3 kB
- appgen/src/action-servlet.xdt 1.0 kB
- appgen/src/Constants.xdt 0.5 kB
- appgen/src/ControllerTest.xdt 1.0 kB
- appgen/src/.../context-hibernate.xdt 0.3 kB
- appgen/src/detailed/context-service.xdt 0.4 kB
- appgen/src/detailed/Controller.xdt 2 kB
- appgen/src/detailed/DAO.xdt 2 kB
- appgen/src/detailed/DAOHibernate.xdt 3 kB
- appgen/src/detailed/DAOTest.xdt 5 kB
- appgen/src/detailed/FormController.xdt 3 kB
- appgen/src/detailed/Manager.xdt 2 kB
- appgen/src/detailed/ManagerImpl.xdt 2 kB
- appgen/src/detailed/ManagerTest.xdt 5 kB
- appgen/src/FormControllerTest.xdt 3 kB
- appgen/src/FormKeys.xdt 0.9 kB
- appgen/src/Form_jsp.xdt 3 kB
- appgen/src/generic/Controller.xdt 1 kB
- appgen/src/generic/FormController.xdt 3 kB
- appgen/src/List_jsp.xdt 2 kB
- appgen/src/menu-config.xdt 0.3 kB
- appgen/src/menu_jsp.xdt 0.2 kB
- appgen/src/.../xdoclet/FormTagsHandler.java 8 kB
- appgen/src/.../MethodExTagsHandler.java 15 kB
- appgen/src/sample-data.xdt 5 kB
- appgen/src/url-mappings.xdt 0.4 kB
- appgen/src/web-tests.xdt 6 kB
Activity
Hide
David Carter
added a comment -
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++) {
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 - 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
Matt Raible
added a comment - Patches committed to CVS - please test when you get a chance.
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.