|
1 | 1 | /*
|
2 |
| - * Copyright 2008-2015 the original author or authors. |
| 2 | + * Copyright 2008-2016 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
22 | 22 | import java.util.Arrays;
|
23 | 23 | import java.util.List;
|
24 | 24 |
|
| 25 | +import org.junit.After; |
25 | 26 | import org.junit.Before;
|
26 | 27 | import org.junit.Test;
|
27 | 28 | import org.junit.runner.RunWith;
|
28 | 29 | import org.springframework.beans.factory.annotation.Autowired;
|
| 30 | +import org.springframework.dao.InvalidDataAccessApiUsageException; |
29 | 31 | import org.springframework.data.domain.Page;
|
30 | 32 | import org.springframework.data.domain.PageRequest;
|
31 | 33 | import org.springframework.data.domain.Slice;
|
|
37 | 39 | import org.springframework.data.repository.query.QueryLookupStrategy;
|
38 | 40 | import org.springframework.test.context.ContextConfiguration;
|
39 | 41 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
| 42 | +import org.springframework.transaction.annotation.Propagation; |
40 | 43 | import org.springframework.transaction.annotation.Transactional;
|
41 | 44 |
|
42 | 45 | /**
|
@@ -68,6 +71,13 @@ public void setUp() {
|
68 | 71 | oliver = userRepository. save( new User( "Oliver August", "Matthews", "[email protected]"));
|
69 | 72 | }
|
70 | 73 |
|
| 74 | + @After |
| 75 | + public void clearUp() { |
| 76 | + |
| 77 | + userRepository.deleteAll(); |
| 78 | + roleRepository.deleteAll(); |
| 79 | + } |
| 80 | + |
71 | 81 | /**
|
72 | 82 | * Tests creation of a simple query.
|
73 | 83 | */
|
@@ -234,4 +244,13 @@ public void translatesNotContainsToNotMemberOf() {
|
234 | 244 | public void executesQueryWithProjectionContainingReferenceToPluralAttribute() {
|
235 | 245 | assertThat(userRepository.findRolesAndFirstnameBy(), is(notNullValue()));
|
236 | 246 | }
|
| 247 | + |
| 248 | + /** |
| 249 | + * @see DATAJPA-1023, DATACMNS-959 |
| 250 | + */ |
| 251 | + @Test(expected = InvalidDataAccessApiUsageException.class) |
| 252 | + @Transactional(propagation = Propagation.NOT_SUPPORTED) |
| 253 | + public void rejectsStreamExecutionIfNoSurroundingTransactionActive() { |
| 254 | + userRepository.findAllByCustomQueryAndStream(); |
| 255 | + } |
237 | 256 | }
|
0 commit comments