コード例 #1
0
 @Test
 public void testReadCell() throws Exception {
   when(mockCell.getCellType()).thenReturn(Cell.CELL_TYPE_NUMERIC);
   final HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
   final HSSFCellStyle cellStyle = hssfWorkbook.createCellStyle();
   final Date currentDate = new Date();
   cellStyle.setDataFormat(
       hssfWorkbook.getCreationHelper().createDataFormat().getFormat("m/d/yyyy h:mm"));
   when(mockCell.getCellStyle()).thenReturn(cellStyle);
   when(mockCell.getDateCellValue()).thenReturn(currentDate);
   final Calendar calendar = calendarConverter.readCell(mockCell);
   assertNotNull(calendar);
   assertEquals(currentDate.getTime(), calendar.getTimeInMillis());
 }
コード例 #2
0
 @Test
 public void testReadCellWithAsNonNumeric() throws Exception {
   when(mockCell.getCellType()).thenReturn(Cell.CELL_TYPE_BOOLEAN);
   assertNull(calendarConverter.readCell(mockCell, ".*"));
 }
コード例 #3
0
 @Test
 public void testReadCellWithAsNonDateFormatted() throws Exception {
   when(mockCell.getCellType()).thenReturn(Cell.CELL_TYPE_BOOLEAN);
   when(mockCell.getNumericCellValue()).thenReturn(-5.0E-324D);
   assertNull(calendarConverter.readCell(mockCell, ".*"));
 }
コード例 #4
0
 @Test
 public void testReadCellWithNullCellAndRegex() throws Exception {
   assertNull(calendarConverter.readCell(null, ".*"));
 }