#106 - Polishing.

Some JavaDoc improvements, copyright headers. Using a logger instead of System.out in the test case now. Removed commented out dependency declaration from JPA pom.xml.
This commit is contained in:
Oliver Gierke
2015-06-18 14:23:18 +02:00
parent fd7d35a826
commit 8ed43d34fc
5 changed files with 13 additions and 20 deletions

View File

@@ -15,4 +15,5 @@
<artifactId>spring-data-jpa-java8</artifactId> <artifactId>spring-data-jpa-java8</artifactId>
<name>Spring Data JPA - Java 8 specific features</name> <name>Spring Data JPA - Java 8 specific features</name>
</project> </project>

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2013-2014 the original author or authors. * Copyright 2013-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -18,6 +18,8 @@ package example.springdata.jpa.java8;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import lombok.extern.slf4j.Slf4j;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -41,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = AuditingConfiguration.class) @SpringApplicationConfiguration(classes = AuditingConfiguration.class)
@Transactional @Transactional
@Slf4j
public class Java8IntegrationTests { public class Java8IntegrationTests {
@Autowired CustomerRepository repository; @Autowired CustomerRepository repository;
@@ -104,10 +107,8 @@ public class Java8IntegrationTests {
} }
/** /**
* Here we demonstrate the usage of CompletableFuture as a result wrapper for asynchronous * Here we demonstrate the usage of {@link CompletableFuture} as a result wrapper for asynchronous repository query
* Repository query methods. * methods. Note, that we need to disable the surrounding transaction to be able to asynchronously read the written
*
* Note that we need to disable the surrounding TX to be able to asynchronously read the wirtten
* data from from another thread within the same test method. * data from from another thread within the same test method.
*/ */
@Test @Test
@@ -118,19 +119,19 @@ public class Java8IntegrationTests {
repository.save(new Customer("Customer2", "Bar")); repository.save(new Customer("Customer2", "Bar"));
CompletableFuture<Void> future = repository.readAllBy().thenAccept(customers -> { CompletableFuture<Void> future = repository.readAllBy().thenAccept(customers -> {
assertThat(customers, hasSize(2)); assertThat(customers, hasSize(2));
customers.forEach(customer -> log.info(customer.toString()));
customers.forEach(System.out::println); log.info("Completed!");
System.out.println("Completed!");
}); });
while (!future.isDone()) { while (!future.isDone()) {
System.out.println("waiting..."); log.info("Waiting for the CompletableFuture to finish...");
TimeUnit.MILLISECONDS.sleep(500); TimeUnit.MILLISECONDS.sleep(500);
} }
future.get(); future.get();
System.out.println("Done");
log.info("Done!");
} }
} }

View File

@@ -1,4 +0,0 @@
#logging.level.org.springframework=INFO
#logging.level.org.springframework.orm=TRACE
#logging.level.org.springframework.transaction=TRACE
#logging.level.org.hsqldb=TRACE

View File

@@ -39,11 +39,6 @@
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
</dependency> </dependency>
<!-- <dependency> -->
<!-- <groupId>com.h2database</groupId> -->
<!-- <artifactId>h2</artifactId> -->
<!-- </dependency> -->
<dependency> <dependency>
<groupId>org.hsqldb</groupId> <groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId> <artifactId>hsqldb</artifactId>