diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index b07a5558c22..7e239d1cc9d 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -37,6 +37,7 @@ import static org.springframework.util.ObjectUtils.isEmpty; * @author Juergen Hoeller * @author Rick Evans * @author Sam Brannen + * @author Hyunjin Choi */ class ObjectUtilsTests { @@ -806,6 +807,20 @@ class ObjectUtilsTests { .withMessage("Constant [bogus] does not exist in enum type org.springframework.util.ObjectUtilsTests$Tropes"); } + @Test + void containsElement() { + String keyObject = "key"; + String[] array = {"foo", "bar", "Bar", keyObject}; + + String fakeObject = "fake"; + + assertThat(ObjectUtils.containsElement(null, keyObject)).isFalse(); + + assertThat(ObjectUtils.containsElement(array, keyObject)).isTrue(); + + assertThat(ObjectUtils.containsElement(array, fakeObject)).isFalse(); + } + private void assertEqualHashCodes(int expected, Object array) { int actual = ObjectUtils.nullSafeHashCode(array); assertThat(actual).isEqualTo(expected);