diff --git a/pom.xml b/pom.xml
index 280496a7..631d597d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.github.springtestdbunit.parent
spring-test-dbunit-parent
- 1.3.0-SNAPSHOT
+ 1.3.1-SNAPSHOT
pom
Spring Test DBUnit Parent
diff --git a/spring-test-dbunit-sample/pom.xml b/spring-test-dbunit-sample/pom.xml
index 571d3b2d..7cf8d554 100644
--- a/spring-test-dbunit-sample/pom.xml
+++ b/spring-test-dbunit-sample/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.github.springtestdbunit.sample
spring-test-dbunit-sample
- 1.3.0-SNAPSHOT
+ 1.3.1-SNAPSHOT
Spring Test DBUnit Sample
4.2.5.RELEASE
@@ -75,7 +75,7 @@
com.github.springtestdbunit
spring-test-dbunit
- 1.3.0-SNAPSHOT
+ 1.3.1-SNAPSHOT
test
diff --git a/spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitRunner.java b/spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitRunner.java
index 6d7ebed1..a18c1eb1 100644
--- a/spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitRunner.java
+++ b/spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitRunner.java
@@ -17,7 +17,7 @@
package com.github.springtestdbunit;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -280,15 +280,23 @@ private static class Annotations implements Iterable {
private final List allAnnotations;
public Annotations(DbUnitTestContext context, Class extends Annotation> container, Class annotation) {
- this.classAnnotations = getAnnotations(context.getTestClass(), container, annotation);
- this.methodAnnotations = getAnnotations(context.getTestMethod(), container, annotation);
+ this.classAnnotations = getClassAnnotations(context.getTestClass(), container, annotation);
+ this.methodAnnotations = getMethodAnnotations(context.getTestMethod(), container, annotation);
List allAnnotations = new ArrayList(this.classAnnotations.size() + this.methodAnnotations.size());
allAnnotations.addAll(this.classAnnotations);
allAnnotations.addAll(this.methodAnnotations);
this.allAnnotations = Collections.unmodifiableList(allAnnotations);
}
- private List getAnnotations(AnnotatedElement element, Class extends Annotation> container,
+ private List getClassAnnotations(Class> element, Class extends Annotation> container,
+ Class annotation) {
+ List annotations = new ArrayList();
+ addAnnotationToList(annotations, AnnotationUtils.findAnnotation(element, annotation));
+ addRepeatableAnnotationsToList(annotations, AnnotationUtils.findAnnotation(element, container));
+ return Collections.unmodifiableList(annotations);
+ }
+
+ private List getMethodAnnotations(Method element, Class extends Annotation> container,
Class annotation) {
List annotations = new ArrayList();
addAnnotationToList(annotations, AnnotationUtils.findAnnotation(element, annotation));
diff --git a/spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/ChildClassUsingParentClassDatabaseSetupTest.java b/spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/ChildClassUsingParentClassDatabaseSetupTest.java
new file mode 100644
index 00000000..80bd0f6d
--- /dev/null
+++ b/spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/ChildClassUsingParentClassDatabaseSetupTest.java
@@ -0,0 +1,18 @@
+package com.github.springtestdbunit.setup;
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.github.springtestdbunit.entity.EntityAssert;
+
+public class ChildClassUsingParentClassDatabaseSetupTest extends ParentClassContainingDatabaseSetup {
+
+ @Autowired
+ private EntityAssert entityAssert;
+
+ @Test
+ public void test() throws Exception {
+ this.entityAssert.assertValues("fromDbUnit");
+ }
+
+}
diff --git a/spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/ParentClassContainingDatabaseSetup.java b/spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/ParentClassContainingDatabaseSetup.java
new file mode 100644
index 00000000..e99ffdb3
--- /dev/null
+++ b/spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/ParentClassContainingDatabaseSetup.java
@@ -0,0 +1,21 @@
+package com.github.springtestdbunit.setup;
+
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestExecutionListeners;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener;
+import com.github.springtestdbunit.annotation.DatabaseOperation;
+import com.github.springtestdbunit.annotation.DatabaseSetup;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/META-INF/dbunit-context.xml")
+@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
+ TransactionDbUnitTestExecutionListener.class })
+@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml")
+@Transactional
+public abstract class ParentClassContainingDatabaseSetup {
+}