• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.misc;
2 
3 import java.io.*;
4 
5 
6 import com.fasterxml.jackson.core.*;
7 import com.fasterxml.jackson.databind.*;
8 
9 /**
10  * Unit test mostly written to cover issue [JACKSON-81]; unintended blocking
11  * after data binding.
12  */
13 public class TestBlocking
14     extends BaseMapTest
15 {
16     /**
17      * This is an indirect test that should trigger problems if (and only if)
18      * underlying parser is advanced beyond the only element array.
19      * Basically, although content is invalid, this should be encountered
20      * quite yet.
21      */
testEagerAdvance()22     public void testEagerAdvance() throws IOException
23     {
24         ObjectMapper mapper = new ObjectMapper();
25         JsonParser jp = createParserUsingReader("[ 1  ");
26         assertToken(JsonToken.START_ARRAY, jp.nextToken());
27         assertToken(JsonToken.VALUE_NUMBER_INT, jp.nextToken());
28 
29         // And then try to map just a single entry: shouldn't fail:
30         Integer I = mapper.readValue(jp, Integer.class);
31         assertEquals(Integer.valueOf(1), I);
32 
33         // and should fail only now:
34         try {
35             jp.nextToken();
36         } catch (IOException ioe) {
37             verifyException(ioe, "Unexpected end-of-input: expected close marker for ARRAY");
38         }
39         jp.close();
40     }
41 }
42