33import com .intuit .ipp .data .Attachable ;
44import com .intuit .ipp .exception .FMSException ;
55import com .intuit .ipp .util .Config ;
6- import mockit .Expectations ;
76
7+ import mockit .Mock ;
8+ import mockit .MockUp ;
89import org .testng .Assert ;
910import org .testng .annotations .BeforeMethod ;
1011import org .testng .annotations .BeforeTest ;
1718import javax .xml .namespace .QName ;
1819import java .awt .image .RenderedImage ;
1920import java .io .ByteArrayInputStream ;
20- import java .io .ByteArrayOutputStream ;
2121import java .io .IOException ;
2222import java .io .InputStream ;
23+ import java .io .OutputStream ;
2324import java .util .Arrays ;
2425import java .util .HashMap ;
2526import java .util .Map ;
@@ -138,9 +139,12 @@ public void execute_uploadFileImageContent() throws FMSException, IOException {
138139 message .getRequestElements ().setEntity (attachable );
139140 message .getRequestElements ().setObjectToSerialize (jaxbElement );
140141
141- new Expectations (ImageIO .class ) {{
142- ImageIO .write ((RenderedImage ) any , anyString , (ByteArrayOutputStream ) any );
143- }};
142+ new MockUp <ImageIO >() {
143+ @ Mock
144+ public boolean write (RenderedImage image , String formatName , OutputStream output ) {
145+ return true ;
146+ }
147+ };
144148
145149 serializeInterceptor .execute (message );
146150 Assert .assertEquals (message .getRequestElements ().getSerializedData (), "EntityBoundary{\" foo\" :\" bar\" }ContentBoundary" );
@@ -162,10 +166,12 @@ public void execute_uploadFileImageContent_exception() throws FMSException, IOEx
162166 message .getRequestElements ().setEntity (attachable );
163167 message .getRequestElements ().setObjectToSerialize (jaxbElement );
164168
165- new Expectations (ImageIO .class ) {{
166- ImageIO .write ((RenderedImage ) any , anyString , (ByteArrayOutputStream ) any );
167- result = new IOException ("IOException thrown" );
168- }};
169+ new MockUp <ImageIO >() {
170+ @ Mock
171+ public boolean write (RenderedImage image , String formatName , OutputStream output ) throws IOException {
172+ throw new IOException ("IOException thrown" );
173+ }
174+ };
169175
170176 serializeInterceptor .execute (message );
171177 Assert .assertEquals (message .getRequestElements ().getSerializedData (), "EntityBoundary{\" foo\" :\" bar\" }ContentBoundary" );
0 commit comments