Skip to content

Commit 734a888

Browse files
committed
Added additional assertions regarding the AuditingEntityListener.
1 parent 4e56bd6 commit 734a888

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/AuditableUserSample.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package org.springframework.data.jpa.example.repository;
22

3+
import static org.hamcrest.CoreMatchers.*;
34
import static org.junit.Assert.*;
45

56
import org.junit.Test;
67
import org.junit.runner.RunWith;
78
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
810
import org.springframework.data.jpa.example.auditing.AuditableUser;
911
import org.springframework.data.jpa.example.auditing.AuditorAwareImpl;
1012
import org.springframework.data.repository.CrudRepository;
1113
import org.springframework.test.context.ContextConfiguration;
1214
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
15+
import org.springframework.test.util.ReflectionTestUtils;
1316
import org.springframework.transaction.annotation.Transactional;
1417

1518
/**
@@ -26,9 +29,14 @@ public class AuditableUserSample {
2629
@Autowired
2730
private AuditorAwareImpl auditorAware;
2831

32+
@Autowired
33+
private AuditingEntityListener<?> listener;
34+
2935
@Test
3036
public void testname() throws Exception {
3137

38+
assertThat(ReflectionTestUtils.getField(listener, "handler"), is(notNullValue()));
39+
3240
AuditableUser user = new AuditableUser();
3341
user.setUsername("username");
3442

0 commit comments

Comments
 (0)