View | Details | Raw Unified | Return to bug 60977
Collapse All | Expand All

(-)src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java (+34 lines)
Lines 30-35 Link Here
30
30
31
import org.apache.poi.POIXMLProperties.CoreProperties;
31
import org.apache.poi.POIXMLProperties.CoreProperties;
32
import org.apache.poi.openxml4j.util.Nullable;
32
import org.apache.poi.openxml4j.util.Nullable;
33
import org.apache.poi.ss.usermodel.Cell;
34
import org.apache.poi.ss.usermodel.Row;
35
import org.apache.poi.ss.usermodel.Sheet;
33
import org.apache.poi.util.LocaleUtil;
36
import org.apache.poi.util.LocaleUtil;
34
import org.apache.poi.xssf.XSSFTestDataSamples;
37
import org.apache.poi.xssf.XSSFTestDataSamples;
35
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
38
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
Lines 265-268 Link Here
265
            return String.valueOf(i);
268
            return String.valueOf(i);
266
        }
269
        }
267
    }
270
    }
271
272
    @Test
273
    public void testBug60977() throws IOException {
274
        try (final XSSFWorkbook workbook = new XSSFWorkbook()) {
275
            final Sheet sheet = workbook.createSheet("sheet");
276
            final Row row = sheet.createRow(0);
277
            final Cell cell = row.createCell(0);
278
            cell.setCellValue("cell");
279
280
            final POIXMLProperties properties = workbook.getProperties();
281
            final POIXMLProperties.CustomProperties customProperties = properties.getCustomProperties();
282
            customProperties.addProperty("Project", "Some name");
283
284
            ///* Manual test to write out the file more than once:
285
            try (final java.io.FileOutputStream fs = new java.io.FileOutputStream("C:\\temp\\test1.xlsx")) {
286
                workbook.write(fs);
287
            }
288
289
            try (final java.io.FileOutputStream fs = new java.io.FileOutputStream("C:\\temp\\test2.xlsx")) {
290
                workbook.write(fs);
291
            }
292
            //*/
293
294
            // in the unit-test just try to write out the file more than once and see if we can still parse it
295
            XSSFWorkbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(workbook);
296
            assertNotNull(wbBack);
297
298
            wbBack = XSSFTestDataSamples.writeOutAndReadBack(workbook);
299
            assertNotNull(wbBack);
300
        }
301
    }
268
}
302
}

Return to bug 60977