1919
2020package com .github .fge .jsonpatch .diff ;
2121
22- import com .fasterxml .jackson .core .JsonParser ;
2322import com .fasterxml .jackson .core .JsonPointer ;
2423import com .fasterxml .jackson .core .type .TypeReference ;
2524import com .fasterxml .jackson .databind .JsonNode ;
2625import com .fasterxml .jackson .databind .ObjectMapper ;
27- import com .fasterxml .jackson .databind .ObjectReader ;
2826import com .github .fge .jsonpatch .JacksonUtils ;
27+ import com .github .fge .jsonpatch .ResourceUtil ;
2928import org .testng .annotations .DataProvider ;
3029import org .testng .annotations .Test ;
3130
3231import java .io .IOException ;
33- import java .io .InputStream ;
34- import java .net .URL ;
3532import java .util .ArrayList ;
3633import java .util .Iterator ;
3734import java .util .List ;
@@ -53,7 +50,7 @@ public UnchangedTest()
5350 throws IOException
5451 {
5552 final String resource = "/jsonpatch/diff/unchanged.json" ;
56- testData = fromResource (resource );
53+ testData = ResourceUtil . fromResource (resource );
5754 }
5855
5956 @ DataProvider
@@ -78,32 +75,4 @@ public void computeUnchangedValuesWorks(final JsonNode first,
7875
7976 assertEquals (actual , expected );
8077 }
81-
82- public static JsonNode fromResource (final String resource )
83- throws IOException
84- {
85- URL url ;
86- url = UnchangedTest .class .getResource (resource );
87-
88- if (url == null )
89- throw new IOException ("resource " + resource + " not found" );
90-
91- ObjectMapper mapper = JacksonUtils .newMapper ();
92-
93- ObjectReader reader = mapper .configure (JsonParser .Feature .AUTO_CLOSE_SOURCE , true )
94- .reader (JsonNode .class );
95-
96- InputStream is = null ;
97- JsonNode node = null ;
98- try {
99- is = url .openStream ();
100- node = reader .readValue (is );
101- } finally {
102- if (is != null )
103- {
104- is .close ();
105- }
106- }
107- return node ;
108- }
10978}
0 commit comments