aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases
diff options
context:
space:
mode:
authorJason Height <jheight@apache.org>2006-01-05 07:29:36 +0000
committerJason Height <jheight@apache.org>2006-01-05 07:29:36 +0000
commit64ea72b8952865137f35d32e7e98dec62e8b87d4 (patch)
tree31071cdf294fce1fda858d69db892f66b17b68f4 /src/testcases
parent507017df2bfa3ba354faf58dac12d566efe49b8b (diff)
downloadpoi-64ea72b8952865137f35d32e7e98dec62e8b87d4.tar.gz
poi-64ea72b8952865137f35d32e7e98dec62e8b87d4.zip
Multiple clone of same sheet now generates unique sheet name BUG 37416 fixed.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@366110 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java18
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java6
2 files changed, 21 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
index a603c27532..e21bacdfc3 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
@@ -204,6 +204,24 @@ public class TestHSSFSheet
cell.setCellValue("Difference Check");
assertEquals(cloned.getRow((short)0).getCell((short)0).getStringCellValue(), "clone_test");
}
+
+ /** tests that the sheet name for multiple clones of the same sheet is unique
+ * BUG 37416
+ */
+ public void testCloneSheetMultipleTimes() {
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ HSSFSheet sheet = workbook.createSheet("Test Clone");
+ HSSFRow row = sheet.createRow((short) 0);
+ HSSFCell cell = row.createCell((short) 0);
+ cell.setCellValue("clone_test");
+ //Clone the sheet multiple times
+ workbook.cloneSheet(0);
+ workbook.cloneSheet(0);
+
+ assertNotNull(workbook.getSheet("Test Clone"));
+ assertNotNull(workbook.getSheet("Test Clone(1)"));
+ assertNotNull(workbook.getSheet("Test Clone(2)"));
+ }
/**
* Test that the ProtectRecord is included when creating or cloning a sheet
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
index 7bf6c47937..7b0b7c3f30 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
@@ -46,15 +46,15 @@ public class TestHSSFWorkbook extends TestCase
try
{
- b.setSheetName( 3, "name1"/*JMH, HSSFWorkbook.ENCODING_UTF_16*/ );
+ b.setSheetName( 3, "name1" );
fail();
}
catch ( IllegalArgumentException pass )
{
}
- b.setSheetName( 3, "name2"/*JMH, HSSFWorkbook.ENCODING_UTF_16*/ );
- b.setSheetName( 3, "name2"/*JMH, HSSFWorkbook.ENCODING_UTF_16*/ );
+ b.setSheetName( 3, "name2" );
+ b.setSheetName( 3, "name2" );
b.setSheetName( 3, "name2" );
HSSFWorkbook c = new HSSFWorkbook( );