Remove LDAP + Data Source Transaction Wrappers
Closes gh-1109
This commit is contained in:
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2023 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
|
||||
*
|
||||
* https://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.transaction.compensating.manager.hibernate;
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Hans Westerbeek
|
||||
*/
|
||||
@Transactional
|
||||
public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements OrgPersonDao {
|
||||
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
public void create(OrgPerson person) {
|
||||
DistinguishedName dn = new DistinguishedName();
|
||||
dn.add("ou", person.getCountry());
|
||||
dn.add("ou", person.getCompany());
|
||||
dn.add("cn", person.getFullname());
|
||||
|
||||
DirContextAdapter ctx = new DirContextAdapter();
|
||||
ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
|
||||
ctx.setAttributeValue("cn", person.getFullname());
|
||||
ctx.setAttributeValue("sn", person.getLastname());
|
||||
ctx.setAttributeValue("description", person.getDescription());
|
||||
this.ldapTemplate.bind(dn, ctx, null);
|
||||
this.getHibernateTemplate().saveOrUpdate(person);
|
||||
|
||||
}
|
||||
|
||||
public void createWithException(OrgPerson person) {
|
||||
this.create(person);
|
||||
throw new DummyException("This method failed");
|
||||
|
||||
}
|
||||
|
||||
public void modifyAttributes(String dn, String lastName, String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", lastName);
|
||||
ctx.setAttributeValue("description", description);
|
||||
|
||||
this.ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
|
||||
}
|
||||
|
||||
public void modifyAttributesWithException(String dn, String lastName, String description) {
|
||||
modifyAttributes(dn, lastName, description);
|
||||
throw new DummyException("This method failed.");
|
||||
}
|
||||
|
||||
public void unbind(OrgPerson person) {
|
||||
String dn = prepareDn(person);
|
||||
this.ldapTemplate.unbind(dn);
|
||||
this.getHibernateTemplate().delete(person);
|
||||
|
||||
}
|
||||
|
||||
public void unbindWithException(OrgPerson person) {
|
||||
this.unbind(person);
|
||||
throw new DummyException("This method failed");
|
||||
}
|
||||
|
||||
public void update(OrgPerson person) {
|
||||
String dn = prepareDn(person);
|
||||
DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", person.getLastname());
|
||||
ctx.setAttributeValue("description", person.getDescription());
|
||||
|
||||
this.ldapTemplate.modifyAttributes(ctx);
|
||||
this.getHibernateTemplate().saveOrUpdate(person);
|
||||
|
||||
}
|
||||
|
||||
public void updateWithException(OrgPerson person) {
|
||||
this.update(person);
|
||||
throw new DummyException("This method failed");
|
||||
}
|
||||
|
||||
public void updateAndRename(String dn, String newDn, String updatedDescription) {
|
||||
|
||||
DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("description", updatedDescription);
|
||||
|
||||
this.ldapTemplate.modifyAttributes(ctx);
|
||||
this.ldapTemplate.rename(dn, newDn);
|
||||
|
||||
}
|
||||
|
||||
public void updateAndRenameWithException(String dn, String newDn, String updatedDescription) {
|
||||
this.updateAndRename(dn, newDn, updatedDescription);
|
||||
throw new DummyException("This method failed");
|
||||
}
|
||||
|
||||
public void setLdapTemplate(LdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
private String prepareDn(OrgPerson person) {
|
||||
return "cn=" + person.getFullname() + ",ou=" + person.getCompany() + ",ou=" + person.getCountry();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2016 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
|
||||
*
|
||||
* https://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.manager;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyDao;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for
|
||||
* {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
@ContextConfiguration(locations = { "/conf/ldapAndJdbcTransactionTestContext.xml" })
|
||||
public class ContextSourceAndDataSourceTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
private DummyDao dummyDao;
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Before
|
||||
public void prepareTestedInstance() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
|
||||
this.jdbcTemplate.execute("drop table PERSON if exists");
|
||||
this.jdbcTemplate
|
||||
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
|
||||
this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
|
||||
new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
this.jdbcTemplate.execute("drop table PERSON if exists");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithException() {
|
||||
try {
|
||||
this.dummyDao.createWithException("Sweden", "company1", "some testperson", "testperson",
|
||||
"some description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'", new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() {
|
||||
this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
Object dbResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'",
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(dbResult).isNotNull();
|
||||
|
||||
this.ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
this.dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
this.dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Updated Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
try {
|
||||
this.ldapTemplate.lookup(newDn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(object).isNotNull();
|
||||
this.dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.unbindWithException(dn, "Some Person");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
try {
|
||||
// Verify result - check that the operation was not rolled back
|
||||
this.ldapTemplate.lookup(dn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?", new Object[] { "Some Person" },
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2016 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
|
||||
*
|
||||
* https://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.manager;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.ldap.CommunicationException;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyDao;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for
|
||||
* {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
@ContextConfiguration(locations = { "/conf/missingLdapAndJdbcTransactionTestContext.xml" })
|
||||
public class ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests
|
||||
extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
private DummyDao dummyDao;
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Before
|
||||
public void prepareTestedInstance() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
this.jdbcTemplate.execute("drop table PERSON if exists");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyThatJdbcTransactionIsClosedIfLdapServerUnavailable_ldap179() {
|
||||
try {
|
||||
this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
fail("CannotCreateTransactionException expected");
|
||||
}
|
||||
catch (CannotCreateTransactionException expected) {
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
|
||||
// Make sure there is no transaction synchronization
|
||||
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
|
||||
|
||||
try {
|
||||
this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
fail("CannotCreateTransactionException expected");
|
||||
}
|
||||
catch (CannotCreateTransactionException expected) {
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,359 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2016 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
|
||||
*
|
||||
* https://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.manager;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyDao;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for
|
||||
* {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}
|
||||
* with namespace configuration.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
@ContextConfiguration(locations = { "/conf/ldapAndJdbcTransactionNamespaceTestContext.xml" })
|
||||
public class ContextSourceAndDataSourceTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
private DummyDao dummyDao;
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Before
|
||||
public void prepareTestedInstance() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
|
||||
this.jdbcTemplate.execute("drop table PERSON if exists");
|
||||
this.jdbcTemplate
|
||||
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
|
||||
this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
|
||||
new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
this.jdbcTemplate.execute("drop table PERSON if exists");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithException() {
|
||||
try {
|
||||
this.dummyDao.createWithException("Sweden", "company1", "some testperson", "testperson",
|
||||
"some description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'", new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() {
|
||||
this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
Object dbResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'",
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(dbResult).isNotNull();
|
||||
|
||||
this.ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
this.dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
this.dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Updated Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
try {
|
||||
this.ldapTemplate.lookup(newDn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(object).isNotNull();
|
||||
this.dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.unbindWithException(dn, "Some Person");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
try {
|
||||
// Verify result - check that the operation was not rolled back
|
||||
this.ldapTemplate.lookup(dn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?", new Object[] { "Some Person" },
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,375 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2016 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
|
||||
*
|
||||
* https://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.manager.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao;
|
||||
import org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager;
|
||||
import org.springframework.orm.hibernate5.HibernateTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ContextSourceAndHibernateTransactionManager}.
|
||||
*
|
||||
* @author Hans Westerbeek
|
||||
*/
|
||||
@ContextConfiguration(locations = { "/conf/ldapAndHibernateTransactionTestContext.xml" })
|
||||
public class ContextSourceAndHibernateTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
private OrgPersonDao dummyDao;
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
@Autowired
|
||||
private HibernateTemplate hibernateTemplate;
|
||||
|
||||
@Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@Before
|
||||
public void prepareTest() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
|
||||
OrgPerson person = new OrgPerson();
|
||||
person.setId(1);
|
||||
person.setLastname("Person");
|
||||
person.setFullname("Some Person");
|
||||
person.setDescription("Sweden, Company1, Some Person");
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("Company1");
|
||||
// "Some Person", "Person", "Sweden, Company1, Some Person"
|
||||
// avoid the transaction manager we have configured, do it manually
|
||||
Session session = this.sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
session.saveOrUpdate(person);
|
||||
tx.commit();
|
||||
session.close();
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
// probably the wrong idea, this will use the thing i am trying to
|
||||
// test..
|
||||
|
||||
Session session = this.sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
Query query = session.createQuery("delete from OrgPerson");
|
||||
query.executeUpdate();
|
||||
tx.commit();
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithException() {
|
||||
OrgPerson person = new OrgPerson();
|
||||
|
||||
person.setId(2);
|
||||
person.setDescription("some description");
|
||||
person.setFullname("Some testperson");
|
||||
person.setLastname("testperson");
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("company1");
|
||||
|
||||
try {
|
||||
this.dummyDao.createWithException(person);
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
// Verify that no entry was created in ldap or hibernate db
|
||||
try {
|
||||
this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
List result = this.hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname",
|
||||
"lastname", person.getLastname());
|
||||
assertThat(result.size() == 0).isTrue();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() {
|
||||
OrgPerson person = new OrgPerson();
|
||||
|
||||
person.setId(2);
|
||||
person.setDescription("some description");
|
||||
person.setFullname("Some testperson");
|
||||
person.setLastname("testperson");
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("company1");
|
||||
// dummyDao.create("Sweden", "company1", "some testperson",
|
||||
// "testperson", "some description");
|
||||
|
||||
this.dummyDao.create(person);
|
||||
person = null;
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 2);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(fromDb).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson originalPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
originalPerson.setLastname("fooo");
|
||||
try {
|
||||
this.dummyDao.updateWithException(originalPerson);
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).as("Person").isNotNull();
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson notUpdatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
assertThat(notUpdatedPerson.getLastname()).isEqualTo("Person");
|
||||
assertThat(notUpdatedPerson.getDescription()).isEqualTo("Sweden, Company1, Some Person");
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
// no need to assert if notUpdatedPerson exists
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
|
||||
this.dummyDao.update(person);
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson updatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
assertThat(updatedPerson.getLastname()).isEqualTo("Updated Person");
|
||||
assertThat(updatedPerson.getDescription()).isEqualTo("Updated description");
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
try {
|
||||
this.ldapTemplate.lookup(newDn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.unbindWithException(person);
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = null;
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1); // will
|
||||
// throw
|
||||
// exception
|
||||
// of
|
||||
// person
|
||||
// does
|
||||
// not
|
||||
// exist
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
this.dummyDao.unbind(person);
|
||||
|
||||
try {
|
||||
// Verify result - check that the operation was not rolled back
|
||||
this.ldapTemplate.lookup(dn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 1);
|
||||
assertThat(person).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2016 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
|
||||
*
|
||||
* https://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.manager.hibernate;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.ldap.CommunicationException;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for
|
||||
* {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager}.
|
||||
*
|
||||
* @author Hans Westerbeek
|
||||
*/
|
||||
@ContextConfiguration(locations = { "/conf/missingLdapAndHibernateTransactionTestContext.xml" })
|
||||
public class ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests
|
||||
extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
private OrgPersonDao dummyDao;
|
||||
|
||||
@Before
|
||||
public void prepareTest() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() {
|
||||
OrgPerson person = new OrgPerson();
|
||||
|
||||
person.setId(2);
|
||||
person.setDescription("some description");
|
||||
person.setFullname("Some testperson");
|
||||
person.setLastname("testperson");
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("company1");
|
||||
|
||||
try {
|
||||
this.dummyDao.create(person);
|
||||
}
|
||||
catch (CannotCreateTransactionException expected) {
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
|
||||
// Make sure there is no transaction synchronization
|
||||
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
|
||||
|
||||
try {
|
||||
this.dummyDao.create(person);
|
||||
}
|
||||
catch (CannotCreateTransactionException expected) {
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,376 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2016 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
|
||||
*
|
||||
* https://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.manager.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao;
|
||||
import org.springframework.orm.hibernate5.HibernateTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for
|
||||
* {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager}
|
||||
* with namespace configuration.
|
||||
*
|
||||
* @author Hans Westerbeek
|
||||
*/
|
||||
@ContextConfiguration(locations = { "/conf/ldapAndHibernateTransactionNamespaceTestContext.xml" })
|
||||
public class ContextSourceAndHibernateTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
private OrgPersonDao dummyDao;
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
@Autowired
|
||||
private HibernateTemplate hibernateTemplate;
|
||||
|
||||
@Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@Before
|
||||
public void prepareTest() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
|
||||
OrgPerson person = new OrgPerson();
|
||||
person.setId(1);
|
||||
person.setLastname("Person");
|
||||
person.setFullname("Some Person");
|
||||
person.setDescription("Sweden, Company1, Some Person");
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("Company1");
|
||||
// "Some Person", "Person", "Sweden, Company1, Some Person"
|
||||
// avoid the transaction manager we have configured, do it manually
|
||||
Session session = this.sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
session.saveOrUpdate(person);
|
||||
tx.commit();
|
||||
session.close();
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
// probably the wrong idea, this will use the thing i am trying to
|
||||
// test..
|
||||
|
||||
Session session = this.sessionFactory.openSession();
|
||||
Transaction tx = session.beginTransaction();
|
||||
Query query = session.createQuery("delete from OrgPerson");
|
||||
query.executeUpdate();
|
||||
tx.commit();
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithException() {
|
||||
OrgPerson person = new OrgPerson();
|
||||
|
||||
person.setId(2);
|
||||
person.setDescription("some description");
|
||||
person.setFullname("Some testperson");
|
||||
person.setLastname("testperson");
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("company1");
|
||||
|
||||
try {
|
||||
this.dummyDao.createWithException(person);
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
// Verify that no entry was created in ldap or hibernate db
|
||||
try {
|
||||
this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
List result = this.hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname",
|
||||
"lastname", person.getLastname());
|
||||
assertThat(result.size() == 0).isTrue();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() {
|
||||
OrgPerson person = new OrgPerson();
|
||||
|
||||
person.setId(2);
|
||||
person.setDescription("some description");
|
||||
person.setFullname("Some testperson");
|
||||
person.setLastname("testperson");
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("company1");
|
||||
// dummyDao.create("Sweden", "company1", "some testperson",
|
||||
// "testperson", "some description");
|
||||
|
||||
this.dummyDao.create(person);
|
||||
person = null;
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 2);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(fromDb).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson originalPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
originalPerson.setLastname("fooo");
|
||||
try {
|
||||
this.dummyDao.updateWithException(originalPerson);
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).as("Person").isNotNull();
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson notUpdatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
assertThat(notUpdatedPerson.getLastname()).isEqualTo("Person");
|
||||
assertThat(notUpdatedPerson.getDescription()).isEqualTo("Sweden, Company1, Some Person");
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
// no need to assert if notUpdatedPerson exists
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
|
||||
this.dummyDao.update(person);
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson updatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
assertThat(updatedPerson.getLastname()).isEqualTo("Updated Person");
|
||||
assertThat(updatedPerson.getDescription()).isEqualTo("Updated description");
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
try {
|
||||
this.ldapTemplate.lookup(newDn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
|
||||
try {
|
||||
// Perform test
|
||||
this.dummyDao.unbindWithException(person);
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = null;
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1); // will
|
||||
// throw
|
||||
// exception
|
||||
// of
|
||||
// person
|
||||
// does
|
||||
// not
|
||||
// exist
|
||||
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
|
||||
this.dummyDao.unbind(person);
|
||||
|
||||
try {
|
||||
// Verify result - check that the operation was not rolled back
|
||||
this.ldapTemplate.lookup(dn);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 1);
|
||||
assertThat(person).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
|
||||
"https://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping auto-import="true" default-lazy="false">
|
||||
|
||||
<class name="org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson" table="PERSON">
|
||||
<id name="id" column="id">
|
||||
<generator class="assigned"/>
|
||||
</id>
|
||||
<property name="fullname" column="fullname"/>
|
||||
<property name="lastname" column="lastname"/>
|
||||
<property name="company" column="company"/>
|
||||
<property name="country" column="country"/>
|
||||
<property name="description" column="description"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -1,51 +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:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:ldap="http://www.springframework.org/schema/ldap"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/ldap https://www.springframework.org/schema/ldap/spring-ldap.xsd">
|
||||
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
<import resource="classpath:/conf/commonContextSourceConfig.xml"/>
|
||||
|
||||
<ldap:ldap-template id="ldapTemplate"/>
|
||||
|
||||
<ldap:transaction-manager session-factory-ref="sessionFactory">
|
||||
<ldap:default-renaming-strategy />
|
||||
</ldap:transaction-manager>
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:aname" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="mappingResources">
|
||||
<list>
|
||||
<value>conf/OrgPerson.hbm.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="hibernateProperties">
|
||||
<value>
|
||||
hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
hibernate.hbm2ddl.auto=create
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.ldap.itest.transaction.compensating.manager.hibernate.DummyDaoLdapAndHibernateImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven />
|
||||
</beans>
|
||||
@@ -1,63 +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:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
<import resource="classpath:/conf/commonNoNamespaceContextSourceConfig.xml"/>
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:aname" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactedContextSource"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="transactedContextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="mappingResources">
|
||||
<list>
|
||||
<value>conf/OrgPerson.hbm.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="hibernateProperties">
|
||||
<value>
|
||||
hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
hibernate.hbm2ddl.auto=create
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
<property name="contextSource" ref="transactedContextSource" />
|
||||
<property name="renamingStrategy">
|
||||
<bean class="org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.ldap.itest.transaction.compensating.manager.hibernate.DummyDaoLdapAndHibernateImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven />
|
||||
</beans>
|
||||
@@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2005-2013 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
|
||||
~
|
||||
~ https://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.
|
||||
-->
|
||||
|
||||
<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/beans
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/ldap https://www.springframework.org/schema/ldap/spring-ldap.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
<import resource="classpath:/conf/commonContextSourceConfig.xml"/>
|
||||
|
||||
<ldap:ldap-template id="ldapTemplate"/>
|
||||
|
||||
<ldap:transaction-manager data-source-ref="dataSource">
|
||||
<ldap:default-renaming-strategy />
|
||||
</ldap:transaction-manager>
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:aname" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="jdbcTemplate"
|
||||
class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.ldap.itest.transaction.compensating.manager.LdapAndJdbcDummyDaoImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven />
|
||||
</beans>
|
||||
@@ -1,49 +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:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
<import resource="classpath:/conf/commonNoNamespaceContextSourceConfig.xml"/>
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:aname" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactedContextSource"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="transactedContextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="jdbcTemplate"
|
||||
class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="contextSource" ref="transactedContextSource" />
|
||||
<property name="renamingStrategy">
|
||||
<bean class="org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.ldap.itest.transaction.compensating.manager.LdapAndJdbcDummyDaoImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven />
|
||||
</beans>
|
||||
@@ -1,80 +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
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<!-- This LDAP server shouldn't exist, and that's what we're testing -->
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="url" value="ldap://127.0.0.1:1337" />
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:aname" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactedContextSource"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="transactedContextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="mappingResources">
|
||||
<list>
|
||||
<value>conf/OrgPerson.hbm.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="hibernateProperties">
|
||||
<value>
|
||||
hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
hibernate.hbm2ddl.auto=create
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
<property name="contextSource" ref="transactedContextSource" />
|
||||
<property name="renamingStrategy">
|
||||
<bean class="org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="dummyDaoTarget"
|
||||
class="org.springframework.ldap.itest.transaction.compensating.manager.hibernate.DummyDaoLdapAndHibernateImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager"
|
||||
ref="transactionManager" />
|
||||
<property name="target" ref="dummyDaoTarget" />
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRES_NEW</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -1,66 +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
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<!-- This LDAP server shouldn't exist, and that's what we're testing -->
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="url" value="ldap://127.0.0.1:1337" />
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:aname" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactedContextSource"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="transactedContextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="jdbcTemplate"
|
||||
class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="contextSource" ref="transactedContextSource" />
|
||||
<property name="renamingStrategy">
|
||||
<bean class="org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="dummyDaoTarget"
|
||||
class="org.springframework.ldap.itest.transaction.compensating.manager.LdapAndJdbcDummyDaoImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager"
|
||||
ref="transactionManager" />
|
||||
<property name="target" ref="dummyDaoTarget" />
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRES_NEW</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user