#54 - Use Stream with try-with-resources.

Tweaked the integration test to use the Stream returned by the repository within a try-with-resources clause so that it gets closed correctly.
This commit is contained in:
Oliver Gierke
2015-03-08 12:54:58 +01:00
parent 966d3c9e44
commit 49df9468b5
2 changed files with 8 additions and 2 deletions

View File

@@ -26,4 +26,4 @@
</dependencies>
</project>
</project>

View File

@@ -15,6 +15,8 @@
*/
package example.springdata.mongodb.people;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
@@ -31,6 +33,7 @@ import example.springdata.mongodb.util.RequiresMongoDB;
* Integration test for {@link PersonRepository}.
*
* @author Thomas Darimont
* @authot Oliver Gierke
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ApplicationConfiguration.class)
@@ -67,6 +70,9 @@ public class PersonRepositoryIntegrationTest {
*/
@Test
public void shouldPerformConversionDuringJava8StreamProcessing() {
repository.findAllByCustomQueryWithStream().forEach(System.out::println);
try (Stream<Person> result = repository.findAllByCustomQueryWithStream()) {
result.forEach(System.out::println);
}
}
}