📄 securedbindingtest.java
字号:
//$Id: SecuredBindingTest.java,v 1.3 2005/01/10 21:31:03 epbernard Exp $package org.hibernate.test.metadata;import junit.framework.TestCase;import org.hibernate.AnnotationException;import org.hibernate.HibernateException;import org.hibernate.Session;import org.hibernate.StaleObjectStateException;import org.hibernate.Transaction;import org.hibernate.SessionFactory;import org.hibernate.cfg.AnnotationConfiguration;import org.hibernate.cfg.Environment;import java.util.Properties;/** * @author Emmanuel Bernard */public class SecuredBindingTest extends TestCase { public SecuredBindingTest(String x) { super(x); } public void testWrongSubClassOrder() throws Exception { AnnotationConfiguration cfg = new AnnotationConfiguration(); cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); try { cfg.addAnnotatedClass(A320.class); fail("Should not be able to bind subclasses before their mothers"); } catch (AnnotationException ae) { //success } } public void testConfigurationMethods() throws Exception { AnnotationConfiguration ac = new AnnotationConfiguration(); Properties p = new Properties(); p.put(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect"); p.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDrive"); p.put("hibernate.connection.url", "jdbc:hsqldb:."); p.put("hibernate.connection.username", "sa"); p.put("hibernate.connection.password", ""); p.put("hibernate.show_sql", "true"); ac.setProperties(p); ac.addAnnotatedClass(Plane.class); SessionFactory sf; try { sf = ac.buildSessionFactory(); fail("Driver property overriding should work"); sf.close(); } catch (HibernateException he) { //success } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -