import java.io.ByteArrayOutputStream;\r
import java.io.IOException;\r
import java.io.InputStream;\r
-import java.io.OutputStream;\r
\r
/**\r
* @author Yegor Kozlov\r
*/\r
public class XSLFTestDataSamples {\r
\r
- public static XMLSlideShow openSampleDocument(String sampleName) throws IOException {\r
+ public static XMLSlideShow openSampleDocument(String sampleName) {\r
InputStream is = POIDataSamples.getSlideShowInstance().openResourceAsStream(sampleName);\r
try {\r
return new XMLSlideShow(OPCPackage.open(is));\r
} catch (Exception e) {\r
throw new RuntimeException(e);\r
} finally {\r
- is.close();\r
+ try {\r
+ is.close();\r
+ } catch (IOException e) {\r
+ throw new RuntimeException(e);\r
+ }\r
}\r
}\r
\r
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);\r
try {\r
doc.write(baos);\r
- } catch (Exception e) {\r
+ } catch (IOException e) {\r
throw new RuntimeException(e);\r
}\r
\r
} catch (Exception e) {\r
throw new RuntimeException(e);\r
} finally {\r
- baos.close();\r
- bais.close();\r
+ try {\r
+ baos.close();\r
+ bais.close();\r
+ } catch (IOException e) {\r
+ throw new RuntimeException(e);\r
+ }\r
}\r
\r
}\r
\r
import static org.junit.Assert.*;\r
\r
+import java.io.IOException;\r
import java.util.List;\r
\r
import org.apache.poi.xslf.XSLFTestDataSamples;\r
public class TestXSLFSheet {\r
\r
@Test\r
- public void testCreateShapes(){\r
+ public void testCreateShapes() throws IOException {\r
XMLSlideShow ppt = new XMLSlideShow();\r
XSLFSlide slide = ppt.createSlide();\r
assertTrue(slide.getShapes().isEmpty());\r
assertSame(shape3, slide.getShapes().get(2));\r
assertSame(shape4, slide.getShapes().get(3));\r
\r
- ppt = XSLFTestDataSamples.writeOutAndReadBack(ppt);\r
- slide = ppt.getSlides().get(0);\r
+ XMLSlideShow ppt2 = XSLFTestDataSamples.writeOutAndReadBack(ppt);\r
+ slide = ppt2.getSlides().get(0);\r
List<XSLFShape> shapes = slide.getShapes();\r
assertEquals(4, shapes.size());\r
\r
assertTrue(shapes.get(1) instanceof XSLFTextBox);\r
assertTrue(shapes.get(2) instanceof XSLFConnectorShape);\r
assertTrue(shapes.get(3) instanceof XSLFGroupShape);\r
+ \r
+ ppt.close();\r
+ ppt2.close();\r
}\r
}
\ No newline at end of file