Add @Override annotations to test sources
Issue: SPR-10129
This commit is contained in:
@@ -37,6 +37,7 @@ public class NestedTestBean implements INestedTestBean {
|
||||
this.company = (company != null ? company : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@@ -145,6 +146,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
@@ -161,10 +163,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return postProcessed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -180,10 +184,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
@@ -196,14 +202,17 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.jedi = jedi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestBean getSpouse() {
|
||||
return (spouses != null ? spouses[0] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpouse(ITestBean spouse) {
|
||||
this.spouses = new ITestBean[] {spouse};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestBean[] getSpouses() {
|
||||
return spouses;
|
||||
}
|
||||
@@ -230,10 +239,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStringArray() {
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStringArray(String[] stringArray) {
|
||||
this.stringArray = stringArray;
|
||||
}
|
||||
@@ -302,6 +313,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.someProperties = someProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INestedTestBean getDoctor() {
|
||||
return doctor;
|
||||
}
|
||||
@@ -310,6 +322,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.doctor = doctor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INestedTestBean getLawyer() {
|
||||
return lawyer;
|
||||
}
|
||||
@@ -342,6 +355,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.someBoolean = someBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexedTestBean getNestedIndexedBean() {
|
||||
return nestedIndexedBean;
|
||||
}
|
||||
@@ -370,18 +384,21 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
/**
|
||||
* @see org.springframework.beans.ITestBean#exceptional(Throwable)
|
||||
*/
|
||||
@Override
|
||||
public void exceptional(Throwable t) throws Throwable {
|
||||
if (t != null) {
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unreliableFileOperation() throws IOException {
|
||||
throw new IOException();
|
||||
}
|
||||
/**
|
||||
* @see org.springframework.beans.ITestBean#returnsThis()
|
||||
*/
|
||||
@Override
|
||||
public Object returnsThis() {
|
||||
return this;
|
||||
}
|
||||
@@ -389,9 +406,11 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
/**
|
||||
* @see org.springframework.beans.IOther#absquatulate()
|
||||
*/
|
||||
@Override
|
||||
public void absquatulate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int haveBirthday() {
|
||||
return age++;
|
||||
}
|
||||
@@ -421,6 +440,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return this.age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object other) {
|
||||
if (this.name != null && other instanceof TestBean) {
|
||||
return this.name.compareTo(((TestBean) other).getName());
|
||||
|
||||
@@ -44,6 +44,7 @@ public class SimpleMapScope implements Scope, Serializable {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object get(String name, ObjectFactory objectFactory) {
|
||||
synchronized (this.map) {
|
||||
Object scopedObject = this.map.get(name);
|
||||
@@ -55,16 +56,19 @@ public class SimpleMapScope implements Scope, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(String name) {
|
||||
synchronized (this.map) {
|
||||
return this.map.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
this.callbacks.add(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
@@ -76,6 +80,7 @@ public class SimpleMapScope implements Scope, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class ExpectedLookupTemplate extends JndiTemplate {
|
||||
* return the object provided in the constructor. If the name is
|
||||
* unexpected, a respective NamingException gets thrown.
|
||||
*/
|
||||
@Override
|
||||
public Object lookup(String name) throws NamingException {
|
||||
Object object = this.jndiObjects.get(name);
|
||||
if (object == null) {
|
||||
|
||||
@@ -91,6 +91,7 @@ public class SimpleNamingContext implements Context {
|
||||
|
||||
// Actual implementations of Context methods follow
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<NameClassPair> list(String root) throws NamingException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Listing name/class pairs under [" + root + "]");
|
||||
@@ -98,6 +99,7 @@ public class SimpleNamingContext implements Context {
|
||||
return new NameClassPairEnumeration(this, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<Binding> listBindings(String root) throws NamingException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Listing bindings under [" + root + "]");
|
||||
@@ -111,6 +113,7 @@ public class SimpleNamingContext implements Context {
|
||||
* Will be used by any standard InitialContext JNDI lookups.
|
||||
* @throws javax.naming.NameNotFoundException if the object could not be found
|
||||
*/
|
||||
@Override
|
||||
public Object lookup(String lookupName) throws NameNotFoundException {
|
||||
String name = this.root + lookupName;
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -136,6 +139,7 @@ public class SimpleNamingContext implements Context {
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lookupLink(String name) throws NameNotFoundException {
|
||||
return lookup(name);
|
||||
}
|
||||
@@ -147,6 +151,7 @@ public class SimpleNamingContext implements Context {
|
||||
* Use SimpleNamingContextBuilder to set up JNDI bindings then.
|
||||
* @see org.springframework.mock.jndi.SimpleNamingContextBuilder#bind
|
||||
*/
|
||||
@Override
|
||||
public void bind(String name, Object obj) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Static JNDI binding: [" + this.root + name + "] = [" + obj + "]");
|
||||
@@ -154,6 +159,7 @@ public class SimpleNamingContext implements Context {
|
||||
this.boundObjects.put(this.root + name, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbind(String name) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Static JNDI remove: [" + this.root + name + "]");
|
||||
@@ -161,16 +167,19 @@ public class SimpleNamingContext implements Context {
|
||||
this.boundObjects.remove(this.root + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebind(String name, Object obj) {
|
||||
bind(name, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String oldName, String newName) throws NameNotFoundException {
|
||||
Object obj = lookup(oldName);
|
||||
unbind(oldName);
|
||||
bind(newName, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context createSubcontext(String name) {
|
||||
String subcontextName = this.root + name;
|
||||
if (!subcontextName.endsWith("/")) {
|
||||
@@ -181,84 +190,104 @@ public class SimpleNamingContext implements Context {
|
||||
return subcontext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroySubcontext(String name) {
|
||||
unbind(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String composeName(String name, String prefix) {
|
||||
return prefix + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hashtable<String, Object> getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object addToEnvironment(String propName, Object propVal) {
|
||||
return this.environment.put(propName, propVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object removeFromEnvironment(String propName) {
|
||||
return this.environment.remove(propName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
|
||||
// Unsupported methods follow: no support for javax.naming.Name
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lookup(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lookupLink(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(Name name, Object obj) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbind(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebind(Name name, Object obj) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(Name oldName, Name newName) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context createSubcontext(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroySubcontext(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameInNamespace() throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NameParser getNameParser(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NameParser getNameParser(String name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Name composeName(Name name, Name prefix) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
@@ -298,22 +327,27 @@ public class SimpleNamingContext implements Context {
|
||||
|
||||
protected abstract T createObject(String strippedName, Object obj);
|
||||
|
||||
@Override
|
||||
public boolean hasMore() {
|
||||
return this.iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return this.iterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreElements() {
|
||||
return this.iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T nextElement() {
|
||||
return this.iterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
@@ -325,6 +359,7 @@ public class SimpleNamingContext implements Context {
|
||||
super(context, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NameClassPair createObject(String strippedName, Object obj) {
|
||||
return new NameClassPair(strippedName, obj.getClass().getName());
|
||||
}
|
||||
@@ -337,6 +372,7 @@ public class SimpleNamingContext implements Context {
|
||||
super(context, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Binding createObject(String strippedName, Object obj) {
|
||||
return new Binding(strippedName, obj);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder
|
||||
* creating a new SimpleNamingContext instance.
|
||||
* @see SimpleNamingContext
|
||||
*/
|
||||
@Override
|
||||
public InitialContextFactory createInitialContextFactory(Hashtable<?,?> environment) {
|
||||
if (activated == null && environment != null) {
|
||||
Object icf = environment.get(Context.INITIAL_CONTEXT_FACTORY);
|
||||
@@ -225,6 +226,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder
|
||||
|
||||
// Default case...
|
||||
return new InitialContextFactory() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Context getInitialContext(Hashtable<?,?> environment) {
|
||||
return new SimpleNamingContext("", boundObjects, (Hashtable<String, Object>) environment);
|
||||
|
||||
@@ -528,6 +528,7 @@ public class HibernateInterceptorTests extends TestCase {
|
||||
sessionControl.verify();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
assertTrue(TransactionSynchronizationManager.getResourceMap().isEmpty());
|
||||
assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
@@ -542,6 +543,7 @@ public class HibernateInterceptorTests extends TestCase {
|
||||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object proceed() throws Throwable {
|
||||
if (!TransactionSynchronizationManager.hasResource(this.sessionFactory)) {
|
||||
throw new IllegalStateException("Session not bound");
|
||||
@@ -561,10 +563,12 @@ public class HibernateInterceptorTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibleObject getStaticPart() {
|
||||
return null;
|
||||
}
|
||||
@@ -573,6 +577,7 @@ public class HibernateInterceptorTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArguments() {
|
||||
return null;
|
||||
}
|
||||
@@ -584,6 +589,7 @@ public class HibernateInterceptorTests extends TestCase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getThis() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ public class HibernateJtaTransactionTests {
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
assertTrue("JTA synchronizations active",
|
||||
@@ -145,6 +146,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setExposeNativeSession(true);
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -154,6 +156,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht = new HibernateTemplate(sf);
|
||||
List htl = ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
return sess.createQuery("some query string").list();
|
||||
@@ -246,6 +249,7 @@ public class HibernateJtaTransactionTests {
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
assertTrue("JTA synchronizations active",
|
||||
@@ -255,6 +259,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setExposeNativeSession(true);
|
||||
List htl = ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -265,6 +270,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setExposeNativeSession(true);
|
||||
htl = ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -338,6 +344,7 @@ public class HibernateJtaTransactionTests {
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
assertTrue("JTA synchronizations active",
|
||||
@@ -347,6 +354,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setExposeNativeSession(true);
|
||||
List htl = ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -357,6 +365,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setExposeNativeSession(true);
|
||||
htl = ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -442,6 +451,7 @@ public class HibernateJtaTransactionTests {
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
assertTrue("JTA synchronizations active",
|
||||
@@ -449,6 +459,7 @@ public class HibernateJtaTransactionTests {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
List htl = ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return l;
|
||||
}
|
||||
@@ -578,6 +589,7 @@ public class HibernateJtaTransactionTests {
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
assertTrue("JTA synchronizations active",
|
||||
@@ -589,6 +601,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
htl = ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -679,9 +692,11 @@ public class HibernateJtaTransactionTests {
|
||||
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
status.setRollbackOnly();
|
||||
try {
|
||||
@@ -693,6 +708,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.execute(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session",
|
||||
TransactionSynchronizationManager.hasResource(sf));
|
||||
@@ -829,6 +845,7 @@ public class HibernateJtaTransactionTests {
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
org.hibernate.Session outerSession = SessionFactoryUtils.getSession(sf, false);
|
||||
assertSame(session1, outerSession);
|
||||
@@ -837,6 +854,7 @@ public class HibernateJtaTransactionTests {
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
org.hibernate.Session innerSession = SessionFactoryUtils.getSession(sf, false);
|
||||
assertSame(session2, innerSession);
|
||||
@@ -844,6 +862,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session innerSession) {
|
||||
if (rollback) {
|
||||
throw new HibernateException("");
|
||||
@@ -949,6 +968,7 @@ public class HibernateJtaTransactionTests {
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
org.hibernate.Session outerSession = SessionFactoryUtils.getSession(sf, false);
|
||||
assertSame(session1, outerSession);
|
||||
@@ -956,6 +976,7 @@ public class HibernateJtaTransactionTests {
|
||||
assertTrue("Has thread session", holder != null);
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return null;
|
||||
}
|
||||
@@ -1074,6 +1095,7 @@ public class HibernateJtaTransactionTests {
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
org.hibernate.Session outerSession = SessionFactoryUtils.getSession(sf, false);
|
||||
assertSame(session1, outerSession);
|
||||
@@ -1082,6 +1104,7 @@ public class HibernateJtaTransactionTests {
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
org.hibernate.Session innerSession = SessionFactoryUtils.getSession(sf, false);
|
||||
assertSame(session2, innerSession);
|
||||
@@ -1089,6 +1112,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session innerSession) {
|
||||
if (rollback) {
|
||||
throw new HibernateException("");
|
||||
@@ -1172,6 +1196,7 @@ public class HibernateJtaTransactionTests {
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Is not new transaction", !status.isNewTransaction());
|
||||
@@ -1181,6 +1206,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
ht.execute(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return null;
|
||||
}
|
||||
@@ -1239,6 +1265,7 @@ public class HibernateJtaTransactionTests {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
tt.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Is not new transaction", !status.isNewTransaction());
|
||||
@@ -1248,6 +1275,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
ht.execute(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return null;
|
||||
}
|
||||
@@ -1255,11 +1283,13 @@ public class HibernateJtaTransactionTests {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
tt2.execute(new TransactionCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
// assertTrue(TransactionSynchronizationManager.isActualTransactionActive());
|
||||
@@ -1315,6 +1345,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1368,6 +1399,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1424,6 +1456,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1436,6 +1469,7 @@ public class HibernateJtaTransactionTests {
|
||||
assertTrue("JTA synchronization registered", synchronization != null);
|
||||
Thread thread = new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronization.afterCompletion(Status.STATUS_ROLLEDBACK);
|
||||
}
|
||||
@@ -1451,11 +1485,13 @@ public class HibernateJtaTransactionTests {
|
||||
tt.setReadOnly(true);
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1513,6 +1549,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1587,6 +1624,7 @@ public class HibernateJtaTransactionTests {
|
||||
ht.setExposeNativeSession(true);
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session1, sess);
|
||||
@@ -1595,6 +1633,7 @@ public class HibernateJtaTransactionTests {
|
||||
});
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session2, sess);
|
||||
@@ -1662,6 +1701,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1725,6 +1765,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1736,10 +1777,12 @@ public class HibernateJtaTransactionTests {
|
||||
TransactionTemplate tt = new TransactionTemplate(new JtaTransactionManager(ut));
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
for (int i = 2; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1813,6 +1856,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1900,6 +1944,7 @@ public class HibernateJtaTransactionTests {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ht.executeFind(new HibernateCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertEquals(session, sess);
|
||||
@@ -1917,6 +1962,7 @@ public class HibernateJtaTransactionTests {
|
||||
// coordinator.
|
||||
Thread synch = new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronization.beforeCompletion();
|
||||
synchronization.afterCompletion(Status.STATUS_COMMITTED);
|
||||
|
||||
@@ -75,6 +75,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
private MockControl sessionControl;
|
||||
private Session session;
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
sfControl = MockControl.createControl(SessionFactory.class);
|
||||
sf = (SessionFactory) sfControl.getMock();
|
||||
@@ -100,6 +101,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -124,6 +126,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -150,6 +153,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -178,6 +182,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -195,6 +200,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
ht.setAllowCreate(false);
|
||||
try {
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
@@ -217,6 +223,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -244,6 +251,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -275,6 +283,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -310,6 +319,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -407,6 +417,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -448,6 +459,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -479,6 +491,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -523,6 +536,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setCacheQueries(true);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertNotSame(session, sess);
|
||||
assertTrue(Proxy.isProxyClass(sess.getClass()));
|
||||
@@ -584,6 +598,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
ht.setCacheQueries(true);
|
||||
ht.setQueryCacheRegion("myRegion");
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertNotSame(session, sess);
|
||||
assertTrue(Proxy.isProxyClass(sess.getClass()));
|
||||
@@ -634,6 +649,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
ht.setCacheQueries(true);
|
||||
ht.setQueryCacheRegion("myRegion");
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertSame(session, sess);
|
||||
sess.createQuery("some query");
|
||||
@@ -692,6 +708,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
ht.setFetchSize(10);
|
||||
ht.setMaxResults(20);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
sess.createQuery("some query");
|
||||
sess.getNamedQuery("some query name");
|
||||
@@ -2273,6 +2290,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final JDBCConnectionException jcex = new JDBCConnectionException("mymsg", sqlEx);
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw jcex;
|
||||
}
|
||||
@@ -2288,6 +2306,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final SQLGrammarException sgex = new SQLGrammarException("mymsg", sqlEx);
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw sgex;
|
||||
}
|
||||
@@ -2303,6 +2322,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final LockAcquisitionException laex = new LockAcquisitionException("mymsg", sqlEx);
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw laex;
|
||||
}
|
||||
@@ -2318,6 +2338,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final ConstraintViolationException cvex = new ConstraintViolationException("mymsg", sqlEx, "myconstraint");
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw cvex;
|
||||
}
|
||||
@@ -2333,6 +2354,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final DataException dex = new DataException("mymsg", sqlEx);
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw dex;
|
||||
}
|
||||
@@ -2348,6 +2370,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final JDBCException jdex = new JDBCException("mymsg", sqlEx);
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw jdex;
|
||||
}
|
||||
@@ -2363,6 +2386,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final PropertyValueException pvex = new PropertyValueException("mymsg", "myentity", "myproperty");
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw pvex;
|
||||
}
|
||||
@@ -2377,6 +2401,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw new PersistentObjectException("");
|
||||
}
|
||||
@@ -2389,6 +2414,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw new TransientObjectException("");
|
||||
}
|
||||
@@ -2402,6 +2428,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final ObjectDeletedException odex = new ObjectDeletedException("msg", "id", TestBean.class.getName());
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw odex;
|
||||
}
|
||||
@@ -2417,6 +2444,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
qex.setQueryString("query");
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw qex;
|
||||
}
|
||||
@@ -2432,6 +2460,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final UnresolvableObjectException uoex = new UnresolvableObjectException("id", TestBean.class.getName());
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw uoex;
|
||||
}
|
||||
@@ -2448,6 +2477,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final ObjectNotFoundException onfe = new ObjectNotFoundException("id", TestBean.class.getName());
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw onfe;
|
||||
}
|
||||
@@ -2464,6 +2494,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final WrongClassException wcex = new WrongClassException("msg", "id", TestBean.class.getName());
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw wcex;
|
||||
}
|
||||
@@ -2480,6 +2511,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final NonUniqueResultException nuex = new NonUniqueResultException(2);
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw nuex;
|
||||
}
|
||||
@@ -2495,6 +2527,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final StaleObjectStateException sosex = new StaleObjectStateException(TestBean.class.getName(), "id");
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw sosex;
|
||||
}
|
||||
@@ -2511,6 +2544,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final StaleStateException ssex = new StaleStateException("msg");
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw ssex;
|
||||
}
|
||||
@@ -2527,6 +2561,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final HibernateException hex = new HibernateException("msg");
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw hex;
|
||||
}
|
||||
@@ -2545,6 +2580,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
final GenericJDBCException gjex = new GenericJDBCException("mymsg", sqlEx);
|
||||
try {
|
||||
createTemplate().execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
throw gjex;
|
||||
}
|
||||
@@ -2572,6 +2608,7 @@ public class HibernateTemplateTests extends TestCase {
|
||||
return new HibernateTemplate(sf);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
try {
|
||||
sfControl.verify();
|
||||
|
||||
@@ -117,6 +117,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
queryControl.replay();
|
||||
|
||||
LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) throws HibernateException {
|
||||
return sf;
|
||||
}
|
||||
@@ -136,6 +137,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sfProxy));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -196,10 +198,12 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
throw new RuntimeException("application exception");
|
||||
}
|
||||
@@ -258,11 +262,13 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return null;
|
||||
}
|
||||
@@ -339,6 +345,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
queryControl.replay();
|
||||
|
||||
LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) throws HibernateException {
|
||||
return sf;
|
||||
}
|
||||
@@ -359,6 +366,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sfProxy));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -416,6 +424,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
txControl.replay();
|
||||
|
||||
LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) throws HibernateException {
|
||||
return sf;
|
||||
}
|
||||
@@ -429,12 +438,15 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
l.add("test");
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
HibernateTemplate ht = new HibernateTemplate(sfProxy);
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return l;
|
||||
}
|
||||
@@ -486,12 +498,15 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
final TransactionTemplate tt = new TransactionTemplate(tm);
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
throw new RuntimeException("application exception");
|
||||
}
|
||||
@@ -548,11 +563,14 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return l;
|
||||
}
|
||||
@@ -631,16 +649,19 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
final SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
|
||||
assertTrue("Has thread session", holder != null);
|
||||
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
assertTrue(TransactionSynchronizationManager.isActualTransactionActive());
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
assertTrue("Not enclosing session", session != holder.getSession());
|
||||
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
@@ -710,6 +731,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
|
||||
assertTrue("Has thread session", holder != null);
|
||||
@@ -717,6 +739,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue(TransactionSynchronizationManager.isActualTransactionActive());
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_NOT_SUPPORTED);
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
@@ -724,6 +747,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return null;
|
||||
}
|
||||
@@ -770,6 +794,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
sessionControl.replay();
|
||||
|
||||
LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) throws HibernateException {
|
||||
return sf;
|
||||
}
|
||||
@@ -783,6 +808,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sfProxy));
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sfProxy));
|
||||
assertTrue("Is not new transaction", !status.isNewTransaction());
|
||||
@@ -791,6 +817,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
HibernateTemplate ht = new HibernateTemplate(sfProxy);
|
||||
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
return null;
|
||||
}
|
||||
@@ -854,6 +881,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
txControl.replay();
|
||||
|
||||
LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) throws HibernateException {
|
||||
return sf;
|
||||
}
|
||||
@@ -873,12 +901,14 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sfProxy));
|
||||
assertTrue("Is not new transaction", !status.isNewTransaction());
|
||||
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
assertFalse(TransactionSynchronizationManager.isActualTransactionActive());
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
assertSame(session1, session);
|
||||
return null;
|
||||
@@ -886,8 +916,10 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
});
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sfProxy));
|
||||
tt2.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) {
|
||||
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
assertTrue(TransactionSynchronizationManager.isActualTransactionActive());
|
||||
@@ -955,10 +987,12 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -1036,10 +1070,12 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
@@ -1113,6 +1149,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
@@ -1195,10 +1232,12 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
|
||||
return l;
|
||||
}
|
||||
@@ -1279,6 +1318,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1287,6 +1327,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setExposeNativeSession(true);
|
||||
return ht.executeFind(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertEquals(session, sess);
|
||||
return l;
|
||||
@@ -1370,17 +1411,20 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
|
||||
assertEquals(tx1, sessionHolder.getTransaction());
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
status.setRollbackOnly();
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setExposeNativeSession(true);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertEquals(session, sess);
|
||||
return null;
|
||||
@@ -1402,6 +1446,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("Not marked rollback-only", !sessionHolder.isRollbackOnly());
|
||||
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1410,6 +1455,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setExposeNativeSession(true);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertEquals(session, sess);
|
||||
return null;
|
||||
@@ -1485,15 +1531,18 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
status.setRollbackOnly();
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setAllowCreate(false);
|
||||
ht.setExposeNativeSession(true);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertEquals(session, sess);
|
||||
return null;
|
||||
@@ -1512,12 +1561,14 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
|
||||
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
HibernateTemplate ht = new HibernateTemplate(sf);
|
||||
ht.setAllowCreate(false);
|
||||
ht.setExposeNativeSession(true);
|
||||
ht.execute(new HibernateCallback() {
|
||||
@Override
|
||||
public Object doInHibernate(org.hibernate.Session sess) throws HibernateException {
|
||||
assertEquals(session, sess);
|
||||
return null;
|
||||
@@ -1612,6 +1663,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1621,6 +1673,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
}
|
||||
else {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1670,6 +1723,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1713,6 +1767,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
TransactionSynchronizationManager.bindResource(sf, new SessionHolder(session));
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1766,6 +1821,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1809,6 +1865,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
|
||||
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
|
||||
@@ -1824,6 +1881,7 @@ public class HibernateTransactionManagerTests extends TestCase {
|
||||
txControl.verify();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
assertTrue(TransactionSynchronizationManager.getResourceMap().isEmpty());
|
||||
assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
@@ -67,8 +67,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final DriverManagerDataSource ds = new DriverManagerDataSource();
|
||||
final List invocations = new ArrayList();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration addInputStream(InputStream is) {
|
||||
try {
|
||||
is.close();
|
||||
@@ -80,6 +82,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(LocalDataSourceConnectionProvider.class.getName(),
|
||||
config.getProperty(Environment.CONNECTION_PROVIDER));
|
||||
@@ -99,8 +102,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final RegionFactory regionFactory = new NoCachingRegionFactory(null);
|
||||
final List invocations = new ArrayList();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration addInputStream(InputStream is) {
|
||||
try {
|
||||
is.close();
|
||||
@@ -112,6 +117,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(LocalRegionFactoryProxy.class.getName(),
|
||||
config.getProperty(Environment.CACHE_REGION_FACTORY));
|
||||
@@ -131,8 +137,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final CacheProvider cacheProvider = new NoCacheProvider();
|
||||
final List invocations = new ArrayList();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration addInputStream(InputStream is) {
|
||||
try {
|
||||
is.close();
|
||||
@@ -145,6 +153,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(LocalCacheProviderProxy.class.getName(),
|
||||
config.getProperty(Environment.CACHE_PROVIDER));
|
||||
@@ -164,8 +173,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final DriverManagerDataSource ds = new DriverManagerDataSource();
|
||||
final List invocations = new ArrayList();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration addInputStream(InputStream is) {
|
||||
try {
|
||||
is.close();
|
||||
@@ -178,6 +189,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(TransactionAwareDataSourceConnectionProvider.class.getName(),
|
||||
config.getProperty(Environment.CONNECTION_PROVIDER));
|
||||
@@ -200,8 +212,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final TransactionManager tm = (TransactionManager) tmControl.getMock();
|
||||
final List invocations = new ArrayList();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration addInputStream(InputStream is) {
|
||||
try {
|
||||
is.close();
|
||||
@@ -214,6 +228,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(LocalJtaDataSourceConnectionProvider.class.getName(),
|
||||
config.getProperty(Environment.CONNECTION_PROVIDER));
|
||||
@@ -242,8 +257,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final DriverManagerDataSource ds = new DriverManagerDataSource();
|
||||
final Set invocations = new HashSet();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration addJar(File file) {
|
||||
invocations.add("addResource " + file.getPath());
|
||||
return this;
|
||||
@@ -251,6 +268,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(LocalDataSourceConnectionProvider.class.getName(),
|
||||
config.getProperty(Environment.CONNECTION_PROVIDER));
|
||||
@@ -274,8 +292,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final DriverManagerDataSource ds = new DriverManagerDataSource();
|
||||
final Set invocations = new HashSet();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration addInputStream(InputStream is) {
|
||||
try {
|
||||
is.close();
|
||||
@@ -288,6 +308,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(LocalDataSourceConnectionProvider.class.getName(),
|
||||
config.getProperty(Environment.CONNECTION_PROVIDER));
|
||||
@@ -313,6 +334,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
public void testLocalSessionFactoryBeanWithValidProperties() throws Exception {
|
||||
final Set invocations = new HashSet();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
assertEquals(UserSuppliedConnectionProvider.class.getName(),
|
||||
config.getProperty(Environment.CONNECTION_PROVIDER));
|
||||
@@ -362,6 +384,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
factoryControl.setVoidCallable(1);
|
||||
factoryControl.replay();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
return sessionFactory;
|
||||
}
|
||||
@@ -378,8 +401,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
@SuppressWarnings("serial")
|
||||
public void testLocalSessionFactoryBeanWithEntityInterceptor() throws Exception {
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration setInterceptor(Interceptor interceptor) {
|
||||
throw new IllegalArgumentException(interceptor.toString());
|
||||
}
|
||||
@@ -405,8 +430,10 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
@SuppressWarnings("serial")
|
||||
public void testLocalSessionFactoryBeanWithNamingStrategy() throws Exception {
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration setNamingStrategy(NamingStrategy namingStrategy) {
|
||||
throw new IllegalArgumentException(namingStrategy.toString());
|
||||
}
|
||||
@@ -431,18 +458,22 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final Properties registeredClassCache = new Properties();
|
||||
final Properties registeredCollectionCache = new Properties();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public Configuration setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy) {
|
||||
registeredClassCache.setProperty(clazz, concurrencyStrategy);
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Configuration setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy) {
|
||||
registeredCollectionCache.setProperty(collectionRole, concurrencyStrategy);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
return null;
|
||||
}
|
||||
@@ -467,17 +498,21 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
final Properties registeredClassCache = new Properties();
|
||||
final Properties registeredCollectionCache = new Properties();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
// changed from return type 'void' to 'Configuration' in Hibernate 3.6
|
||||
@Override
|
||||
public void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String regionName) {
|
||||
registeredClassCache.setProperty(clazz, concurrencyStrategy + "," + regionName);
|
||||
}
|
||||
@Override
|
||||
public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String regionName) {
|
||||
registeredCollectionCache.setProperty(collectionRole, concurrencyStrategy + "," + regionName);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
return null;
|
||||
}
|
||||
@@ -501,13 +536,16 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
public void testLocalSessionFactoryBeanWithEventListeners() throws Exception {
|
||||
final Map registeredListeners = new HashMap();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public void setListener(String type, Object listener) {
|
||||
registeredListeners.put(type, listener);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
return null;
|
||||
}
|
||||
@@ -526,14 +564,17 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
public void testLocalSessionFactoryBeanWithEventListenerSet() throws Exception {
|
||||
final Map registeredListeners = new HashMap();
|
||||
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
|
||||
@Override
|
||||
protected Configuration newConfiguration() {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public void setListeners(String type, Object[] listeners) {
|
||||
assertTrue(listeners instanceof MergeEventListener[]);
|
||||
registeredListeners.put(type, new HashSet(Arrays.asList(listeners)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
return null;
|
||||
}
|
||||
@@ -594,14 +635,17 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
|
||||
public List registeredFilterDefinitions = new LinkedList();
|
||||
|
||||
@Override
|
||||
protected Configuration newConfiguration() throws HibernateException {
|
||||
return new Configuration() {
|
||||
@Override
|
||||
public void addFilterDefinition(FilterDefinition definition) {
|
||||
registeredFilterDefinitions.add(definition);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
return null;
|
||||
}
|
||||
@@ -612,6 +656,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
|
||||
public Mappings mappings;
|
||||
|
||||
@Override
|
||||
protected SessionFactory newSessionFactory(Configuration config) {
|
||||
this.mappings = config.createMappings();
|
||||
return null;
|
||||
@@ -622,9 +667,11 @@ public class LocalSessionFactoryBeanTests extends TestCase {
|
||||
@SuppressWarnings("serial")
|
||||
public static class DummyMergeEventListener implements MergeEventListener {
|
||||
|
||||
@Override
|
||||
public void onMerge(MergeEvent event) throws HibernateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMerge(MergeEvent event, Map copiedAlready) throws HibernateException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class HibernateDaoSupportTests extends TestCase {
|
||||
sfControl.replay();
|
||||
final List test = new ArrayList();
|
||||
HibernateDaoSupport dao = new HibernateDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
test.add("test");
|
||||
}
|
||||
@@ -53,6 +54,7 @@ public class HibernateDaoSupportTests extends TestCase {
|
||||
HibernateTemplate template = new HibernateTemplate();
|
||||
final List test = new ArrayList();
|
||||
HibernateDaoSupport dao = new HibernateDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
test.add("test");
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ public class LobTypeTests extends TestCase {
|
||||
private MockControl lobCreatorControl = MockControl.createControl(LobCreator.class);
|
||||
private LobCreator lobCreator = (LobCreator) lobCreatorControl.getMock();
|
||||
|
||||
@Override
|
||||
protected void setUp() throws SQLException {
|
||||
lobHandler.getLobCreator();
|
||||
lobHandlerControl.setReturnValue(lobCreator);
|
||||
@@ -613,6 +614,7 @@ public class LobTypeTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
try {
|
||||
rsControl.verify();
|
||||
|
||||
@@ -182,6 +182,7 @@ public class OpenSessionInViewTests {
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "anything";
|
||||
}
|
||||
@@ -422,6 +423,7 @@ public class OpenSessionInViewTests {
|
||||
filter2.init(filterConfig2);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(sf));
|
||||
servletRequest.setAttribute("invoked", Boolean.TRUE);
|
||||
@@ -429,6 +431,7 @@ public class OpenSessionInViewTests {
|
||||
};
|
||||
|
||||
final FilterChain filterChain2 = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
|
||||
throws IOException, ServletException {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(sf2));
|
||||
@@ -480,6 +483,7 @@ public class OpenSessionInViewTests {
|
||||
filter.init(filterConfig);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(sf));
|
||||
count.incrementAndGet();
|
||||
@@ -498,6 +502,7 @@ public class OpenSessionInViewTests {
|
||||
asyncManager.setTaskExecutor(new SyncTaskExecutor());
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "anything";
|
||||
}
|
||||
@@ -568,6 +573,7 @@ public class OpenSessionInViewTests {
|
||||
filter.init(filterConfig);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(sf));
|
||||
servletRequest.setAttribute("invoked", Boolean.TRUE);
|
||||
@@ -639,6 +645,7 @@ public class OpenSessionInViewTests {
|
||||
filter2.init(filterConfig2);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
HibernateTransactionManager tm = new HibernateTransactionManager(sf);
|
||||
TransactionStatus ts = tm.getTransaction(
|
||||
@@ -658,6 +665,7 @@ public class OpenSessionInViewTests {
|
||||
};
|
||||
|
||||
final FilterChain filterChain2 = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
|
||||
throws IOException, ServletException {
|
||||
|
||||
@@ -738,6 +746,7 @@ public class OpenSessionInViewTests {
|
||||
filter2.init(filterConfig2);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
HibernateTransactionManager tm = new HibernateTransactionManager(sf);
|
||||
TransactionStatus ts = tm.getTransaction(
|
||||
@@ -760,6 +769,7 @@ public class OpenSessionInViewTests {
|
||||
};
|
||||
|
||||
FilterChain filterChain2 = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
|
||||
throws IOException, ServletException {
|
||||
filter.doFilter(servletRequest, servletResponse, filterChain);
|
||||
|
||||
@@ -31,9 +31,11 @@ public class ScopedBeanInterceptorTests extends TestCase {
|
||||
final Object realObject = new Object();
|
||||
|
||||
ScopedObject scoped = new ScopedObject() {
|
||||
@Override
|
||||
public Object getTargetObject() {
|
||||
return realObject;
|
||||
}
|
||||
@Override
|
||||
public void removeFromScope() {
|
||||
// do nothing
|
||||
}
|
||||
@@ -53,9 +55,11 @@ public class ScopedBeanInterceptorTests extends TestCase {
|
||||
final Object proxy = proxyFactory.getProxy();
|
||||
|
||||
ScopedObject scoped = new ScopedObject() {
|
||||
@Override
|
||||
public Object getTargetObject() {
|
||||
return proxy;
|
||||
}
|
||||
@Override
|
||||
public void removeFromScope() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class SqlMapClientTests extends TestCase {
|
||||
template.setSqlMapClient(client);
|
||||
template.afterPropertiesSet();
|
||||
Object result = template.execute(new SqlMapClientCallback() {
|
||||
@Override
|
||||
public Object doInSqlMapClient(SqlMapExecutor executor) {
|
||||
assertTrue(executor == session);
|
||||
return "done";
|
||||
@@ -124,6 +125,7 @@ public class SqlMapClientTests extends TestCase {
|
||||
template.setSqlMapClient(client);
|
||||
template.afterPropertiesSet();
|
||||
Object result = template.execute(new SqlMapClientCallback() {
|
||||
@Override
|
||||
public Object doInSqlMapClient(SqlMapExecutor executor) {
|
||||
assertTrue(executor == session);
|
||||
return "done";
|
||||
@@ -420,6 +422,7 @@ public class SqlMapClientTests extends TestCase {
|
||||
public MockControl executorControl = MockControl.createControl(SqlMapExecutor.class);
|
||||
public SqlMapExecutor executor = (SqlMapExecutor) executorControl.getMock();
|
||||
|
||||
@Override
|
||||
public Object execute(SqlMapClientCallback action) throws DataAccessException {
|
||||
try {
|
||||
return action.doInSqlMapClient(executor);
|
||||
@@ -433,6 +436,7 @@ public class SqlMapClientTests extends TestCase {
|
||||
|
||||
private static class TestRowHandler implements RowHandler {
|
||||
|
||||
@Override
|
||||
public void handleRow(Object row) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class LobTypeHandlerTests extends TestCase {
|
||||
private MockControl lobCreatorControl = MockControl.createControl(LobCreator.class);
|
||||
private LobCreator lobCreator = (LobCreator) lobCreatorControl.getMock();
|
||||
|
||||
@Override
|
||||
protected void setUp() throws SQLException {
|
||||
rs.findColumn("column");
|
||||
rsControl.setReturnValue(1);
|
||||
@@ -170,9 +171,11 @@ public class LobTypeHandlerTests extends TestCase {
|
||||
lobHandlerControl.setReturnValue(new ByteArrayInputStream(baos.toByteArray()), 1);
|
||||
lobCreator.setBlobAsBytes(ps, 1, baos.toByteArray());
|
||||
lobCreatorControl.setMatcher(new ArgumentsMatcher() {
|
||||
@Override
|
||||
public boolean matches(Object[] o1, Object[] o2) {
|
||||
return Arrays.equals((byte[]) o1[2], (byte[]) o2[2]);
|
||||
}
|
||||
@Override
|
||||
public String toString(Object[] objects) {
|
||||
return null;
|
||||
}
|
||||
@@ -224,6 +227,7 @@ public class LobTypeHandlerTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
try {
|
||||
rsControl.verify();
|
||||
|
||||
@@ -94,6 +94,7 @@ public class JdoInterceptorTests extends TestCase {
|
||||
this.persistenceManagerFactory = persistenceManagerFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object proceed() throws Throwable {
|
||||
if (!TransactionSynchronizationManager.hasResource(this.persistenceManagerFactory)) {
|
||||
throw new IllegalStateException("PersistenceManager not bound");
|
||||
@@ -101,6 +102,7 @@ public class JdoInterceptorTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArguments() {
|
||||
return null;
|
||||
}
|
||||
@@ -117,10 +119,12 @@ public class JdoInterceptorTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibleObject getStaticPart() {
|
||||
return getMethod();
|
||||
}
|
||||
@@ -136,6 +140,7 @@ public class JdoInterceptorTests extends TestCase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getThis() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
private MockControl pmControl;
|
||||
private PersistenceManager pm;
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
|
||||
pmf = (PersistenceManagerFactory) pmfControl.getMock();
|
||||
@@ -59,6 +60,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
pmfControl.setReturnValue(null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
try {
|
||||
pmfControl.verify();
|
||||
@@ -75,6 +77,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
jt.setAllowCreate(false);
|
||||
try {
|
||||
jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return null;
|
||||
}
|
||||
@@ -96,6 +99,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = (List) jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return l;
|
||||
}
|
||||
@@ -116,6 +120,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = (List) jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return l;
|
||||
}
|
||||
@@ -136,6 +141,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
final List l = new ArrayList();
|
||||
l.add("test");
|
||||
List result = (List) jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return l;
|
||||
}
|
||||
@@ -620,6 +626,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
public void testTemplateExceptions() {
|
||||
try {
|
||||
createTemplate().execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new JDOObjectNotFoundException();
|
||||
}
|
||||
@@ -632,6 +639,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new JDOOptimisticVerificationException();
|
||||
}
|
||||
@@ -644,6 +652,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new JDODataStoreException();
|
||||
}
|
||||
@@ -656,6 +665,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new JDOFatalDataStoreException();
|
||||
}
|
||||
@@ -668,6 +678,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new JDOUserException();
|
||||
}
|
||||
@@ -680,6 +691,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new JDOFatalUserException();
|
||||
}
|
||||
@@ -692,6 +704,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
|
||||
try {
|
||||
createTemplate().execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new JDOException();
|
||||
}
|
||||
@@ -714,6 +727,7 @@ public class JdoTemplateTests extends TestCase {
|
||||
JdoTemplate template = createTemplate();
|
||||
template.setJdoDialect(dialect);
|
||||
template.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
private Transaction tx;
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
|
||||
pmf = (PersistenceManagerFactory) pmfControl.getMock();
|
||||
@@ -78,6 +79,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
pmfControl.setReturnValue(null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
try {
|
||||
pmfControl.verify();
|
||||
@@ -123,6 +125,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
@@ -149,6 +152,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -188,10 +192,12 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new RuntimeException("application exception");
|
||||
}
|
||||
@@ -232,10 +238,12 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new RuntimeException("application exception");
|
||||
}
|
||||
@@ -278,10 +286,12 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return null;
|
||||
@@ -318,6 +328,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
l.add("test");
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.reset();
|
||||
tx.isActive();
|
||||
@@ -329,9 +340,11 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
txControl.replay();
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -365,6 +378,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
final TransactionTemplate tt = new TransactionTemplate(tm);
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.reset();
|
||||
tx.isActive();
|
||||
@@ -376,9 +390,11 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
txControl.replay();
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
throw new RuntimeException("application exception");
|
||||
}
|
||||
@@ -418,6 +434,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.reset();
|
||||
tx.isActive();
|
||||
@@ -433,9 +450,11 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
txControl.replay();
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -478,6 +497,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
l.add("test");
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.verify();
|
||||
txControl.reset();
|
||||
@@ -492,9 +512,11 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
txControl.replay();
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -534,6 +556,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.verify();
|
||||
txControl.reset();
|
||||
@@ -549,15 +572,18 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -604,11 +630,13 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
pm2.flush();
|
||||
@@ -616,6 +644,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
}
|
||||
});
|
||||
Object result = jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
pm2.flush();
|
||||
@@ -667,6 +696,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
utControl.verify();
|
||||
@@ -692,15 +722,18 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -737,11 +770,13 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
assertTrue("Is not new transaction", !status.isNewTransaction());
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return l;
|
||||
}
|
||||
@@ -770,6 +805,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
|
||||
try {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
}
|
||||
});
|
||||
@@ -806,10 +842,12 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return l;
|
||||
}
|
||||
@@ -868,11 +906,13 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
assertTrue("Has thread con", TransactionSynchronizationManager.hasResource(ds));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return l;
|
||||
}
|
||||
@@ -938,11 +978,13 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
assertTrue("Has thread con", TransactionSynchronizationManager.hasResource(ds));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm) {
|
||||
return l;
|
||||
}
|
||||
@@ -1004,6 +1046,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
assertTrue("Hasn't thread con", !TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1011,6 +1054,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
jt.setPersistenceManagerFactory(pmf);
|
||||
jt.setJdoDialect(dialect);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -1104,6 +1148,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
assertTrue("Has thread con", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1113,6 +1158,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
}
|
||||
else {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(pmf));
|
||||
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(ds));
|
||||
@@ -1122,6 +1168,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
}
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
pm2.flush();
|
||||
return l;
|
||||
@@ -1193,6 +1240,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
JdoTemplate jt = new JdoTemplate(pmf);
|
||||
@@ -1201,6 +1249,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
jt.setExposeNativePersistenceManager(true);
|
||||
}
|
||||
return jt.execute(new JdoCallback() {
|
||||
@Override
|
||||
public Object doInJdo(PersistenceManager pm2) {
|
||||
if (exposeNativePm) {
|
||||
assertSame(pm, pm2);
|
||||
@@ -1249,6 +1298,7 @@ public class JdoTransactionManagerTests extends TestCase {
|
||||
assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
|
||||
status.flush();
|
||||
|
||||
@@ -37,6 +37,7 @@ public class LocalPersistenceManagerFactoryTests extends TestCase {
|
||||
MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
|
||||
final PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock();
|
||||
LocalPersistenceManagerFactoryBean pmfb = new LocalPersistenceManagerFactoryBean() {
|
||||
@Override
|
||||
protected PersistenceManagerFactory newPersistenceManagerFactory(Map props) {
|
||||
return pmf;
|
||||
}
|
||||
@@ -73,6 +74,7 @@ public class LocalPersistenceManagerFactoryTests extends TestCase {
|
||||
|
||||
public void testLocalPersistenceManagerFactoryBeanWithInvalidProperty() throws IOException {
|
||||
LocalPersistenceManagerFactoryBean pmfb = new LocalPersistenceManagerFactoryBean() {
|
||||
@Override
|
||||
protected PersistenceManagerFactory newPersistenceManagerFactory(Map props) {
|
||||
throw new IllegalArgumentException((String) props.get("myKey"));
|
||||
}
|
||||
@@ -92,6 +94,7 @@ public class LocalPersistenceManagerFactoryTests extends TestCase {
|
||||
|
||||
public void testLocalPersistenceManagerFactoryBeanWithFile() throws IOException {
|
||||
LocalPersistenceManagerFactoryBean pmfb = new LocalPersistenceManagerFactoryBean() {
|
||||
@Override
|
||||
protected PersistenceManagerFactory newPersistenceManagerFactory(Map props) {
|
||||
throw new IllegalArgumentException((String) props.get("myKey"));
|
||||
}
|
||||
@@ -109,6 +112,7 @@ public class LocalPersistenceManagerFactoryTests extends TestCase {
|
||||
|
||||
public void testLocalPersistenceManagerFactoryBeanWithName() throws IOException {
|
||||
LocalPersistenceManagerFactoryBean pmfb = new LocalPersistenceManagerFactoryBean() {
|
||||
@Override
|
||||
protected PersistenceManagerFactory newPersistenceManagerFactory(String name) {
|
||||
throw new IllegalArgumentException(name);
|
||||
}
|
||||
@@ -126,6 +130,7 @@ public class LocalPersistenceManagerFactoryTests extends TestCase {
|
||||
|
||||
public void testLocalPersistenceManagerFactoryBeanWithNameAndProperties() throws IOException {
|
||||
LocalPersistenceManagerFactoryBean pmfb = new LocalPersistenceManagerFactoryBean() {
|
||||
@Override
|
||||
protected PersistenceManagerFactory newPersistenceManagerFactory(String name) {
|
||||
throw new IllegalArgumentException(name);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class JdoDaoSupportTests extends TestCase {
|
||||
pmfControl.replay();
|
||||
final List test = new ArrayList();
|
||||
JdoDaoSupport dao = new JdoDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
test.add("test");
|
||||
}
|
||||
@@ -56,6 +57,7 @@ public class JdoDaoSupportTests extends TestCase {
|
||||
JdoTemplate template = new JdoTemplate();
|
||||
final List test = new ArrayList();
|
||||
JdoDaoSupport dao = new JdoDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
test.add("test");
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ public class OpenPersistenceManagerInViewTests extends TestCase {
|
||||
filter2.init(filterConfig2);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(pmf));
|
||||
servletRequest.setAttribute("invoked", Boolean.TRUE);
|
||||
@@ -153,6 +154,7 @@ public class OpenPersistenceManagerInViewTests extends TestCase {
|
||||
};
|
||||
|
||||
final FilterChain filterChain2 = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
|
||||
throws IOException, ServletException {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(pmf2));
|
||||
|
||||
@@ -80,10 +80,12 @@ public abstract class AbstractEntityManagerFactoryBeanTests extends TestCase {
|
||||
return emf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistenceUnitInfo getPersistenceUnitInfo() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPersistenceUnitName() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests extends Abstr
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
Provider provider = getProvider();
|
||||
switch (provider) {
|
||||
|
||||
@@ -35,10 +35,12 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
public class DefaultJpaDialectTests extends TestCase {
|
||||
JpaDialect dialect;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
dialect = new DefaultJpaDialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
dialect = null;
|
||||
}
|
||||
|
||||
@@ -242,6 +242,7 @@ public class JpaInterceptorTests extends TestCase {
|
||||
this.entityManagerFactory = entityManagerFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object proceed() throws Throwable {
|
||||
if (!TransactionSynchronizationManager.hasResource(this.entityManagerFactory)) {
|
||||
throw new IllegalStateException("Session not bound");
|
||||
@@ -261,10 +262,12 @@ public class JpaInterceptorTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibleObject getStaticPart() {
|
||||
return null;
|
||||
}
|
||||
@@ -273,6 +276,7 @@ public class JpaInterceptorTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArguments() {
|
||||
return null;
|
||||
}
|
||||
@@ -284,6 +288,7 @@ public class JpaInterceptorTests extends TestCase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getThis() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class JpaTemplateTests extends TestCase {
|
||||
|
||||
private EntityManagerFactory factory;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
template = new JpaTemplate();
|
||||
|
||||
@@ -57,6 +58,7 @@ public class JpaTemplateTests extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
template = null;
|
||||
factoryControl = null;
|
||||
@@ -95,6 +97,7 @@ public class JpaTemplateTests extends TestCase {
|
||||
|
||||
template.execute(new JpaCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) throws PersistenceException {
|
||||
assertSame(em, manager);
|
||||
return null;
|
||||
@@ -104,6 +107,7 @@ public class JpaTemplateTests extends TestCase {
|
||||
template.setExposeNativeEntityManager(false);
|
||||
template.execute(new JpaCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) throws PersistenceException {
|
||||
assertNotSame(em, manager);
|
||||
return null;
|
||||
@@ -128,6 +132,7 @@ public class JpaTemplateTests extends TestCase {
|
||||
try {
|
||||
template.executeFind(new JpaCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) throws PersistenceException {
|
||||
assertSame(em, manager);
|
||||
return new Object();
|
||||
@@ -161,6 +166,7 @@ public class JpaTemplateTests extends TestCase {
|
||||
factoryControl.replay();
|
||||
|
||||
template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) throws PersistenceException {
|
||||
assertSame(em, manager);
|
||||
return null;
|
||||
@@ -183,6 +189,7 @@ public class JpaTemplateTests extends TestCase {
|
||||
try {
|
||||
template.execute(new JpaCallback() {
|
||||
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) throws PersistenceException {
|
||||
assertSame(em, manager);
|
||||
return null;
|
||||
|
||||
@@ -60,6 +60,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
private TransactionTemplate tt;
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
factoryControl = MockControl.createControl(EntityManagerFactory.class);
|
||||
factory = (EntityManagerFactory) factoryControl.getMock();
|
||||
@@ -80,6 +81,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
manager.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
assertTrue(TransactionSynchronizationManager.getResourceMap().isEmpty());
|
||||
assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
@@ -106,9 +108,11 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return l;
|
||||
@@ -146,9 +150,11 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return l;
|
||||
@@ -188,9 +194,11 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
throw new RuntimeException("some exception");
|
||||
}
|
||||
@@ -229,9 +237,11 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
throw new RuntimeException("some exception");
|
||||
}
|
||||
@@ -269,10 +279,12 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
|
||||
Object res = template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return l;
|
||||
@@ -307,6 +319,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.reset();
|
||||
txControl.expectAndReturn(tx.getRollbackOnly(), false);
|
||||
@@ -316,9 +329,11 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return l;
|
||||
@@ -351,6 +366,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.reset();
|
||||
txControl.expectAndReturn(tx.isActive(), true, 2);
|
||||
@@ -360,8 +376,10 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
throw new RuntimeException("exception");
|
||||
}
|
||||
@@ -400,6 +418,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.reset();
|
||||
txControl.expectAndReturn(tx.isActive(), true);
|
||||
@@ -412,9 +431,11 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
|
||||
template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em2) {
|
||||
em2.flush();
|
||||
return l;
|
||||
@@ -462,6 +483,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.verify();
|
||||
txControl.reset();
|
||||
@@ -476,8 +498,10 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em2) {
|
||||
em2.flush();
|
||||
return l;
|
||||
@@ -517,6 +541,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
txControl.verify();
|
||||
txControl.reset();
|
||||
@@ -531,6 +556,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
JpaTemplate template2 = new JpaTemplate(factory);
|
||||
template2.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) throws PersistenceException {
|
||||
return null;
|
||||
}
|
||||
@@ -538,8 +564,10 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
return tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em2) {
|
||||
em2.flush();
|
||||
return l;
|
||||
@@ -582,13 +610,16 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertFalse(TransactionSynchronizationManager.hasResource(factory));
|
||||
TransactionTemplate tt2 = new TransactionTemplate(transactionManager);
|
||||
tt2.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
return tt2.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em2) {
|
||||
em2.flush();
|
||||
return l;
|
||||
@@ -630,9 +661,11 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
JpaTemplate template2 = new JpaTemplate(factory);
|
||||
template2.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) throws PersistenceException {
|
||||
return null;
|
||||
}
|
||||
@@ -642,8 +675,10 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
TransactionTemplate tt2 = new TransactionTemplate(transactionManager);
|
||||
tt2.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
return tt2.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em2) {
|
||||
em2.flush();
|
||||
return l;
|
||||
@@ -694,18 +729,23 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em2) {
|
||||
em2.flush();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
@Override
|
||||
public void afterCompletion(int status) {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em2) {
|
||||
em2.flush();
|
||||
return null;
|
||||
@@ -750,11 +790,13 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(!TransactionSynchronizationManager.hasResource(factory));
|
||||
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
assertTrue(!status.isNewTransaction());
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return l;
|
||||
@@ -790,11 +832,13 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(!TransactionSynchronizationManager.hasResource(factory));
|
||||
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
assertTrue(!status.isNewTransaction());
|
||||
template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return null;
|
||||
@@ -836,10 +880,12 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
return l;
|
||||
}
|
||||
@@ -881,10 +927,12 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
return null;
|
||||
}
|
||||
@@ -929,11 +977,13 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
assertTrue(!status.isNewTransaction());
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return l;
|
||||
@@ -976,11 +1026,13 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
assertTrue(!status.isNewTransaction());
|
||||
template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return null;
|
||||
@@ -1026,10 +1078,12 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
Object result = tt.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
return template.execute(new JpaCallback() {
|
||||
@Override
|
||||
public Object doInJpa(EntityManager em) {
|
||||
em.flush();
|
||||
return l;
|
||||
@@ -1063,6 +1117,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
|
||||
try {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
}
|
||||
});
|
||||
@@ -1092,6 +1147,7 @@ public class JpaTransactionManagerTests extends TestCase {
|
||||
assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
|
||||
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
status.flush();
|
||||
|
||||
@@ -366,12 +366,14 @@ public class LocalContainerEntityManagerFactoryBeanTests extends AbstractEntityM
|
||||
|
||||
private static class DummyContainerPersistenceProvider implements PersistenceProvider {
|
||||
|
||||
@Override
|
||||
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo pui, Map map) {
|
||||
actualPui = pui;
|
||||
actualProps = map;
|
||||
return mockEmf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityManagerFactory createEntityManagerFactory(String emfName, Map properties) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -380,23 +382,29 @@ public class LocalContainerEntityManagerFactoryBeanTests extends AbstractEntityM
|
||||
|
||||
private static class NoOpEntityTransaction implements EntityTransaction {
|
||||
|
||||
@Override
|
||||
public void begin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRollbackOnly() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRollbackOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,12 @@ public class LocalEntityManagerFactoryBeanTests extends AbstractEntityManagerFac
|
||||
|
||||
protected static class DummyPersistenceProvider implements PersistenceProvider {
|
||||
|
||||
@Override
|
||||
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo pui, Map map) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityManagerFactory createEntityManagerFactory(String emfName, Map properties) {
|
||||
actualName = emfName;
|
||||
actualProps = properties;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.orm.jpa.EntityManagerFactoryInfo;
|
||||
*/
|
||||
public class EclipseLinkEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return ECLIPSELINK_CONFIG_LOCATIONS;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class HibernateEntityManagerFactoryIntegrationTests extends
|
||||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return HIBERNATE_CONFIG_LOCATIONS;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class HibernateMultiEntityManagerFactoryIntegrationTests extends
|
||||
this.entityManagerFactory2 = entityManagerFactory2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {
|
||||
"/org/springframework/orm/jpa/hibernate/hibernate-manager-multi.xml",
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
*/
|
||||
public class OpenJpaEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return OPENJPA_CONFIG_LOCATIONS;
|
||||
}
|
||||
@@ -62,6 +63,7 @@ public class OpenJpaEntityManagerFactoryIntegrationTests extends AbstractContain
|
||||
TransactionTemplate tt = new TransactionTemplate(transactionManager);
|
||||
tt.setPropagationBehavior(TransactionTemplate.PROPAGATION_NESTED);
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
Person tony = new Person();
|
||||
tony.setFirstName("Tony");
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.Ignore;
|
||||
@Ignore("this test causes gradle to hang")
|
||||
public class OpenJpaEntityManagerFactoryWithAspectJWeavingIntegrationTests extends OpenJpaEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {
|
||||
"/org/springframework/orm/jpa/openjpa/openjpa-manager-aspectj-weaving.xml",
|
||||
|
||||
@@ -38,6 +38,7 @@ public class JpaDaoSupportTests extends TestCase {
|
||||
mockControl.replay();
|
||||
final List test = new ArrayList();
|
||||
JpaDaoSupport dao = new JpaDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
test.add("test");
|
||||
}
|
||||
@@ -56,6 +57,7 @@ public class JpaDaoSupportTests extends TestCase {
|
||||
mockControl.replay();
|
||||
final List test = new ArrayList();
|
||||
JpaDaoSupport dao = new JpaDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
test.add("test");
|
||||
}
|
||||
@@ -73,6 +75,7 @@ public class JpaDaoSupportTests extends TestCase {
|
||||
JpaTemplate template = new JpaTemplate();
|
||||
final List test = new ArrayList();
|
||||
JpaDaoSupport dao = new JpaDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
test.add("test");
|
||||
}
|
||||
|
||||
@@ -163,6 +163,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
asyncManager.setTaskExecutor(new SyncTaskExecutor());
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "anything";
|
||||
}
|
||||
@@ -257,6 +258,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
filter2.init(filterConfig2);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
servletRequest.setAttribute("invoked", Boolean.TRUE);
|
||||
@@ -264,6 +266,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
};
|
||||
|
||||
final FilterChain filterChain2 = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
|
||||
throws IOException, ServletException {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory2));
|
||||
@@ -323,6 +326,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory));
|
||||
servletRequest.setAttribute("invoked", Boolean.TRUE);
|
||||
@@ -333,6 +337,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
final AtomicInteger count2 = new AtomicInteger(0);
|
||||
|
||||
final FilterChain filterChain2 = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
|
||||
throws IOException, ServletException {
|
||||
assertTrue(TransactionSynchronizationManager.hasResource(factory2));
|
||||
@@ -355,6 +360,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
asyncManager.setTaskExecutor(new SyncTaskExecutor());
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "anything";
|
||||
}
|
||||
|
||||
@@ -734,14 +734,17 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Override
|
||||
public Object getObject() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getObjectType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
@@ -785,6 +788,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
|
||||
@SuppressWarnings("serial")
|
||||
public static class SpecificPublicPersistenceContextSetter extends DefaultPublicPersistenceContextSetter {
|
||||
|
||||
@Override
|
||||
@PersistenceContext(unitName="unit2", type = PersistenceContextType.EXTENDED)
|
||||
public void setEntityManager(EntityManager em) {
|
||||
super.setEntityManager(em);
|
||||
@@ -880,6 +884,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
|
||||
|
||||
public static boolean closed;
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if ("isOpen".equals(method.getName())) {
|
||||
return true;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.orm.jpa.EntityManagerFactoryInfo;
|
||||
*/
|
||||
public class TopLinkEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return TOPLINK_CONFIG_LOCATIONS;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class TopLinkMultiEntityManagerFactoryIntegrationTests extends
|
||||
this.entityManagerFactory2 = entityManagerFactory2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] {
|
||||
"/org/springframework/orm/jpa/toplink/toplink-manager-multi.xml",
|
||||
|
||||
@@ -172,6 +172,7 @@ public abstract class AbstractDependencyInjectionSpringContextTests extends Abst
|
||||
* message will be written to the log.
|
||||
* @see #injectDependencies()
|
||||
*/
|
||||
@Override
|
||||
protected void prepareTestInstance() throws Exception {
|
||||
if (getApplicationContext() == null) {
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
|
||||
@@ -95,6 +95,7 @@ public abstract class AbstractSingleSpringContextTests extends AbstractSpringCon
|
||||
* This implementation is final. Override {@code onSetUp} for custom behavior.
|
||||
* @see #onSetUp()
|
||||
*/
|
||||
@Override
|
||||
protected final void setUp() throws Exception {
|
||||
// lazy load, in case getApplicationContext() has not yet been called.
|
||||
if (this.applicationContext == null) {
|
||||
@@ -136,6 +137,7 @@ public abstract class AbstractSingleSpringContextTests extends AbstractSpringCon
|
||||
* custom behavior.
|
||||
* @see #onTearDown()
|
||||
*/
|
||||
@Override
|
||||
protected final void tearDown() throws Exception {
|
||||
onTearDown();
|
||||
}
|
||||
@@ -168,6 +170,7 @@ public abstract class AbstractSingleSpringContextTests extends AbstractSpringCon
|
||||
* {@code contextKey()} returns.
|
||||
* @see #getConfigLocations()
|
||||
*/
|
||||
@Override
|
||||
protected ConfigurableApplicationContext loadContext(Object key) throws Exception {
|
||||
return loadContextLocations((String[]) key);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public abstract class AbstractTransactionalDataSourceSpringContextTests
|
||||
* cleared, as a defensive measure against accidental <i>permanent</i> wiping of a database.
|
||||
* @see org.springframework.test.AbstractTransactionalSpringContextTests#setComplete()
|
||||
*/
|
||||
@Override
|
||||
protected final void setComplete() {
|
||||
if (this.zappedTables) {
|
||||
throw new IllegalStateException("Cannot set complete after deleting tables");
|
||||
|
||||
@@ -187,6 +187,7 @@ public abstract class AbstractTransactionalSpringContextTests extends AbstractDe
|
||||
* @throws Exception simply let any exception propagate
|
||||
* @see #onTearDown()
|
||||
*/
|
||||
@Override
|
||||
protected void onSetUp() throws Exception {
|
||||
this.complete = !this.isRollback();
|
||||
|
||||
@@ -250,6 +251,7 @@ public abstract class AbstractTransactionalSpringContextTests extends AbstractDe
|
||||
* @throws Exception simply let any exception propagate
|
||||
* @see #onSetUp()
|
||||
*/
|
||||
@Override
|
||||
protected void onTearDown() throws Exception {
|
||||
// Call onTearDownInTransaction and end transaction if the transaction
|
||||
// is still active.
|
||||
|
||||
@@ -66,6 +66,7 @@ public abstract class ConditionalTestCase extends TestCase {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runBare() throws Throwable {
|
||||
// getName will return the name of the method being run
|
||||
if (isDisabledInThisEnvironment(getName())) {
|
||||
|
||||
@@ -173,6 +173,7 @@ public abstract class AbstractAnnotationAwareTransactionalTests extends
|
||||
|
||||
// Let JUnit handle execution. We're just changing the state of the test class first.
|
||||
runTestTimed(new TestExecutionCallback() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
try {
|
||||
AbstractAnnotationAwareTransactionalTests.super.runBare();
|
||||
|
||||
@@ -50,6 +50,7 @@ public class SystemProfileValueSource implements ProfileValueSource {
|
||||
* system properties.
|
||||
* @see System#getProperty(String)
|
||||
*/
|
||||
@Override
|
||||
public String get(String key) {
|
||||
Assert.hasText(key, "'key' must not be empty");
|
||||
return System.getProperty(key);
|
||||
|
||||
@@ -331,6 +331,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
this.ltw = ltw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof LocalContainerEntityManagerFactoryBean) {
|
||||
((LocalContainerEntityManagerFactoryBean) bean).setLoadTimeWeaver(this.ltw);
|
||||
@@ -352,6 +353,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
this.shadowingClassLoader = shadowingClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTransformer(ClassFileTransformer transformer) {
|
||||
try {
|
||||
Method addClassFileTransformer =
|
||||
@@ -364,10 +366,12 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getInstrumentableClassLoader() {
|
||||
return this.shadowingClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getThrowawayClassLoader() {
|
||||
// Be sure to copy the same resource overrides and same class file transformers:
|
||||
// We want the throwaway class loader to behave like the instrumentable class loader.
|
||||
|
||||
@@ -28,10 +28,12 @@ public class MockJtaTransaction implements javax.transaction.Transaction {
|
||||
|
||||
private Synchronization synchronization;
|
||||
|
||||
@Override
|
||||
public int getStatus() {
|
||||
return Status.STATUS_ACTIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSynchronization(Synchronization synchronization) {
|
||||
this.synchronization = synchronization;
|
||||
}
|
||||
@@ -40,20 +42,25 @@ public class MockJtaTransaction implements javax.transaction.Transaction {
|
||||
return synchronization;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enlistResource(XAResource xaResource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delistResource(XAResource xaResource, int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRollbackOnly() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user