diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java index f3b35e88fe..a0152ed447 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,33 +30,33 @@ import org.springframework.util.StringValueResolver; * *

The default placeholder syntax follows the Ant / Log4J / JSP EL style: * - *

${...}
+ *
${...}
* * Example XML bean definition: * - *
{@code
- *
- *    
- *    
- *
- *}
+ *
+ * 
+ *   
+ *   
+ * 
+ * 
* * Example properties file: * - *
 driver=com.mysql.jdbc.Driver
+ * 
driver=com.mysql.jdbc.Driver
  * dbname=mysql:mydb
* * Annotated bean definitions may take advantage of property replacement using * the {@link org.springframework.beans.factory.annotation.Value @Value} annotation: * - *
@Value("${person.age}")
+ *
@Value("${person.age}")
* * Implementations check simple property values, lists, maps, props, and bean names * in bean references. Furthermore, placeholder values can also cross-reference * other placeholders, like: * - *
rootPath=myrootdir
- *subPath=${rootPath}/subdir
+ *
rootPath=myrootdir
+ * subPath=${rootPath}/subdir
* * In contrast to {@link PropertyOverrideConfigurer}, subclasses of this type allow * filling in of explicit placeholders in bean definitions. @@ -75,9 +75,9 @@ import org.springframework.util.StringValueResolver; * *

Example XML property with default value: * - *

{@code
- *  
- *}
+ *
+ *   
+ * 
* * @author Chris Beams * @author Juergen Hoeller @@ -107,14 +107,14 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi /** Defaults to {@value #DEFAULT_VALUE_SEPARATOR} */ protected String valueSeparator = DEFAULT_VALUE_SEPARATOR; - protected boolean ignoreUnresolvablePlaceholders = false; - protected String nullValue; - private BeanFactory beanFactory; + protected boolean ignoreUnresolvablePlaceholders = false; private String beanName; + private BeanFactory beanFactory; + /** * Set the prefix that a placeholder string starts with. @@ -143,13 +143,13 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi } /** - * Set a value that should be treated as {@code null} when - * resolved as a placeholder value: e.g. "" (empty String) or "null". + * Set a value that should be treated as {@code null} when resolved + * as a placeholder value: e.g. "" (empty String) or "null". *

Note that this will only apply to full property values, * not to parts of concatenated values. *

By default, no such null value is defined. This means that - * there is no way to express {@code null} as a property - * value unless you explicitly map a corresponding value here. + * there is no way to express {@code null} as a property value + * unless you explicitly map a corresponding value here. */ public void setNullValue(String nullValue) { this.nullValue = nullValue; diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java index c5c9f0978f..44ca01b25e 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import net.sf.ehcache.Status; import org.springframework.cache.Cache; import org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager; -import org.springframework.util.Assert; /** * CacheManager backed by an EhCache {@link net.sf.ehcache.CacheManager}. @@ -81,8 +80,10 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag @Override protected Collection loadCaches() { Status status = getCacheManager().getStatus(); - Assert.isTrue(Status.STATUS_ALIVE.equals(status), - "An 'alive' EhCache CacheManager is required - current cache is " + status.toString()); + if (!Status.STATUS_ALIVE.equals(status)) { + throw new IllegalStateException( + "An 'alive' EhCache CacheManager is required - current cache is " + status.toString()); + } String[] names = getCacheManager().getCacheNames(); Collection caches = new LinkedHashSet(names.length); @@ -94,8 +95,7 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag @Override protected Cache getMissingCache(String name) { - // check the EhCache cache again - // (in case the cache was added at runtime) + // Check the EhCache cache again (in case the cache was added at runtime) Ehcache ehcache = getCacheManager().getEhcache(name); if (ehcache != null) { return new EhCacheCache(ehcache); diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java index 4c3e41722b..e0f7db5f1e 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,12 @@ import org.springframework.cache.transaction.AbstractTransactionSupportingCacheM public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCacheManagerTests { private CacheManager nativeCacheManager; + private EhCacheCacheManager cacheManager; + private EhCacheCacheManager transactionalCacheManager; + @Before public void setup() { nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests") @@ -58,7 +61,8 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache protected EhCacheCacheManager getCacheManager(boolean transactionAware) { if (transactionAware) { return transactionalCacheManager; - } else { + } + else { return cacheManager; } } @@ -77,4 +81,5 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache protected void removeNativeCache(String cacheName) { nativeCacheManager.removeCache(cacheName); } + } diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java index b8f201e104..734622672f 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,9 +33,12 @@ import static org.mockito.BDDMockito.*; public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheManagerTests { private CacheManagerMock cacheManagerMock; + private JCacheCacheManager cacheManager; + private JCacheCacheManager transactionalCacheManager; + @Before public void setupOnce() { cacheManagerMock = new CacheManagerMock(); @@ -55,7 +58,8 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM protected JCacheCacheManager getCacheManager(boolean transactionAware) { if (transactionAware) { return transactionalCacheManager; - } else { + } + else { return cacheManager; } } @@ -75,9 +79,11 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM cacheManagerMock.removeCache(cacheName); } + private static class CacheManagerMock { private final List cacheNames; + private final CacheManager cacheManager; private CacheManagerMock() { @@ -103,4 +109,5 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM given(cacheManager.getCache(name)).willReturn(null); } } + } diff --git a/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java index 3adb8bbea0..a86bd573cd 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,11 +42,10 @@ public abstract class AbstractTransactionSupportingCacheManagerTests cacheMap = new ConcurrentHashMap(16); - private Set cacheNames = new LinkedHashSet(16); + private final Set cacheNames = new LinkedHashSet(16); // Early cache initialization on startup @@ -96,6 +96,16 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing this.cacheNames.add(cache.getName()); } + /** + * Check for a registered cache of the given name. + * In contrast to {@link #getCache(String)}, this method does not trigger + * the lazy creation of missing caches via {@link #getMissingCache(String)}. + * @param name the cache identifier (must not be {@code null}) + * @return the associated Cache instance, or {@code null} if none found + * @since 4.1 + * @see #getCache(String) + * @see #getMissingCache(String) + */ protected final Cache lookupCache(String name) { return this.cacheMap.get(name); } @@ -120,6 +130,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing * @param name the name of the cache to retrieve * @return the missing cache or {@code null} if no such cache exists or could be * created + * @since 4.1 * @see #getCache(String) */ protected Cache getMissingCache(String name) { diff --git a/spring-context/src/main/java/org/springframework/scripting/ScriptEvaluator.java b/spring-context/src/main/java/org/springframework/scripting/ScriptEvaluator.java index eb5e115a22..918877c4e5 100644 --- a/spring-context/src/main/java/org/springframework/scripting/ScriptEvaluator.java +++ b/spring-context/src/main/java/org/springframework/scripting/ScriptEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public interface ScriptEvaluator { * Evaluate the given script with the given arguments. * @param script the ScriptSource for the script to evaluate * @param arguments the key-value pairs to expose to the script, - * typically as script variables. May be {@code null}. + * typically as script variables (may be {@code null} or empty) * @return the return value of the script, if any * @throws ScriptCompilationException if the evaluator failed to read, * compile or evaluate the script diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java index e65642c06d..4d139c46c3 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java @@ -25,15 +25,17 @@ import org.junit.runners.model.Statement; import org.springframework.test.context.TestContextManager; /** - * {@code RunAfterTestClassCallbacks} is a custom JUnit {@link Statement} which allows the - * Spring TestContext Framework to be plugged into the JUnit execution chain by - * calling {@link TestContextManager#afterTestClass() afterTestClass()} on the supplied + * {@code RunAfterTestClassCallbacks} is a custom JUnit {@link Statement} which allows + * the Spring TestContext Framework to be plugged into the JUnit execution chain + * by calling {@link TestContextManager#afterTestClass afterTestClass()} on the supplied * {@link TestContextManager}. * - * @see #evaluate() - * @see RunBeforeTestMethodCallbacks + *

NOTE: This class requires JUnit 4.9 or higher. + * * @author Sam Brannen * @since 3.0 + * @see #evaluate() + * @see RunBeforeTestClassCallbacks */ public class RunAfterTestClassCallbacks extends Statement { @@ -43,8 +45,7 @@ public class RunAfterTestClassCallbacks extends Statement { /** - * Constructs a new {@code RunAfterTestClassCallbacks} statement. - * + * Construct a new {@code RunAfterTestClassCallbacks} statement. * @param next the next {@code Statement} in the execution chain * @param testContextManager the TestContextManager upon which to call * {@code afterTestClass()} @@ -54,12 +55,13 @@ public class RunAfterTestClassCallbacks extends Statement { this.testContextManager = testContextManager; } + /** - * Invokes the next {@link Statement} in the execution chain (typically an instance of + * Evaluate the next {@link Statement} in the execution chain (typically an instance of * {@link org.junit.internal.runners.statements.RunAfters RunAfters}), catching any - * exceptions thrown, and then calls {@link TestContextManager#afterTestClass()}. If - * the call to {@code afterTestClass()} throws an exception, it will also be tracked. - * Multiple exceptions will be combined into a {@link MultipleFailureException}. + * exceptions thrown, and then invoke {@link TestContextManager#afterTestClass()}. + *

If the invocation of {@code afterTestClass()} throws an exception, it will also + * be tracked. Multiple exceptions will be combined into a {@link MultipleFailureException}. */ @Override public void evaluate() throws Throwable { @@ -67,15 +69,15 @@ public class RunAfterTestClassCallbacks extends Statement { try { this.next.evaluate(); } - catch (Throwable e) { - errors.add(e); + catch (Throwable ex) { + errors.add(ex); } try { this.testContextManager.afterTestClass(); } - catch (Exception e) { - errors.add(e); + catch (Throwable ex) { + errors.add(ex); } if (errors.isEmpty()) { diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java index 2c68e7e1c3..1a1aa877d4 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,13 +28,15 @@ import org.springframework.test.context.TestContextManager; /** * {@code RunAfterTestMethodCallbacks} is a custom JUnit {@link Statement} which allows * the Spring TestContext Framework to be plugged into the JUnit execution chain - * by calling {@link TestContextManager#afterTestMethod(Object, Method, Throwable) - * afterTestMethod()} on the supplied {@link TestContextManager}. + * by calling {@link TestContextManager#afterTestMethod afterTestMethod()} on the supplied + * {@link TestContextManager}. + * + *

NOTE: This class requires JUnit 4.9 or higher. * - * @see #evaluate() - * @see RunBeforeTestMethodCallbacks * @author Sam Brannen * @since 3.0 + * @see #evaluate() + * @see RunBeforeTestMethodCallbacks */ public class RunAfterTestMethodCallbacks extends Statement { @@ -48,8 +50,7 @@ public class RunAfterTestMethodCallbacks extends Statement { /** - * Constructs a new {@code RunAfterTestMethodCallbacks} statement. - * + * Construct a new {@code RunAfterTestMethodCallbacks} statement. * @param next the next {@code Statement} in the execution chain * @param testInstance the current test instance (never {@code null}) * @param testMethod the test method which has just been executed on the @@ -59,19 +60,22 @@ public class RunAfterTestMethodCallbacks extends Statement { */ public RunAfterTestMethodCallbacks(Statement next, Object testInstance, Method testMethod, TestContextManager testContextManager) { + this.next = next; this.testInstance = testInstance; this.testMethod = testMethod; this.testContextManager = testContextManager; } + /** - * Invokes the next {@link Statement} in the execution chain (typically an instance of + * Evaluate the next {@link Statement} in the execution chain (typically an instance of * {@link org.junit.internal.runners.statements.RunAfters RunAfters}), catching any - * exceptions thrown, and then calls - * {@link TestContextManager#afterTestMethod(Object, Method, Throwable)} with the - * first caught exception (if any). If the call to {@code afterTestMethod()} throws an - * exception, it will also be tracked. Multiple exceptions will be combined into a + * exceptions thrown, and then invoke + * {@link TestContextManager#afterTestMethod(Object, Method, Throwable)} supplying the + * first caught exception (if any). + *

If the invocation of {@code afterTestMethod()} throws an exception, that + * exception will also be tracked. Multiple exceptions will be combined into a * {@link MultipleFailureException}. */ @Override @@ -81,16 +85,16 @@ public class RunAfterTestMethodCallbacks extends Statement { try { this.next.evaluate(); } - catch (Throwable e) { - testException = e; - errors.add(e); + catch (Throwable ex) { + testException = ex; + errors.add(ex); } try { this.testContextManager.afterTestMethod(this.testInstance, this.testMethod, testException); } - catch (Exception e) { - errors.add(e); + catch (Throwable ex) { + errors.add(ex); } if (errors.isEmpty()) { diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestClassCallbacks.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestClassCallbacks.java index 4592d7e7f7..6d4d716ba2 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestClassCallbacks.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestClassCallbacks.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ import org.springframework.test.context.TestContextManager; * by calling {@link TestContextManager#beforeTestClass() beforeTestClass()} on the * supplied {@link TestContextManager}. * - * @see #evaluate() - * @see RunAfterTestMethodCallbacks * @author Sam Brannen * @since 3.0 + * @see #evaluate() + * @see RunAfterTestMethodCallbacks */ public class RunBeforeTestClassCallbacks extends Statement { @@ -39,8 +39,7 @@ public class RunBeforeTestClassCallbacks extends Statement { /** - * Constructs a new {@code RunBeforeTestClassCallbacks} statement. - * + * Construct a new {@code RunBeforeTestClassCallbacks} statement. * @param next the next {@code Statement} in the execution chain * @param testContextManager the TestContextManager upon which to call * {@code beforeTestClass()} @@ -50,10 +49,11 @@ public class RunBeforeTestClassCallbacks extends Statement { this.testContextManager = testContextManager; } + /** - * Calls {@link TestContextManager#beforeTestClass()} and then invokes the next - * {@link Statement} in the execution chain (typically an instance of - * {@link org.junit.internal.runners.statements.RunBefores RunBefores}). + * Invoke {@link TestContextManager#beforeTestClass()} and then evaluate + * the next {@link Statement} in the execution chain (typically an instance + * of {@link org.junit.internal.runners.statements.RunBefores RunBefores}). */ @Override public void evaluate() throws Throwable { diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestMethodCallbacks.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestMethodCallbacks.java index 051425b75d..dd683bb050 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestMethodCallbacks.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunBeforeTestMethodCallbacks.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,10 +28,10 @@ import org.springframework.test.context.TestContextManager; * by calling {@link TestContextManager#beforeTestMethod(Object, Method) * beforeTestMethod()} on the supplied {@link TestContextManager}. * - * @see #evaluate() - * @see RunAfterTestMethodCallbacks * @author Sam Brannen * @since 3.0 + * @see #evaluate() + * @see RunAfterTestMethodCallbacks */ public class RunBeforeTestMethodCallbacks extends Statement { @@ -45,8 +45,7 @@ public class RunBeforeTestMethodCallbacks extends Statement { /** - * Constructs a new {@code RunBeforeTestMethodCallbacks} statement. - * + * Construct a new {@code RunBeforeTestMethodCallbacks} statement. * @param next the next {@code Statement} in the execution chain * @param testInstance the current test instance (never {@code null}) * @param testMethod the test method which is about to be executed on the @@ -56,15 +55,18 @@ public class RunBeforeTestMethodCallbacks extends Statement { */ public RunBeforeTestMethodCallbacks(Statement next, Object testInstance, Method testMethod, TestContextManager testContextManager) { + this.next = next; this.testInstance = testInstance; this.testMethod = testMethod; this.testContextManager = testContextManager; } + /** - * Calls {@link TestContextManager#beforeTestMethod(Object, Method)} and then invokes - * the next {@link Statement} in the execution chain (typically an instance of + * Invoke {@link TestContextManager#beforeTestMethod(Object, Method)} + * and then evaluate the next {@link Statement} in the execution chain + * (typically an instance of * {@link org.junit.internal.runners.statements.RunBefores RunBefores}). */ @Override diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeout.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeout.java index 75492e62ee..19b6ed4a7c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeout.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,20 @@ import java.util.concurrent.TimeoutException; import org.junit.runners.model.Statement; -import org.springframework.test.annotation.Timed; - /** * {@code SpringFailOnTimeout} is a custom JUnit {@link Statement} which adds - * support for Spring's {@link Timed @Timed} annotation by throwing an exception - * if the next statement in the execution chain takes more than the specified - * number of milliseconds. + * support for Spring's {@link org.springframework.test.annotation.Timed @Timed} + * annotation by throwing an exception if the next statement in the execution + * chain takes more than the specified number of milliseconds. + * + *

In contrast to JUnit's + * {@link org.junit.internal.runners.statements.FailOnTimeout FailOnTimeout}, + * the next {@code statement} will be executed in the same thread as the + * caller and will therefore not be aborted preemptively. * - * @see #evaluate() * @author Sam Brannen * @since 3.0 + * @see #evaluate() */ public class SpringFailOnTimeout extends Statement { @@ -40,24 +43,25 @@ public class SpringFailOnTimeout extends Statement { /** - * Constructs a new {@code SpringFailOnTimeout} statement. - * - * @param next the next {@code Statement} in the execution chain - * @param timeout the configured {@code timeout} for the current test - * @see Timed#millis() + * Construct a new {@code SpringFailOnTimeout} statement for the supplied + * {@code timeout}. + *

If the supplied {@code timeout} is {@code 0}, the execution of the + * {@code next} statement will not be timed. + * @param next the next {@code Statement} in the execution chain; never {@code null} + * @param timeout the configured {@code timeout} for the current test, in milliseconds; + * never negative */ public SpringFailOnTimeout(Statement next, long timeout) { this.next = next; this.timeout = timeout; } + /** - * Invokes the next {@link Statement statement} in the execution chain - * (typically an instance of - * {@link org.junit.internal.runners.statements.InvokeMethod InvokeMethod} - * or {@link org.junit.internal.runners.statements.ExpectException - * ExpectException}) and throws an exception if the next {@code statement} - * takes more than the specified {@code timeout}. + * Evaluate the next {@link Statement statement} in the execution chain + * (typically an instance of {@link SpringRepeat}) and throw a + * {@link TimeoutException} if the next {@code statement} executes longer + * than the specified {@code timeout}. */ @Override public void evaluate() throws Throwable { @@ -68,7 +72,8 @@ public class SpringFailOnTimeout extends Statement { finally { long elapsed = System.currentTimeMillis() - startTime; if (elapsed > this.timeout) { - throw new TimeoutException(String.format("Test took %s ms; limit was %s ms.", elapsed, this.timeout)); + throw new TimeoutException( + String.format("Test took %s ms; limit was %s ms.", elapsed, this.timeout)); } } } diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringRepeat.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringRepeat.java index 78d7a9b7b5..a333e41eb9 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringRepeat.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/SpringRepeat.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,17 +22,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.runners.model.Statement; -import org.springframework.test.annotation.Repeat; -import org.springframework.util.ClassUtils; - /** * {@code SpringRepeat} is a custom JUnit {@link Statement} which adds support - * for Spring's {@link Repeat @Repeat} annotation by repeating the test for - * the specified number of times. + * for Spring's {@link org.springframework.test.annotation.Repeat @Repeat} + * annotation by repeating the test the specified number of times. * - * @see #evaluate() * @author Sam Brannen * @since 3.0 + * @see #evaluate() */ public class SpringRepeat extends Statement { @@ -46,12 +43,11 @@ public class SpringRepeat extends Statement { /** - * Constructs a new {@code SpringRepeat} statement. - * + * Construct a new {@code SpringRepeat} statement for the supplied + * {@code testMethod} and {@code repeat} count. * @param next the next {@code Statement} in the execution chain * @param testMethod the current test method * @param repeat the configured repeat count for the current test method - * @see Repeat#value() */ public SpringRepeat(Statement next, Method testMethod, int repeat) { this.next = next; @@ -59,16 +55,17 @@ public class SpringRepeat extends Statement { this.repeat = Math.max(1, repeat); } + /** - * Invokes the next {@link Statement statement} in the execution chain for - * the specified repeat count. + * Evaluate the next {@link Statement statement} in the execution chain + * repeatedly, using the specified repeat count. */ @Override public void evaluate() throws Throwable { for (int i = 0; i < this.repeat; i++) { if (this.repeat > 1 && logger.isInfoEnabled()) { logger.info(String.format("Repetition %d of test %s#%s()", (i + 1), - ClassUtils.getShortName(this.testMethod.getDeclaringClass()), this.testMethod.getName())); + this.testMethod.getDeclaringClass().getSimpleName(), this.testMethod.getName())); } this.next.evaluate(); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java index 896278983e..04f1bc2f24 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java @@ -129,6 +129,8 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran /** * Same signature as {@link #getTransactionAttribute}, but doesn't cache the result. * {@link #getTransactionAttribute} is effectively a caching decorator for this method. + *

As of 4.1.8, this method can be overridden. + * @since 4.1.8 * @see #getTransactionAttribute */ protected TransactionAttribute computeTransactionAttribute(Method method, Class targetClass) {