// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/HibernateConfig.java
// public class HibernateConfig {
//     
//     public static SessionFactory createSessionFactory(Properties properties) {
//         Configuration cfg = extendConfiguration(new Configuration())
//             .addProperties(properties);
//         return cfg.buildSessionFactory();
//     }
// 
//     public static Configuration extendConfiguration(Configuration config) {
//         return config
//             .addResource("com/globalsight/ling/tm3/core/persistence/xml/BaseTm.hbm.xml")
//             .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Attribute.hbm.xml")
//             .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Event.hbm.xml");
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Test;
import com.globalsight.ling.tm3.core.persistence.HibernateConfig;
         }
         catch (Exception e) {
             currentTransaction.rollback();
             throw e;
         }
     }

     
    // when it's safe to assume at most one tuv per locale
    private static <T extends TM3Data> TM3Tuv<T> getLocaleTuv(TM3Tu<T> tu, TM3Locale locale) {
        List<TM3Tuv<T>> tuvs = tu.getLocaleTuvs(locale);
        if (tuvs.size() == 0) {
            return null;
        } else if (tuvs.size() == 1) {
            return tuvs.get(0);
        } else {
            throw new RuntimeException("unexpected multiple target tuvs");
        }
    }
    
    public static SessionFactory setupHibernate() {
        long start = System.currentTimeMillis();
        Properties props = new Properties();
        try {
            props.load(TM3Tests.class.getResourceAsStream("/test.properties"));
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
        Configuration cfg = new Configuration().addProperties(props);
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/HibernateConfig.java
// public class HibernateConfig {
//     
//     public static SessionFactory createSessionFactory(Properties properties) {
//         Configuration cfg = extendConfiguration(new Configuration())
//             .addProperties(properties);
//         return cfg.buildSessionFactory();
//     }
// 
//     public static Configuration extendConfiguration(Configuration config) {
//         return config
//             .addResource("com/globalsight/ling/tm3/core/persistence/xml/BaseTm.hbm.xml")
//             .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Attribute.hbm.xml")
//             .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Event.hbm.xml");
//     }
// }


// Path: src/test/java/com/globalsight/ling/tm3/core/TM3Tests.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Test;
import com.globalsight.ling.tm3.core.persistence.HibernateConfig;

         }
         catch (Exception e) {
             currentTransaction.rollback();
             throw e;
         }
     }

     
    // when it's safe to assume at most one tuv per locale
    private static <T extends TM3Data> TM3Tuv<T> getLocaleTuv(TM3Tu<T> tu, TM3Locale locale) {
        List<TM3Tuv<T>> tuvs = tu.getLocaleTuvs(locale);
        if (tuvs.size() == 0) {
            return null;
        } else if (tuvs.size() == 1) {
            return tuvs.get(0);
        } else {
            throw new RuntimeException("unexpected multiple target tuvs");
        }
    }
    
    public static SessionFactory setupHibernate() {
        long start = System.currentTimeMillis();
        Properties props = new Properties();
        try {
            props.load(TM3Tests.class.getResourceAsStream("/test.properties"));
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
        Configuration cfg = new Configuration().addProperties(props);
        cfg = HibernateConfig.extendConfiguration(cfg);