diff --git a/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java index e1e56217b9..f72dce31da 100644 --- a/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java @@ -68,35 +68,47 @@ public class MergedContextConfiguration implements Serializable { private static final long serialVersionUID = -3290560718464957422L; private static final String[] EMPTY_STRING_ARRAY = new String[0]; + private static final Class[] EMPTY_CLASS_ARRAY = new Class[0]; - private static final Set>> EMPTY_INITIALIZER_CLASSES = // - Collections.>> emptySet(); + + private static final Set>> EMPTY_INITIALIZER_CLASSES = + Collections.>> emptySet(); + private final Class testClass; + private final String[] locations; + private final Class[] classes; + private final Set>> contextInitializerClasses; + private final String[] activeProfiles; + private final String[] propertySourceLocations; + private final String[] propertySourceProperties; + private final ContextLoader contextLoader; + private final CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate; private final MergedContextConfiguration parent; private static String[] processStrings(String[] array) { - return array == null ? EMPTY_STRING_ARRAY : array; + return (array != null ? array : EMPTY_STRING_ARRAY); } private static Class[] processClasses(Class[] classes) { - return classes == null ? EMPTY_CLASS_ARRAY : classes; + return (classes != null ? classes : EMPTY_CLASS_ARRAY); } private static Set>> processContextInitializerClasses( Set>> contextInitializerClasses) { - return contextInitializerClasses == null ? EMPTY_INITIALIZER_CLASSES - : Collections.unmodifiableSet(contextInitializerClasses); + + return (contextInitializerClasses != null ? + Collections.unmodifiableSet(contextInitializerClasses) : EMPTY_INITIALIZER_CLASSES); } private static String[] processActiveProfiles(String[] activeProfiles) { @@ -117,15 +129,15 @@ public class MergedContextConfiguration implements Serializable { * loader or "null" if the supplied loaded is {@code null}. */ protected static String nullSafeToString(ContextLoader contextLoader) { - return contextLoader == null ? "null" : contextLoader.getClass().getName(); + return (contextLoader != null ? contextLoader.getClass().getName() : "null"); } + /** * Create a new {@code MergedContextConfiguration} instance for the * supplied parameters. *

Delegates to * {@link #MergedContextConfiguration(Class, String[], Class[], Set, String[], String[], String[], ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)}. - * * @param testClass the test class for which the configuration was merged * @param locations the merged context resource locations * @param classes the merged annotated classes @@ -134,6 +146,7 @@ public class MergedContextConfiguration implements Serializable { */ public MergedContextConfiguration(Class testClass, String[] locations, Class[] classes, String[] activeProfiles, ContextLoader contextLoader) { + this(testClass, locations, classes, null, activeProfiles, contextLoader); } @@ -142,7 +155,6 @@ public class MergedContextConfiguration implements Serializable { * supplied parameters. *

Delegates to * {@link #MergedContextConfiguration(Class, String[], Class[], Set, String[], String[], String[], ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)}. - * * @param testClass the test class for which the configuration was merged * @param locations the merged context resource locations * @param classes the merged annotated classes @@ -151,12 +163,10 @@ public class MergedContextConfiguration implements Serializable { * @param contextLoader the resolved {@code ContextLoader} * @see #MergedContextConfiguration(Class, String[], Class[], Set, String[], ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration) */ - public MergedContextConfiguration( - Class testClass, - String[] locations, - Class[] classes, + public MergedContextConfiguration(Class testClass, String[] locations, Class[] classes, Set>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader) { + this(testClass, locations, classes, contextInitializerClasses, activeProfiles, contextLoader, null, null); } @@ -165,7 +175,6 @@ public class MergedContextConfiguration implements Serializable { * supplied parameters. *

Delegates to * {@link #MergedContextConfiguration(Class, String[], Class[], Set, String[], String[], String[], ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)}. - * * @param testClass the test class for which the configuration was merged * @param locations the merged context resource locations * @param classes the merged annotated classes @@ -177,13 +186,11 @@ public class MergedContextConfiguration implements Serializable { * @param parent the parent configuration or {@code null} if there is no parent * @since 3.2.2 */ - public MergedContextConfiguration( - Class testClass, - String[] locations, - Class[] classes, + public MergedContextConfiguration(Class testClass, String[] locations, Class[] classes, Set>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) { + this(testClass, locations, classes, contextInitializerClasses, activeProfiles, null, null, contextLoader, cacheAwareContextLoaderDelegate, parent); } @@ -203,7 +210,6 @@ public class MergedContextConfiguration implements Serializable { /** * Create a new {@code MergedContextConfiguration} instance for the * supplied parameters. - * *

If a {@code null} value is supplied for {@code locations}, * {@code classes}, {@code activeProfiles}, {@code propertySourceLocations}, * or {@code propertySourceProperties} an empty array will be stored instead. @@ -211,7 +217,6 @@ public class MergedContextConfiguration implements Serializable { * {@code contextInitializerClasses} an empty set will be stored instead. * Furthermore, active profiles will be sorted, and duplicate profiles * will be removed. - * * @param testClass the test class for which the configuration was merged * @param locations the merged context resource locations * @param classes the merged annotated classes @@ -225,14 +230,12 @@ public class MergedContextConfiguration implements Serializable { * @param parent the parent configuration or {@code null} if there is no parent * @since 4.1 */ - public MergedContextConfiguration( - Class testClass, - String[] locations, - Class[] classes, + public MergedContextConfiguration(Class testClass, String[] locations, Class[] classes, Set>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) { + this.testClass = testClass; this.locations = processStrings(locations); this.classes = processClasses(classes); @@ -245,11 +248,13 @@ public class MergedContextConfiguration implements Serializable { this.parent = parent; } + /** - * Get the {@linkplain Class test class} associated with this {@code MergedContextConfiguration}. + * Get the {@linkplain Class test class} associated with this + * {@code MergedContextConfiguration}. */ public Class getTestClass() { - return testClass; + return this.testClass; } /** @@ -259,20 +264,19 @@ public class MergedContextConfiguration implements Serializable { * files or Groovy scripts. */ public String[] getLocations() { - return locations; + return this.locations; } /** * Get the merged annotated classes for the {@linkplain #getTestClass() test class}. */ public Class[] getClasses() { - return classes; + return this.classes; } /** * Determine if this {@code MergedContextConfiguration} instance has * path-based context resource locations. - * * @return {@code true} if the {@link #getLocations() locations} array is not empty * @since 4.0.4 * @see #hasResources() @@ -285,7 +289,6 @@ public class MergedContextConfiguration implements Serializable { /** * Determine if this {@code MergedContextConfiguration} instance has * class-based resources. - * * @return {@code true} if the {@link #getClasses() classes} array is not empty * @since 4.0.4 * @see #hasResources() @@ -298,7 +301,6 @@ public class MergedContextConfiguration implements Serializable { /** * Determine if this {@code MergedContextConfiguration} instance has * either path-based context resource locations or class-based resources. - * * @return {@code true} if either the {@link #getLocations() locations} * or the {@link #getClasses() classes} array is not empty * @since 4.0.4 @@ -306,7 +308,7 @@ public class MergedContextConfiguration implements Serializable { * @see #hasClasses() */ public boolean hasResources() { - return hasLocations() || hasClasses(); + return (hasLocations() || hasClasses()); } /** @@ -314,7 +316,7 @@ public class MergedContextConfiguration implements Serializable { * {@linkplain #getTestClass() test class}. */ public Set>> getContextInitializerClasses() { - return contextInitializerClasses; + return this.contextInitializerClasses; } /** @@ -323,17 +325,17 @@ public class MergedContextConfiguration implements Serializable { * @see ActiveProfiles */ public String[] getActiveProfiles() { - return activeProfiles; + return this.activeProfiles; } /** - * Get the merged resource locations for test {@code PropertySources} for the - * {@linkplain #getTestClass() test class}. + * Get the merged resource locations for test {@code PropertySources} + * for the {@linkplain #getTestClass() test class}. * @see TestPropertySource#locations * @see java.util.Properties */ public String[] getPropertySourceLocations() { - return propertySourceLocations; + return this.propertySourceLocations; } /** @@ -345,20 +347,19 @@ public class MergedContextConfiguration implements Serializable { * @see java.util.Properties */ public String[] getPropertySourceProperties() { - return propertySourceProperties; + return this.propertySourceProperties; } /** * Get the resolved {@link ContextLoader} for the {@linkplain #getTestClass() test class}. */ public ContextLoader getContextLoader() { - return contextLoader; + return this.contextLoader; } /** - * Get the {@link MergedContextConfiguration} for the parent application context in a - * context hierarchy. - * + * Get the {@link MergedContextConfiguration} for the parent application context + * in a context hierarchy. * @return the parent configuration or {@code null} if there is no parent * @see #getParentApplicationContext() * @since 3.2.2 @@ -370,43 +371,21 @@ public class MergedContextConfiguration implements Serializable { /** * Get the parent {@link ApplicationContext} for the context defined by this * {@code MergedContextConfiguration} from the context cache. - *

- * If the parent context has not yet been loaded, it will be loaded, stored in the - * cache, and then returned. - * + *

If the parent context has not yet been loaded, it will be loaded, stored + * in the cache, and then returned. * @return the parent {@code ApplicationContext} or {@code null} if there is no parent * @see #getParent() * @since 3.2.2 */ public ApplicationContext getParentApplicationContext() { - if (parent == null) { + if (this.parent == null) { return null; } - - Assert.state(cacheAwareContextLoaderDelegate != null, - "Cannot retrieve a parent application context without access to the CacheAwareContextLoaderDelegate."); - return cacheAwareContextLoaderDelegate.loadContext(parent); + Assert.state(this.cacheAwareContextLoaderDelegate != null, + "Cannot retrieve a parent application context without access to the CacheAwareContextLoaderDelegate"); + return this.cacheAwareContextLoaderDelegate.loadContext(this.parent); } - /** - * Generate a unique hash code for all properties of this - * {@code MergedContextConfiguration} excluding the - * {@linkplain #getTestClass() test class}. - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(locations); - result = prime * result + Arrays.hashCode(classes); - result = prime * result + contextInitializerClasses.hashCode(); - result = prime * result + Arrays.hashCode(activeProfiles); - result = prime * result + Arrays.hashCode(propertySourceLocations); - result = prime * result + Arrays.hashCode(propertySourceProperties); - result = prime * result + (parent == null ? 0 : parent.hashCode()); - result = prime * result + nullSafeToString(contextLoader).hashCode(); - return result; - } /** * Determine if the supplied object is equal to this {@code MergedContextConfiguration} @@ -420,57 +399,68 @@ public class MergedContextConfiguration implements Serializable { * {@link #getContextLoader() ContextLoaders}. */ @Override - public boolean equals(Object obj) { - - if (this == obj) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (!(obj instanceof MergedContextConfiguration)) { + if (!(other instanceof MergedContextConfiguration)) { return false; } - final MergedContextConfiguration that = (MergedContextConfiguration) obj; - - if (!Arrays.equals(this.locations, that.locations)) { + MergedContextConfiguration otherConfig = (MergedContextConfiguration) other; + if (!Arrays.equals(this.locations, otherConfig.locations)) { return false; } - - if (!Arrays.equals(this.classes, that.classes)) { + if (!Arrays.equals(this.classes, otherConfig.classes)) { return false; } - - if (!this.contextInitializerClasses.equals(that.contextInitializerClasses)) { + if (!this.contextInitializerClasses.equals(otherConfig.contextInitializerClasses)) { return false; } - - if (!Arrays.equals(this.activeProfiles, that.activeProfiles)) { + if (!Arrays.equals(this.activeProfiles, otherConfig.activeProfiles)) { return false; } - - if (!Arrays.equals(this.propertySourceLocations, that.propertySourceLocations)) { + if (!Arrays.equals(this.propertySourceLocations, otherConfig.propertySourceLocations)) { return false; } - - if (!Arrays.equals(this.propertySourceProperties, that.propertySourceProperties)) { + if (!Arrays.equals(this.propertySourceProperties, otherConfig.propertySourceProperties)) { return false; } if (this.parent == null) { - if (that.parent != null) { + if (otherConfig.parent != null) { return false; } } - else if (!this.parent.equals(that.parent)) { + else if (!this.parent.equals(otherConfig.parent)) { return false; } - if (!nullSafeToString(this.contextLoader).equals(nullSafeToString(that.contextLoader))) { + if (!nullSafeToString(this.contextLoader).equals(nullSafeToString(otherConfig.contextLoader))) { return false; } return true; } + /** + * Generate a unique hash code for all properties of this + * {@code MergedContextConfiguration} excluding the + * {@linkplain #getTestClass() test class}. + */ + @Override + public int hashCode() { + int result = Arrays.hashCode(this.locations); + result = 31 * result + Arrays.hashCode(this.classes); + result = 31 * result + this.contextInitializerClasses.hashCode(); + result = 31 * result + Arrays.hashCode(this.activeProfiles); + result = 31 * result + Arrays.hashCode(this.propertySourceLocations); + result = 31 * result + Arrays.hashCode(this.propertySourceProperties); + result = 31 * result + (this.parent != null ? this.parent.hashCode() : 0); + result = 31 * result + nullSafeToString(this.contextLoader).hashCode(); + return result; + } + /** * Provide a String representation of the {@linkplain #getTestClass() test class}, * {@linkplain #getLocations() locations}, {@linkplain #getClasses() annotated classes}, @@ -483,17 +473,17 @@ public class MergedContextConfiguration implements Serializable { */ @Override public String toString() { - return new ToStringCreator(this)// - .append("testClass", testClass)// - .append("locations", ObjectUtils.nullSafeToString(locations))// - .append("classes", ObjectUtils.nullSafeToString(classes))// - .append("contextInitializerClasses", ObjectUtils.nullSafeToString(contextInitializerClasses))// - .append("activeProfiles", ObjectUtils.nullSafeToString(activeProfiles))// - .append("propertySourceLocations", ObjectUtils.nullSafeToString(propertySourceLocations))// - .append("propertySourceProperties", ObjectUtils.nullSafeToString(propertySourceProperties))// - .append("contextLoader", nullSafeToString(contextLoader))// - .append("parent", parent)// - .toString(); + return new ToStringCreator(this) + .append("testClass", this.testClass) + .append("locations", ObjectUtils.nullSafeToString(this.locations)) + .append("classes", ObjectUtils.nullSafeToString(this.classes)) + .append("contextInitializerClasses", ObjectUtils.nullSafeToString(this.contextInitializerClasses)) + .append("activeProfiles", ObjectUtils.nullSafeToString(this.activeProfiles)) + .append("propertySourceLocations", ObjectUtils.nullSafeToString(this.propertySourceLocations)) + .append("propertySourceProperties", ObjectUtils.nullSafeToString(this.propertySourceProperties)) + .append("contextLoader", nullSafeToString(this.contextLoader)) + .append("parent", this.parent) + .toString(); } } diff --git a/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java index fb577b6aa1..0537622ba1 100644 --- a/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java @@ -63,7 +63,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * supplied parameters. *

Delegates to * {@link #WebMergedContextConfiguration(Class, String[], Class[], Set, String[], String[], String[], String, ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)}. - * * @param testClass the test class for which the configuration was merged * @param locations the merged resource locations * @param classes the merged annotated classes @@ -76,10 +75,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * {@link #WebMergedContextConfiguration(Class, String[], Class[], Set, String[], String, ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)} instead. */ @Deprecated - public WebMergedContextConfiguration( - Class testClass, - String[] locations, - Class[] classes, + public WebMergedContextConfiguration(Class testClass, String[] locations, Class[] classes, Set>> contextInitializerClasses, String[] activeProfiles, String resourceBasePath, ContextLoader contextLoader) { @@ -92,7 +88,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * supplied parameters. *

Delegates to * {@link #WebMergedContextConfiguration(Class, String[], Class[], Set, String[], String[], String[], String, ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)}. - * * @param testClass the test class for which the configuration was merged * @param locations the merged resource locations * @param classes the merged annotated classes @@ -109,10 +104,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * instead. */ @Deprecated - public WebMergedContextConfiguration( - Class testClass, - String[] locations, - Class[] classes, + public WebMergedContextConfiguration(Class testClass, String[] locations, Class[] classes, Set>> contextInitializerClasses, String[] activeProfiles, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) { @@ -137,7 +129,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { /** * Create a new {@code WebMergedContextConfiguration} instance for the * supplied parameters. - * *

If a {@code null} value is supplied for {@code locations}, * {@code classes}, {@code activeProfiles}, {@code propertySourceLocations}, * or {@code propertySourceProperties} an empty array will be stored instead. @@ -146,7 +137,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * If an empty value is supplied for the {@code resourceBasePath} * an empty string will be used. Furthermore, active profiles will be sorted, * and duplicate profiles will be removed. - * * @param testClass the test class for which the configuration was merged * @param locations the merged resource locations * @param classes the merged annotated classes @@ -161,10 +151,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * @param parent the parent configuration or {@code null} if there is no parent * @since 4.1 */ - public WebMergedContextConfiguration( - Class testClass, - String[] locations, - Class[] classes, + public WebMergedContextConfiguration(Class testClass, String[] locations, Class[] classes, Set>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, String resourceBasePath, ContextLoader contextLoader, @@ -176,6 +163,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { this.resourceBasePath = !StringUtils.hasText(resourceBasePath) ? "" : resourceBasePath; } + /** * Get the resource path to the root directory of the web application for the * {@linkplain #getTestClass() test class}, configured via {@code @WebAppConfiguration}. @@ -185,18 +173,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { return this.resourceBasePath; } - /** - * Generate a unique hash code for all properties of this - * {@code WebMergedContextConfiguration} excluding the - * {@linkplain #getTestClass() test class}. - */ - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + resourceBasePath.hashCode(); - return result; - } /** * Determine if the supplied object is equal to this {@code WebMergedContextConfiguration} @@ -209,18 +185,25 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * {@link #getContextLoader() ContextLoaders}. */ @Override - public boolean equals(Object obj) { - - if (this == obj) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (!(obj instanceof WebMergedContextConfiguration)) { + if (!(other instanceof WebMergedContextConfiguration)) { return false; } + WebMergedContextConfiguration otherConfig = (WebMergedContextConfiguration) other; + return super.equals(otherConfig) && this.getResourceBasePath().equals(otherConfig.getResourceBasePath()); + } - final WebMergedContextConfiguration that = (WebMergedContextConfiguration) obj; - - return super.equals(that) && this.getResourceBasePath().equals(that.getResourceBasePath()); + /** + * Generate a unique hash code for all properties of this + * {@code WebMergedContextConfiguration} excluding the + * {@linkplain #getTestClass() test class}. + */ + @Override + public int hashCode() { + return 31 * super.hashCode() + this.resourceBasePath.hashCode(); } /** @@ -236,18 +219,18 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { */ @Override public String toString() { - return new ToStringCreator(this)// - .append("testClass", getTestClass())// - .append("locations", ObjectUtils.nullSafeToString(getLocations()))// - .append("classes", ObjectUtils.nullSafeToString(getClasses()))// - .append("contextInitializerClasses", ObjectUtils.nullSafeToString(getContextInitializerClasses()))// - .append("activeProfiles", ObjectUtils.nullSafeToString(getActiveProfiles()))// - .append("propertySourceLocations", ObjectUtils.nullSafeToString(getPropertySourceLocations()))// - .append("propertySourceProperties", ObjectUtils.nullSafeToString(getPropertySourceProperties()))// - .append("resourceBasePath", getResourceBasePath())// - .append("contextLoader", nullSafeToString(getContextLoader()))// - .append("parent", getParent())// - .toString(); + return new ToStringCreator(this) + .append("testClass", getTestClass()) + .append("locations", ObjectUtils.nullSafeToString(getLocations())) + .append("classes", ObjectUtils.nullSafeToString(getClasses())) + .append("contextInitializerClasses", ObjectUtils.nullSafeToString(getContextInitializerClasses())) + .append("activeProfiles", ObjectUtils.nullSafeToString(getActiveProfiles())) + .append("propertySourceLocations", ObjectUtils.nullSafeToString(getPropertySourceLocations())) + .append("propertySourceProperties", ObjectUtils.nullSafeToString(getPropertySourceProperties())) + .append("resourceBasePath", getResourceBasePath()) + .append("contextLoader", nullSafeToString(getContextLoader())) + .append("parent", getParent()) + .toString(); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java index 038def4034..3da7bf810c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -41,8 +41,10 @@ import static org.junit.Assert.*; public class MergedContextConfigurationTests { private static final String[] EMPTY_STRING_ARRAY = new String[0]; + private static final Class[] EMPTY_CLASS_ARRAY = new Class[0]; + private final GenericXmlContextLoader loader = new GenericXmlContextLoader(); @@ -50,7 +52,6 @@ public class MergedContextConfigurationTests { public void hashCodeWithNulls() { MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(null, null, null, null, null); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(null, null, null, null, null); - assertTrue(mergedConfig1.hashCode() > 0); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -63,19 +64,19 @@ public class MergedContextConfigurationTests { @Test public void hashCodeWithEmptyArrays() { - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @Test public void hashCodeWithEmptyArraysAndDifferentLoaders() { - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, new AnnotationConfigContextLoader()); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, new AnnotationConfigContextLoader()); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -83,9 +84,9 @@ public class MergedContextConfigurationTests { public void hashCodeWithSameLocations() { String[] locations = new String[] { "foo", "bar}" }; MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), locations, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), locations, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -94,19 +95,19 @@ public class MergedContextConfigurationTests { String[] locations1 = new String[] { "foo", "bar}" }; String[] locations2 = new String[] { "baz", "quux}" }; MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), locations1, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), locations2, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @Test public void hashCodeWithSameConfigClasses() { Class[] classes = new Class[] { String.class, Integer.class }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -114,20 +115,20 @@ public class MergedContextConfigurationTests { public void hashCodeWithDifferentConfigClasses() { Class[] classes1 = new Class[] { String.class, Integer.class }; Class[] classes2 = new Class[] { Boolean.class, Number.class }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes1, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes2, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes1, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes2, EMPTY_STRING_ARRAY, loader); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @Test public void hashCodeWithSameProfiles() { String[] activeProfiles = new String[] { "catbert", "dogbert" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -135,10 +136,10 @@ public class MergedContextConfigurationTests { public void hashCodeWithSameProfilesReversed() { String[] activeProfiles1 = new String[] { "catbert", "dogbert" }; String[] activeProfiles2 = new String[] { "dogbert", "catbert" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles1, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles2, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -146,10 +147,10 @@ public class MergedContextConfigurationTests { public void hashCodeWithSameDuplicateProfiles() { String[] activeProfiles1 = new String[] { "catbert", "dogbert" }; String[] activeProfiles2 = new String[] { "catbert", "dogbert", "catbert", "dogbert", "catbert" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles1, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles2, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -157,46 +158,46 @@ public class MergedContextConfigurationTests { public void hashCodeWithDifferentProfiles() { String[] activeProfiles1 = new String[] { "catbert", "dogbert" }; String[] activeProfiles2 = new String[] { "X", "Y" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles1, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles2, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @Test public void hashCodeWithSameInitializers() { - Set>> initializerClasses1 = // - new HashSet>>(); + Set>> initializerClasses1 = + new HashSet>>(); initializerClasses1.add(FooInitializer.class); initializerClasses1.add(BarInitializer.class); - Set>> initializerClasses2 = // - new HashSet>>(); + Set>> initializerClasses2 = + new HashSet>>(); initializerClasses2.add(BarInitializer.class); initializerClasses2.add(FooInitializer.class); - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @Test public void hashCodeWithDifferentInitializers() { - Set>> initializerClasses1 = // - new HashSet>>(); + Set>> initializerClasses1 = + new HashSet>>(); initializerClasses1.add(FooInitializer.class); - Set>> initializerClasses2 = // - new HashSet>>(); + Set>> initializerClasses2 = + new HashSet>>(); initializerClasses2.add(BarInitializer.class); - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -206,12 +207,12 @@ public class MergedContextConfigurationTests { @Test public void hashCodeWithSameParent() { MergedContextConfiguration parent = new MergedContextConfiguration(getClass(), new String[] { "foo", "bar}" }, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent); + EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -221,14 +222,14 @@ public class MergedContextConfigurationTests { @Test public void hashCodeWithDifferentParents() { MergedContextConfiguration parent1 = new MergedContextConfiguration(getClass(), new String[] { "foo", "bar}" }, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration parent2 = new MergedContextConfiguration(getClass(), new String[] { "baz", "quux" }, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent1); + EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent1); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent2); + EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent2); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); } @@ -237,7 +238,7 @@ public class MergedContextConfigurationTests { MergedContextConfiguration mergedConfig = new MergedContextConfiguration(null, null, null, null, null); assertEquals(mergedConfig, mergedConfig); assertNotEquals(mergedConfig, null); - assertNotEquals(mergedConfig, new Integer(1)); + assertNotEquals(mergedConfig, 1); } @Test @@ -256,19 +257,19 @@ public class MergedContextConfigurationTests { @Test public void equalsWithEmptyArrays() { - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1, mergedConfig2); } @Test public void equalsWithEmptyArraysAndDifferentLoaders() { - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, new AnnotationConfigContextLoader()); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, new AnnotationConfigContextLoader()); assertNotEquals(mergedConfig1, mergedConfig2); assertNotEquals(mergedConfig2, mergedConfig1); } @@ -276,10 +277,10 @@ public class MergedContextConfigurationTests { @Test public void equalsWithSameLocations() { String[] locations = new String[] { "foo", "bar}" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), locations, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), locations, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + locations, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + locations, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1, mergedConfig2); } @@ -287,10 +288,10 @@ public class MergedContextConfigurationTests { public void equalsWithDifferentLocations() { String[] locations1 = new String[] { "foo", "bar}" }; String[] locations2 = new String[] { "baz", "quux}" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), locations1, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), locations2, - EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + locations1, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + locations2, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertNotEquals(mergedConfig1, mergedConfig2); assertNotEquals(mergedConfig2, mergedConfig1); } @@ -298,10 +299,10 @@ public class MergedContextConfigurationTests { @Test public void equalsWithSameConfigClasses() { Class[] classes = new Class[] { String.class, Integer.class }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1, mergedConfig2); } @@ -309,10 +310,10 @@ public class MergedContextConfigurationTests { public void equalsWithDifferentConfigClasses() { Class[] classes1 = new Class[] { String.class, Integer.class }; Class[] classes2 = new Class[] { Boolean.class, Number.class }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes1, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - classes2, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes1, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, classes2, EMPTY_STRING_ARRAY, loader); assertNotEquals(mergedConfig1, mergedConfig2); assertNotEquals(mergedConfig2, mergedConfig1); } @@ -320,10 +321,10 @@ public class MergedContextConfigurationTests { @Test public void equalsWithSameProfiles() { String[] activeProfiles = new String[] { "catbert", "dogbert" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles, loader); assertEquals(mergedConfig1, mergedConfig2); } @@ -331,10 +332,10 @@ public class MergedContextConfigurationTests { public void equalsWithSameProfilesReversed() { String[] activeProfiles1 = new String[] { "catbert", "dogbert" }; String[] activeProfiles2 = new String[] { "dogbert", "catbert" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles1, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles2, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); assertEquals(mergedConfig1, mergedConfig2); } @@ -342,10 +343,10 @@ public class MergedContextConfigurationTests { public void equalsWithSameDuplicateProfiles() { String[] activeProfiles1 = new String[] { "catbert", "dogbert" }; String[] activeProfiles2 = new String[] { "catbert", "dogbert", "catbert", "dogbert", "catbert" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles1, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles2, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); assertEquals(mergedConfig1, mergedConfig2); } @@ -353,47 +354,47 @@ public class MergedContextConfigurationTests { public void equalsWithDifferentProfiles() { String[] activeProfiles1 = new String[] { "catbert", "dogbert" }; String[] activeProfiles2 = new String[] { "X", "Y" }; - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles1, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, activeProfiles2, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); assertNotEquals(mergedConfig1, mergedConfig2); assertNotEquals(mergedConfig2, mergedConfig1); } @Test public void equalsWithSameInitializers() { - Set>> initializerClasses1 = // - new HashSet>>(); + Set>> initializerClasses1 = + new HashSet>>(); initializerClasses1.add(FooInitializer.class); initializerClasses1.add(BarInitializer.class); - Set>> initializerClasses2 = // - new HashSet>>(); + Set>> initializerClasses2 = + new HashSet>>(); initializerClasses2.add(BarInitializer.class); initializerClasses2.add(FooInitializer.class); - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); assertEquals(mergedConfig1, mergedConfig2); } @Test public void equalsWithDifferentInitializers() { - Set>> initializerClasses1 = // - new HashSet>>(); + Set>> initializerClasses1 = + new HashSet>>(); initializerClasses1.add(FooInitializer.class); - Set>> initializerClasses2 = // - new HashSet>>(); + Set>> initializerClasses2 = + new HashSet>>(); initializerClasses2.add(BarInitializer.class); - MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); - MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, - EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); + MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), + EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); assertNotEquals(mergedConfig1, mergedConfig2); assertNotEquals(mergedConfig2, mergedConfig1); } @@ -440,6 +441,7 @@ public class MergedContextConfigurationTests { } } + private static class BarInitializer implements ApplicationContextInitializer { @Override diff --git a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java index 2bac5b66fe..1d6993b2f7 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java @@ -42,11 +42,13 @@ public class HttpHeadersTests { private HttpHeaders headers; + @Before public void setUp() { headers = new HttpHeaders(); } + @Test public void accept() { MediaType mediaType1 = new MediaType("text", "html"); @@ -59,9 +61,7 @@ public class HttpHeadersTests { assertEquals("Invalid Accept header", "text/html, text/plain", headers.getFirst("Accept")); } - // SPR-9655 - - @Test + @Test // SPR-9655 public void acceptiPlanet() { headers.add("Accept", "text/html"); headers.add("Accept", "text/plain"); @@ -228,7 +228,7 @@ public class HttpHeadersTests { calendar.setTimeZone(TimeZone.getTimeZone("CET")); long date = calendar.getTimeInMillis(); headers.setIfModifiedSince(date); - assertEquals("Invalid If-Modified-Since header", date, headers.getIfNotModifiedSince()); + assertEquals("Invalid If-Modified-Since header", date, headers.getIfModifiedSince()); assertEquals("Invalid If-Modified-Since header", "Thu, 18 Dec 2008 10:20:00 GMT", headers.getFirst("if-modified-since")); } @@ -260,12 +260,9 @@ public class HttpHeadersTests { headers.getFirst("Content-Disposition")); } - // SPR-11917 - - @Test + @Test // SPR-11917 public void getAllowEmptySet() { headers.setAllow(Collections. emptySet()); - assertThat(headers.getAllow(), Matchers.emptyCollectionOf(HttpMethod.class)); } diff --git a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java index f3ffc519c1..81dbcd122b 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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,7 +30,6 @@ public class UriUtilsTests { private static final String ENC = "UTF-8"; - @Test public void encodeScheme() throws UnsupportedEncodingException { assertEquals("Invalid encoded result", "foobar+-.", UriUtils.encodeScheme("foobar+-.", ENC));