Author: dgeraskov
Date: 2010-09-21 08:26:03 -0400 (Tue, 21 Sep 2010)
New Revision: 20675
Modified:
tools/trunk/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java
tools/trunk/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
Log:
Fix failing tests
Modified: tools/trunk/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java
===================================================================
--- tools/trunk/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java 2010-09-21
03:16:47 UTC (rev 20674)
+++ tools/trunk/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java 2010-09-21
12:26:03 UTC (rev 20675)
@@ -36,8 +36,6 @@
*/
public class MapAndAnyTest extends NonReflectiveTestCase {
- private String mappingFile = "Properties.hbm.xml";
-
private Exporter hbmexporter;
/**
@@ -50,7 +48,8 @@
protected String[] getMappings() {
return new String[] {
- mappingFile
+ "Properties.hbm.xml",
+ "Person2.hbm.xml"
};
}
@@ -116,11 +115,6 @@
}
public void testMetaValueRead() throws Exception{
- String oldMappingFile = mappingFile;
- mappingFile = "Person2.hbm.xml";
-
- super.setUp();//rebuld cfg
-
Configuration config = getCfg();
PersistentClass pc =
config.getClassMapping("org.hibernate.tool.hbm2x.hbm2hbmxml.Person2");
assertNotNull(pc);
@@ -130,7 +124,7 @@
Any any = (Any) prop.getValue();
assertTrue("Expected to get one meta-value element", any.getMetaValues() !=
null);
assertEquals("Expected to get one meta-value element", 1,
any.getMetaValues().size());
- mappingFile = oldMappingFile;
+
}
public void testMapManyToAny() throws DocumentException {
Modified: tools/trunk/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
===================================================================
--- tools/trunk/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java 2010-09-21
03:16:47 UTC (rev 20674)
+++ tools/trunk/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java 2010-09-21
12:26:03 UTC (rev 20675)
@@ -1,6 +1,13 @@
package org.hibernate.tool.stat;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Settings;
import org.hibernate.classic.Session;
import org.hibernate.tool.NonReflectiveTestCase;
@@ -48,13 +55,40 @@
tx.commit();
s.close();
- Thread.sleep( 100000 );
+ Statement statement = null;
+ Connection con = null;
+ Settings settings = null;
+ try {
+ settings = getConfiguration().buildSettings();
+ con = settings.getConnectionProvider().getConnection();
+ statement = con.createStatement();
+ statement.execute("drop table Session_attributes");
+ statement.execute("drop table Users");
+ statement.execute("drop table Groups");
+ con.commit();
+ } finally {
+ if (statement!=null) statement.close();
+ settings.getConnectionProvider().closeConnection(con);
+ }
+ //Uncomment if you want to look on StatisticsBrowser
+ //Thread.sleep( 100000 );
+
}
+
protected String getBaseForMappings() {
return "org/hibernate/tool/stat/";
}
+
+ protected void addMappings(String[] files, Configuration cfg) {
+ Properties prop = new Properties();
+ prop.put(Environment.CACHE_PROVIDER,
+ "org.hibernate.cache.EhCacheProvider");
+ cfg.addProperties(prop);
+ super.addMappings(files, cfg);
+ }
+
protected String[] getMappings() {
return new String[] { "UserGroup.hbm.xml"};
}