inheritancetests.java
来自「一个hibernate的自动测试框架源码」· Java 代码 · 共 51 行
JAVA
51 行
package net.chrisrichardson.ormunit.hibernate.tests;
import java.util.Collections;
import junit.framework.TestCase;
import net.chrisrichardson.ormunit.UnmappedPropertiesException;
import net.chrisrichardson.ormunit.hibernate.AccessStrategy;
import net.chrisrichardson.ormunit.hibernate.MappedClassChecker;
import org.hibernate.cfg.Configuration;
public class InheritanceTests extends TestCase {
public Configuration getConfiguration(String file) {
Configuration configuration = new Configuration();
configuration.addFile("src/test/resources/net/chrisrichardson/ormunit/hibernate/tests/" + file);
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
configuration.buildSessionFactory();
return configuration;
}
public void testJavaInheritanceExcept() {
MappedClassChecker classChecker = new MappedClassChecker(Subclass.class, getConfiguration("inheritanceOutsideOfHibernate.hbm.xml"), AccessStrategy.FIELD);
classChecker.assertAllPropertiesMappedExcept("baz", "bar");
}
public void testAllJavaInheritance() {
MappedClassChecker classChecker = new MappedClassChecker(Subclass.class, getConfiguration("inheritanceOutsideOfHibernate.hbm.xml"), AccessStrategy.FIELD);
try {
classChecker.assertAllPropertiesMapped();
fail();
} catch (UnmappedPropertiesException e) {
}
}
public void testSubclassInheritanceExcept() {
MappedClassChecker classChecker = new MappedClassChecker(Subclass.class, getConfiguration("inheritanceUsingSubclass.hbm.xml"), AccessStrategy.FIELD);
classChecker.assertAllPropertiesMappedExcept(Collections.singleton("bar"));
}
public void testAllSubclassInheritance() {
MappedClassChecker classChecker = new MappedClassChecker(Subclass.class, getConfiguration("inheritanceUsingSubclass.hbm.xml"), AccessStrategy.FIELD);
try {
classChecker.assertAllPropertiesMapped();
fail();
} catch (UnmappedPropertiesException e) {
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?