Remove @ConditionalOnBean(DataSource.class) from JPA config

Stacktrace is then obviously about DataSource, not EntityManager.

Fixes gh-375
This commit is contained in:
Dave Syer
2014-02-20 09:03:35 +00:00
parent 33db285b6c
commit 44b877cd7d
2 changed files with 16 additions and 3 deletions

View File

@@ -23,7 +23,10 @@ import java.util.Map;
import javax.sql.DataSource;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
@@ -60,6 +63,9 @@ import static org.junit.Assert.assertTrue;
*/
public abstract class AbstractJpaAutoConfigurationTests {
@Rule
public ExpectedException expected = ExpectedException.none();
protected AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@After
@@ -69,6 +75,16 @@ public abstract class AbstractJpaAutoConfigurationTests {
protected abstract Class<?> getAutoConfigureClass();
@Test
public void testNoDataSource() throws Exception {
this.context.register(PropertyPlaceholderAutoConfiguration.class,
getAutoConfigureClass());
this.expected.expect(BeanCreationException.class);
this.expected.expectMessage("No qualifying bean");
this.expected.expectMessage("DataSource");
this.context.refresh();
}
@Test
public void testEntityManagerCreated() throws Exception {
setupTestConfiguration();