poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r759714 [2/2] - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/ ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/model/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/ ...
Date Sun, 29 Mar 2009 16:10:42 GMT
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java?rev=759714&r1=759713&r2=759714&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java Sun Mar 29 16:10:40 2009
@@ -59,23 +59,6 @@
         assertEquals(3, nameRecord.getSheetNumber());
     }
 
-    public void testCaseInsensitiveNames() {
-        HSSFWorkbook b = new HSSFWorkbook( );
-        HSSFSheet originalSheet = b.createSheet("Sheet1");
-        HSSFSheet fetchedSheet = b.getSheet("sheet1");
-        if(fetchedSheet == null) {
-            throw new AssertionFailedError("Identified bug 44892");
-        }
-        assertEquals(originalSheet, fetchedSheet);
-        try {
-            b.createSheet("sHeeT1");
-            fail("should have thrown exceptiuon due to duplicate sheet name");
-        } catch (IllegalArgumentException e) {
-            // expected during successful test
-            assertEquals("The workbook already contains a sheet of this name", e.getMessage());
-        }
-    }
-
     public void testWindowOneDefaults() {
         HSSFWorkbook b = new HSSFWorkbook( );
         try {
@@ -154,7 +137,7 @@
         // So, start again
         b = getTestDataProvider().openSampleWorkbook("44010-SingleChart.xls");
 
-        b = writeRead(b);
+        b = getTestDataProvider().writeOutAndReadBack(b);
         assertEquals(2, b.getNumberOfSheets());
         s = b.getSheetAt(1);
         assertEquals(0, s.getFirstRowNum());
@@ -184,7 +167,7 @@
         // So, start again
         b = getTestDataProvider().openSampleWorkbook("44010-TwoCharts.xls");
 
-        b = writeRead(b);
+        b = getTestDataProvider().writeOutAndReadBack(b);
         assertEquals(3, b.getNumberOfSheets());
 
         s = b.getSheetAt(1);
@@ -195,11 +178,6 @@
         assertEquals(8, s.getLastRowNum());
     }
 
-    private static HSSFWorkbook writeRead(HSSFWorkbook b) {
-        return HSSFTestDataSamples.writeOutAndReadBack(b);
-    }
-
-
     public void testSelectedSheet_bug44523() {
         HSSFWorkbook wb=new HSSFWorkbook();
         HSSFSheet sheet1 = wb.createSheet("Sheet1");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java?rev=759714&r1=759713&r2=759714&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java Sun Mar 29 16:10:40 2009
@@ -16,132 +16,39 @@
 */
 package org.apache.poi.hssf.usermodel;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-
-import org.apache.poi.util.TempFile;
-
 import junit.framework.TestCase;
+import org.apache.poi.hssf.HSSFTestDataSamples;
 
 public class TestUnicodeWorkbook extends TestCase {
 
-    public TestUnicodeWorkbook(String s) {
-        super(s);
-    }
-    
-    /** Tests that all of the unicode capable string fields can be set, written and then read back
-     * 
-     *
-     */
-    public void testUnicodeInAll() throws Exception {
-        HSSFWorkbook wb = new HSSFWorkbook();
-        //Create a unicode dataformat (contains euro symbol)
-        HSSFDataFormat df = wb.createDataFormat();
-        final String formatStr = "_([$\u20ac-2]\\\\\\ * #,##0.00_);_([$\u20ac-2]\\\\\\ * \\\\\\(#,##0.00\\\\\\);_([$\u20ac-2]\\\\\\ *\\\"\\-\\\\\"??_);_(@_)";
-        short fmt = df.getFormat(formatStr);
-        
-        //Create a unicode sheet name (euro symbol)
-        HSSFSheet s = wb.createSheet("\u20ac");
-        
-        //Set a unicode header (you guessed it the euro symbol)
-        HSSFHeader h = s.getHeader();
-        h.setCenter("\u20ac");
-        h.setLeft("\u20ac");
-        h.setRight("\u20ac");
-        
-        //Set a unicode footer
-        HSSFFooter f = s.getFooter();
-        f.setCenter("\u20ac");
-        f.setLeft("\u20ac");
-        f.setRight("\u20ac");                
-
-        HSSFRow r = s.createRow(0);
-        HSSFCell c = r.createCell(1);
-        c.setCellValue(12.34);
-        c.getCellStyle().setDataFormat(fmt);
-        
-        HSSFCell c2 = r.createCell(2);
-        c.setCellValue(new HSSFRichTextString("\u20ac"));
-
-        HSSFCell c3 = r.createCell(3);
-        String formulaString = "TEXT(12.34,\"\u20ac###,##\")";
-        c3.setCellFormula(formulaString);
-
-        
-        File tempFile = TempFile.createTempFile("unicode", "test.xls");
-        FileOutputStream stream = new FileOutputStream(tempFile);
-        wb.write(stream);
-        
-        wb = null;
-        FileInputStream in = new FileInputStream(tempFile);
-        wb = new HSSFWorkbook(in);
-
-        //Test the sheetname
-        s = wb.getSheet("\u20ac");
-        assertNotNull(s);
-        
-        //Test the header
-        h = s.getHeader();
-        assertEquals(h.getCenter(), "\u20ac");
-        assertEquals(h.getLeft(), "\u20ac");
-        assertEquals(h.getRight(), "\u20ac");
-        
-        //Test the footer
-        f = s.getFooter();
-        assertEquals(f.getCenter(), "\u20ac");
-        assertEquals(f.getLeft(), "\u20ac");
-        assertEquals(f.getRight(), "\u20ac");                
-
-        //Test the dataformat
-        r = s.getRow(0);
-        c = r.getCell(1);
-        df = wb.createDataFormat();
-        assertEquals(formatStr, df.getFormat(c.getCellStyle().getDataFormat()));
-        
-        //Test the cell string value
-        c2 = r.getCell(2);
-        assertEquals(c.getRichStringCellValue().getString(), "\u20ac");
-        
-        //Test the cell formula
-        c3 = r.getCell(3);
-        assertEquals(c3.getCellFormula(), formulaString);
-    }
-    
     /** Tests Bug38230
      *  That a Umlat is written  and then read back.
      *  It should have been written as a compressed unicode.
-     * 
-     * 
+     *
+     *
      *
      */
     public void testUmlatReadWrite() throws Exception {
         HSSFWorkbook wb = new HSSFWorkbook();
-        
+
         //Create a unicode sheet name (euro symbol)
         HSSFSheet s = wb.createSheet("test");
-        
+
         HSSFRow r = s.createRow(0);
         HSSFCell c = r.createCell(1);
         c.setCellValue(new HSSFRichTextString("\u00e4"));
-        
+
         //Confirm that the sring will be compressed
         assertEquals(c.getRichStringCellValue().getUnicodeString().getOptionFlags(), 0);
-        
-        File tempFile = TempFile.createTempFile("umlat", "test.xls");
-        FileOutputStream stream = new FileOutputStream(tempFile);
-        wb.write(stream);
-        
-        wb = null;
-        FileInputStream in = new FileInputStream(tempFile);
-        wb = new HSSFWorkbook(in);
+
+        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
 
         //Test the sheetname
         s = wb.getSheet("test");
         assertNotNull(s);
-        
+
         c = r.getCell(1);
         assertEquals(c.getRichStringCellValue().getString(), "\u00e4");
-    }    
+    }
 
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java?rev=759714&r1=759713&r2=759714&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java Sun Mar 29 16:10:40 2009
@@ -44,4 +44,10 @@
      */
     Workbook createWorkbook();
 
+    /**
+     * Opens a sample file from the standard HSSF test data directory
+     *
+     * @return an open <tt>InputStream</tt> for the specified sample file
+     */
+    byte[] getTestDataFileContent(String fileName);
 }

Added: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=759714&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Sun Mar 29 16:10:40 2009
@@ -0,0 +1,298 @@
+/* ====================================================================
+   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.ss.usermodel;
+
+import junit.framework.TestCase;
+import junit.framework.AssertionFailedError;
+import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.util.CellRangeAddress;
+
+/**
+ * A base class for bugzilla issues that can be described in terms of common ss interfaces.
+ *
+ * @author Yegor Kozlov
+ */
+public abstract class BaseTestBugzillaIssues extends TestCase {
+
+    protected abstract ITestDataProvider getTestDataProvider();
+
+    /**
+     *
+     * Test writing a hyperlink
+     * Open resulting sheet in Excel and check that A1 contains a hyperlink
+     *
+     * Also tests bug 15353 (problems with hyperlinks to Google)
+     */
+    public void test23094() {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet s = wb.createSheet();
+        Row r = s.createRow(0);
+        r.createCell(0).setCellFormula("HYPERLINK(\"http://jakarta.apache.org\",\"Jakarta\")");
+        r.createCell(1).setCellFormula("HYPERLINK(\"http://google.com\",\"Google\")");
+
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+        r = wb.getSheetAt(0).getRow(0);
+
+        Cell cell_0 = r.getCell(0);
+        assertEquals("HYPERLINK(\"http://jakarta.apache.org\",\"Jakarta\")", cell_0.getCellFormula());
+        Cell cell_1 = r.getCell(1);
+        assertEquals("HYPERLINK(\"http://google.com\",\"Google\")", cell_1.getCellFormula());
+    }
+
+    /**
+     * test writing a file with large number of unique strings,
+     * open resulting file in Excel to check results!
+     * @param  num the number of strings to generate
+     */
+    public void baseTest15375(int num) {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet sheet = wb.createSheet();
+        CreationHelper factory = wb.getCreationHelper();
+
+        String tmp1 = null;
+        String tmp2 = null;
+        String tmp3 = null;
+
+        for (int i = 0; i < num; i++) {
+            tmp1 = "Test1" + i;
+            tmp2 = "Test2" + i;
+            tmp3 = "Test3" + i;
+
+            Row row = sheet.createRow(i);
+
+            Cell cell = row.createCell(0);
+            cell.setCellValue(factory.createRichTextString(tmp1));
+            cell = row.createCell(1);
+            cell.setCellValue(factory.createRichTextString(tmp2));
+            cell = row.createCell(2);
+            cell.setCellValue(factory.createRichTextString(tmp3));
+        }
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+        for (int i = 0; i < num; i++) {
+            tmp1 = "Test1" + i;
+            tmp2 = "Test2" + i;
+            tmp3 = "Test3" + i;
+
+            Row row = sheet.getRow(i);
+
+            assertEquals(tmp1, row.getCell(0).getStringCellValue());
+            assertEquals(tmp2, row.getCell(1).getStringCellValue());
+            assertEquals(tmp3, row.getCell(2).getStringCellValue());
+        }
+    }
+
+    /**
+     * Merged regions were being removed from the parent in cloned sheets
+     */
+    public void test22720() {
+       Workbook workBook = getTestDataProvider().createWorkbook();
+       workBook.createSheet("TEST");
+       Sheet template = workBook.getSheetAt(0);
+
+       template.addMergedRegion(new CellRangeAddress(0, 1, 0, 2));
+       template.addMergedRegion(new CellRangeAddress(1, 2, 0, 2));
+
+       Sheet clone = workBook.cloneSheet(0);
+       int originalMerged = template.getNumMergedRegions();
+       assertEquals("2 merged regions", 2, originalMerged);
+
+       //remove merged regions from clone
+       for (int i=template.getNumMergedRegions()-1; i>=0; i--) {
+           clone.removeMergedRegion(i);
+       }
+
+       assertEquals("Original Sheet's Merged Regions were removed", originalMerged, template.getNumMergedRegions());
+       //check if template's merged regions are OK
+       if (template.getNumMergedRegions()>0) {
+            // fetch the first merged region...EXCEPTION OCCURS HERE
+            template.getMergedRegion(0);
+       }
+       //make sure we dont exception
+
+    }
+
+    public void test28031() {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet sheet = wb.createSheet();
+        wb.setSheetName(0, "Sheet1");
+
+        Row row = sheet.createRow(0);
+        Cell cell = row.createCell(0);
+        String formulaText =
+            "IF(ROUND(A2*B2*C2,2)>ROUND(B2*D2,2),ROUND(A2*B2*C2,2),ROUND(B2*D2,2))";
+        cell.setCellFormula(formulaText);
+
+        assertEquals(formulaText, cell.getCellFormula());
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+        cell = wb.getSheetAt(0).getRow(0).getCell(0);
+        assertEquals("IF(ROUND(A2*B2*C2,2)>ROUND(B2*D2,2),ROUND(A2*B2*C2,2),ROUND(B2*D2,2))", cell.getCellFormula());
+    }
+
+    /**
+     * Bug 21334: "File error: data may have been lost" with a file
+     * that contains macros and this formula:
+     * {=SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""))>0,1))}
+     */
+    public void test21334() {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet sh = wb.createSheet();
+        Cell cell = sh.createRow(0).createCell(0);
+        String formula = "SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),\"\"),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),\"\"))>0,1))";
+        cell.setCellFormula(formula);
+
+        Workbook wb_sv = getTestDataProvider().writeOutAndReadBack(wb);
+        Cell cell_sv = wb_sv.getSheetAt(0).getRow(0).getCell(0);
+        assertEquals(formula, cell_sv.getCellFormula());
+    }
+
+    /** another test for the number of unique strings issue
+     *test opening the resulting file in Excel*/
+    public void test22568() {
+        int r=2000;int c=3;
+
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet sheet = wb.createSheet("ExcelTest") ;
+
+        int col_cnt=0, rw_cnt=0 ;
+
+        col_cnt = c;
+        rw_cnt = r;
+
+        Row rw ;
+        rw = sheet.createRow(0) ;
+        //Header row
+        for(int j=0; j<col_cnt; j++){
+            Cell cell = rw.createCell(j) ;
+            cell.setCellValue("Col " + (j+1));
+        }
+
+        for(int i=1; i<rw_cnt; i++){
+            rw = sheet.createRow(i) ;
+            for(int j=0; j<col_cnt; j++){
+                Cell cell = rw.createCell(j) ;
+                cell.setCellValue("Row:" + (i+1) + ",Column:" + (j+1));
+            }
+        }
+
+        sheet.setDefaultColumnWidth(18) ;
+
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+        sheet = wb.getSheetAt(0);
+        rw = sheet.getRow(0);
+        //Header row
+        for(int j=0; j<col_cnt; j++){
+            Cell cell = rw.getCell(j) ;
+            assertEquals("Col " + (j+1), cell.getStringCellValue());
+        }
+        for(int i=1; i<rw_cnt; i++){
+            rw = sheet.getRow(i) ;
+            for(int j=0; j<col_cnt; j++){
+                Cell cell = rw.getCell(j) ;
+                assertEquals("Row:" + (i+1) + ",Column:" + (j+1), cell.getStringCellValue());
+            }
+        }
+    }
+
+    /**
+     * Bug 42448: Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69
+     */
+    public void test42448(){
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Cell cell = wb.createSheet().createRow(0).createCell(0);
+        cell.setCellFormula("SUMPRODUCT(A!C7:A!C67, B8:B68) / B69");
+        assertTrue("no errors parsing formula", true);
+    }
+
+    /**
+     * HSSFRichTextString.length() returns negative for really
+     *  long strings
+     */
+    public void test46368() {
+        Workbook wb = getTestDataProvider().createWorkbook();
+    	Sheet s = wb.createSheet();
+    	Row r = s.createRow(0);
+    	for(int i=0; i<15; i++) {
+    		int len = 32760 + i;
+    		Cell c = r.createCell(i);
+
+    		StringBuffer sb = new StringBuffer();
+    		for(int j=0; j<len; j++) {
+    			sb.append("x");
+    		}
+    		RichTextString rtr = wb.getCreationHelper().createRichTextString(sb.toString());
+    		assertEquals(len, rtr.length());
+    		c.setCellValue(rtr);
+    	}
+
+    	// Save and reload
+    	wb = getTestDataProvider().writeOutAndReadBack(wb);
+    	s = wb.getSheetAt(0);
+    	r = s.getRow(0);
+    	for(int i=0; i<15; i++) {
+    		int len = 32760 + i;
+    		Cell c = r.getCell(i);
+    		assertEquals(len, c.getRichStringCellValue().length());
+    	}
+    }
+
+    public void test18800() {
+       Workbook book = getTestDataProvider().createWorkbook();
+       book.createSheet("TEST");
+       Sheet sheet = book.cloneSheet(0);
+       book.setSheetName(1,"CLONE");
+       sheet.createRow(0).createCell(0).setCellValue("Test");
+
+       book = getTestDataProvider().writeOutAndReadBack(book);
+       sheet = book.getSheet("CLONE");
+       Row row = sheet.getRow(0);
+       Cell cell = row.getCell(0);
+       assertEquals("Test", cell.getRichStringCellValue().getString());
+   }
+
+    private static void addNewSheetWithCellsA1toD4(Workbook book, int sheet) {
+
+        Sheet sht = book .createSheet("s" + sheet);
+        for (int r=0; r < 4; r++) {
+
+            Row   row = sht.createRow (r);
+            for (int c=0; c < 4; c++) {
+
+                Cell cel = row.createCell(c);
+                cel.setCellValue(sheet*100 + r*10 + c);
+            }
+        }
+    }
+
+    public void testBug43093() {
+        Workbook xlw = getTestDataProvider().createWorkbook();
+
+        addNewSheetWithCellsA1toD4(xlw, 1);
+        addNewSheetWithCellsA1toD4(xlw, 2);
+        addNewSheetWithCellsA1toD4(xlw, 3);
+        addNewSheetWithCellsA1toD4(xlw, 4);
+
+        Sheet s2   = xlw.getSheet("s2");
+        Row   s2r3 = s2.getRow(3);
+        Cell  s2E4 = s2r3.createCell(4);
+        s2E4.setCellFormula("SUM(s3!B2:C3)");
+
+        FormulaEvaluator eva = xlw.getCreationHelper().createFormulaEvaluator();
+        double d = eva.evaluate(s2E4).getNumberValue();
+
+        assertEquals(d, (311+312+321+322), 0.0000001);
+    }
+}
\ No newline at end of file

Propchange: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java?rev=759714&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java Sun Mar 29 16:10:40 2009
@@ -0,0 +1,204 @@
+/* ====================================================================
+   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.ss.usermodel;
+
+import junit.framework.TestCase;
+import junit.framework.AssertionFailedError;
+import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.util.CellRangeAddress;
+
+/**
+ * @author Yegor Kozlov
+ */
+public abstract class BaseTestFont extends TestCase {
+
+    protected abstract ITestDataProvider getTestDataProvider();
+
+    public void baseTestDefaultFont(String defaultName, short defaultSize, short defaultColor){
+        //get default font and check against default value
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        Font fontFind=workbook.findFont(Font.BOLDWEIGHT_NORMAL, defaultColor, defaultSize, defaultName, false, false, Font.SS_NONE, Font.U_NONE);
+        assertNotNull(fontFind);
+
+        //get default font, then change 2 values and check against different values (height changes)
+        Font font=workbook.createFont();
+        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
+        assertEquals(Font.BOLDWEIGHT_BOLD, font.getBoldweight());
+        font.setUnderline(Font.U_DOUBLE);
+        assertEquals(Font.U_DOUBLE, font.getUnderline());
+        font.setFontHeightInPoints((short)15);
+        assertEquals(15*20, font.getFontHeight());
+        assertEquals(15, font.getFontHeightInPoints());
+        fontFind=workbook.findFont(Font.BOLDWEIGHT_BOLD, defaultColor, (short)(15*20), defaultName, false, false, Font.SS_NONE, Font.U_DOUBLE);
+        assertNotNull(fontFind);
+    }
+
+	public void testGetNumberOfFonts(){
+        Workbook wb = getTestDataProvider().createWorkbook();
+        int num0 = wb.getNumberOfFonts();
+
+        Font f1=wb.createFont();
+	 	f1.setBoldweight(Font.BOLDWEIGHT_BOLD);
+	 	short idx1 = f1.getIndex();
+        wb.createCellStyle().setFont(f1);
+
+		Font f2=wb.createFont();
+	 	f2.setUnderline(Font.U_DOUBLE);
+        short idx2 = f2.getIndex();
+		wb.createCellStyle().setFont(f2);
+
+		Font f3=wb.createFont();
+	 	f3.setFontHeightInPoints((short)23);
+        short idx3 = f3.getIndex();
+		wb.createCellStyle().setFont(f3);
+
+		assertEquals(num0 + 3,wb.getNumberOfFonts());
+	 	assertEquals(Font.BOLDWEIGHT_BOLD,wb.getFontAt(idx1).getBoldweight());
+        assertEquals(Font.U_DOUBLE,wb.getFontAt(idx2).getUnderline());
+        assertEquals(23,wb.getFontAt(idx3).getFontHeightInPoints());
+	}
+
+    /**
+     * Tests that we can define fonts to a new
+     *  file, save, load, and still see them
+     * @throws Exception
+     */
+    public void testCreateSave() {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet s1 = wb.createSheet();
+        Row r1 = s1.createRow(0);
+        Cell r1c1 = r1.createCell(0);
+        r1c1.setCellValue(2.2);
+
+        int num0 = wb.getNumberOfFonts();
+
+        Font font=wb.createFont();
+        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
+        font.setStrikeout(true);
+        font.setColor(IndexedColors.YELLOW.getIndex());
+        font.setFontName("Courier");
+        short font1Idx = font.getIndex();
+        wb.createCellStyle().setFont(font);
+        assertEquals(num0 + 1, wb.getNumberOfFonts());
+
+        CellStyle cellStyleTitle=wb.createCellStyle();
+        cellStyleTitle.setFont(font);
+        r1c1.setCellStyle(cellStyleTitle);
+
+        // Save and re-load
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+        s1 = wb.getSheetAt(0);
+
+        assertEquals(num0 + 1, wb.getNumberOfFonts());
+        short idx = s1.getRow(0).getCell(0).getCellStyle().getFontIndex();
+        Font fnt = wb.getFontAt(idx);
+        assertNotNull(fnt);
+        assertEquals(IndexedColors.YELLOW.getIndex(), fnt.getColor());
+        assertEquals("Courier", fnt.getFontName());
+
+        // Now add an orphaned one
+        Font font2 = wb.createFont();
+        font2.setItalic(true);
+        font2.setFontHeightInPoints((short)15);
+        short font2Idx = font2.getIndex();
+        wb.createCellStyle().setFont(font2);
+        assertEquals(num0 + 2, wb.getNumberOfFonts());
+
+        // Save and re-load
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+        s1 = wb.getSheetAt(0);
+
+        assertEquals(num0 + 2, wb.getNumberOfFonts());
+        assertNotNull(wb.getFontAt(font1Idx));
+        assertNotNull(wb.getFontAt(font2Idx));
+
+        assertEquals(15, wb.getFontAt(font2Idx).getFontHeightInPoints());
+        assertEquals(true, wb.getFontAt(font2Idx).getItalic());
+    }
+
+
+
+    /**
+     * Test that fonts get added properly
+     *
+     * @see org.apache.poi.hssf.usermodel.TestBugs#test45338()
+     */
+    public void test45338() {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        int num0 = wb.getNumberOfFonts();
+
+        Sheet s = wb.createSheet();
+        s.createRow(0);
+        s.createRow(1);
+        s.getRow(0).createCell(0);
+        s.getRow(1).createCell(0);
+
+        //default font
+        Font f1 = wb.getFontAt((short)0);
+        assertEquals(Font.BOLDWEIGHT_NORMAL, f1.getBoldweight());
+
+        // Check that asking for the same font
+        //  multiple times gives you the same thing.
+        // Otherwise, our tests wouldn't work!
+        assertSame(wb.getFontAt((short)0), wb.getFontAt((short)0));
+
+        // Look for a new font we have
+        //  yet to add
+        assertNull(
+            wb.findFont(
+                Font.BOLDWEIGHT_BOLD, (short)123, (short)(22*20),
+                "Thingy", false, true, (short)2, (byte)2
+            )
+        );
+
+        Font nf = wb.createFont();
+        short nfIdx = nf.getIndex();
+        assertEquals(num0 + 1, wb.getNumberOfFonts());
+
+        assertSame(nf, wb.getFontAt(nfIdx));
+
+        nf.setBoldweight(Font.BOLDWEIGHT_BOLD);
+        nf.setColor((short)123);
+        nf.setFontHeightInPoints((short)22);
+        nf.setFontName("Thingy");
+        nf.setItalic(false);
+        nf.setStrikeout(true);
+        nf.setTypeOffset((short)2);
+        nf.setUnderline((byte)2);
+
+        assertEquals(num0 + 1, wb.getNumberOfFonts());
+        assertEquals(nf, wb.getFontAt(nfIdx));
+
+        assertEquals(wb.getFontAt(nfIdx), wb.getFontAt(nfIdx));
+        assertTrue(wb.getFontAt((short)0) != wb.getFontAt(nfIdx));
+
+        // Find it now
+        assertNotNull(
+            wb.findFont(
+                Font.BOLDWEIGHT_BOLD, (short)123, (short)(22*20),
+                "Thingy", false, true, (short)2, (byte)2
+            )
+        );
+        assertSame(nf,
+               wb.findFont(
+                   Font.BOLDWEIGHT_BOLD, (short)123, (short)(22*20),
+                   "Thingy", false, true, (short)2, (byte)2
+               )
+        );
+    }
+
+}
\ No newline at end of file

Propchange: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java?rev=759714&r1=759713&r2=759714&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java Sun Mar 29 16:10:40 2009
@@ -19,10 +19,16 @@
 
 import junit.framework.TestCase;
 import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.formula.FormulaParser;
+import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.hssf.record.formula.Ptg;
 
 /**
- * Tests of implementation of {@link org.apache.poi.ss.usermodel.Name}
+ * Tests of implementations of {@link org.apache.poi.ss.usermodel.Name}.
  *
+ * @author Yegor Kozlov
  */
 public abstract class BaseTestNamedRange extends TestCase {
 
@@ -84,6 +90,18 @@
         //-1 means the name applies to the entire workbook
         name1.setSheetIndex(-1);
         assertEquals(-1, name1.getSheetIndex());
+
+        //names cannot be blank and must begin with a letter or underscore and not contain spaces
+        String[] invalidNames = {"", "123", "1Name", "Named Range"};
+        for (String name : invalidNames) {
+            try {
+                name1.setNameName(name);
+                fail("should have thrown exceptiuon due to invalid name: " + name);
+            } catch (IllegalArgumentException e) {
+                // expected during successful test
+                ;
+            }
+        }
     }
 
     public void testUnicodeNamedRange() {
@@ -170,4 +188,314 @@
         }
         assertEquals(3, cnt);
     }
+
+    /**
+     * Test case provided by czhang@cambian.com (Chun Zhang)
+     * <p>
+     * Addresses Bug <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=13775" target="_bug">#13775</a>
+     */
+    public void testMultiNamedRange() {
+
+         // Create a new workbook
+         Workbook wb = getTestDataProvider().createWorkbook();
+
+         // Create a worksheet 'sheet1' in the new workbook
+         wb.createSheet ();
+         wb.setSheetName (0, "sheet1");
+
+         // Create another worksheet 'sheet2' in the new workbook
+         wb.createSheet ();
+         wb.setSheetName (1, "sheet2");
+
+         // Create a new named range for worksheet 'sheet1'
+         Name namedRange1 = wb.createName();
+
+         // Set the name for the named range for worksheet 'sheet1'
+         namedRange1.setNameName("RangeTest1");
+
+         // Set the reference for the named range for worksheet 'sheet1'
+         namedRange1.setRefersToFormula("sheet1" + "!$A$1:$L$41");
+
+         // Create a new named range for worksheet 'sheet2'
+         Name namedRange2 = wb.createName();
+
+         // Set the name for the named range for worksheet 'sheet2'
+         namedRange2.setNameName("RangeTest2");
+
+         // Set the reference for the named range for worksheet 'sheet2'
+         namedRange2.setRefersToFormula("sheet2" + "!$A$1:$O$21");
+
+         // Write the workbook to a file
+         // Read the Excel file and verify its content
+         wb = getTestDataProvider().writeOutAndReadBack(wb);
+         Name nm1 =wb.getNameAt(wb.getNameIndex("RangeTest1"));
+         assertTrue("Name is "+nm1.getNameName(),"RangeTest1".equals(nm1.getNameName()));
+         assertTrue("Reference is "+nm1.getRefersToFormula(),(wb.getSheetName(0)+"!$A$1:$L$41").equals(nm1.getRefersToFormula()));
+
+         Name nm2 =wb.getNameAt(wb.getNameIndex("RangeTest2"));
+         assertTrue("Name is "+nm2.getNameName(),"RangeTest2".equals(nm2.getNameName()));
+         assertTrue("Reference is "+nm2.getRefersToFormula(),(wb.getSheetName(1)+"!$A$1:$O$21").equals(nm2.getRefersToFormula()));
+     }
+
+    /**
+     * Test to see if the print areas can be retrieved/created in memory
+     */
+    public void testSinglePrintArea() {
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        workbook.createSheet("Test Print Area");
+        String sheetName = workbook.getSheetName(0);
+
+        String reference = "$A$1:$B$1";
+        workbook.setPrintArea(0, reference);
+
+        String retrievedPrintArea = workbook.getPrintArea(0);
+
+        assertNotNull("Print Area not defined for first sheet", retrievedPrintArea);
+        assertEquals("'" + sheetName + "'!$A$1:$B$1", retrievedPrintArea);
+    }
+
+     /**
+      * For Convenience, don't force sheet names to be used
+      */
+     public void testSinglePrintAreaWOSheet()
+     {
+         Workbook workbook = getTestDataProvider().createWorkbook();
+         workbook.createSheet("Test Print Area");
+         String sheetName = workbook.getSheetName(0);
+
+         String reference = "$A$1:$B$1";
+         workbook.setPrintArea(0, reference);
+
+         String retrievedPrintArea = workbook.getPrintArea(0);
+
+         assertNotNull("Print Area not defined for first sheet", retrievedPrintArea);
+         assertEquals("'" + sheetName + "'!" + reference, retrievedPrintArea);
+     }
+
+     /**
+      * Test to see if the print area made it to the file
+      */
+     public void testPrintAreaFile() {
+         Workbook workbook = getTestDataProvider().createWorkbook();
+         workbook.createSheet("Test Print Area");
+         String sheetName = workbook.getSheetName(0);
+
+
+         String reference = "$A$1:$B$1";
+         workbook.setPrintArea(0, reference);
+
+         workbook = getTestDataProvider().writeOutAndReadBack(workbook);
+
+         String retrievedPrintArea = workbook.getPrintArea(0);
+         assertNotNull("Print Area not defined for first sheet", retrievedPrintArea);
+         assertEquals("References Match", "'" + sheetName + "'!$A$1:$B$1", retrievedPrintArea);
+    }
+
+    /**
+     * Test to see if multiple print areas made it to the file
+     */
+    public void testMultiplePrintAreaFile() {
+        Workbook workbook = getTestDataProvider().createWorkbook();
+
+        workbook.createSheet("Sheet1");
+        workbook.createSheet("Sheet2");
+        workbook.createSheet("Sheet3");
+        String reference1 = "$A$1:$B$1";
+        String reference2 = "$B$2:$D$5";
+        String reference3 = "$D$2:$F$5";
+
+        workbook.setPrintArea(0, reference1);
+        workbook.setPrintArea(1, reference2);
+        workbook.setPrintArea(2, reference3);
+
+        //Check created print areas
+        String retrievedPrintArea;
+
+        retrievedPrintArea = workbook.getPrintArea(0);
+        assertNotNull("Print Area Not Found (Sheet 1)", retrievedPrintArea);
+        assertEquals("Sheet1!" + reference1, retrievedPrintArea);
+
+        retrievedPrintArea = workbook.getPrintArea(1);
+        assertNotNull("Print Area Not Found (Sheet 2)", retrievedPrintArea);
+        assertEquals("Sheet2!" + reference2, retrievedPrintArea);
+
+        retrievedPrintArea = workbook.getPrintArea(2);
+        assertNotNull("Print Area Not Found (Sheet 3)", retrievedPrintArea);
+        assertEquals("Sheet3!" + reference3, retrievedPrintArea);
+
+        // Check print areas after re-reading workbook
+        workbook = getTestDataProvider().writeOutAndReadBack(workbook);
+
+        retrievedPrintArea = workbook.getPrintArea(0);
+        assertNotNull("Print Area Not Found (Sheet 1)", retrievedPrintArea);
+        assertEquals("Sheet1!" + reference1, retrievedPrintArea);
+
+        retrievedPrintArea = workbook.getPrintArea(1);
+        assertNotNull("Print Area Not Found (Sheet 2)", retrievedPrintArea);
+        assertEquals("Sheet2!" + reference2, retrievedPrintArea);
+
+        retrievedPrintArea = workbook.getPrintArea(2);
+        assertNotNull("Print Area Not Found (Sheet 3)", retrievedPrintArea);
+        assertEquals("Sheet3!" + reference3, retrievedPrintArea);
+    }
+
+    /**
+     * Tests the setting of print areas with coordinates (Row/Column designations)
+     *
+     */
+    public void testPrintAreaCoords(){
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        workbook.createSheet("Test Print Area");
+        String sheetName = workbook.getSheetName(0);
+
+        workbook.setPrintArea(0, 0, 1, 0, 0);
+
+        String retrievedPrintArea = workbook.getPrintArea(0);
+
+        assertNotNull("Print Area not defined for first sheet", retrievedPrintArea);
+        assertEquals("'" + sheetName + "'!$A$1:$B$1", retrievedPrintArea);
+    }
+
+
+    /**
+     * Tests the parsing of union area expressions, and re-display in the presence of sheet names
+     * with special characters.
+     */
+    public void testPrintAreaUnion(){
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        workbook.createSheet("Test Print Area");
+
+        String reference = "$A$1:$B$1,$D$1:$F$2";
+        workbook.setPrintArea(0, reference);
+        String retrievedPrintArea = workbook.getPrintArea(0);
+        assertNotNull("Print Area not defined for first sheet", retrievedPrintArea);
+        assertEquals("'Test Print Area'!$A$1:$B$1,'Test Print Area'!$D$1:$F$2", retrievedPrintArea);
+    }
+
+    /**
+     * Verifies an existing print area is deleted
+     *
+     */
+    public void testPrintAreaRemove() {
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        workbook.createSheet("Test Print Area");
+        workbook.getSheetName(0);
+
+        workbook.setPrintArea(0, 0, 1, 0, 0);
+
+        String retrievedPrintArea = workbook.getPrintArea(0);
+
+        assertNotNull("Print Area not defined for first sheet", retrievedPrintArea);
+
+        workbook.removePrintArea(0);
+        assertNull("PrintArea was not removed", workbook.getPrintArea(0));
+    }
+
+    /**
+     * Test that multiple named ranges can be added written and read
+     */
+    public void testMultipleNamedWrite() {
+        Workbook wb	 = getTestDataProvider().createWorkbook();
+
+
+        wb.createSheet("testSheet1");
+        String sheetName = wb.getSheetName(0);
+
+        assertEquals("testSheet1", sheetName);
+
+        //Creating new Named Range
+        Name newNamedRange = wb.createName();
+
+        newNamedRange.setNameName("RangeTest");
+        newNamedRange.setRefersToFormula(sheetName + "!$D$4:$E$8");
+
+        //Creating another new Named Range
+        Name newNamedRange2 = wb.createName();
+
+        newNamedRange2.setNameName("AnotherTest");
+        newNamedRange2.setRefersToFormula(sheetName + "!$F$1:$G$6");
+
+        wb.getNameAt(0);
+
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+        Name nm =wb.getNameAt(wb.getNameIndex("RangeTest"));
+        assertTrue("Name is "+nm.getNameName(),"RangeTest".equals(nm.getNameName()));
+        assertTrue("Reference is "+nm.getRefersToFormula(),(wb.getSheetName(0)+"!$D$4:$E$8").equals(nm.getRefersToFormula()));
+
+        nm = wb.getNameAt(wb.getNameIndex("AnotherTest"));
+        assertTrue("Name is "+nm.getNameName(),"AnotherTest".equals(nm.getNameName()));
+        assertTrue("Reference is "+nm.getRefersToFormula(),newNamedRange2.getRefersToFormula().equals(nm.getRefersToFormula()));
+    }
+    /**
+     * Verifies correct functioning for "single cell named range" (aka "named cell")
+     */
+    public void testNamedCell_1() {
+
+        // setup for this testcase
+        String sheetName = "Test Named Cell";
+        String cellName = "named_cell";
+        String cellValue = "TEST Value";
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet sheet = wb.createSheet(sheetName);
+        CreationHelper factory = wb.getCreationHelper();
+        sheet.createRow(0).createCell(0).setCellValue(factory.createRichTextString(cellValue));
+
+        // create named range for a single cell using areareference
+        Name namedCell = wb.createName();
+        namedCell.setNameName(cellName);
+        String reference = "'" + sheetName + "'" + "!A1:A1";
+        namedCell.setRefersToFormula(reference);
+
+        // retrieve the newly created named range
+        int namedCellIdx = wb.getNameIndex(cellName);
+        Name aNamedCell = wb.getNameAt(namedCellIdx);
+        assertNotNull(aNamedCell);
+
+        // retrieve the cell at the named range and test its contents
+        AreaReference aref = new AreaReference(aNamedCell.getRefersToFormula());
+        assertTrue("Should be exactly 1 cell in the named cell :'" +cellName+"'", aref.isSingleCell());
+
+        CellReference cref = aref.getFirstCell();
+        assertNotNull(cref);
+        Sheet s = wb.getSheet(cref.getSheetName());
+        assertNotNull(s);
+        Row r = sheet.getRow(cref.getRow());
+        Cell c = r.getCell(cref.getCol());
+        String contents = c.getRichStringCellValue().getString();
+        assertEquals("Contents of cell retrieved by its named reference", contents, cellValue);
+    }
+
+    /**
+     * Verifies correct functioning for "single cell named range" (aka "named cell")
+     */
+    public void testNamedCell_2() {
+
+        // setup for this testcase
+        String sname = "TestSheet", cname = "TestName", cvalue = "TestVal";
+        Workbook wb = getTestDataProvider().createWorkbook();
+        CreationHelper factory = wb.getCreationHelper();
+        Sheet sheet = wb.createSheet(sname);
+        sheet.createRow(0).createCell(0).setCellValue(factory.createRichTextString(cvalue));
+
+        // create named range for a single cell using cellreference
+        Name namedCell = wb.createName();
+        namedCell.setNameName(cname);
+        String reference = sname+"!A1";
+        namedCell.setRefersToFormula(reference);
+
+        // retrieve the newly created named range
+        int namedCellIdx = wb.getNameIndex(cname);
+        Name aNamedCell = wb.getNameAt(namedCellIdx);
+        assertNotNull(aNamedCell);
+
+        // retrieve the cell at the named range and test its contents
+        CellReference cref = new CellReference(aNamedCell.getRefersToFormula());
+        assertNotNull(cref);
+        Sheet s = wb.getSheet(cref.getSheetName());
+        Row r = sheet.getRow(cref.getRow());
+        Cell c = r.getCell(cref.getCol());
+        String contents = c.getRichStringCellValue().getString();
+        assertEquals("Contents of cell retrieved by its named reference", contents, cvalue);
+    }
+
 }
\ No newline at end of file

Added: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java?rev=759714&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java Sun Mar 29 16:10:40 2009
@@ -0,0 +1,53 @@
+/* ====================================================================
+   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.ss.usermodel;
+
+import junit.framework.TestCase;
+import org.apache.poi.ss.ITestDataProvider;
+
+/**
+ * @author Yegor Kozlov
+ */
+public abstract class BaseTestPicture extends TestCase {
+
+    protected abstract ITestDataProvider getTestDataProvider();
+
+    public void baseTestResize(ClientAnchor referenceAnchor) {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        Sheet sh1 = wb.createSheet();
+        Drawing  p1 = sh1.createDrawingPatriarch();
+        CreationHelper factory = wb.getCreationHelper();
+
+        byte[] pictureData = getTestDataProvider().getTestDataFileContent("logoKarmokar4.png");
+        int idx1 = wb.addPicture( pictureData, Workbook.PICTURE_TYPE_PNG );
+        Picture picture = p1.createPicture(factory.createClientAnchor(), idx1);
+        picture.resize();
+        ClientAnchor anchor1 = picture.getPreferredSize();
+
+        //assert against what would BiffViewer print if we insert the image in xls and dump the file
+        assertEquals(referenceAnchor.getCol1(), anchor1.getCol1());
+        assertEquals(referenceAnchor.getRow1(), anchor1.getRow1());
+        assertEquals(referenceAnchor.getCol2(), anchor1.getCol2());
+        assertEquals(referenceAnchor.getRow2(), anchor1.getRow2());
+        assertEquals(referenceAnchor.getDx1(), anchor1.getDx1());
+        assertEquals(referenceAnchor.getDy1(), anchor1.getDy1());
+        assertEquals(referenceAnchor.getDx2(), anchor1.getDx2());
+        assertEquals(referenceAnchor.getDy2(), anchor1.getDy2());
+    }
+
+
+}
\ No newline at end of file

Propchange: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java?rev=759714&r1=759713&r2=759714&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java Sun Mar 29 16:10:40 2009
@@ -41,6 +41,9 @@
         assertEquals(-1, row.getFirstCellNum());
         assertEquals(-1, row.getLastCellNum());
 
+        //getting cells from an empty row should returns null
+        for(int i=0; i < 10; i++) assertNull(row.getCell(i));
+
         row.createCell(2);
         assertEquals(2, row.getFirstCellNum());
         assertEquals(3, row.getLastCellNum());

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java?rev=759714&r1=759713&r2=759714&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java Sun Mar 29 16:10:40 2009
@@ -562,4 +562,31 @@
         assertFalse(sheet.isColumnBroken(11));
         assertFalse(sheet.isColumnBroken(12));
     }
+
+    public void testGetFirstLastRowNum() {
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        Sheet sheet = workbook.createSheet("Sheet 1");
+        Row row10 = sheet.createRow(9);
+        Row row1 = sheet.createRow(0);
+        Row row2 = sheet.createRow(1);
+        assertEquals(0, sheet.getFirstRowNum());
+        assertEquals(9, sheet.getLastRowNum());
+    }
+
+    public void testGetFooter() {
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        Sheet sheet = workbook.createSheet("Sheet 1");
+        assertNotNull(sheet.getFooter());
+        sheet.getFooter().setCenter("test center footer");
+        assertEquals("test center footer", sheet.getFooter().getCenter());
+    }
+
+    public void testGetSetColumnHidden() {
+        Workbook workbook = getTestDataProvider().createWorkbook();
+        Sheet sheet = workbook.createSheet("Sheet 1");
+        sheet.setColumnHidden(2, true);
+        assertTrue(sheet.isColumnHidden(2));
+    }
+
+
 }
\ No newline at end of file

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java?rev=759714&r1=759713&r2=759714&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java Sun Mar 29 16:10:40 2009
@@ -273,4 +273,77 @@
         assertSame(sheet, cell.getSheet());
         assertSame(row, cell.getRow());
     }
+
+    /** Tests that all of the unicode capable string fields can be set, written and then read back
+     *
+     *
+     */
+    public void testUnicodeInAll() throws Exception {
+        Workbook wb = getTestDataProvider().createWorkbook();
+        CreationHelper factory = wb.getCreationHelper();
+        //Create a unicode dataformat (contains euro symbol)
+        DataFormat df = wb.createDataFormat();
+        final String formatStr = "_([$\u20ac-2]\\\\\\ * #,##0.00_);_([$\u20ac-2]\\\\\\ * \\\\\\(#,##0.00\\\\\\);_([$\u20ac-2]\\\\\\ *\\\"\\-\\\\\"??_);_(@_)";
+        short fmt = df.getFormat(formatStr);
+
+        //Create a unicode sheet name (euro symbol)
+        Sheet s = wb.createSheet("\u20ac");
+
+        //Set a unicode header (you guessed it the euro symbol)
+        Header h = s.getHeader();
+        h.setCenter("\u20ac");
+        h.setLeft("\u20ac");
+        h.setRight("\u20ac");
+
+        //Set a unicode footer
+        Footer f = s.getFooter();
+        f.setCenter("\u20ac");
+        f.setLeft("\u20ac");
+        f.setRight("\u20ac");
+
+        Row r = s.createRow(0);
+        Cell c = r.createCell(1);
+        c.setCellValue(12.34);
+        c.getCellStyle().setDataFormat(fmt);
+
+        Cell c2 = r.createCell(2);
+        c.setCellValue(factory.createRichTextString("\u20ac"));
+
+        Cell c3 = r.createCell(3);
+        String formulaString = "TEXT(12.34,\"\u20ac###,##\")";
+        c3.setCellFormula(formulaString);
+
+        wb = getTestDataProvider().writeOutAndReadBack(wb);
+
+        //Test the sheetname
+        s = wb.getSheet("\u20ac");
+        assertNotNull(s);
+
+        //Test the header
+        h = s.getHeader();
+        assertEquals(h.getCenter(), "\u20ac");
+        assertEquals(h.getLeft(), "\u20ac");
+        assertEquals(h.getRight(), "\u20ac");
+
+        //Test the footer
+        f = s.getFooter();
+        assertEquals(f.getCenter(), "\u20ac");
+        assertEquals(f.getLeft(), "\u20ac");
+        assertEquals(f.getRight(), "\u20ac");
+
+        //Test the dataformat
+        r = s.getRow(0);
+        c = r.getCell(1);
+        df = wb.createDataFormat();
+        assertEquals(formatStr, df.getFormat(c.getCellStyle().getDataFormat()));
+
+        //Test the cell string value
+        c2 = r.getCell(2);
+        assertEquals(c.getRichStringCellValue().getString(), "\u20ac");
+
+        //Test the cell formula
+        c3 = r.getCell(3);
+        assertEquals(c3.getCellFormula(), formulaString);
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message