Source Code Cross Referenced for TestPOIDocumentScratchpad.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi;
019:
020:        import junit.framework.TestCase;
021:        import java.io.*;
022:
023:        import org.apache.poi.hslf.HSLFSlideShow;
024:        import org.apache.poi.hwpf.HWPFDocument;
025:        import org.apache.poi.poifs.filesystem.*;
026:
027:        /**
028:         * Tests that POIDocument correctly loads and saves the common
029:         *  (hspf) Document Properties
030:         *
031:         * This is part 2 of 2 of the tests - it only does the POIDocuments
032:         *  which are part of the scratchpad (not main)
033:         *  
034:         * @author Nick Burch (nick at torchbox dot com)
035:         */
036:        public class TestPOIDocumentScratchpad extends TestCase {
037:            // The POI Documents to work on
038:            private POIDocument doc;
039:            private POIDocument doc2;
040:            // POIFS primed on the test (powerpoint and word) data
041:            private POIFSFileSystem pfs;
042:            private POIFSFileSystem pfs2;
043:
044:            /**
045:             * Set things up, using a PowerPoint document and 
046:             *  a Word Document for our testing
047:             */
048:            public void setUp() throws Exception {
049:                String dirnameHSLF = System.getProperty("HSLF.testdata.path");
050:                String filenameHSLF = dirnameHSLF + "/basic_test_ppt_file.ppt";
051:                String dirnameHSSF = System.getProperty("HSSF.testdata.path");
052:                String filenameHSSF = dirnameHSLF + "/DateFormats.ppt";
053:                String dirnameHWPF = System.getProperty("HWPF.testdata.path");
054:                String filenameHWPF = dirnameHWPF + "/test2.doc";
055:
056:                FileInputStream fisHSLF = new FileInputStream(filenameHSLF);
057:                pfs = new POIFSFileSystem(fisHSLF);
058:                doc = new HSLFSlideShow(pfs);
059:
060:                FileInputStream fisHWPF = new FileInputStream(filenameHWPF);
061:                pfs2 = new POIFSFileSystem(fisHWPF);
062:                doc2 = new HWPFDocument(pfs2);
063:            }
064:
065:            public void testReadProperties() throws Exception {
066:                // We should have both sets
067:                assertNotNull(doc.getDocumentSummaryInformation());
068:                assertNotNull(doc.getSummaryInformation());
069:
070:                // Check they are as expected for the test doc
071:                assertEquals("Hogwarts", doc.getSummaryInformation()
072:                        .getAuthor());
073:                assertEquals(10598, doc.getDocumentSummaryInformation()
074:                        .getByteCount());
075:            }
076:
077:            public void testReadProperties2() throws Exception {
078:                // Check again on the word one
079:                assertNotNull(doc2.getDocumentSummaryInformation());
080:                assertNotNull(doc2.getSummaryInformation());
081:
082:                assertEquals("Hogwarts", doc2.getSummaryInformation()
083:                        .getAuthor());
084:                assertEquals("", doc2.getSummaryInformation().getKeywords());
085:                assertEquals(0, doc2.getDocumentSummaryInformation()
086:                        .getByteCount());
087:            }
088:
089:            public void testWriteProperties() throws Exception {
090:                // Just check we can write them back out into a filesystem
091:                POIFSFileSystem outFS = new POIFSFileSystem();
092:                doc.writeProperties(outFS);
093:
094:                // Should now hold them
095:                assertNotNull(outFS
096:                        .createDocumentInputStream("\005SummaryInformation"));
097:                assertNotNull(outFS
098:                        .createDocumentInputStream("\005DocumentSummaryInformation"));
099:            }
100:
101:            public void testWriteReadProperties() throws Exception {
102:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
103:
104:                // Write them out
105:                POIFSFileSystem outFS = new POIFSFileSystem();
106:                doc.writeProperties(outFS);
107:                outFS.writeFilesystem(baos);
108:
109:                // Create a new version
110:                ByteArrayInputStream bais = new ByteArrayInputStream(baos
111:                        .toByteArray());
112:                POIFSFileSystem inFS = new POIFSFileSystem(bais);
113:
114:                // Check they're still there
115:                doc.filesystem = inFS;
116:                doc.readProperties();
117:
118:                // Delegate test
119:                testReadProperties();
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.