You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ug...@apache.org on 2008/01/22 12:26:41 UTC
svn commit: r614178 -
/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
Author: ugo
Date: Tue Jan 22 03:26:27 2008
New Revision: 614178
URL: http://svn.apache.org/viewvc?rev=614178&view=rev
Log:
Tests for XSSFSheet, contributed by Paolo Mottadelli <p....@sourcesense.com>.
Added:
poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (with props)
Added: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=614178&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (added)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Tue Jan 22 03:26:27 2008
@@ -0,0 +1,93 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+import java.util.Iterator;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+
+import junit.framework.TestCase;
+
+
+public class TestXSSFSheet extends TestCase {
+
+ public void testRowIterator() throws Exception {
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ Sheet sheet = workbook.createSheet("Sheet 1");
+ Row row1 = sheet.createRow(0);
+ Row row2 = sheet.createRow(1);
+ Iterator<Row> it = sheet.rowIterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ assertEquals(row1, it.next());
+ assertTrue(it.hasNext());
+ assertEquals(row2, it.next());
+ assertFalse(it.hasNext());
+ }
+
+ public void testGetRow() throws Exception {
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ Sheet sheet = workbook.createSheet("Sheet 1");
+ Row row1 = sheet.createRow(0);
+ Cell cell = row1.createCell((short) 0);
+ cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell.setCellValue((double) 1000);
+
+ // Test getting a row and check its cell's value
+ Row row_got = sheet.getRow(0);
+ Cell cell_got = row_got.getCell((short) 0);
+ assertEquals((double) 1000, cell_got.getNumericCellValue());
+ }
+
+ public void testCreateRow() throws Exception {
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ Sheet sheet = workbook.createSheet("Sheet 1");
+
+ // Test row creation with consecutive indexes
+ Row row1 = sheet.createRow(0);
+ Row row2 = sheet.createRow(1);
+ assertEquals(0, row1.getRowNum());
+ Iterator<Row> it = sheet.rowIterator();
+ assertTrue(it.hasNext());
+ assertEquals(row1, it.next());
+ assertTrue(it.hasNext());
+ assertEquals(row2, it.next());
+
+ // Test row creation with non consecutive index
+ Row row101 = sheet.createRow(100);
+ assertNotNull(row101);
+
+ // Test overwriting an existing row
+ Row row2_ovrewritten = sheet.createRow(1);
+ Cell cell = row2_ovrewritten.createCell((short) 0);
+ cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell.setCellValue((double) 100);
+ Iterator<Row> it2 = sheet.rowIterator();
+ assertTrue(it2.hasNext());
+ assertEquals(row1, it2.next());
+ assertTrue(it2.hasNext());
+ Row row2_overwritten_copy = it2.next();
+ assertEquals(row2_ovrewritten, row2_overwritten_copy);
+ assertEquals(row2_overwritten_copy.getCell((short) 0).getNumericCellValue(), (double) 100);
+
+
+
+ }
+}
Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org