Polishing

(cherry picked from commit cc93c2a)
This commit is contained in:
Juergen Hoeller
2016-07-26 00:03:21 +02:00
parent dadd2c3709
commit 29e8ba3efc
2 changed files with 17 additions and 49 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.junit.AssumptionViolatedException;
import org.springframework.util.ClassUtils;
@@ -33,38 +32,8 @@ import static org.junit.Assume.*;
* conditions hold {@code true}. If the assumption fails, it means the test should be
* skipped.
*
* <p>For example, if a set of tests require at least JDK 1.7 it can use
* {@code Assume#atLeast(JavaVersion.JAVA_17)} as shown below:
*
* <pre class="code">
* public void MyTests {
*
* &#064;BeforeClass
* public static void assumptions() {
* Assume.atLeast(JavaVersion.JAVA_17);
* }
*
* // ... all the test methods that require at least JDK 1.7
* }
* </pre>
*
* If only a single test requires at least JDK 1.7 it can use the
* {@code Assume#atLeast(JavaVersion.JAVA_17)} as shown below:
*
* <pre class="code">
* public void MyTests {
*
* &#064;Test
* public void requiresJdk17 {
* Assume.atLeast(JavaVersion.JAVA_17);
* // ... perform the actual test
* }
* }
* </pre>
*
* In addition to assumptions based on the JDK version, tests can be categorized into
* {@link TestGroup}s. Active groups are enabled using the 'testGroups' system property,
* usually activated from the gradle command line:
* Tests can be categorized into {@link TestGroup}s. Active groups are enabled using
* the 'testGroups' system property, usually activated from the gradle command line:
* <pre>
* gradle test -PtestGroups="performance"
* </pre>
@@ -76,7 +45,6 @@ import static org.junit.Assume.*;
* @author Phillip Webb
* @author Sam Brannen
* @since 3.2
* @see #atLeast(JavaVersion)
* @see #group(TestGroup)
* @see #group(TestGroup, Executable)
*/
@@ -92,8 +60,8 @@ public abstract class Assume {
*/
public static void atLeast(JavaVersion version) {
if (!JavaVersion.runningVersion().isAtLeast(version)) {
throw new AssumptionViolatedException("Requires JDK " + version + " but running "
+ JavaVersion.runningVersion());
throw new AssumptionViolatedException("Requires JDK " + version + " but running " +
JavaVersion.runningVersion());
}
}
@@ -104,8 +72,7 @@ public abstract class Assume {
*/
public static void group(TestGroup group) {
if (!GROUPS.contains(group)) {
throw new AssumptionViolatedException("Requires unspecified group " + group
+ " from " + GROUPS);
throw new AssumptionViolatedException("Requires unspecified group " + group + " from " + GROUPS);
}
}
@@ -154,11 +121,12 @@ public abstract class Assume {
}
}
/**
* @since 4.2
*/
@FunctionalInterface
public static interface Executable {
public interface Executable {
void execute() throws Exception;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.transaction.interceptor;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
@@ -85,7 +86,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
new NamedThreadLocal<TransactionInfo>("Current aspect-driven transaction");
private final ConcurrentHashMap<Object, PlatformTransactionManager> transactionManagerCache =
private final Map<Object, PlatformTransactionManager> transactionManagerCache =
new ConcurrentHashMap<Object, PlatformTransactionManager>();
/**
@@ -243,7 +244,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
public void afterPropertiesSet() {
if (getTransactionManager() == null && this.beanFactory == null) {
throw new IllegalStateException(
"Setting the property 'transactionManager' or running in a ListableBeanFactory is required");
"Setting the property 'transactionManager' or running in a BeanFactory is required");
}
if (this.transactionAttributeSource == null) {
throw new IllegalStateException(
@@ -449,17 +450,16 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
TransactionInfo txInfo = new TransactionInfo(tm, txAttr, joinpointIdentification);
if (txAttr != null) {
// We need a transaction for this method
// We need a transaction for this method...
if (logger.isTraceEnabled()) {
logger.trace("Getting transaction for [" + txInfo.getJoinpointIdentification() + "]");
}
// The transaction manager will flag an error if an incompatible tx already exists
// The transaction manager will flag an error if an incompatible tx already exists.
txInfo.newTransactionStatus(status);
}
else {
// The TransactionInfo.hasTransaction() method will return
// false. We created it only to preserve the integrity of
// the ThreadLocal stack maintained in this class.
// The TransactionInfo.hasTransaction() method will return false. We created it only
// to preserve the integrity of the ThreadLocal stack maintained in this class.
if (logger.isTraceEnabled())
logger.trace("Don't need to create transaction for [" + joinpointIdentification +
"]: This method isn't transactional.");