You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/21 02:55:56 UTC

svn commit: r776905 [2/2] - in /poi/trunk/src/ooxml/testcases/org/apache/poi: openxml4j/opc/ openxml4j/opc/compliance/ openxml4j/opc/internal/ xssf/ xssf/model/ xssf/usermodel/

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java Thu May 21 00:55:56 2009
@@ -1,104 +1,105 @@
-/* ====================================================================
-   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 junit.framework.TestCase;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.POIXMLDocumentPart;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
-
-import java.util.List;
-import java.util.Arrays;
-import java.io.IOException;
-
-/**
- * @author Yegor Kozlov
- */
-public class TestXSSFPictureData extends TestCase {
-    public void testRead(){
-        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithDrawing.xlsx");
-        List<XSSFPictureData> pictures = wb.getAllPictures();
-        //wb.getAllPictures() should return the same instance across multiple calls
-        assertSame(pictures, wb.getAllPictures());
-
-        assertEquals(5, pictures.size());
-        String[] ext = {"jpeg", "emf", "png", "emf", "wmf"};
-        for (int i = 0; i < pictures.size(); i++) {
-            assertEquals(ext[i], pictures.get(i).suggestFileExtension());
-        }
-
-        int num = pictures.size();
-
-        byte[] pictureData = {0xA, 0xB, 0XC, 0xD, 0xE, 0xF};
-
-        int idx = wb.addPicture(pictureData, XSSFWorkbook.PICTURE_TYPE_JPEG);
-        assertEquals(num + 1, pictures.size());
-        //idx is 0-based index in the #pictures array
-        assertEquals(pictures.size() - 1, idx);
-        XSSFPictureData pict = pictures.get(idx);
-        assertEquals("jpeg", pict.suggestFileExtension());
-        assertTrue(Arrays.equals(pictureData, pict.getData()));
-    }
-
-    public void testNew(){
-        XSSFWorkbook wb = new XSSFWorkbook();
-        XSSFSheet sheet = wb.createSheet();
-        XSSFDrawing drawing = sheet.createDrawingPatriarch();
-
-        byte[] jpegData = "test jpeg data".getBytes();
-        byte[] wmfData =  "test wmf data".getBytes();
-        byte[] pngData =  "test png data".getBytes();
-
-        List<XSSFPictureData> pictures = wb.getAllPictures();
-        assertEquals(0, pictures.size());
-
-        int jpegIdx = wb.addPicture(jpegData, XSSFWorkbook.PICTURE_TYPE_JPEG);
-        assertEquals(1, pictures.size());
-        assertEquals("jpeg", pictures.get(jpegIdx).suggestFileExtension());
-        assertTrue(Arrays.equals(jpegData, pictures.get(jpegIdx).getData()));
-
-        int wmfIdx = wb.addPicture(wmfData, XSSFWorkbook.PICTURE_TYPE_WMF);
-        assertEquals(2, pictures.size());
-        assertEquals("wmf", pictures.get(wmfIdx).suggestFileExtension());
-        assertTrue(Arrays.equals(wmfData, pictures.get(wmfIdx).getData()));
-
-        int pngIdx = wb.addPicture(pngData, XSSFWorkbook.PICTURE_TYPE_PNG);
-        assertEquals(3, pictures.size());
-        assertEquals("png", pictures.get(pngIdx).suggestFileExtension());
-        assertTrue(Arrays.equals(pngData, pictures.get(pngIdx).getData()));
-
-        //TODO finish usermodel API for XSSFPicture
-        XSSFPicture p1 = drawing.createPicture(new XSSFClientAnchor(), jpegIdx);
-        XSSFPicture p2 = drawing.createPicture(new XSSFClientAnchor(), wmfIdx);
-        XSSFPicture p3 = drawing.createPicture(new XSSFClientAnchor(), pngIdx);
-
-        //check that the added pictures are accessible after write
-        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
-        List<XSSFPictureData> pictures2 = wb.getAllPictures();
-        assertEquals(3, pictures2.size());
-
-        assertEquals("jpeg", pictures2.get(jpegIdx).suggestFileExtension());
-        assertTrue(Arrays.equals(jpegData, pictures2.get(jpegIdx).getData()));
-
-        assertEquals("wmf", pictures2.get(wmfIdx).suggestFileExtension());
-        assertTrue(Arrays.equals(wmfData, pictures2.get(wmfIdx).getData()));
-
-        assertEquals("png", pictures2.get(pngIdx).suggestFileExtension());
-        assertTrue(Arrays.equals(pngData, pictures2.get(pngIdx).getData()));
-
-    }
-}
+/* ====================================================================
+   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 junit.framework.TestCase;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.POIXMLDocumentPart;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
+
+import java.util.List;
+import java.util.Arrays;
+import java.io.IOException;
+
+/**
+ * @author Yegor Kozlov
+ */
+public final class TestXSSFPictureData extends TestCase {
+    public void testRead(){
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithDrawing.xlsx");
+        List<XSSFPictureData> pictures = wb.getAllPictures();
+        //wb.getAllPictures() should return the same instance across multiple calls
+        assertSame(pictures, wb.getAllPictures());
+
+        assertEquals(5, pictures.size());
+        String[] ext = {"jpeg", "emf", "png", "emf", "wmf"};
+        for (int i = 0; i < pictures.size(); i++) {
+            assertEquals(ext[i], pictures.get(i).suggestFileExtension());
+        }
+
+        int num = pictures.size();
+
+        byte[] pictureData = {0xA, 0xB, 0XC, 0xD, 0xE, 0xF};
+
+        int idx = wb.addPicture(pictureData, XSSFWorkbook.PICTURE_TYPE_JPEG);
+        assertEquals(num + 1, pictures.size());
+        //idx is 0-based index in the #pictures array
+        assertEquals(pictures.size() - 1, idx);
+        XSSFPictureData pict = pictures.get(idx);
+        assertEquals("jpeg", pict.suggestFileExtension());
+        assertTrue(Arrays.equals(pictureData, pict.getData()));
+    }
+
+    public void testNew(){
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet sheet = wb.createSheet();
+        XSSFDrawing drawing = sheet.createDrawingPatriarch();
+
+        byte[] jpegData = "test jpeg data".getBytes();
+        byte[] wmfData =  "test wmf data".getBytes();
+        byte[] pngData =  "test png data".getBytes();
+
+        List<XSSFPictureData> pictures = wb.getAllPictures();
+        assertEquals(0, pictures.size());
+
+        int jpegIdx = wb.addPicture(jpegData, XSSFWorkbook.PICTURE_TYPE_JPEG);
+        assertEquals(1, pictures.size());
+        assertEquals("jpeg", pictures.get(jpegIdx).suggestFileExtension());
+        assertTrue(Arrays.equals(jpegData, pictures.get(jpegIdx).getData()));
+
+        int wmfIdx = wb.addPicture(wmfData, XSSFWorkbook.PICTURE_TYPE_WMF);
+        assertEquals(2, pictures.size());
+        assertEquals("wmf", pictures.get(wmfIdx).suggestFileExtension());
+        assertTrue(Arrays.equals(wmfData, pictures.get(wmfIdx).getData()));
+
+        int pngIdx = wb.addPicture(pngData, XSSFWorkbook.PICTURE_TYPE_PNG);
+        assertEquals(3, pictures.size());
+        assertEquals("png", pictures.get(pngIdx).suggestFileExtension());
+        assertTrue(Arrays.equals(pngData, pictures.get(pngIdx).getData()));
+
+        //TODO finish usermodel API for XSSFPicture
+        XSSFPicture p1 = drawing.createPicture(new XSSFClientAnchor(), jpegIdx);
+        XSSFPicture p2 = drawing.createPicture(new XSSFClientAnchor(), wmfIdx);
+        XSSFPicture p3 = drawing.createPicture(new XSSFClientAnchor(), pngIdx);
+
+        //check that the added pictures are accessible after write
+        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+        List<XSSFPictureData> pictures2 = wb.getAllPictures();
+        assertEquals(3, pictures2.size());
+
+        assertEquals("jpeg", pictures2.get(jpegIdx).suggestFileExtension());
+        assertTrue(Arrays.equals(jpegData, pictures2.get(jpegIdx).getData()));
+
+        assertEquals("wmf", pictures2.get(wmfIdx).suggestFileExtension());
+        assertTrue(Arrays.equals(wmfData, pictures2.get(wmfIdx).getData()));
+
+        assertEquals("png", pictures2.get(pngIdx).suggestFileExtension());
+        assertTrue(Arrays.equals(pngData, pictures2.get(pngIdx).getData()));
+
+    }
+}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java Thu May 21 00:55:56 2009
@@ -1,134 +1,134 @@
-/* ====================================================================
-   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.io.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Comment;
-import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.model.CommentsTable;
-import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
-
-/**
- * Tests functionality of the XSSFRichTextRun object
- *
- * @author Yegor Kozlov
- */
-public class TestXSSFRichTextString extends TestCase {
-
-    public void testCreate() throws Exception {
-
-        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
-        assertEquals("Apache POI", rt.getString());
-
-        CTRst st = rt.getCTRst();
-        assertTrue(st.isSetT());
-        assertEquals("Apache POI", st.getT());
-
-        rt.append(" is cool stuff");
-        assertEquals(2, st.sizeOfRArray());
-        assertFalse(st.isSetT());
-
-        assertEquals("Apache POI is cool stuff", rt.getString());
-    }
-
-
-    public void testApplyFont() throws Exception {
-
-        XSSFRichTextString rt = new XSSFRichTextString();
-        rt.append("123");
-        rt.append("4567");
-        rt.append("89");
-
-        XSSFFont font1 = new XSSFFont();
-        font1.setBold(true);
-
-        rt.applyFont(2, 5, font1);
-
-        assertEquals(5, rt.numFormattingRuns());
-        assertEquals(0, rt.getIndexOfFormattingRun(0));
-        assertEquals(2, rt.getLengthOfFormattingRun(0));
-
-        assertEquals(2, rt.getIndexOfFormattingRun(1));
-        assertEquals(3, rt.getLengthOfFormattingRun(1));
-
-        assertEquals(5, rt.getIndexOfFormattingRun(2));
-        assertEquals(3, rt.getLengthOfFormattingRun(2));
-
-        assertEquals(8, rt.getIndexOfFormattingRun(3));
-        assertEquals(1, rt.getLengthOfFormattingRun(3));
-    }
-
-    public void testClearFormatting() throws Exception {
-
-        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
-        assertEquals("Apache POI", rt.getString());
-
-        rt.clearFormatting();
-
-        CTRst st = rt.getCTRst();
-        assertTrue(st.isSetT());
-        assertEquals("Apache POI", rt.getString());
-        assertEquals(0, rt.numFormattingRuns());
-
-        XSSFFont font = new XSSFFont();
-        font.setBold(true);
-
-        rt.applyFont(7, 10, font);
-        assertEquals(2, rt.numFormattingRuns());
-        rt.clearFormatting();
-        assertEquals("Apache POI", rt.getString());
-        assertEquals(0, rt.numFormattingRuns());
-
-    }
-
-    public void testGetFonts() throws Exception {
-
-        XSSFRichTextString rt = new XSSFRichTextString();
-
-        XSSFFont font1 = new XSSFFont();
-        font1.setFontName("Arial");
-        font1.setItalic(true);
-        rt.append("The quick", font1);
-
-        XSSFFont font1$ = rt.getFontOfFormattingRun(0);
-        assertEquals(font1.getItalic(), font1$.getItalic());
-        assertEquals(font1.getFontName(), font1$.getFontName());
-
-        XSSFFont font2 = new XSSFFont();
-        font2.setFontName("Courier");
-        font2.setBold(true);
-        rt.append(" brown fox", font2);
-
-        XSSFFont font2$ = rt.getFontOfFormattingRun(1);
-        assertEquals(font2.getBold(), font2$.getBold());
-        assertEquals(font2.getFontName(), font2$.getFontName());
-
-    }
-}
+/* ====================================================================
+   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.io.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Comment;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.model.CommentsTable;
+import org.apache.xmlbeans.XmlOptions;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+
+/**
+ * Tests functionality of the XSSFRichTextRun object
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestXSSFRichTextString extends TestCase {
+
+    public void testCreate() throws Exception {
+
+        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
+        assertEquals("Apache POI", rt.getString());
+
+        CTRst st = rt.getCTRst();
+        assertTrue(st.isSetT());
+        assertEquals("Apache POI", st.getT());
+
+        rt.append(" is cool stuff");
+        assertEquals(2, st.sizeOfRArray());
+        assertFalse(st.isSetT());
+
+        assertEquals("Apache POI is cool stuff", rt.getString());
+    }
+
+
+    public void testApplyFont() throws Exception {
+
+        XSSFRichTextString rt = new XSSFRichTextString();
+        rt.append("123");
+        rt.append("4567");
+        rt.append("89");
+
+        XSSFFont font1 = new XSSFFont();
+        font1.setBold(true);
+
+        rt.applyFont(2, 5, font1);
+
+        assertEquals(5, rt.numFormattingRuns());
+        assertEquals(0, rt.getIndexOfFormattingRun(0));
+        assertEquals(2, rt.getLengthOfFormattingRun(0));
+
+        assertEquals(2, rt.getIndexOfFormattingRun(1));
+        assertEquals(3, rt.getLengthOfFormattingRun(1));
+
+        assertEquals(5, rt.getIndexOfFormattingRun(2));
+        assertEquals(3, rt.getLengthOfFormattingRun(2));
+
+        assertEquals(8, rt.getIndexOfFormattingRun(3));
+        assertEquals(1, rt.getLengthOfFormattingRun(3));
+    }
+
+    public void testClearFormatting() throws Exception {
+
+        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
+        assertEquals("Apache POI", rt.getString());
+
+        rt.clearFormatting();
+
+        CTRst st = rt.getCTRst();
+        assertTrue(st.isSetT());
+        assertEquals("Apache POI", rt.getString());
+        assertEquals(0, rt.numFormattingRuns());
+
+        XSSFFont font = new XSSFFont();
+        font.setBold(true);
+
+        rt.applyFont(7, 10, font);
+        assertEquals(2, rt.numFormattingRuns());
+        rt.clearFormatting();
+        assertEquals("Apache POI", rt.getString());
+        assertEquals(0, rt.numFormattingRuns());
+
+    }
+
+    public void testGetFonts() throws Exception {
+
+        XSSFRichTextString rt = new XSSFRichTextString();
+
+        XSSFFont font1 = new XSSFFont();
+        font1.setFontName("Arial");
+        font1.setItalic(true);
+        rt.append("The quick", font1);
+
+        XSSFFont font1$ = rt.getFontOfFormattingRun(0);
+        assertEquals(font1.getItalic(), font1$.getItalic());
+        assertEquals(font1.getFontName(), font1$.getFontName());
+
+        XSSFFont font2 = new XSSFFont();
+        font2.setFontName("Courier");
+        font2.setBold(true);
+        rt.append(" brown fox", font2);
+
+        XSSFFont font2$ = rt.getFontOfFormattingRun(1);
+        assertEquals(font2.getBold(), font2$.getBold());
+        assertEquals(font2.getFontName(), font2$.getFontName());
+
+    }
+}



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