Browse Source

Polishing

pull/543/merge
Juergen Hoeller 11 years ago
parent
commit
cc917de24d
  1. 6
      spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java
  2. 16
      spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java
  3. 2
      spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java
  4. 10
      spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java

6
spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java

@ -367,14 +367,15 @@ public class AnnotationConfigUtils { @@ -367,14 +367,15 @@ public class AnnotationConfigUtils {
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
Class<?> containerClass, Class<?> annotationClass) {
return attributesForRepeatable(metadata, containerClass.getName(), annotationClass.getName());
}
@SuppressWarnings("unchecked")
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
String containerClassName, String annotationClassName) {
Set<AnnotationAttributes> result = new LinkedHashSet<AnnotationAttributes>();
Set<AnnotationAttributes> result = new LinkedHashSet<AnnotationAttributes>();
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false));
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false);
@ -386,8 +387,7 @@ public class AnnotationConfigUtils { @@ -386,8 +387,7 @@ public class AnnotationConfigUtils {
return Collections.unmodifiableSet(result);
}
private static void addAttributesIfNotNull(Set<AnnotationAttributes> result,
Map<String, Object> attributes) {
private static void addAttributesIfNotNull(Set<AnnotationAttributes> result, Map<String, Object> attributes) {
if (attributes != null) {
result.add(AnnotationAttributes.fromMap(attributes));
}

16
spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java

@ -38,10 +38,11 @@ import static java.lang.annotation.RetentionPolicy.*; @@ -38,10 +38,11 @@ import static java.lang.annotation.RetentionPolicy.*;
* which is enabled by default.
*
* <p>The configuration options provided by this annotation are equivalent to
* those supported by {@link ScriptUtils} and {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
* ResourceDatabasePopulator} but are a superset of those provided by the
* {@code <jdbc:initialize-database />} XML namespace element. Consult the
* Javadoc of individual attributes in this annotation for details.
* those supported by {@link ScriptUtils} and
* {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator}
* but are a superset of those provided by the {@code <jdbc:initialize-database/>}
* XML namespace element. Consult the javadocs of individual attributes in this
* annotation for details.
*
* <p>Beginning with Java 8, {@code @Sql} can be used as a
* <em>{@linkplain Repeatable repeatable}</em> annotation. Otherwise,
@ -66,7 +67,7 @@ import static java.lang.annotation.RetentionPolicy.*; @@ -66,7 +67,7 @@ import static java.lang.annotation.RetentionPolicy.*;
@Documented
@Inherited
@Retention(RUNTIME)
@Target({ TYPE, METHOD })
@Target({TYPE, METHOD})
@Repeatable(SqlGroup.class)
public @interface Sql {
@ -85,7 +86,7 @@ public @interface Sql { @@ -85,7 +86,7 @@ public @interface Sql {
* The configured SQL scripts will be executed <em>after</em> the
* corresponding test method.
*/
AFTER_TEST_METHOD;
AFTER_TEST_METHOD
}
@ -98,10 +99,8 @@ public @interface Sql { @@ -98,10 +99,8 @@ public @interface Sql {
/**
* The paths to the SQL scripts to execute.
*
* <p>This attribute may <strong>not</strong> be used in conjunction with
* {@link #value}, but it may be used instead of {@link #value}.
*
* <h3>Path Resource Semantics</h3>
* <p>Each path will be interpreted as a Spring
* {@link org.springframework.core.io.Resource Resource}. A plain path
@ -114,7 +113,6 @@ public @interface Sql { @@ -114,7 +113,6 @@ public @interface Sql {
* {@link ResourceUtils#CLASSPATH_URL_PREFIX classpath:},
* {@link ResourceUtils#FILE_URL_PREFIX file:}, {@code http:}, etc.) will be
* loaded using the specified resource protocol.
*
* <h3>Default Script Detection</h3>
* <p>If no SQL scripts are specified, an attempt will be made to detect a
* <em>default</em> script depending on where this annotation is declared.

2
spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

@ -231,7 +231,7 @@ public class UriComponentsBuilder { @@ -231,7 +231,7 @@ public class UriComponentsBuilder {
builder.scheme((scheme != null) ? scheme.toLowerCase() : scheme);
builder.userInfo(m.group(4));
String host = m.group(5);
if(StringUtils.hasLength(scheme) && !StringUtils.hasLength(host)) {
if (StringUtils.hasLength(scheme) && !StringUtils.hasLength(host)) {
throw new IllegalArgumentException("[" + httpUrl + "] is not a valid HTTP URL");
}
builder.host(host);

10
spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java

@ -224,7 +224,7 @@ public class AnnotationConfigDispatcherServletInitializerTests { @@ -224,7 +224,7 @@ public class AnnotationConfigDispatcherServletInitializerTests {
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[]{MyConfiguration.class};
return new Class<?>[] {MyConfiguration.class};
}
@Override
@ -254,16 +254,12 @@ public class AnnotationConfigDispatcherServletInitializerTests { @@ -254,16 +254,12 @@ public class AnnotationConfigDispatcherServletInitializerTests {
}
private static class MyBean {
public static class MyBean {
}
@Configuration
@SuppressWarnings("unused")
private static class MyConfiguration {
public MyConfiguration() {
}
public static class MyConfiguration {
@Bean
public MyBean bean() {

Loading…
Cancel
Save