updated deprecated Assert. method usage. This is not related to this 2.4.0 boot update

This commit is contained in:
Gerardo Roza 2021-01-06 11:49:12 -03:00
parent 83664977f0
commit 1112f95497
2 changed files with 10 additions and 9 deletions

View File

@ -51,21 +51,21 @@ public class ValuesWithDefaultsApp {
@PostConstruct
public void afterInitialize() {
// strings
Assert.isTrue(stringWithDefaultValue.equals("my default value"));
Assert.isTrue(stringWithBlankDefaultValue.equals(""));
Assert.isTrue(stringWithDefaultValue.equals("my default value"), "unexpected value for stringWithDefaultValue");
Assert.isTrue(stringWithBlankDefaultValue.equals(""), "unexpected value for stringWithBlankDefaultValue");
// other primitives
Assert.isTrue(booleanWithDefaultValue);
Assert.isTrue(intWithDefaultValue == 42);
Assert.isTrue(booleanWithDefaultValue, "unexpected value for booleanWithDefaultValue");
Assert.isTrue(intWithDefaultValue == 42, "unexpected value for intWithDefaultValue");
// arrays
List<String> stringListValues = Arrays.asList("one", "two", "three");
Assert.isTrue(Arrays.asList(stringArrayWithDefaults).containsAll(stringListValues));
Assert.isTrue(Arrays.asList(stringArrayWithDefaults).containsAll(stringListValues), "unexpected value for stringArrayWithDefaults");
List<Integer> intListValues = Arrays.asList(1, 2, 3);
Assert.isTrue(Arrays.asList(ArrayUtils.toObject(intArrayWithDefaults)).containsAll(intListValues));
Assert.isTrue(Arrays.asList(ArrayUtils.toObject(intArrayWithDefaults)).containsAll(intListValues), "unexpected value for intArrayWithDefaults");
// SpEL
Assert.isTrue(spelWithDefaultValue.equals("my default system property value"));
Assert.isTrue(spelWithDefaultValue.equals("my default system property value"), "unexpected value for spelWithDefaultValue");
}
}

View File

@ -13,6 +13,7 @@ import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringListPropertiesApplication.class)
@ -47,7 +48,7 @@ public class ListsPropertiesUnitTest {
@Test
public void whenContextIsInitialized_thenInjectedArrayContainsExpectedValues() {
assertEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings);
assertArrayEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings);
}
@Test
@ -82,7 +83,7 @@ public class ListsPropertiesUnitTest {
String[] arrayOfStrings = environment.getProperty("arrayOfStrings", String[].class);
List<String> listOfStrings = (List<String>)environment.getProperty("arrayOfStrings", List.class);
assertEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings);
assertArrayEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings);
assertEquals(Arrays.asList("Baeldung", "dot", "com"), listOfStrings);
}
}