Merge branch '3.2.x' into master
* 3.2.x: Exclude spring-build-src from maven publish Move spring-build-junit into spring-core Relocate MergePlugin package Develop a gradle plugin to add test dependencies Expose Gradle buildSrc for IDE support Fix [deprecation] compiler warnings Upgrade to xmlunit version 1.3 Improve 'build' folder ignores Fix regression in static setter method support Fix SpEL JavaBean compliance for setters Conflicts: spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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.build.test.hamcrest;
|
||||
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
/**
|
||||
* Additional hamcrest matchers.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class Matchers {
|
||||
|
||||
/**
|
||||
* Create a matcher that wrapps the specified matcher and tests against the
|
||||
* {@link Throwable#getCause() cause} of an exception. If the item tested
|
||||
* is {@code null} not a {@link Throwable} the wrapped matcher will be called
|
||||
* with a {@code null} item.
|
||||
*
|
||||
* <p>Often useful when working with JUnit {@link ExpectedException}
|
||||
* {@link Rule @Rule}s, for example:
|
||||
* <pre>
|
||||
* thrown.expect(DataAccessException.class);
|
||||
* thrown.except(exceptionCause(isA(SQLException.class)));
|
||||
* </pre>
|
||||
*
|
||||
* @param matcher the matcher to wrap (must not be null)
|
||||
* @return a matcher that tests using the exception cause
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Matcher<T> exceptionCause(final Matcher<T> matcher) {
|
||||
return (Matcher<T>) new BaseMatcher<Object>() {
|
||||
@Override
|
||||
public boolean matches(Object item) {
|
||||
Throwable cause = null;
|
||||
if(item != null && item instanceof Throwable) {
|
||||
cause = ((Throwable)item).getCause();
|
||||
}
|
||||
return matcher.matches(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("exception cause ").appendDescriptionOf(matcher);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -16,16 +16,20 @@
|
||||
|
||||
package org.springframework.jdbc.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -34,9 +38,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean;
|
||||
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Juergen Hoeller
|
||||
@@ -123,7 +124,8 @@ public class JdbcNamespaceIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testMultipleDataSourcesHaveDifferentDatabaseNames() throws Exception {
|
||||
DefaultListableBeanFactory factory = new XmlBeanFactory(new ClassPathResource(
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(new ClassPathResource(
|
||||
"org/springframework/jdbc/config/jdbc-config-multiple-datasources.xml"));
|
||||
assertBeanPropertyValueOf("databaseName", "firstDataSource", factory);
|
||||
assertBeanPropertyValueOf("databaseName", "secondDataSource", factory);
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.jdbc.core;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.isA;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -35,7 +34,7 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.build.test.hamcrest.Matchers.exceptionCause;
|
||||
import static org.springframework.tests.Matchers.exceptionCause;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
|
||||
@@ -22,7 +22,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.build.test.hamcrest.Matchers.exceptionCause;
|
||||
import static org.springframework.tests.Matchers.exceptionCause;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
* @author Juergen Hoeller
|
||||
* @author Thomas Risberg
|
||||
*/
|
||||
@Deprecated
|
||||
public class SimpleJdbcTemplateTests {
|
||||
|
||||
private static final String SQL = "sql";
|
||||
|
||||
@@ -36,7 +36,9 @@ import javax.sql.DataSource;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.Customer;
|
||||
import org.springframework.jdbc.datasource.TestDataSourceWrapper;
|
||||
@@ -59,7 +61,8 @@ public class GenericSqlQueryTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.beanFactory = new XmlBeanFactory(
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(
|
||||
new ClassPathResource("org/springframework/jdbc/object/GenericSqlQueryTests-context.xml"));
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
this.connection = mock(Connection.class);
|
||||
|
||||
@@ -31,8 +31,8 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.TestDataSourceWrapper;
|
||||
@@ -46,7 +46,8 @@ public class GenericStoredProcedureTests {
|
||||
|
||||
@Test
|
||||
public void testAddInvoices() throws Exception {
|
||||
BeanFactory bf = new XmlBeanFactory(
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("org/springframework/jdbc/object/GenericStoredProcedureTests-context.xml"));
|
||||
Connection connection = mock(Connection.class);
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
|
||||
Reference in New Issue
Block a user