* PDF to X * PDF to X * Remove created doc * Code fixes and cleanup for PDF module * Fix web.xml in spring-mvc-web-vs-initializer project * Rollback web.xml * Fixes to PDF article * Merge with main eugen branch * Junit 5 * Fix name of test and modifier
30 lines
592 B
Java
30 lines
592 B
Java
package com.baeldung;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
import static org.junit.jupiter.api.Assertions.expectThrows;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
public class AssertionTest {
|
|
|
|
@Test
|
|
public void testConvertToDoubleThrowException() {
|
|
String age = "eighteen";
|
|
expectThrows(NumberFormatException.class, () -> {
|
|
convertToInt(age);
|
|
});
|
|
|
|
assertThrows(NumberFormatException.class, () -> {
|
|
convertToInt(age);
|
|
});
|
|
}
|
|
|
|
private static Integer convertToInt(String str) {
|
|
if (str == null) {
|
|
return null;
|
|
}
|
|
return Integer.valueOf(str);
|
|
}
|
|
|
|
}
|