22
33import static org .junit .Assert .assertEquals ;
44import static org .junit .Assert .assertFalse ;
5+ import static org .junit .Assert .assertThrows ;
56import static org .junit .Assert .assertTrue ;
67
78import com .typesafe .config .Config ;
89import com .typesafe .config .ConfigFactory ;
10+ import org .junit .Assert ;
911import org .junit .Test ;
1012
1113public class VmConfigTest {
@@ -99,7 +101,7 @@ public void testEstimateEnergyMaxRetryBoundaryValues() {
99101
100102 @ Test
101103 public void testConstantCallTimeoutDefaultWhenAbsent () {
102- // No path in the config, no entry in reference.conf -> default 0L kept,
104+ // reference.conf default is 0; absence of a user override keeps that default;
103105 // no validation triggered.
104106 VmConfig vm = VmConfig .fromConfig (withRef ());
105107 assertEquals (0L , vm .getConstantCallTimeoutMs ());
@@ -121,24 +123,18 @@ public void testConstantCallTimeoutAcceptsAnyPositiveValue() {
121123
122124 @ Test
123125 public void testConstantCallTimeoutNegativeRejected () {
124- try {
126+ IllegalArgumentException thrown = assertThrows ( IllegalArgumentException . class , () -> {
125127 VmConfig .fromConfig (withRef ("vm { constantCallTimeoutMs = -1 }" ));
126- org .junit .Assert .fail ("expected IllegalArgumentException for negative ms" );
127- } catch (IllegalArgumentException ex ) {
128- org .junit .Assert .assertTrue (ex .getMessage (),
129- ex .getMessage ().contains ("constantCallTimeoutMs" ));
130- }
128+ });
129+ Assert .assertTrue (thrown .getMessage ().contains ("constantCallTimeoutMs" ));
131130 }
132131
133132 @ Test
134133 public void testConstantCallTimeoutOverflowRejected () {
135134 long value = Long .MAX_VALUE / 1000 + 1L ;
136- try {
135+ IllegalArgumentException thrown = assertThrows ( IllegalArgumentException . class , () -> {
137136 VmConfig .fromConfig (withRef ("vm { constantCallTimeoutMs = " + value + " }" ));
138- org .junit .Assert .fail ("expected IllegalArgumentException for overflowing ms" );
139- } catch (IllegalArgumentException ex ) {
140- org .junit .Assert .assertTrue (ex .getMessage (),
141- ex .getMessage ().contains ("deadline conversion" ));
142- }
137+ });
138+ Assert .assertTrue (thrown .getMessage ().contains ("deadline conversion" ));
143139 }
144140}
0 commit comments