Author: max.andersen(a)jboss.com
Date: 2006-10-03 20:11:08 -0400 (Tue, 03 Oct 2006)
New Revision: 10549
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java
Log:
tests for graph generation in hbm2doc and meta attributes in hbm2hbmxml
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -183,4 +183,8 @@
public Configuration getConfiguration() {
return getCfg();
}
+
+ protected void buildSessionFactory() {
+ sessions = getCfg().buildSessionFactory();
+ }
}
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -1,6 +1,7 @@
package org.hibernate.tool.hbm2x;
import java.io.File;
+import java.util.Properties;
import org.hibernate.tool.NonReflectiveTestCase;
@@ -28,9 +29,15 @@
protected void setUp() throws Exception {
super.setUp();
DocExporter exporter = new DocExporter(getCfg(), getOutputDir() );
+ Properties properties = new Properties();
+ properties.put("dot.executable",
System.getProperties().getProperty("dot.executable","dot.exe"));
+ exporter.setProperties( properties );
exporter.start();
}
+ protected void tearDown() throws Exception {
+ //super.tearDown();
+ }
public void testExporter() {
assertFileAndExists(new File(getOutputDir(), "header.html") );
@@ -48,6 +55,12 @@
assertTrue(new File(getOutputDir(),
"entities/org/hibernate/tool/hbm2x/UPerson.html").exists() );
assertFileAndExists(new File(getOutputDir(),
"entities/org/hibernate/tool/hbm2x/UUser.html") );
+ assertFileAndExists(new File(getOutputDir(),
"entities/entitygraph.dot"));
+ assertFileAndExists(new File(getOutputDir(),
"entities/entitygraph.png"));
+
+ assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.dot"));
+ assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.png"));
+
}
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -35,7 +35,17 @@
assertEquals("<basic
attrib='1'></basic>\r\n",string);
}
-
+
+ public void testCloseTag() throws IOException, DocumentException, SAXException {
+
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XMLPrettyPrinter.prettyPrint(new
ByteArrayInputStream("<basic></basic>".getBytes() ),
byteArrayOutputStream);
+
+ String string = byteArrayOutputStream.toString();
+
+ assertEquals("<basic/>\r\n",string);
+ }
+
public void testDeclarationWithoutValidation() throws IOException, DocumentException,
SAXException {
String input = "<hibernate-mapping
defaultx-lazy=\"false\"/>";
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml 2006-10-04
00:11:08 UTC (rev 10549)
@@ -11,12 +11,14 @@
(2) Id generation with no arguments.
-->
<class name="Basic" table="`bas-ic`">
-
+ <meta attribute="class-meta"
inherit="false">Basic</meta>
+ <meta attribute="class-meta"
inherit="false">Basic2</meta>
<id name="basicId"
length="10"
type="string"
unsaved-value="null"
+ <meta attribute="id-meta"
inherit="false">basicId</meta>
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">uni_table</param>
<param name="column">next_hi_value</param>
@@ -26,12 +28,20 @@
<property name="description"
not-null="true"
length="200"
- type="string" />
+ type="string">
+ <meta attribute="property-desc"
inherit="false">description</meta>
+ </property>
<property name="price" length="3"
type="big_decimal" />
<property name="numberAvailable" type="int"
column="`number-Available`"/>
+ <set name="aSet">
+ <meta attribute="set-desc">anotherone</meta>
+ <key/>
+ <one-to-many class="Basic"/>
+ </set>
+
</class>
</hibernate-mapping>
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -127,6 +127,36 @@
}
+ public void testMetaAttributes() throws DocumentException {
+ File outputXml = new File(getOutputDir().getAbsolutePath() +
"/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml");
+ assertFileAndExists(outputXml);
+
+ SAXReader xmlReader = this.getSAXReader();
+
+ Document document = xmlReader.read(outputXml);
+
+ XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/meta");
+ List list = xpath.selectNodes(document);
+ assertEquals("Expected to get one meta element", 2, list.size());
+ Node node = (Node) list.get(0);
+ assertEquals(node.getText(),"Basic");
+
+ xpath =
DocumentHelper.createXPath("//hibernate-mapping/class/property/meta");
+ list = xpath.selectNodes(document);
+ assertEquals("Expected to get one meta element", 1, list.size());
+ node = (Node) list.get(0);
+ assertEquals(node.getText(),"description");
+
+ xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/meta");
+ list = xpath.selectNodes(document);
+ assertEquals("Expected to get one meta element", 1, list.size());
+ node = (Node) list.get(0);
+ assertEquals(node.getText(),"anotherone");
+
+
+ }
+
+
public void testComments() throws DocumentException {
File outputXml = new File(getOutputDir().getAbsolutePath() +
"/org/hibernate/tool/hbm2x/hbm2hbmxml/ClassFullAttribute.hbm.xml");
assertFileAndExists(outputXml);
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -15,9 +15,19 @@
cfg.setProperty( Environment.USE_STRUCTURED_CACHE, "true" );
}*/
+ protected void setUp() throws Exception {
+ // TODO Auto-generated method stub
+ super.setUp();
+ if(getSessions()==null) {
+ buildSessionFactory();
+ }
+ }
public void testBrowser() throws Exception {
getSessions().getStatistics().setStatisticsEnabled( true );
+
new StatisticsBrowser().showStatistics( getSessions().getStatistics(), false );
+
+
Session s = openSession();
Transaction tx = s.beginTransaction();
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java 2006-10-03
23:52:56 UTC (rev 10548)
+++ trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -164,6 +164,7 @@
}
// The directory is now empty so delete it
+ System.out.println("deleting: " + dir);
return dir.delete();
}
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -4,6 +4,7 @@
*/
package org.hibernate.tool.test.jdbc2cfg;
+import java.io.File;
import java.sql.Types;
import java.util.Iterator;
import java.util.List;
@@ -12,6 +13,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.JDBCMetaDataConfiguration;
import org.hibernate.cfg.Settings;
@@ -32,6 +34,7 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.tool.JDBCMetaDataBinderTestCase;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
/**
* @author max
@@ -489,6 +492,7 @@
return ( (SimpleValue)property.getValue() ).getTypeName();
}
+
protected String[] getCreateSQL() {
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java
===================================================================
---
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java 2006-10-03
23:52:56 UTC (rev 10548)
+++
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java 2006-10-04
00:11:08 UTC (rev 10549)
@@ -24,6 +24,7 @@
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Set;
import org.hibernate.tool.JDBCMetaDataBinderTestCase;
+import org.hibernate.tool.stat.StatisticsBrowser;
import persistentclasses.Item;
import persistentclasses.Orders;
@@ -116,6 +117,8 @@
SessionFactory sf = cfg.buildSessionFactory();
+
+
Session session = sf.openSession();
Transaction t = session.beginTransaction();
@@ -135,6 +138,7 @@
t.commit();
session.close();
+ new StatisticsBrowser().showStatistics( sf.getStatistics(), true );
session = sf.openSession();
t = session.beginTransaction();