I am playing with Spring test dbunit library, I have a question about datasets. I have a POJO
representing an entity I want to persist into in-memory database in my tests. This POJO
is not annotated by any JPA annotations like @Entity
, @Table
or @Column
, is it possible to use such class in XML dataset file with @DatabaseSetup
annotation?
Code example: XML dataset file:
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<Person id="1" dateOfBirth="2000-07-25T10:55:58" age="10.5" sex="MALE"/>
</dataset>
and Person POJO class:
public class Person {
private Long id;
private LocalDateTime dateOfBirth;
private BigDecimal age;
private Sex sex;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDateTime getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(LocalDateTime dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public BigDecimal getAge() {
return age;
}
public void setAge(BigDecimal age) {
this.age = age;
}
public Sex getSex() {
return sex;
}
public void setSex(Sex sex) {
this.sex = sex;
}
Right now I am getting following error:
org.dbunit.dataset.NoSuchTableException: Person
I have another POJO class with JPA annotations and it is processed without any errors by @DatabaseSetup
annotation. I am trying to use both POJOs in single test. Are JPA annotations required by Spring test DBUnit library in order to setup my database before tests?