SPR-7009, SPR-6972: backed out unintentionally committed tests
This commit is contained in:
parent
706a09c49e
commit
c13e5f9f5b
|
|
@ -1,35 +0,0 @@
|
|||
package org.springframework.beans;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
public class Spr6972Tests {
|
||||
@Test
|
||||
public void repro() {
|
||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("Spr6972Tests-context.xml", this.getClass()));
|
||||
TestSpringBean bean = bf.getBean(TestSpringBean.class);
|
||||
assertTrue(bean.bool);
|
||||
assertNotNull(bean.map);
|
||||
}
|
||||
}
|
||||
|
||||
class TestSpringBean {
|
||||
boolean bool;
|
||||
Map<String, String> map;
|
||||
|
||||
public TestSpringBean(boolean bool, Map<String, String> map) {
|
||||
this.bool = bool;
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public TestSpringBean(Map<String, String> map) {
|
||||
this(true, map);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<bean id="testSpringBean" class="org.springframework.beans.TestSpringBean">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry><key><value>entry1</value></key><value>string1</value></entry>
|
||||
<entry><key><value>entry2</value></key><value>string2</value></entry>
|
||||
<entry><key><value>entry3</value></key><value>string3</value></entry>
|
||||
<entry><key><value>entry4</value></key><value>string4</value></entry>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</beans>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:component-scan base-package="org.springframework.transaction.interceptor">
|
||||
<context:include-filter type="regex" expression="org.springframework.transaction.interceptor.TestRepositoryImpl"/>
|
||||
</context:component-scan>
|
||||
|
||||
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
|
||||
|
||||
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
|
||||
<property name="beanNames" value="testRepository" />
|
||||
<property name="interceptorNames" value="transactionInterceptor" />
|
||||
</bean>
|
||||
|
||||
<!-- Further stuff required for setup -->
|
||||
|
||||
<!-- Just register one to have a PersistenceExceptionTranslator -->
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
|
||||
<property name="dataSource">
|
||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:db" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="mappingLocations">
|
||||
<list>
|
||||
</list>
|
||||
</property>
|
||||
<property name="hibernateProperties">
|
||||
<props>
|
||||
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
|
||||
<prop key="hibernate.hbm2ddl.auto">create</prop>
|
||||
<prop key="hibernate.show_sql">false</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="transactionAttributeSource">
|
||||
<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2010 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.transaction.interceptor;
|
||||
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.IllegalTransactionStateException;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* Tests cornering SPR-7009.
|
||||
*
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class TransactionInterceptorDoubleProxyingTests {
|
||||
|
||||
@Autowired
|
||||
TestRepository repository;
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
// method 1 is required, so no problem
|
||||
assertThat(repository.method1(), equalTo("result1"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalTransactionStateException.class)
|
||||
public void test2() {
|
||||
// method 2 is mandatory, so expect exception
|
||||
assertThat(repository.method2(), equalTo("result2"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
interface TestRepository {
|
||||
|
||||
public String method1();
|
||||
|
||||
public String method2();
|
||||
|
||||
}
|
||||
|
||||
@Repository("testRepository")
|
||||
class TestRepositoryImpl implements TestRepository {
|
||||
|
||||
@Transactional
|
||||
public String method1() {
|
||||
return "result1";
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.MANDATORY)
|
||||
public String method2() {
|
||||
return "result2";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue