2323import org .junit .Before ;
2424import org .junit .Rule ;
2525import org .junit .Test ;
26- import org .junit .rules .ExpectedException ;
2726import org .mockito .InOrder ;
2827import org .mockito .Mock ;
2928import org .mockito .Mockito ;
@@ -41,9 +40,6 @@ public final class JsonDecoderTest {
4140 @ Rule
4241 public MockitoRule mockitoRule = MockitoJUnit .rule ();
4342
44- @ Rule
45- public ExpectedException exception = ExpectedException .none ();
46-
4743 @ Mock
4844 private StreamReceiver receiver ;
4945
@@ -322,44 +318,33 @@ public void testShouldProcessMultipleRecords() {
322318
323319 @ Test
324320 public void testShouldOnlyParseObjects () {
325- exception .expect (MetafactureException .class );
326- exception .expectMessage ("Unexpected token 'VALUE_NULL'" );
327-
328- jsonDecoder .process ("null" );
321+ Assert .assertThrows ("Unexpected token 'VALUE_NULL'" , MetafactureException .class , () ->
322+ jsonDecoder .process ("null" ));
329323 }
330324
331325 @ Test
332326 public void testShouldNotParseIncompleteObjects () {
333- exception .expect (MetafactureException .class );
334- exception .expectMessage ("Unexpected end-of-input" );
335-
336- jsonDecoder .process ("{" );
327+ Assert .assertThrows ("Unexpected end-of-input" , MetafactureException .class , () ->
328+ jsonDecoder .process ("{" ));
337329 }
338330
339331 @ Test
340332 public void testShouldNotParseTrailingContent () {
341- exception .expect (MetafactureException .class );
342- exception .expectMessage ("Unexpected token 'VALUE_NULL'" );
343-
344- jsonDecoder .process ("{\" lit\" :\" value\" }null" );
333+ Assert .assertThrows ("Unexpected token 'VALUE_NULL'" , MetafactureException .class , () ->
334+ jsonDecoder .process ("{\" lit\" :\" value\" }null" ));
345335 }
346336
347337 @ Test
348338 public void testShouldNotParseTrailingGarbage () {
349- exception .expect (MetafactureException .class );
350- exception .expectMessage ("Unrecognized token 'XXX'" );
351-
352- jsonDecoder .process ("{\" lit\" :\" value\" }XXX" );
339+ Assert .assertThrows ("Unrecognized token 'XXX'" , MetafactureException .class , () ->
340+ jsonDecoder .process ("{\" lit\" :\" value\" }XXX" ));
353341 }
354342
355343 @ Test
356344 public void testShouldNotParseComments () {
357- exception .expect (MetafactureException .class );
358- exception .expectMessage ("Unexpected character ('/' (code 47))" );
359-
360345 Assert .assertFalse (jsonDecoder .getAllowComments ());
361-
362- jsonDecoder .process ("//{\" lit\" :\" value\" }" );
346+ Assert . assertThrows ( "Unexpected character ('/' (code 47))" , MetafactureException . class , () ->
347+ jsonDecoder .process ("//{\" lit\" :\" value\" }" ) );
363348 }
364349
365350 @ Test
@@ -374,12 +359,9 @@ public void testShouldParseCommentsIfEnabled() {
374359
375360 @ Test
376361 public void testShouldNotParseInlineComments () {
377- exception .expect (MetafactureException .class );
378- exception .expectMessage ("Unexpected character ('/' (code 47))" );
379-
380362 Assert .assertFalse (jsonDecoder .getAllowComments ());
381-
382- jsonDecoder .process ("{\" lit\" :/*comment*/\" value\" }" );
363+ Assert . assertThrows ( "Unexpected character ('/' (code 47))" , MetafactureException . class , () ->
364+ jsonDecoder .process ("{\" lit\" :/*comment*/\" value\" }" ) );
383365 }
384366
385367 @ Test
0 commit comments