From hibernate-commits at lists.jboss.org Tue Oct 31 08:24:28 2006 Content-Type: multipart/mixed; boundary="===============1052968555811439810==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r10665 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/tool/hbm2x templates/doc/entities test/org/hibernate/tool/hbm2x Date: Tue, 31 Oct 2006 08:24:28 -0500 Message-ID: --===============1052968555811439810== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: max.andersen(a)jboss.com Date: 2006-10-31 08:24:23 -0500 (Tue, 31 Oct 2006) New Revision: 10665 Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x= /FileVisitor.java Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x= /DocExporter.java branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity= .ftl branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x= /DocExporterTest.java Log: HBX-791 Generic type information is hidden in hbm2doc Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/too= l/hbm2x/DocExporter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2= x/DocExporter.java 2006-10-31 13:23:35 UTC (rev 10664) +++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2= x/DocExporter.java 2006-10-31 13:24:23 UTC (rev 10665) @@ -123,12 +123,6 @@ * Doc File Manager. */ private DocFileManager docFileManager; - - /** - * As of now we are not using generics. In future we may allow to pass= one of the parameters in ant for generics = - */ - //TODO Should we allow user to make use of genrics? - private boolean jdk5 =3D false; = /** * Creates a new object. @@ -270,7 +264,9 @@ = = protected void setupContext() { - getProperties().put("jdk5", "" + useJdk5()); + if(!getProperties().contains( "jdk5" )) { + getProperties().setProperty( "jdk5", "true" ); + } = super.setupContext(); docHelper =3D new DocHelper( getConfiguration(), getCfg2JavaTool() ); docFileManager =3D new DocFileManager(docHelper, getOutputDirector= y() ); @@ -619,13 +615,5 @@ public String getName() { return "hbm2doc"; } - = - public boolean useJdk5() { - return jdk5; - } - - public void setJdk5(boolean jdk5) { - this.jdk5 =3D jdk5; - } - = + = } \ No newline at end of file Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities= /entity.ftl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entit= y.ftl 2006-10-31 13:23:35 UTC (rev 10664) +++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entit= y.ftl 2006-10-31 13:24:23 UTC (rev 10665) @@ -86,10 +86,10 @@ 0)>ROWSPAN=3D"${rowspan}"> <#if dochelper.getComponentPOJO(property)?exists> - ${compoclass.getJavaTypeName(property, jdk5)?default(" ")} + ${compoclass.getJavaTypeName(property, jdk5)?html?default("&nb= sp;")} <#else> - ${compoclass.getJavaTypeName(property, jdk5)?default(" ")} + ${compoclass.getJavaTypeName(property, jdk5)?html?default("&nbs= p;")} = @@ -125,7 +125,7 @@ Column - ${class.getJavaTypeName(propertyIdentifier, jdk5)?default(" = ")} + ${class.getJavaTypeName(propertyIdentifier, jdk5)?html?default("&= nbsp;")} <#if class.hasFieldJavaDoc(propertyIdentifier)> @@ -206,10 +206,10 @@ 0)>ROWSPAN=3D"${rowspan}"> <#if dochelper.getComponentPOJO(property)?exists> - ${class.getJavaTypeName(property, jdk5)?default(" ")} + ${class.getJavaTypeName(property, jdk5)?html?default(" ")} <#else> - ${class.getJavaTypeName(property, jdk5)?default(" ")} + ${class.getJavaTypeName(property, jdk5)?html?default(" ")} = Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/too= l/hbm2x/DocExporterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2= x/DocExporterTest.java 2006-10-31 13:23:35 UTC (rev 10664) +++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2= x/DocExporterTest.java 2006-10-31 13:24:23 UTC (rev 10665) @@ -1,9 +1,13 @@ package org.hibernate.tool.hbm2x; = import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.OutputStream; import java.util.Properties; = import org.hibernate.tool.NonReflectiveTestCase; +import org.w3c.tidy.Tidy; = public class DocExporterTest extends NonReflectiveTestCase { = @@ -30,6 +34,7 @@ super.setUp(); DocExporter exporter =3D new DocExporter(getCfg(), getOutputDir() ); Properties properties =3D new Properties(); + properties.put( "jdk5", "true"); // test generics properties.put("dot.executable", System.getProperties().getProperty("dot= .executable","dot.exe")); exporter.setProperties( properties ); exporter.start(); @@ -61,7 +66,20 @@ assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.dot")= ); assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.png")= ); = - = + /* Tidy complains about valid html 4.x = + final Tidy tidy =3D new Tidy(); + = + + new FileVisitor() { + protected void process(File dir) { + if(dir.isFile() && dir.getName().endsWith( ".html" )) { + testHtml( tidy, dir ); + } + = + } + }.visit( getOutputDir() );*/ + = + = } = public void testCommentIncluded() { @@ -71,5 +89,27 @@ = assertNotNull(findFirstString("A unique customer comment!", tableFile)); } + = + public void testGenericsRenderedCorrectly() { +// A unique customer comment! + File tableFile =3D new File(getOutputDir(), "entities/org/hibernate/t= ool/hbm2x/Customer.html"); + assertFileAndExists(tableFile ); + = + assertEquals("Generics syntax should not occur verbatim in html",null,fi= ndFirstString("List<", tableFile)); + assertNotNull("Generics syntax occur verbatim in html",findFirstString("= List<", tableFile)); + } = + + private void testHtml(final Tidy tidy, File dir) { + try { + System.out.println("*****Parsing " + dir); + tidy.parse( new FileInputStream(dir), (OutputStream)null ); + assertEquals(dir + "has errors ", 0, tidy.getParseErrors()); + assertEquals(dir + "has warnings ", 0, tidy.getParseWarnings()); + } + catch (FileNotFoundException e) { + fail(); + } + } + } Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/h= bm2x/FileVisitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2= x/FileVisitor.java 2006-10-31 13:23:35 UTC (rev 10664) +++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2= x/FileVisitor.java 2006-10-31 13:24:23 UTC (rev 10665) @@ -0,0 +1,21 @@ +package org.hibernate.tool.hbm2x; + +import java.io.File; + +public abstract class FileVisitor { + + + public void visit(File dir) { + process(dir); + = + if (dir.isDirectory()) { + String[] children =3D dir.list(); + for (int i=3D0; i