* BAEL-3154

* BAEL-3154 add Apache Commons Lang example

* Moved to java-strings-3
This commit is contained in:
Kevin Kraus 2019-08-10 13:26:35 -05:00 committed by maibin
parent b891c53dcc
commit 2aeb078fd1
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package com.baeldung.string.equalsIgnoreCase;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class StringEqualsIgnoreCaseUnitTest {
private String string1 = "equals ignore case";
private String string2 = "EQUALS IGNORE CASE";
@Test
public void givenEqualStringsWithDifferentCase_whenUsingEqualsIgnoreCase_ThenTheyAreEqual() {
assertThat(string1.equalsIgnoreCase(string2)).isTrue();
}
@Test
public void givenEqualStringsWithDifferentCase_whenUsingApacheCommonsEqualsIgnoreCase_ThenTheyAreEqual() {
assertThat(StringUtils.equalsIgnoreCase(string1, string2)).isTrue();
}
@Test
public void givenAStringAndNullValue_whenUsingApacheCommonsEqualsIgnoreCase_ThenTheyAreNotEqual() {
assertThat(StringUtils.equalsIgnoreCase(string1, null)).isFalse();
}
}