LDAP-321: ContextSourceTransactionManager overrides isExistingTransaction
PreviouslyIllegalStateException: No value for key PoolingContextSource would be thrown. This is now fixed since isExistingTransaction is now provided.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2002-2015 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.ldap.itest.ldap321;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.transaction.TransactionConfiguration;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:ldap321.xml")
|
||||
@TransactionConfiguration(transactionManager = "txManager",defaultRollback = true)
|
||||
@Transactional
|
||||
public class Ldap321Test{
|
||||
@Autowired
|
||||
private RoleRepo roleRepo;
|
||||
|
||||
@Test
|
||||
public void testQueryRoleMap() throws Exception {
|
||||
Map<String,String> roleMap=roleRepo.queryRoleMap();
|
||||
assertNotNull(roleMap);
|
||||
|
||||
for(String roleName:roleMap.keySet()){
|
||||
System.out.println(roleName+":"+ roleMap.get(roleName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2002-2015 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.ldap.itest.ldap321;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class RoleRepo {
|
||||
|
||||
@Transactional
|
||||
public Map<String,String> queryRoleMap() {
|
||||
return new HashMap<String,String>();
|
||||
}
|
||||
|
||||
}
|
||||
26
test/integration-tests/src/test/resources/ldap321.xml
Normal file
26
test/integration-tests/src/test/resources/ldap321.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:ldap="http://www.springframework.org/schema/ldap"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
|
||||
|
||||
<ldap:transaction-manager id="txManager">
|
||||
<ldap:default-renaming-strategy />
|
||||
</ldap:transaction-manager>
|
||||
|
||||
<tx:annotation-driven transaction-manager="txManager"/>
|
||||
<bean class="org.springframework.ldap.itest.ldap321.RoleRepo"/>
|
||||
|
||||
<ldap:context-source password="secret" url="ldap://localhost:9321" username="uid=admin,ou=system" />
|
||||
|
||||
<beans profile="default">
|
||||
<bean id="embeddedLdapServer" class="org.springframework.ldap.test.EmbeddedLdapServerFactoryBean">
|
||||
<property name="partitionName" value="example"/>
|
||||
<property name="partitionSuffix" value="dc=261consulting,dc=com" />
|
||||
<property name="port" value="9321" />
|
||||
</bean>
|
||||
</beans>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user