This commit is contained in:
Phillip Webb
2014-05-20 13:13:39 +01:00
parent e40acd81e4
commit 8bcda1bcbe
91 changed files with 477 additions and 438 deletions

View File

@@ -231,7 +231,7 @@ public class BatchAutoConfigurationTests {
public JobRepository getJobRepository() throws Exception {
if (this.jobRepository == null) {
this.factory.afterPropertiesSet();
this.jobRepository = (JobRepository) this.factory.getObject();
this.jobRepository = this.factory.getObject();
}
return this.jobRepository;
}

View File

@@ -16,13 +16,12 @@
package org.springframework.boot.autoconfigure.integration;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.integration.support.channel.HeaderChannelRegistry;
import static org.junit.Assert.assertNotNull;
/**
* @author Artem Bilan
* @since 1.1

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.jdbc;
import org.junit.Test;
@@ -6,7 +22,7 @@ import static org.junit.Assert.assertEquals;
/**
* Tests for {@link DataSourceProperties}.
*
*
* @author Maciej Walkowiak
*/
public class DataSourcePropertiesTests {

View File

@@ -1,54 +0,0 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.jdbc;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* Tests for {@link DriverClassNameProvider}.
*
* @author Maciej Walkowiak
*/
public class DriverClassNameProviderTest {
private DriverClassNameProvider driverClassNameProvider = new DriverClassNameProvider();
@Test
public void testGettingClassNameForKnownDatabase() {
String driverClassName = driverClassNameProvider.getDriverClassName("jdbc:postgresql://hostname/dbname");
assertEquals("org.postgresql.Driver", driverClassName);
}
@Test
public void testReturnsNullForUnknownDatabase() {
String driverClassName = driverClassNameProvider.getDriverClassName("jdbc:unknowndb://hostname/dbname");
assertNull(driverClassName);
}
@Test(expected = IllegalArgumentException.class)
public void testFailureOnNullJdbcUrl() {
driverClassNameProvider.getDriverClassName(null);
}
@Test(expected = IllegalArgumentException.class)
public void testFailureOnMalformedJdbcUrl() {
driverClassNameProvider.getDriverClassName("malformed:url");
}
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.jdbc;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* Tests for {@link DriverClassNameProvider}.
*
* @author Maciej Walkowiak
*/
public class DriverClassNameProviderTests {
private DriverClassNameProvider provider = new DriverClassNameProvider();
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void classNameForKnownDatabase() {
String driverClassName = this.provider
.getDriverClassName("jdbc:postgresql://hostname/dbname");
assertEquals("org.postgresql.Driver", driverClassName);
}
@Test
public void nullForUnknownDatabase() {
String driverClassName = this.provider
.getDriverClassName("jdbc:unknowndb://hostname/dbname");
assertNull(driverClassName);
}
@Test
public void failureOnNullJdbcUrl() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("JdbcUrl must not be null");
this.provider.getDriverClassName(null);
}
@Test
public void failureOnMalformedJdbcUrl() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("JdbcUrl must start with");
this.provider.getDriverClassName("malformed:url");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Tests for {@link EntityManagerFactoryBuilder}.
*
* @author Dave Syer
*/
public class EntityManagerFactoryBuilderTests {

View File

@@ -47,7 +47,7 @@ import static org.junit.Assert.assertThat;
/**
* Tests for {@link VelocityAutoConfiguration}.
*
*
* @author Andy Wilkinson
*/
public class VelocityAutoConfigurationTests {

View File

@@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
/**
* Tests for {@link VelocityTemplateAvailabilityProvider}.
*
*
* @author Andy Wilkinson
*/
public class VelocityTemplateAvailabilityProviderTests {