Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java Thu Dec 24 18:42:29 2020 @@ -17,10 +17,10 @@ package org.apache.poi.hslf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -33,8 +33,8 @@ import org.apache.poi.hslf.usermodel.HSL import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.TempFile; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that HSLFSlideShow writes the powerpoint bit of data back out @@ -52,11 +52,11 @@ public final class TestReWrite { private POIFSFileSystem pfsB; private POIFSFileSystem pfsC; - @Before + @BeforeEach public void setUp() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - + pfsA = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); hssA = new HSLFSlideShowImpl(pfsA); @@ -72,39 +72,39 @@ public final class TestReWrite { assertWritesOutTheSame(hssA, pfsA); assertWritesOutTheSame(hssB, pfsB); } - + public void assertWritesOutTheSame(HSLFSlideShowImpl hss, POIFSFileSystem pfs) throws Exception { // Write out to a byte array, and to a temp file ByteArrayOutputStream baos = new ByteArrayOutputStream(); hss.write(baos); - + final File file = TempFile.createTempFile("TestHSLF", ".ppt"); final File file2 = TempFile.createTempFile("TestHSLF", ".ppt"); hss.write(file); hss.write(file2); - + // Build an input stream of it, and read back as a POIFS from the stream ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); POIFSFileSystem npfS = new POIFSFileSystem(bais); - + // And the same on the temp file POIFSFileSystem npfF = new POIFSFileSystem(file); - + // And another where we do an in-place write POIFSFileSystem npfRF = new POIFSFileSystem(file2, false); HSLFSlideShowImpl hssRF = new HSLFSlideShowImpl(npfRF); hssRF.write(); hssRF.close(); npfRF = new POIFSFileSystem(file2); - + // Check all of them in turn for (POIFSFileSystem npf : new POIFSFileSystem[] { npfS, npfF, npfRF }) { // Check that the "PowerPoint Document" sections have the same size DocumentEntry oProps = (DocumentEntry)pfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT); DocumentEntry nProps = (DocumentEntry)npf.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT); assertEquals(oProps.getSize(),nProps.getSize()); - + // Check that they contain the same data byte[] _oData = new byte[oProps.getSize()]; byte[] _nData = new byte[nProps.getSize()]; @@ -155,7 +155,7 @@ public final class TestReWrite { // We need to identify and fix that first //assertSlideShowWritesOutTheSame(hssB, pfsB); } - + public void assertSlideShowWritesOutTheSame(HSLFSlideShowImpl hss, POIFSFileSystem pfs) throws IOException { // Create a slideshow covering it @SuppressWarnings("resource") @@ -190,7 +190,7 @@ public final class TestReWrite { } npfs.close(); } - + @Test public void test48593() throws IOException { HSLFSlideShow ppt1 = new HSLFSlideShow();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java Thu Dec 24 18:42:29 2020 @@ -19,7 +19,7 @@ package org.apache.poi.hslf; import static org.apache.poi.POITestCase.assertContains; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -33,9 +33,9 @@ import org.apache.poi.hslf.record.Record import org.apache.poi.hslf.record.UserEditAtom; import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that HSLFSlideShow writes the powerpoint bit of data back out @@ -49,14 +49,14 @@ public final class TestReWriteSanity { // POIFS primed on the test data private POIFSFileSystem pfs; - @Before + @BeforeEach public void setUp() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); ss = new HSLFSlideShowImpl(pfs); } - - @After + + @AfterEach public void tearDown() throws Exception { pfs.close(); ss.close(); @@ -113,7 +113,7 @@ public final class TestReWriteSanity { CurrentUserAtom cua = wss.getCurrentUserAtom(); int listedUEPos = (int)cua.getCurrentEditOffset(); assertEquals(lastUEPos,listedUEPos); - + wss.close(); } } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java Thu Dec 24 18:42:29 2020 @@ -18,7 +18,7 @@ package org.apache.poi.hslf; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.poi.POIDataSamples; import org.apache.poi.hslf.record.Notes; @@ -26,8 +26,8 @@ import org.apache.poi.hslf.record.Record import org.apache.poi.hslf.record.Slide; import org.apache.poi.hslf.record.SlideListWithText; import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that HSLFSlideShow returns the right numbers of key records when @@ -39,7 +39,7 @@ public final class TestRecordCounts { // HSLFSlideShow primed on the test data private HSLFSlideShowImpl ss; - @Before + @BeforeEach public void setup() throws Exception { ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java Thu Dec 24 18:42:29 2020 @@ -16,8 +16,8 @@ ==================================================================== */ package org.apache.poi.hslf.dev; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; import java.io.PrintStream; @@ -29,19 +29,19 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.stream.Stream; import org.apache.poi.POIDataSamples; import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException; import org.apache.poi.hslf.exceptions.OldPowerPointFormatException; import org.apache.poi.util.IOUtils; import org.apache.poi.util.NullPrintStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public abstract class BasePPTIteratingTest { protected static final Set<String> OLD_FILES = new HashSet<>(); static { @@ -60,22 +60,21 @@ public abstract class BasePPTIteratingTe protected static final Map<String,Class<? extends Throwable>> EXCLUDED = new HashMap<>(); - @Parameterized.Parameters(name="{index}: {0}") - public static Iterable<Object[]> files() { + public static Stream<Arguments> files() { String dataDirName = System.getProperty(POIDataSamples.TEST_PROPERTY); if(dataDirName == null) { dataDirName = "test-data"; } - List<Object[]> files = new ArrayList<>(); + List<Arguments> files = new ArrayList<>(); findFile(files, dataDirName + "/slideshow"); - return files; + return files.stream(); } private final PrintStream save = System.out; - @Before + @BeforeEach public void setUpBase() throws UnsupportedEncodingException { // set a higher max allocation limit as some test-files require more IOUtils.setByteArrayMaxOverride(5*1024*1024); @@ -84,7 +83,7 @@ public abstract class BasePPTIteratingTe System.setOut(new NullPrintStream()); } - @After + @AfterEach public void tearDownBase() { System.setOut(save); @@ -92,21 +91,19 @@ public abstract class BasePPTIteratingTe IOUtils.setByteArrayMaxOverride(-1); } - private static void findFile(List<Object[]> list, String dir) { + private static void findFile(List<Arguments> list, String dir) { String[] files = new File(dir).list((arg0, arg1) -> arg1.toLowerCase(Locale.ROOT).endsWith(".ppt")); - assertNotNull("Did not find any ppt files in directory " + dir, files); + assertNotNull(files, "Did not find any ppt files in directory " + dir); for(String file : files) { - list.add(new Object[] { new File(dir, file) }); + list.add(Arguments.of(new File(dir, file))); } } - @Parameterized.Parameter - public File file; - - @Test - public void testAllFiles() throws Exception { + @ParameterizedTest + @MethodSource("files") + public void testAllFiles(File file) throws Exception { String fileName = file.getName(); Class<? extends Throwable> t = null; if (EXCLUDED.containsKey(fileName)) { Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPDrawingTextListing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPDrawingTextListing.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPDrawingTextListing.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPDrawingTextListing.java Thu Dec 24 18:42:29 2020 @@ -17,24 +17,19 @@ package org.apache.poi.hslf.dev; import org.apache.poi.EmptyFileException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class TestPPDrawingTextListing extends BasePPTIteratingTest { @Test public void testMain() throws IOException { // calls System.exit(): PPDrawingTextListing.main(new String[0]); - - try { - PPDrawingTextListing.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> PPDrawingTextListing.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java Thu Dec 24 18:42:29 2020 @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.hslf.dev; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; import java.util.Collections; @@ -24,7 +24,7 @@ import java.util.Set; import org.apache.poi.EmptyFileException; import org.apache.poi.hslf.HSLFTestDataSamples; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestPPTXMLDump extends BasePPTIteratingTest { @Test Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTListing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTListing.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTListing.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTListing.java Thu Dec 24 18:42:29 2020 @@ -16,7 +16,8 @@ ==================================================================== */ package org.apache.poi.hslf.dev; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; import java.io.IOException; @@ -24,20 +25,20 @@ import java.io.PrintStream; import org.apache.poi.EmptyFileException; import org.apache.poi.util.NullPrintStream; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class TestSLWTListing extends BasePPTIteratingTest { private static PrintStream oldStdErr; - @BeforeClass + @BeforeAll public static void muteStdErr() { oldStdErr = System.err; System.setErr(new NullPrintStream()); } - @AfterClass + @AfterAll public static void restoreStdErr() { System.setErr(oldStdErr); } @@ -45,12 +46,7 @@ public class TestSLWTListing extends Bas @Test public void testMain() throws IOException { // calls System.exit(): SLWTListing.main(new String[0]); - try { - SLWTListing.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> SLWTListing.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTTextListing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTTextListing.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTTextListing.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSLWTTextListing.java Thu Dec 24 18:42:29 2020 @@ -17,24 +17,19 @@ package org.apache.poi.hslf.dev; import org.apache.poi.EmptyFileException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class TestSLWTTextListing extends BasePPTIteratingTest { @Test public void testMain() throws IOException { // calls System.exit(): SLWTTextListing.main(new String[0]); - - try { - SLWTTextListing.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> SLWTTextListing.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideAndNotesAtomListing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideAndNotesAtomListing.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideAndNotesAtomListing.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideAndNotesAtomListing.java Thu Dec 24 18:42:29 2020 @@ -18,12 +18,13 @@ package org.apache.poi.hslf.dev; import org.apache.poi.EmptyFileException; import org.apache.poi.hslf.HSLFTestDataSamples; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class TestSlideAndNotesAtomListing extends BasePPTIteratingTest { @Test @@ -32,13 +33,7 @@ public class TestSlideAndNotesAtomListin SlideAndNotesAtomListing.main(new String[] { HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath() }); - - try { - SlideAndNotesAtomListing.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> SlideAndNotesAtomListing.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideIdListing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideIdListing.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideIdListing.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideIdListing.java Thu Dec 24 18:42:29 2020 @@ -18,12 +18,13 @@ package org.apache.poi.hslf.dev; import org.apache.poi.EmptyFileException; import org.apache.poi.hslf.HSLFTestDataSamples; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class TestSlideIdListing extends BasePPTIteratingTest { @Test @@ -32,13 +33,7 @@ public class TestSlideIdListing extends SlideIdListing.main(new String[] { HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath() }); - - try { - SlideIdListing.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> SlideIdListing.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java Thu Dec 24 18:42:29 2020 @@ -16,7 +16,8 @@ ==================================================================== */ package org.apache.poi.hslf.dev; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; import java.io.FileNotFoundException; @@ -28,7 +29,7 @@ import java.util.Set; import org.apache.poi.EmptyFileException; import org.apache.poi.hslf.HSLFTestDataSamples; import org.apache.poi.util.IOUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestSlideShowDumper extends BasePPTIteratingTest { private static final Set<String> FAILING = new HashSet<>(); @@ -47,13 +48,7 @@ public class TestSlideShowDumper extends HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath(), HSLFTestDataSamples.getSampleFile("pictures.ppt").getAbsolutePath() }); - - try { - SlideShowDumper.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> SlideShowDumper.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java Thu Dec 24 18:42:29 2020 @@ -16,14 +16,15 @@ ==================================================================== */ package org.apache.poi.hslf.dev; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; import java.io.IOException; import org.apache.poi.EmptyFileException; import org.apache.poi.hslf.HSLFTestDataSamples; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestSlideShowRecordDumper extends BasePPTIteratingTest { @Test @@ -42,12 +43,7 @@ public class TestSlideShowRecordDumper e HSLFTestDataSamples.getSampleFile("pictures.ppt").getAbsolutePath() }); - try { - SlideShowRecordDumper.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> SlideShowRecordDumper.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestTextStyleListing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestTextStyleListing.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestTextStyleListing.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestTextStyleListing.java Thu Dec 24 18:42:29 2020 @@ -17,14 +17,15 @@ package org.apache.poi.hslf.dev; import org.apache.poi.EmptyFileException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.HashSet; import java.util.Set; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class TestTextStyleListing extends BasePPTIteratingTest { private static Set<String> FAILING = new HashSet<>(); @@ -35,12 +36,7 @@ public class TestTextStyleListing extend @Test public void testMain() throws IOException { // calls System.exit(): TextStyleListing.main(new String[0]); - try { - TextStyleListing.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> TextStyleListing.main(new String[]{"invalidfile"})); } @Override @@ -48,7 +44,7 @@ public class TestTextStyleListing extend try { TextStyleListing.main(new String[]{pFile.getAbsolutePath()}); } catch (ArrayIndexOutOfBoundsException e) { - // some corrupted documents currently can cause this excpetion + // some corrupted documents currently can cause this exception if (!FAILING.contains(pFile.getName())) { throw e; } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestUserEditAndPersistListing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestUserEditAndPersistListing.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestUserEditAndPersistListing.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestUserEditAndPersistListing.java Thu Dec 24 18:42:29 2020 @@ -17,24 +17,19 @@ package org.apache.poi.hslf.dev; import org.apache.poi.EmptyFileException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class TestUserEditAndPersistListing extends BasePPTIteratingTest { @Test public void testMain() throws IOException { // calls System.exit(): UserEditAndPersistListing.main(new String[0]); - - try { - UserEditAndPersistListing.main(new String[]{"invalidfile"}); - fail("Should catch exception here"); - } catch (EmptyFileException e) { - // expected here - } + assertThrows(EmptyFileException.class, () -> UserEditAndPersistListing.main(new String[]{"invalidfile"})); } @Override Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java Thu Dec 24 18:42:29 2020 @@ -18,14 +18,14 @@ package org.apache.poi.hslf.extractor; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; import org.apache.poi.POIDataSamples; import org.apache.poi.util.StringUtil; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that the QuickButCruddyTextExtractor works correctly @@ -62,7 +62,7 @@ public final class TestCruddyExtractor { "This is page two\nIt has several blocks of text\nNone of them have formatting", }; - @Before + @BeforeEach public void setup() throws Exception { te = new QuickButCruddyTextExtractor(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java Thu Dec 24 18:42:29 2020 @@ -20,10 +20,10 @@ package org.apache.poi.hslf.extractor; import static org.apache.poi.POITestCase.assertContains; import static org.apache.poi.POITestCase.assertContainsIgnoreCase; import static org.apache.poi.POITestCase.assertNotContained; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayOutputStream; import java.io.File; @@ -45,7 +45,7 @@ import org.apache.poi.sl.usermodel.Objec import org.apache.poi.sl.usermodel.SlideShow; import org.apache.poi.sl.usermodel.SlideShowFactory; import org.apache.poi.util.IOUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests that the extractor correctly gets the text out of our sample file @@ -74,19 +74,18 @@ public final class TestExtractor { /** * Where our embeded files live */ - private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); + private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - @SuppressWarnings("unchecked") private SlideShowExtractor<?,?> openExtractor(String fileName) throws IOException { try (InputStream is = slTests.openResourceAsStream(fileName)) { - return new SlideShowExtractor(SlideShowFactory.create(is)); + return new SlideShowExtractor<>(SlideShowFactory.create(is)); } } - + @Test public void testReadSheetText() throws IOException { // Basic 2 page example - try (SlideShowExtractor ppe = openExtractor("basic_test_ppt_file.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("basic_test_ppt_file.ppt")) { assertEquals(EXPECTED_PAGE1+EXPECTED_PAGE2, ppe.getText()); } @@ -98,7 +97,7 @@ public final class TestExtractor { "Plain Text \n"; // 1 page example with text boxes - try (SlideShowExtractor ppe = openExtractor("with_textbox.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("with_textbox.ppt")) { assertEquals(expectText2, ppe.getText()); } } @@ -106,7 +105,7 @@ public final class TestExtractor { @Test public void testReadNoteText() throws IOException { // Basic 2 page example - try (SlideShowExtractor ppe = openExtractor("basic_test_ppt_file.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("basic_test_ppt_file.ppt")) { ppe.setNotesByDefault(true); ppe.setSlidesByDefault(false); ppe.setMasterByDefault(false); @@ -115,7 +114,7 @@ public final class TestExtractor { } // Other one doesn't have notes - try (SlideShowExtractor ppe = openExtractor("with_textbox.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("with_textbox.ppt")) { ppe.setNotesByDefault(true); ppe.setSlidesByDefault(false); ppe.setMasterByDefault(false); @@ -130,7 +129,7 @@ public final class TestExtractor { String[] slText = { EXPECTED_PAGE1, EXPECTED_PAGE2 }; String[] ntText = { NOTES_PAGE1, NOTES_PAGE2 }; - try (SlideShowExtractor ppe = openExtractor("basic_test_ppt_file.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("basic_test_ppt_file.ppt")) { ppe.setSlidesByDefault(true); ppe.setNotesByDefault(false); assertEquals(slText[0] + slText[1], ppe.getText()); @@ -199,10 +198,10 @@ public final class TestExtractor { @Test public void testExtractFromOwnEmbeded() throws IOException { try (SlideShowExtractor<?,?> ppe = openExtractor("ppt_with_embeded.ppt")) { - List<? extends ObjectShape> shapes = ppe.getOLEShapes(); - assertEquals("Expected 6 ole shapes", 6, shapes.size()); + List<? extends ObjectShape<?,?>> shapes = ppe.getOLEShapes(); + assertEquals(6, shapes.size(), "Expected 6 ole shapes"); int num_ppt = 0, num_doc = 0, num_xls = 0; - for (ObjectShape ole : shapes) { + for (ObjectShape<?,?> ole : shapes) { String name = ((HSLFObjectShape)ole).getInstanceName(); InputStream data = ole.getObjectData().getInputStream(); if ("Worksheet".equals(name)) { @@ -220,9 +219,9 @@ public final class TestExtractor { } data.close(); } - assertEquals("Expected 2 embedded Word Documents", 2, num_doc); - assertEquals("Expected 2 embedded Excel Spreadsheets", 2, num_xls); - assertEquals("Expected 2 embedded PowerPoint Presentations", 2, num_ppt); + assertEquals(2, num_doc, "Expected 2 embedded Word Documents"); + assertEquals(2, num_xls, "Expected 2 embedded Excel Spreadsheets"); + assertEquals(2, num_ppt, "Expected 2 embedded PowerPoint Presentations"); } } @@ -232,7 +231,7 @@ public final class TestExtractor { @Test public void test52991() throws IOException { try (SlideShowExtractor<?,?> ppe = openExtractor("badzip.ppt")) { - for (ObjectShape shape : ppe.getOLEShapes()) { + for (ObjectShape<?,?> shape : ppe.getOLEShapes()) { IOUtils.copy(shape.getObjectData().getInputStream(), new ByteArrayOutputStream()); } } @@ -243,9 +242,9 @@ public final class TestExtractor { */ @Test public void testWithComments() throws IOException { - try (final SlideShowExtractor ppe = openExtractor("WithComments.ppt")) { + try (final SlideShowExtractor<?,?> ppe = openExtractor("WithComments.ppt")) { String text = ppe.getText(); - assertFalse("Comments not in by default", text.contains("This is a test comment")); + assertFalse(text.contains("This is a test comment"), "Comments not in by default"); ppe.setCommentsByDefault(true); @@ -255,9 +254,9 @@ public final class TestExtractor { // And another file - try (SlideShowExtractor ppe = openExtractor("45543.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("45543.ppt")) { String text = ppe.getText(); - assertFalse("Comments not in by default", text.contains("testdoc")); + assertFalse(text.contains("testdoc"), "Comments not in by default"); ppe.setCommentsByDefault(true); @@ -294,8 +293,8 @@ public final class TestExtractor { private void testHeaderFooterInner(final HSLFSlideShow ppt) throws IOException { try (final SlideShowExtractor<?,?> ppe = new SlideShowExtractor<>(ppt)) { String text = ppe.getText(); - assertFalse("Header shouldn't be there by default\n" + text, text.contains("testdoc")); - assertFalse("Header shouldn't be there by default\n" + text, text.contains("test phrase")); + assertFalse(text.contains("testdoc"), "Header shouldn't be there by default\n" + text); + assertFalse(text.contains("test phrase"), "Header shouldn't be there by default\n" + text); ppe.setNotesByDefault(true); text = ppe.getText(); @@ -309,7 +308,7 @@ public final class TestExtractor { String masterTitleText = "This is the Master Title"; String masterRandomText = "This text comes from the Master Slide"; String masterFooterText = "Footer from the master slide"; - try (final SlideShowExtractor ppe = openExtractor("WithMaster.ppt")) { + try (final SlideShowExtractor<?,?> ppe = openExtractor("WithMaster.ppt")) { ppe.setMasterByDefault(true); String text = ppe.getText(); @@ -329,7 +328,7 @@ public final class TestExtractor { @Test public void testSlideMasterText2() throws IOException { - try (final SlideShowExtractor ppe = openExtractor("bug62591.ppt")) { + try (final SlideShowExtractor<?,?> ppe = openExtractor("bug62591.ppt")) { ppe.setMasterByDefault(true); String text = ppe.getText(); assertNotContained(text, "Titelmasterformat"); @@ -338,7 +337,7 @@ public final class TestExtractor { @Test public void testMasterText() throws IOException { - try (final SlideShowExtractor ppe = openExtractor("master_text.ppt")) { + try (final SlideShowExtractor<?,?> ppe = openExtractor("master_text.ppt")) { // Initially not there String text = ppe.getText(); assertFalse(text.contains("Text that I added to the master slide")); @@ -354,7 +353,7 @@ public final class TestExtractor { // Now with another file only containing master text // Will always show up - try (final SlideShowExtractor ppe = openExtractor("WithMaster.ppt")) { + try (final SlideShowExtractor<?,?> ppe = openExtractor("WithMaster.ppt")) { String masterText = "Footer from the master slide"; String text = ppe.getText(); @@ -368,7 +367,7 @@ public final class TestExtractor { */ @Test public void testChineseText() throws IOException { - try (final SlideShowExtractor ppe = openExtractor("54880_chinese.ppt")) { + try (final SlideShowExtractor<?,?> ppe = openExtractor("54880_chinese.ppt")) { String text = ppe.getText(); // Check for the english text line @@ -405,7 +404,7 @@ public final class TestExtractor { @Test public void testTable() throws Exception { - try (SlideShowExtractor ppe = openExtractor("54111.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("54111.ppt")) { String text = ppe.getText(); String target = "TH Cell 1\tTH Cell 2\tTH Cell 3\tTH Cell 4\n" + "Row 1, Cell 1\tRow 1, Cell 2\tRow 1, Cell 3\tRow 1, Cell 4\n" + @@ -416,7 +415,7 @@ public final class TestExtractor { assertContains(text, target); } - try (SlideShowExtractor ppe = openExtractor("54722.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("54722.ppt")) { String text = ppe.getText(); String target = "this\tText\tis\twithin\ta\n" + @@ -428,7 +427,7 @@ public final class TestExtractor { // bug 60003 @Test public void testExtractMasterSlideFooterText() throws Exception { - try (SlideShowExtractor ppe = openExtractor("60003.ppt")) { + try (SlideShowExtractor<?,?> ppe = openExtractor("60003.ppt")) { ppe.setMasterByDefault(true); String text = ppe.getText(); @@ -438,7 +437,7 @@ public final class TestExtractor { @Test public void testExtractGroupedShapeText() throws Exception { - try (final SlideShowExtractor ppe = openExtractor("bug62092.ppt")) { + try (final SlideShowExtractor<?,?> ppe = openExtractor("bug62092.ppt")) { final String text = ppe.getText(); //this tests that we're ignoring text shapes at depth=0 @@ -476,7 +475,7 @@ public final class TestExtractor { "Times New Roman", "\t\n ,-./01234679:ABDEFGILMNOPRSTVWabcdefghijklmnoprstuvwxyz\u00F3\u201C\u201D", "Arial", " Lacdilnost" }; - try (SlideShowExtractor ppt = openExtractor("45543.ppt")) { + try (SlideShowExtractor<?,?> ppt = openExtractor("45543.ppt")) { for (int i=0; i<expected.length; i+=2) { BitSet l = ppt.getCodepoints(expected[i], null, null); String s = l.stream().mapToObj(Character::toChars).map(String::valueOf).collect(Collectors.joining()); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java Thu Dec 24 18:42:29 2020 @@ -17,8 +17,8 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.geom.Area; import java.awt.geom.Line2D; @@ -26,7 +26,7 @@ import java.awt.geom.Path2D; import java.awt.geom.Rectangle2D; import org.apache.poi.hslf.usermodel.HSLFFreeformShape; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test Freeform object. Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java Thu Dec 24 18:42:29 2020 @@ -17,10 +17,10 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.InputStream; @@ -36,7 +36,7 @@ import org.apache.poi.sl.usermodel.Slide import org.apache.poi.sl.usermodel.SlideShow; import org.apache.poi.sl.usermodel.TextParagraph; import org.apache.poi.sl.usermodel.TextShape; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test {@link org.apache.poi.hslf.model.HeadersFooters} object @@ -127,7 +127,7 @@ public final class TestHeadersFooters assertFalse(hd1.isUserDateVisible()); assertNull(hd1.getDateTimeText()); } - + ppt.close(); } @@ -210,7 +210,7 @@ public final class TestHeadersFooters assertTrue(hdd2.isSlideNumberVisible()); assertTrue(hdd2.isFooterVisible()); assertEquals("My slide footer", hdd2.getFooterText()); - + ppt2.close(); ppt1.close(); } @@ -230,7 +230,7 @@ public final class TestHeadersFooters assertEquals("My notes footer", hdd2.getFooterText()); assertTrue(hdd2.isHeaderVisible()); assertEquals("My notes header", hdd2.getHeaderText()); - + ppt2.close(); ppt1.close(); } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java Thu Dec 24 18:42:29 2020 @@ -19,8 +19,8 @@ package org.apache.poi.hslf.model; import static org.apache.poi.hslf.usermodel.HSLFTextParagraph.getRawText; import static org.apache.poi.hslf.usermodel.HSLFTextParagraph.toExternalString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.awt.geom.Rectangle2D; import java.io.IOException; @@ -37,8 +37,7 @@ import org.apache.poi.hslf.usermodel.HSL import org.apache.poi.hslf.usermodel.HSLFTextBox; import org.apache.poi.hslf.usermodel.HSLFTextParagraph; import org.apache.poi.hslf.usermodel.HSLFTextRun; -import org.apache.poi.sl.usermodel.Hyperlink; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test Hyperlink. Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java Thu Dec 24 18:42:29 2020 @@ -25,7 +25,7 @@ import org.apache.poi.hslf.usermodel.HSL import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound; import org.apache.poi.sl.usermodel.StrokeStyle.LineDash; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test Line shape. @@ -126,7 +126,7 @@ public final class TestLine { line.setLineCompound(LineCompound.DOUBLE); line.setLineWidth(8.0); slide.addShape(line); - + ppt.close(); } } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java Thu Dec 24 18:42:29 2020 @@ -17,9 +17,9 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; @@ -30,7 +30,7 @@ import org.apache.poi.hslf.usermodel.HSL import org.apache.poi.hslf.usermodel.HSLFSlide; import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.PictureData.PictureType; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test <code>MovieShape</code> object. Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java Thu Dec 24 18:42:29 2020 @@ -17,8 +17,8 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; @@ -30,37 +30,34 @@ import java.util.List; import org.apache.poi.POIDataSamples; import org.apache.poi.hslf.usermodel.HSLFObjectData; +import org.apache.poi.hslf.usermodel.HSLFObjectShape; import org.apache.poi.hslf.usermodel.HSLFPictureData; import org.apache.poi.hslf.usermodel.HSLFShape; import org.apache.poi.hslf.usermodel.HSLFSlide; import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; -import org.apache.poi.hslf.usermodel.HSLFObjectShape; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.sl.usermodel.PictureData.PictureType; import org.apache.poi.util.IOUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; +/** Tests support for OLE objects. */ public final class TestOleEmbedding { - private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); - /** - * Tests support for OLE objects. - * - * @throws Exception if an error occurs. - */ + private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); + @Test public void testOleEmbedding2003() throws IOException { HSLFSlideShowImpl slideShow = new HSLFSlideShowImpl(_slTests.openResourceAsStream("ole2-embedding-2003.ppt")); // Placeholder EMFs for clients that don't support the OLE components. List<HSLFPictureData> pictures = slideShow.getPictureData(); - assertEquals("Should be two pictures", 2, pictures.size()); + assertEquals(2, pictures.size(), "Should be two pictures"); - long[] checkSums = {0xD37A4204l, 0x26A62F68l, 0x82853169l, 0xE0E45D2Bl}; + long[] checkSums = {0xD37A4204L, 0x26A62F68L, 0x82853169L, 0xE0E45D2BL}; int checkId = 0; - + // check for checksum to be uptodate for (HSLFPictureData pd : pictures) { long checkEMF = IOUtils.calculateChecksum(pd.getData()); @@ -69,16 +66,16 @@ public final class TestOleEmbedding { // Actual embedded objects. HSLFObjectData[] objects = slideShow.getEmbeddedObjects(); - assertEquals("Should be two objects", 2, objects.length); + assertEquals(2, objects.length, "Should be two objects"); for (HSLFObjectData od : objects) { long checkEMF = IOUtils.calculateChecksum(od.getInputStream()); assertEquals(checkSums[checkId++], checkEMF); } - + slideShow.close(); } - - + + @Test public void testOLEShape() throws IOException { @@ -112,29 +109,29 @@ public final class TestOleEmbedding { } } - assertEquals("Expected 2 OLE shapes", 2, cnt); + assertEquals(2, cnt, "Expected 2 OLE shapes"); ppt.close(); } - + @Test public void testEmbedding() throws IOException { HSLFSlideShow ppt = new HSLFSlideShow(); - + File pict = POIDataSamples.getSlideShowInstance().getFile("clock.jpg"); HSLFPictureData pictData = ppt.addPicture(pict, PictureType.JPEG); - + InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("Employee.xls"); POIFSFileSystem poiData1 = new POIFSFileSystem(is); is.close(); - + int oleObjectId1 = ppt.addEmbed(poiData1); - + HSLFSlide slide1 = ppt.createSlide(); HSLFObjectShape oleShape1 = new HSLFObjectShape(pictData); oleShape1.setObjectID(oleObjectId1); slide1.addShape(oleShape1); oleShape1.setAnchor(new Rectangle2D.Double(100,100,100,100)); - + // add second slide with different order in object creation HSLFSlide slide2 = ppt.createSlide(); HSLFObjectShape oleShape2 = new HSLFObjectShape(pictData); @@ -142,30 +139,30 @@ public final class TestOleEmbedding { is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SimpleWithImages.xls"); POIFSFileSystem poiData2 = new POIFSFileSystem(is); is.close(); - + int oleObjectId2 = ppt.addEmbed(poiData2); oleShape2.setObjectID(oleObjectId2); slide2.addShape(oleShape2); oleShape2.setAnchor(new Rectangle2D.Double(100,100,100,100)); - + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ppt.write(bos); - + ppt = new HSLFSlideShow(new ByteArrayInputStream(bos.toByteArray())); HSLFObjectShape comp = (HSLFObjectShape)ppt.getSlides().get(0).getShapes().get(0); byte[] compData = IOUtils.toByteArray(comp.getObjectData().getInputStream()); - + bos.reset(); poiData1.writeFilesystem(bos); byte[] expData = bos.toByteArray(); - + assertArrayEquals(expData, compData); - + poiData1.close(); poiData2.close(); ppt.close(); } - + } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java Thu Dec 24 18:42:29 2020 @@ -17,7 +17,7 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; @@ -26,7 +26,7 @@ import org.apache.poi.common.usermodel.f import org.apache.poi.hslf.usermodel.HSLFFontInfo; import org.apache.poi.hslf.usermodel.HSLFFontInfoPredefined; import org.apache.poi.hslf.usermodel.HSLFSlideShow; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** @@ -57,7 +57,7 @@ public final class TestPPFont { assertEquals(HSLFFontInfoPredefined.WINGDINGS.getTypeface(), font3.getTypeface()); assertEquals(FontCharset.SYMBOL, font3.getCharset()); assertEquals(FontPitch.VARIABLE, font3.getPitch()); - + ppt.close(); } } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java Thu Dec 24 18:42:29 2020 @@ -17,13 +17,13 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import org.apache.poi.hslf.usermodel.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test setting text properties of newly added TextBoxes Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Thu Dec 24 18:42:29 2020 @@ -18,11 +18,11 @@ package org.apache.poi.hslf.model; import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.Color; import java.awt.Dimension; @@ -56,19 +56,19 @@ import org.apache.poi.hslf.usermodel.HSL import org.apache.poi.sl.usermodel.PictureData.PictureType; import org.apache.poi.sl.usermodel.ShapeType; import org.apache.poi.sl.usermodel.StrokeStyle.LineDash; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test drawing shapes via Graphics2D */ public final class TestShapes { - private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); + private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); private HSLFSlideShow ppt; private HSLFSlideShow pptB; - @Before + @BeforeEach public void setUp() throws Exception { try (InputStream is1 = _slTests.openResourceAsStream("empty.ppt"); InputStream is2 = _slTests.openResourceAsStream("empty_textbox.ppt")) { @@ -386,14 +386,14 @@ public final class TestShapes { HSLFSlideShow ss = new HSLFSlideShow(_slTests.openResourceAsStream(file)); HSLFSlide sl = ss.getSlides().get(0); List<HSLFShape> sh = sl.getShapes(); - assertEquals("expected four shaped in " + file, 4, sh.size()); + assertEquals(4, sh.size(), "expected four shaped in " + file); //remove all for (int i = 0; i < sh.size(); i++) { boolean ok = sl.removeShape(sh.get(i)); - assertTrue("Failed to delete shape #" + i, ok); + assertTrue(ok, "Failed to delete shape #" + i); } //now Slide.getShapes() should return an empty array - assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().size()); + assertEquals(0, sl.getShapes().size(), "expected 0 shaped in " + file); //serialize and read again. The file should be readable and contain no shapes ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -403,7 +403,7 @@ public final class TestShapes { ss = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); sl = ss.getSlides().get(0); - assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().size()); + assertEquals(0, sl.getShapes().size(), "expected 0 shaped in " + file); ss.close(); } @@ -449,9 +449,9 @@ public final class TestShapes { assertEquals(dgShapesUsed + 1, dg.getNumShapes()); //check that EscherDggRecord is updated - assertEquals("mismatch @"+i, shape.getShapeId() + 1, dgg.getShapeIdMax()); - assertEquals("mismatch @"+i, dggMaxId + 1, dgg.getShapeIdMax()); - assertEquals("mismatch @"+i, dggShapesUsed + 1, dgg.getNumShapesSaved()); + assertEquals(shape.getShapeId() + 1, dgg.getShapeIdMax(), "mismatch @"+i); + assertEquals(dggMaxId + 1, dgg.getShapeIdMax(), "mismatch @"+i); + assertEquals(dggShapesUsed + 1, dgg.getNumShapesSaved(), "mismatch @"+i); dggShapesUsed = dgg.getNumShapesSaved(); dggMaxId = dgg.getShapeIdMax(); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java Thu Dec 24 18:42:29 2020 @@ -17,8 +17,8 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; @@ -27,7 +27,7 @@ import org.apache.poi.hslf.exceptions.En import org.apache.poi.hslf.record.ColorSchemeAtom; import org.apache.poi.hslf.record.PPDrawing; import org.apache.poi.hslf.usermodel.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test common functionality of the <code>Sheet</code> object. @@ -36,7 +36,7 @@ import org.junit.Test; * @author Yegor Kozlov */ public final class TestSheet { - private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); + private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); /** * For each ppt in the test directory check that all sheets are properly initialized @@ -92,7 +92,7 @@ public final class TestSheet { } List<HSLFShape> shape = sheet.getShapes(); - assertTrue("no shapes", shape != null && !shape.isEmpty()); + assertTrue(shape != null && !shape.isEmpty(), "no shapes"); for (HSLFShape s : shape) { assertNotNull(s.getSpContainer()); assertNotNull(s.getSheet()); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java Thu Dec 24 18:42:29 2020 @@ -18,13 +18,13 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.poi.POIDataSamples; import org.apache.poi.hslf.record.SlideAtom; import org.apache.poi.hslf.usermodel.*; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that changing a slide's idea of what notes sheet is its works right @@ -35,7 +35,7 @@ public final class TestSlideChangeNotes // SlideShow primed on the test data private HSLFSlideShow ss; - @Before + @BeforeEach public void init() throws Exception { POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); HSLFSlideShowImpl hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java Thu Dec 24 18:42:29 2020 @@ -21,9 +21,9 @@ import static org.apache.poi.sl.usermode import static org.apache.poi.sl.usermodel.TextShape.TextPlaceholder.CENTER_BODY; import static org.apache.poi.sl.usermodel.TextShape.TextPlaceholder.CENTER_TITLE; import static org.apache.poi.sl.usermodel.TextShape.TextPlaceholder.TITLE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -43,7 +43,7 @@ import org.apache.poi.hslf.usermodel.HSL import org.apache.poi.hslf.usermodel.HSLFTextRun; import org.apache.poi.hslf.usermodel.HSLFTitleMaster; import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for SlideMaster @@ -103,7 +103,7 @@ public final class TestSlideMaster { return getMasterProp(ppt, masterIdx, txtype, propName, isCharacter).getValue(); } - + /** * Test we can read default text attributes for a title master sheet */ Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java Thu Dec 24 18:42:29 2020 @@ -17,15 +17,15 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import org.apache.poi.POIDataSamples; import org.apache.poi.hslf.usermodel.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test adding new slides to a ppt. Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java Thu Dec 24 18:42:29 2020 @@ -17,10 +17,11 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -38,7 +39,7 @@ import org.apache.poi.sl.usermodel.Slide import org.apache.poi.sl.usermodel.SlideShow; import org.apache.poi.sl.usermodel.TableShape; import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test <code>Table</code> object. @@ -108,20 +109,20 @@ public final class TestTable { } // Table(rownum, colnum) must throw IllegalArgumentException if any of the arguments is less than 1 - @Test(expected=IllegalArgumentException.class) + @Test public void testIllegalRowCnstruction() throws IOException { try (HSLFSlideShow ppt = new HSLFSlideShow()) { HSLFSlide slide = ppt.createSlide(); - slide.createTable(0, 5); + assertThrows(IllegalArgumentException.class, () -> slide.createTable(0, 5)); } } // Table(rownum, colnum) must throw IllegalArgumentException if any of the arguments is less than 1 - @Test(expected=IllegalArgumentException.class) + @Test public void testIllegalColConstruction() throws IOException { try (HSLFSlideShow ppt = new HSLFSlideShow()) { HSLFSlide slide = ppt.createSlide(); - slide.createTable(5, 0); + assertThrows(IllegalArgumentException.class, () -> slide.createTable(5, 0)); } } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java Thu Dec 24 18:42:29 2020 @@ -17,8 +17,8 @@ package org.apache.poi.hslf.model; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -32,8 +32,8 @@ import org.apache.poi.hslf.usermodel.HSL import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that if we load something up, get a TextRun, set the text @@ -47,7 +47,7 @@ public final class TestTextRunReWrite { /** * Load up a test PPT file with rich data */ - @Before + @BeforeEach public void setUp() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); String filename = "Single_Coloured_Page_With_Fonts_and_Alignments.ppt"; @@ -63,8 +63,8 @@ public final class TestTextRunReWrite { // Grab the first text run on the first sheet List<HSLFTextParagraph> tr1 = ss.getSlides().get(0).getTextParagraphs().get(0); List<HSLFTextParagraph> tr2 = ss.getSlides().get(0).getTextParagraphs().get(1); - - + + assertEquals(30, HSLFTextParagraph.getRawText(tr1).length()); assertEquals(179, HSLFTextParagraph.getRawText(tr2).length()); @@ -112,7 +112,7 @@ public final class TestTextRunReWrite { oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData); npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData); assertArrayEquals(_oData, _nData); - + npfs.close(); } @@ -159,7 +159,7 @@ public final class TestTextRunReWrite { // Check that the "PowerPoint Document" sections have the same size DirectoryNode oDir = ss.getSlideShowImpl().getDirectory(); - + DocumentEntry oProps = (DocumentEntry)oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT); DocumentEntry nProps = (DocumentEntry)npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT); assertEquals(oProps.getSize(),nProps.getSize()); @@ -171,7 +171,7 @@ public final class TestTextRunReWrite { oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData); npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData); assertArrayEquals(_oData, _nData); - + npfs.close(); } } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java Thu Dec 24 18:42:29 2020 @@ -18,14 +18,14 @@ package org.apache.poi.hslf.record; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests that {@link HeadersFootersAtom} works properly Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java Thu Dec 24 18:42:29 2020 @@ -18,12 +18,12 @@ package org.apache.poi.hslf.record; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.io.ByteArrayOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests that CString works properly @@ -105,7 +105,7 @@ public final class TestCString { break; } } - assertFalse("Arrays should not be equals", equals); + assertFalse(equals, "Arrays should not be equals"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ca.writeOut(baos); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java Thu Dec 24 18:42:29 2020 @@ -18,11 +18,11 @@ package org.apache.poi.hslf.record; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests that ColorSchemAtom works properly Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java Thu Dec 24 18:42:29 2020 @@ -18,10 +18,10 @@ package org.apache.poi.hslf.record; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayOutputStream; import java.text.SimpleDateFormat; @@ -29,8 +29,8 @@ import java.util.Date; import java.util.Locale; import org.apache.poi.util.LocaleUtil; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Tests that Comment2000 works properly. @@ -41,59 +41,59 @@ import org.junit.Test; public final class TestComment2000 { // From a real file private final byte[] data_a = new byte[] { - 0x0F, 00, 0xE0-256, 0x2E, 0x9C-256, 00, 00, 00, - 00, 00, 0xBA-256, 0x0F, 0x14, 00, 00, 00, - 0x44, 00, 0x75, 00, 0x6D, 00, 0x62, 00, - 0x6C, 00, 0x65, 00, 0x64, 00, 0x6F, 00, - 0x72, 00, 0x65, 00, - 0x10, 00, 0xBA-256, 0x0F, 0x4A, 00, 00, 00, - 0x59, 00, 0x65, 00, 0x73, 00, 0x2C, 00, - 0x20, 00, 0x74, 00, 0x68, 00, 0x65, 00, - 0x79, 00, 0x20, 00, 0x63, 00, 0x65, 00, - 0x72, 00, 0x74, 00, 0x61, 00, 0x69, 00, - 0x6E, 00, 0x6C, 00, 0x79, 00, 0x20, 00, - 0x61, 00, 0x72, 00, 0x65, 00, 0x2C, 00, - 0x20, 00, 0x61, 00, 0x72, 00, 0x65, 00, - 0x6E, 00, 0x27, 00, 0x74, 00, 0x20, 00, - 0x74, 00, 0x68, 00, 0x65, 00, 0x79, 00, 0x21, 00, - 0x20, 00, 0xBA-256, 0x0F, 0x02, 00, 00, 00, - 0x44, 00, - 00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00, - 01, 00, 00, 00, 0xD6-256, 07, 01, 00, - 02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00, - 0x0F, 00, 0xCD-256, 00, 0x92-256, 00, - 00, 00, 0x92-256, 00, 00, 00 + 0x0F, 0, 0xE0-256, 0x2E, 0x9C-256, 0, 0, 0, + 0, 0, 0xBA-256, 0x0F, 0x14, 0, 0, 0, + 0x44, 0, 0x75, 0, 0x6D, 0, 0x62, 0, + 0x6C, 0, 0x65, 0, 0x64, 0, 0x6F, 0, + 0x72, 0, 0x65, 0, + 0x10, 0, 0xBA-256, 0x0F, 0x4A, 0, 0, 0, + 0x59, 0, 0x65, 0, 0x73, 0, 0x2C, 0, + 0x20, 0, 0x74, 0, 0x68, 0, 0x65, 0, + 0x79, 0, 0x20, 0, 0x63, 0, 0x65, 0, + 0x72, 0, 0x74, 0, 0x61, 0, 0x69, 0, + 0x6E, 0, 0x6C, 0, 0x79, 0, 0x20, 0, + 0x61, 0, 0x72, 0, 0x65, 0, 0x2C, 0, + 0x20, 0, 0x61, 0, 0x72, 0, 0x65, 0, + 0x6E, 0, 0x27, 0, 0x74, 0, 0x20, 0, + 0x74, 0, 0x68, 0, 0x65, 0, 0x79, 0, 0x21, 0, + 0x20, 0, 0xBA-256, 0x0F, 0x02, 0, 0, 0, + 0x44, 0, + 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0, + 0x01, 0, 0, 0, 0xD6-256, 0x07, 0x01, 0, + 0x02, 0, 0x18, 0, 0x0A, 0, 0x1A, 0, + 0x0F, 0, 0xCD-256, 0, 0x92-256, 0, + 0, 0, 0x92-256, 0, 0, 0 }; private final byte[] data_b = new byte[] { - 0x0F, 00, 0xE0-256, 0x2E, 0xAC-256, 00, 00, 00, - 00, 00, 0xBA-256, 0x0F, 0x10, 00, 00, 00, - 0x48, 00, 0x6F, 00, 0x67, 00, 0x77, 00, - 0x61, 00, 0x72, 00, 0x74, 00, 0x73, 00, - 0x10, 00, 0xBA-256, 0x0F, 0x5E, 00, 00, 00, - 0x43, 00, 0x6F, 00, 0x6D, 00, 0x6D, 00, - 0x65, 00, 0x6E, 00, 0x74, 00, 0x73, 00, - 0x20, 00, 0x61, 00, 0x72, 00, 0x65, 00, - 0x20, 00, 0x66, 00, 0x75, 00, 0x6E, 00, - 0x20, 00, 0x74, 00, 0x68, 00, 0x69, 00, - 0x6E, 00, 0x67, 00, 0x73, 00, 0x20, 00, - 0x74, 00, 0x6F, 00, 0x20, 00, 0x61, 00, - 0x64, 00, 0x64, 00, 0x20, 00, 0x69, 00, - 0x6E, 00, 0x2C, 00, 0x20, 00, 0x61, 00, - 0x72, 00, 0x65, 00, 0x6E, 00, 0x27, 00, - 0x74, 00, 0x20, 00, 0x74, 00, 0x68, 00, - 0x65, 00, 0x79, 00, 0x3F, 00, - 0x20, 00, 0xBA-256, 0x0F, 0x02, 00, 00, 00, - 0x48, 00, - 00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00, - 01, 00, 00, 00, 0xD6-256, 0x07, 01, 00, - 02, 00, 0x18, 00, 0x16, 00, 0x19, 00, 03, - 00, 0xD5-256, 02, 0x0A, 00, 00, 00, - 0x0A, 00, 00, 00 + 0x0F, 0, 0xE0-256, 0x2E, 0xAC-256, 0, 0, 0, + 0, 0, 0xBA-256, 0x0F, 0x10, 0, 0, 0, + 0x48, 0, 0x6F, 0, 0x67, 0, 0x77, 0, + 0x61, 0, 0x72, 0, 0x74, 0, 0x73, 0, + 0x10, 0, 0xBA-256, 0x0F, 0x5E, 0, 0, 0, + 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0, + 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0, + 0x20, 0, 0x61, 0, 0x72, 0, 0x65, 0, + 0x20, 0, 0x66, 0, 0x75, 0, 0x6E, 0, + 0x20, 0, 0x74, 0, 0x68, 0, 0x69, 0, + 0x6E, 0, 0x67, 0, 0x73, 0, 0x20, 0, + 0x74, 0, 0x6F, 0, 0x20, 0, 0x61, 0, + 0x64, 0, 0x64, 0, 0x20, 0, 0x69, 0, + 0x6E, 0, 0x2C, 0, 0x20, 0, 0x61, 0, + 0x72, 0, 0x65, 0, 0x6E, 0, 0x27, 0, + 0x74, 0, 0x20, 0, 0x74, 0, 0x68, 0, + 0x65, 0, 0x79, 0, 0x3F, 0, + 0x20, 0, 0xBA-256, 0x0F, 0x02, 0, 0, 0, + 0x48, 0, + 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0, + 0x01, 0, 0, 0, 0xD6-256, 0x07, 0x01, 0, + 0x02, 0, 0x18, 0, 0x16, 0, 0x19, 0, 0x03, + 0, 0xD5-256, 0x02, 0x0A, 0, 0, 0, + 0x0A, 0, 0, 0 }; private static SimpleDateFormat sdf; - @BeforeClass + @BeforeAll public static void initDateFormat() { sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ROOT); sdf.setTimeZone(LocaleUtil.getUserTimeZone()); @@ -198,7 +198,7 @@ public final class TestComment2000 { break; } } - assertFalse("Arrays should not be equals", equals); + assertFalse(equals, "Arrays should not be equals"); // Check bytes are now the same ByteArrayOutputStream baosa = new ByteArrayOutputStream(); @@ -230,7 +230,7 @@ public final class TestComment2000 { 0x00, (byte)0xBA, 0x0F, 0x02, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x00, 0x00, (byte)0xE1, 0x2E, 0x1C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, (byte)0xD9, 0x07, 0x08, 0x00, 0x01, 0x00, 0x18, 0x00, 0x10, 0x00, 0x1F, 0x00, 0x05, 0x00, (byte)0x80, 0x03, - 0x0A, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 00 + 0x0A, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00 }; Comment2000 ca = new Comment2000(data, 0, data.length); Record[] ch = ca.getChildRecords(); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java Thu Dec 24 18:42:29 2020 @@ -18,7 +18,7 @@ package org.apache.poi.hslf.record; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayOutputStream; import java.text.SimpleDateFormat; @@ -26,8 +26,8 @@ import java.util.Date; import java.util.Locale; import org.apache.poi.util.LocaleUtil; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Tests that Comment2000Atom works properly. @@ -52,8 +52,8 @@ public final class TestComment2000Atom { }; private static SimpleDateFormat sdf; - - @BeforeClass + + @BeforeAll public static void initDateFormat() { sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ROOT); sdf.setTimeZone(LocaleUtil.getUserTimeZone()); Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java Thu Dec 24 18:42:29 2020 @@ -17,9 +17,9 @@ package org.apache.poi.hslf.record; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -29,7 +29,7 @@ import org.apache.poi.hslf.exceptions.En import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests that CurrentUserAtom works properly. @@ -37,7 +37,7 @@ import org.junit.Test; * @author Nick Burch (nick at torchbox dot com) */ public final class TestCurrentUserAtom { - private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); + private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); /** Not encrypted */ private static final String normalFile = "basic_test_ppt_file.ppt"; /** Encrypted */ @@ -57,35 +57,33 @@ public final class TestCurrentUserAtom { // Round trip POIFSFileSystem poifs = new POIFSFileSystem(); cu.writeToFS(poifs); - + CurrentUserAtom cu2 = new CurrentUserAtom(poifs.getRoot()); assertEquals("Hogwarts", cu2.getLastEditUsername()); assertEquals(0x2942, cu2.getCurrentEditOffset()); - + poifs.close(); } - @Test(expected = EncryptedPowerPointFileException.class) + @Test public void readEnc() throws Exception { - try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(encFile))) { new CurrentUserAtom(fs.getRoot()); - assertTrue(true); // not yet failed - - new HSLFSlideShowImpl(fs).close(); + assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(fs).close()); } } @Test public void writeNormal() throws Exception { // Get raw contents from a known file - POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile)); - DocumentEntry docProps = (DocumentEntry)fs.getRoot().getEntry("Current User"); - byte[] contents = new byte[docProps.getSize()]; - InputStream in = fs.getRoot().createDocumentInputStream("Current User"); - in.read(contents); - in.close(); - fs.close(); + byte[] contents; + try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile))) { + DocumentEntry docProps = (DocumentEntry) fs.getRoot().getEntry("Current User"); + contents = new byte[docProps.getSize()]; + try (InputStream in = fs.getRoot().createDocumentInputStream("Current User")) { + in.read(contents); + } + } // Now build up a new one CurrentUserAtom cu = new CurrentUserAtom(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org