我有一个抽象类的人,并继承了所使用的类。我正在使用json文件进行单元测试,但是当我运行测试时,我在ColumnNameToIndexes缓存映射中得到以下错误org.dbunit.dataset.NoSuchColumnException employ.EMAIL - (非大写输入列:email)。请注意,地图的列名称不区分大小写。我做错了什么?
班级人员
import java.io.Serializable;
import java.lang.Long;
import java.lang.String;
import javax.persistence.*;
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Person implements Serializable {
@Id
@Column(name = "id", unique = true, nullable = false, updatable = false,
length = 11)
private Long id;
@Column(name = "name", nullable = false, updatable = true, length = 50)
private String name;
@Column(name = "email", nullable = false, updatable = true, length = 30)
private String email;
@Column(name = "phone", nullable = false, updatable = true, length = 16)
private String phone;
@Column(name = "password", unique = false, nullable = false, updatable = true, length = 20)
private String password;
private static final long serialVersionUID = 1L;
public Person() {
super();
}
}
受雇班级
import java.io.Serializable;
import javax.persistence.*;
public class Employed extends Person implements Serializable {
private static final long serialVersionUID = 1L;
public Employed() {
super();
}
}
测试
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
import org.jboss.arquillian.transaction.api.annotation.Transactional;
import org.jboss.arquillian.persistence.UsingDataSet;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class EmployedTest {
@PersistenceContext
private EntityManager entityManager;
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(WebArchive.class,
"test.war").addPackage(Employed.class.getPackage())
.addAsResource("persistenceForTest.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Test
@Transactional(value=TransactionMode.ROLLBACK)
@UsingDataSet({"employed.json"})
public void findTest() {
Employed employed = entityManager.find(Employed.class,123456L);
Assert.assertEquals("pete",employed.getName());
}
}
和JSON文件
{
"EMPLOYED":
[
{
"id":123456,
"name":"pete",
"email":"pete@gmail.com",
"phone":"3233934933",
"password":"123456"
}
]
}