}
}
}
- throw new IOException("Your InputStream was neither an OLE2 stream, nor an OOXML stream " +
- "or you haven't provide the poi-ooxml*.jar and/or poi-scratchpad*.jar in the classpath/modulepath - FileMagic: "+fm);
+ throw new IOException(
+ "Your InputStream was neither an OLE2 stream, nor an OOXML stream " +
+ "or you haven't provide the poi-ooxml*.jar and/or poi-scratchpad*.jar in the classpath/modulepath - FileMagic: " + fm +
+ ", providers: " + Singleton.INSTANCE.provider);
}
public static void addProvider(ExtractorProvider provider){
}
}
throw new IOException("Your InputStream was neither an OLE2 stream, nor an OOXML stream " +
- "or you haven't provide the poi-ooxml*.jar in the classpath/modulepath - FileMagic: "+fm);
+ "or you haven't provide the poi-ooxml*.jar in the classpath/modulepath - FileMagic: " + fm +
+ ", having providers: " + Singleton.INSTANCE.provider);
}
public static void addProvider(WorkbookProvider provider){
@RunWith(Parameterized.class)
public class TestHxxFEncryption {
- @Parameter(value = 0)
+ @Parameter
public POIDataSamples sampleDir;
@Parameter(value = 1)
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
public class TestThemesTable {
- private final String testFileSimple = "Themes.xlsx";
- private final String testFileComplex = "Themes2.xlsx";
- // TODO .xls version available too, add HSSF support then check
+ private static final String testFileComplex = "Themes2.xlsx";
+ // TODO .xls version available too, add HSSF support then check
+
+ // For offline testing
+ private static final boolean createFiles = false;
// What colours they should show up as
- private static String[] rgbExpected = {
+ private static final String[] rgbExpected = {
"ffffff", // Lt1
"000000", // Dk1
"eeece1", // Lt2
@Test
public void testThemesTableColors() throws Exception {
// Load our two test workbooks
+ String testFileSimple = "Themes.xlsx";
XSSFWorkbook simple = XSSFTestDataSamples.openSampleWorkbook(testFileSimple);
XSSFWorkbook complex = XSSFTestDataSamples.openSampleWorkbook(testFileComplex);
// Save and re-load them, to check for stability across that
workbooks.put("Re-Saved_" + testFileSimple, simpleRS);
workbooks.put(testFileComplex, complex);
workbooks.put("Re-Saved_" + testFileComplex, complexRS);
-
+
// Sanity check
- assertEquals(rgbExpected.length, rgbExpected.length);
-
- // For offline testing
- boolean createFiles = false;
-
+ assertEquals(12, rgbExpected.length);
+
// Check each workbook in turn, and verify that the colours
// for the theme-applied cells in Column A are correct
for (String whatWorkbook : workbooks.keySet()) {
XSSFSheet sheet = workbook.getSheetAt(0);
int startRN = 0;
if (whatWorkbook.endsWith(testFileComplex)) startRN++;
-
+
for (int rn=startRN; rn<rgbExpected.length+startRN; rn++) {
XSSFRow row = sheet.getRow(rn);
assertNotNull("Missing row " + rn + " in " + whatWorkbook, row);
assertNotNull(ctColor);
assertTrue(ctColor.isSetTheme());
assertEquals(themeElem.idx, ctColor.getTheme());
-
+
// Get the colour, via the theme
XSSFColor color = font.getXSSFColor();
// Theme colours aren't tinted
assertEquals(
"Wrong theme index " + expectedThemeIdx + " on " + whatWorkbook,
expectedThemeIdx, themeIdx);
-
+
if (createFiles) {
XSSFCellStyle cs = row.getSheet().getWorkbook().createCellStyle();
cs.setFillForegroundColor(color);
row.createCell(1).setCellStyle(cs);
}
}
-
+
if (createFiles) {
FileOutputStream fos = new FileOutputStream("Generated_"+whatWorkbook);
workbook.write(fos);
* Column C = Explicit Colour Foreground
* Column E = Explicit Colour Background, Black Foreground
* Column G = Conditional Formatting Backgrounds
- *
- * Note - Grey Row has an odd way of doing the styling...
+ *
+ * Note - Grey Row has an odd way of doing the styling...
*/
@Test
public void themedAndNonThemedColours() throws IOException {
assertNull(color.getARGBHex());
}
}
-
+
// Check the CF colours
// TODO
}
private static void assertCellContents(String expected, XSSFCell cell) {
assertNotNull(cell);
- assertEquals(expected.toLowerCase(Locale.ROOT),
+ assertEquals(expected.toLowerCase(Locale.ROOT),
cell.getStringCellValue().toLowerCase(Locale.ROOT));
}
-
+
@Test
@SuppressWarnings("resource")
public void testAddNew() {
XSSFWorkbook wb = new XSSFWorkbook();
wb.createSheet();
assertNull(wb.getTheme());
-
+
StylesTable styles = wb.getStylesSource();
assertNull(styles.getTheme());
-
+
styles.ensureThemesTable();
-
+
assertNotNull(styles.getTheme());
assertNotNull(wb.getTheme());
-
+
wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
styles = wb.getStylesSource();
assertNotNull(styles.getTheme());
package org.apache.poi.hssf.record;
import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
-import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
"EQpiGoagbEQ3NMJCVEMSJiIMhTAMjxdcz2ERGmIaBqEiuqERElENSQhEGMrT+APX2vm3iyMAAA=="
);
- assertArrayEquals(data1, data1);
-
RecordInputStream in1 = TestcaseRecordInputStream.create(data1);
NameRecord nr1 = new NameRecord(in1);
assert_bug50244(nr1);
fe.clearAllCachedResultValues();
cv = fe.evaluate(cellB1);
// Identified bug 46898
- assertNotEquals(cv.getCellType(), ErrorEval.CIRCULAR_REF_ERROR.getErrorCode());
+ assertNotEquals(cv.getErrorValue(), ErrorEval.CIRCULAR_REF_ERROR.getErrorCode());
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(46.0, cv.getNumberValue(), 0.0);
cv = fe.evaluate(cellE1);
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(43.0, cv.getNumberValue(), 0.0);
-
}
}
}
private static final Locale ja_JP = Locale.JAPAN;
private static final TimeZone TOKYO = TimeZone.getTimeZone("Asia/Tokyo");
private static final Calendar JAPAN_CALENDAR = Calendar.getInstance(TOKYO, ja_JP);
-
+
/**
* Reset the Locale to the user default before the test so that it isn't influenced
* by the LocaleUtil's state being changed by previous tests.
// http://www.codeaffine.com/2014/07/21/a-junit-rule-to-run-a-test-in-its-own-thread/
LocaleUtil.setUserLocale(Locale.getDefault());
LocaleUtil.setUserTimeZone(TimeZone.getDefault());
-
+
assumeFalse(ja_JP.equals(LocaleUtil.getUserLocale()));
assumeFalse(TOKYO.equals(LocaleUtil.getUserTimeZone()));
}
LocaleUtil.resetUserLocale();
LocaleUtil.resetUserTimeZone();
}
-
+
@Test
@SuppressForbidden("implementation around default locales in POI")
public void userLocale() {
Locale DEFAULT_LOCALE = LocaleUtil.getUserLocale();
-
+
assertEquals(DEFAULT_LOCALE, LocaleUtil.getUserLocale());
assertNotEquals(ja_JP, LocaleUtil.getUserLocale());
-
+
LocaleUtil.setUserLocale(ja_JP);
assertEquals(ja_JP, LocaleUtil.getUserLocale());
-
+
LocaleUtil.resetUserLocale();
assertEquals(DEFAULT_LOCALE, LocaleUtil.getUserLocale());
}
-
+
@Test
@SuppressForbidden("implementation around default locales in POI")
public void userTimeZone() {
TimeZone DEFAULT_TIME_ZONE = LocaleUtil.getUserTimeZone();
-
+
assertEquals(DEFAULT_TIME_ZONE, LocaleUtil.getUserTimeZone());
- assertNotEquals(TOKYO, LocaleUtil.getUserLocale());
-
+ assertNotEquals(TOKYO, LocaleUtil.getUserTimeZone());
+
LocaleUtil.setUserTimeZone(TOKYO);
assertEquals(TOKYO, LocaleUtil.getUserTimeZone());
}
-
+
@Test
@SuppressForbidden("implementation around default locales in POI")
public void localeCalendar() {
Locale DEFAULT_LOCALE = LocaleUtil.getUserLocale();
TimeZone DEFAULT_TIME_ZONE = LocaleUtil.getUserTimeZone();
Calendar DEFAULT_CALENDAR = LocaleUtil.getLocaleCalendar();
-
+
assertEquals(DEFAULT_LOCALE, LocaleUtil.getUserLocale());
assertEquals(DEFAULT_TIME_ZONE, LocaleUtil.getUserTimeZone());
assertCalendarEquals(DEFAULT_CALENDAR, LocaleUtil.getLocaleCalendar());
assertNotEquals(ja_JP, LocaleUtil.getUserLocale());
assertNotEquals(TOKYO, LocaleUtil.getUserTimeZone());
assertCalendarNotEquals(JAPAN_CALENDAR, LocaleUtil.getLocaleCalendar());
-
+
LocaleUtil.setUserLocale(ja_JP);
LocaleUtil.setUserTimeZone(TOKYO);
assertCalendarEquals(JAPAN_CALENDAR, LocaleUtil.getLocaleCalendar());
//assertCalendarEquals(JAPAN_CALENDAR, LocaleUtil.getLocaleCalendar(2016, 00, 01));
//assertCalendarEquals(JAPAN_CALENDAR, LocaleUtil.getLocaleCalendar(2016, 00, 01, 00, 00, 00));
}
-
+
private static void assertCalendarNotEquals(Calendar expected, Calendar actual) {
// FIXME: add more tests to compare calendars, ignoring whether the dates are equal
assertNotEquals("time zone", expected.getTimeZone(), actual.getTimeZone());