/** * Generate a unique hash code for all properties of this * {@code WebMergedContextConfiguration} excluding the * {@linkplain #getTestClass() test class}. */ @Override public int hashCode() { return super.hashCode() * 31 + this.resourceBasePath.hashCode(); }
/** * 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.contextCustomizers.hashCode(); result = 31 * result + (this.parent != null ? this.parent.hashCode() : 0); result = 31 * result + nullSafeClassName(this.contextLoader).hashCode(); return result; }
@Test public void hashCodeWithSameInitializers() { Set<Class<? extends ApplicationContextInitializer<?>>> initializerClasses1 = new HashSet<>(); initializerClasses1.add(FooInitializer.class); initializerClasses1.add(BarInitializer.class); Set<Class<? extends ApplicationContextInitializer<?>>> 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); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test public void hashCodeWithNullArrays() { MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), null, null, null, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), null, null, null, loader); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@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); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test 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); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test public void hashCodeWithDifferentInitializers() { Set<Class<? extends ApplicationContextInitializer<?>>> initializerClasses1 = new HashSet<>(); initializerClasses1.add(FooInitializer.class); Set<Class<? extends ApplicationContextInitializer<?>>> 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); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test public void hashCodeWithSameLocations() { 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); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test public void hashCodeWithDifferentLocations() { 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); 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); assertEquals(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); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test 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); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test 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); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test 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); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
/** * @since 3.2.2 */ @Test public void hashCodeWithSameParent() { MergedContextConfiguration parent = new MergedContextConfiguration(getClass(), new String[] { "foo", "bar}" }, 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 mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
@Test public void hashCodeWithNulls() { MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(null, null, null, null, null); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(null, null, null, null, null); assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
/** * @since 3.2.2 */ @Test public void hashCodeWithDifferentParents() { MergedContextConfiguration parent1 = new MergedContextConfiguration(getClass(), new String[] { "foo", "bar}" }, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration parent2 = new MergedContextConfiguration(getClass(), new String[] { "baz", "quux" }, 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); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent2); assertNotEquals(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()); assertNotEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode()); }
/** * Generate a unique hash code for all properties of this * {@code WebMergedContextConfiguration} excluding the * {@linkplain #getTestClass() test class}. */ @Override public int hashCode() { return super.hashCode() * 31 + this.resourceBasePath.hashCode(); }
/** * Generate a unique hash code for all properties of this * {@code WebMergedContextConfiguration} excluding the * {@linkplain #getTestClass() test class}. */ @Override public int hashCode() { return super.hashCode() * 31 + this.resourceBasePath.hashCode(); }