Commit b23f68b0 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '1.5.x'

parents 7e438ca6 81e33dc8
......@@ -16,9 +16,12 @@
package org.springframework.boot.autoconfigure.jdbc;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.test.context.HidePackagesClassLoader;
import static org.assertj.core.api.Assertions.assertThat;
......@@ -31,6 +34,9 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class DataSourcePropertiesTests {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Test
public void determineDriver() {
DataSourceProperties properties = new DataSourceProperties();
......@@ -59,6 +65,17 @@ public class DataSourcePropertiesTests {
.isEqualTo(EmbeddedDatabaseConnection.H2.getUrl());
}
@Test
public void determineUrlWithNoEmbeddedSupport() throws Exception {
DataSourceProperties properties = new DataSourceProperties();
properties.setBeanClassLoader(new HidePackagesClassLoader("org.h2",
"org.apache.derby", "org.hsqldb"));
properties.afterPropertiesSet();
this.thrown.expect(DataSourceProperties.DataSourceBeanCreationException.class);
this.thrown.expectMessage("Cannot determine embedded database url");
properties.determineUrl();
}
@Test
public void determineUrlWithExplicitConfig() throws Exception {
DataSourceProperties properties = new DataSourceProperties();
......
......@@ -106,7 +106,7 @@ public enum EmbeddedDatabaseConnection {
*/
public String getUrl(String databaseName) {
Assert.hasText(databaseName, "DatabaseName must not be null.");
return String.format(this.url, databaseName);
return this.url != null ? String.format(this.url, databaseName) : null;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment