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/tool/hbm2x/DocExporter.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java 2006-10-31
13:23:35 UTC (rev 10664)
+++
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/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 = 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 = new DocHelper( getConfiguration(), getCfg2JavaTool() );
docFileManager = new DocFileManager(docHelper, getOutputDirectory() );
@@ -619,13 +615,5 @@
public String getName() {
return "hbm2doc";
}
-
- public boolean useJdk5() {
- return jdk5;
- }
-
- public void setJdk5(boolean jdk5) {
- this.jdk5 = jdk5;
- }
-
+
}
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-10-31
13:23:35 UTC (rev 10664)
+++
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-10-31
13:24:23 UTC (rev 10665)
@@ -86,10 +86,10 @@
<TD WIDTH="14%" <#if
(rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<#if dochelper.getComponentPOJO(property)?exists>
<A HREF='${docFileManager.getRef(docFile,
docFileManager.getEntityDocFileByDeclarationName(dochelper.getComponentPOJO(property)))}'
TARGET="generalFrame">
- ${compoclass.getJavaTypeName(property,
jdk5)?default(" ")}
+ ${compoclass.getJavaTypeName(property,
jdk5)?html?default(" ")}
</A>
<#else>
- ${compoclass.getJavaTypeName(property, jdk5)?default(" ")}
+ ${compoclass.getJavaTypeName(property,
jdk5)?html?default(" ")}
</#if>
</TD>
@@ -125,7 +125,7 @@
Column
</TD>
<TD WIDTH="14%">
- ${class.getJavaTypeName(propertyIdentifier,
jdk5)?default(" ")}
+ ${class.getJavaTypeName(propertyIdentifier,
jdk5)?html?default(" ")}
</TD>
<TD WIDTH="58%">
<#if class.hasFieldJavaDoc(propertyIdentifier)>
@@ -206,10 +206,10 @@
<TD WIDTH="14%" <#if
(rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<#if dochelper.getComponentPOJO(property)?exists>
<A HREF='${docFileManager.getRef(docFile,
docFileManager.getEntityDocFileByDeclarationName(dochelper.getComponentPOJO(property)))}'
TARGET="generalFrame">
- ${class.getJavaTypeName(property, jdk5)?default(" ")}
+ ${class.getJavaTypeName(property, jdk5)?html?default(" ")}
</A>
<#else>
- ${class.getJavaTypeName(property, jdk5)?default(" ")}
+ ${class.getJavaTypeName(property, jdk5)?html?default(" ")}
</#if>
</TD>
Modified:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-10-31
13:23:35 UTC (rev 10664)
+++
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/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 = new DocExporter(getCfg(), getOutputDir() );
Properties properties = 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 = 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 = new File(getOutputDir(),
"entities/org/hibernate/tool/hbm2x/Customer.html");
+ assertFileAndExists(tableFile );
+
+ assertEquals("Generics syntax should not occur verbatim in
html",null,findFirstString("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/hbm2x/FileVisitor.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/FileVisitor.java 2006-10-31
13:23:35 UTC (rev 10664)
+++
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/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 = dir.list();
+ for (int i=0; i<children.length; i++) {
+ visit(new File(dir, children[i]));
+ }
+ }
+ }
+
+ abstract protected void process(File dir);
+
+}