From 2ead194254e959fb83ed9278357393942253c9ad Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 27 Sep 2007 16:38:06 +0000 Subject: [PATCH] HHH-2859 : work api git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14030 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../legacy/ConfigurationPerformanceTest.java | 255 ------------------ 1 file changed, 255 deletions(-) delete mode 100644 testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java diff --git a/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java b/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java deleted file mode 100644 index 576213c39a..0000000000 --- a/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Created on 01-05-2004 - * - */ -package org.hibernate.test.legacy; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.PrintWriter; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import org.hibernate.HibernateException; -import org.hibernate.SessionFactory; -import org.hibernate.junit.UnitTestCase; -import org.hibernate.cfg.Configuration; -import org.hibernate.classic.Session; - -/** - * @author MAX - * - */ -public class ConfigurationPerformanceTest extends UnitTestCase { - - String[] files = new String[] { - "legacy/ABC.hbm.xml", - "legacy/ABCExtends.hbm.xml", - "legacy/Baz.hbm.xml", - "legacy/Blobber.hbm.xml", - "legacy/Broken.hbm.xml", - "legacy/Category.hbm.xml", - "legacy/Circular.hbm.xml", - "legacy/Commento.hbm.xml", - "legacy/ComponentNotNullMaster.hbm.xml", - "legacy/Componentizable.hbm.xml", - "legacy/Container.hbm.xml", - "legacy/Custom.hbm.xml", - "legacy/CustomSQL.hbm.xml", - "legacy/Eye.hbm.xml", - "legacy/Fee.hbm.xml", - "legacy/Fo.hbm.xml", - "legacy/FooBar.hbm.xml", - "legacy/Fum.hbm.xml", - "legacy/Fumm.hbm.xml", - "legacy/Glarch.hbm.xml", - "legacy/Holder.hbm.xml", - "legacy/IJ2.hbm.xml", - "legacy/Immutable.hbm.xml", - "legacy/Location.hbm.xml", - "legacy/Many.hbm.xml", - "legacy/Map.hbm.xml", - "legacy/Marelo.hbm.xml", - "legacy/MasterDetail.hbm.xml", - "legacy/Middle.hbm.xml", - "legacy/Multi.hbm.xml", - "legacy/MultiExtends.hbm.xml", - "legacy/Nameable.hbm.xml", - "legacy/One.hbm.xml", - "legacy/ParentChild.hbm.xml", - "legacy/Qux.hbm.xml", - "legacy/Simple.hbm.xml", - "legacy/SingleSeveral.hbm.xml", - "legacy/Stuff.hbm.xml", - "legacy/UpDown.hbm.xml", - "legacy/Vetoer.hbm.xml", - "legacy/WZ.hbm.xml", - }; - - boolean keepFilesAround = false ; // set to true to be able to "coldstart" start. - - public ConfigurationPerformanceTest(String string) { - super( string ); - } - - public void testLoadingAndSerializationOfConfiguration() throws HibernateException, FileNotFoundException, IOException, ClassNotFoundException { - - String prefix = "./src/test/java/org/hibernate/test/"; - try { - // first time - System.err.println("###FIRST SAVELOAD###"); - saveAndLoad(prefix,files, "hibernate.cfg.bin"); - // second time to validate - System.err.println("###SECOND SAVELOAD###"); - saveAndLoad(prefix,files, "hibernate.cfg.bin"); - } - finally { - System.err.println( "###CLEANING UP###" ); - if(!keepFilesAround) { - File file = null; - try { - // clean up - file = new File("hibernate.cfg.bin"); - file.delete(); - } - catch( Throwable t ) { - System.err.println( "Unable to cleanup [" + file + "] : " + t ); - } - - for (int i = 0; i < files.length; i++) { - try { - String fileName = files[i]; - file = new File( prefix, fileName + ".bin" ); - file.delete(); - } - catch( Throwable t ) { - System.err.println( "Unable to cleanup [" + file + "] : " + t ); - } - } - } - } - - } - - // this method requires generation of test files (can be done with generateTestFiles) + their compile - public void xtestSessionFactoryCreationTime() throws FileNotFoundException, IOException, ClassNotFoundException { - File perfs = new File("perfsrc"); - generateTestFiles(perfs, "perftest"); - if(perfs.exists()) { - SessionFactory factory = saveAndLoad("perfsrc/perftest/", new File(perfs, "perftest").list(new FilenameFilter() { - - public boolean accept(File dir, String name) { - return name.endsWith(".hbm.xml"); - } - - }), "hibernateperftest.cfg.bin"); - - Session session = factory.openSession(); - Object o = session.load("perftest.Test1", new Long(42)); - System.out.println(o); - } else { - System.err.println(perfs.getAbsoluteFile() + " not found"); - } - } - - private SessionFactory saveAndLoad(String prefix, String[] files, String cfgName) throws IOException, FileNotFoundException, ClassNotFoundException { - long start = System.currentTimeMillis(); - - Configuration cfg = new Configuration(); - System.err.println("Created configuration: " + (System.currentTimeMillis() - start) / 1000.0 + " sec."); - - System.err.println("saveAndLoad from " + prefix + " with cfg = " + cfgName); - if(!new File(cfgName).exists()) { - start = System.currentTimeMillis(); - /*for (int i=0; i\r\n" + - "\r\n"); - - hbmWriter.println(""); - - javaWriter.println("public class " + name + " {"); - javaWriter.println(" static { System.out.println(\"" + name + " initialized!\"); }"); - hbmWriter.println(""); - - hbmWriter.println(""); - for(int propCount=0;propCount<100;propCount++) { - String propName = "Prop" + propCount; - - writeJavaProperty(javaWriter, propName); - - hbmWriter.println(""); - - } - hbmWriter.println(""); - javaWriter.println("}"); - hbmWriter.println(""); - } finally { - if(javaWriter!=null) { - javaWriter.flush(); - javaWriter.close(); - } - if(hbmWriter!=null) { - hbmWriter.flush(); - hbmWriter.close(); - } - } - } - - } - - - private void writeJavaProperty(PrintWriter javaWriter, String propName) { - javaWriter.println(" String " + propName + ";"); - javaWriter.println(" String get" + propName + "() { return " + propName + "; }"); - javaWriter.println(" void set" + propName + "(String newVal) { " + propName + "=newVal; }"); - } -}