unfinished release guide. It would be nice to have a html version.
[poi.git] / src / scratchpad / ooxml-testcases / org / apache / poi / hslf / extractor / TestHXFPowerPointExtractor.java
blob6a006ab5c810db6d332e02c3b11c7a3e0d4af4b7
1 /* ====================================================================
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 ==================================================================== */
17 package org.apache.poi.hslf.extractor;
19 import java.io.File;
21 import org.apache.poi.hslf.HSLFXML;
22 import org.apache.poi.hslf.usermodel.HSLFXMLSlideShow;
23 import org.apache.poi.hxf.HXFDocument;
25 import junit.framework.TestCase;
27 /**
28 * Tests for HXFPowerPointExtractor
30 public class TestHXFPowerPointExtractor extends TestCase {
31 /**
32 * A simple file
34 private HSLFXML xmlA;
36 protected void setUp() throws Exception {
37 super.setUp();
39 File fileA = new File(
40 System.getProperty("HSLF.testdata.path") +
41 File.separator + "sample.pptx"
44 xmlA = new HSLFXML(HXFDocument.openPackage(fileA));
47 /**
48 * Get text out of the simple file
50 public void testGetSimpleText() throws Exception {
51 new HXFPowerPointExtractor(xmlA.getPackage());
52 new HXFPowerPointExtractor(new HSLFXMLSlideShow(xmlA));
54 HXFPowerPointExtractor extractor =
55 new HXFPowerPointExtractor(xmlA.getPackage());
56 extractor.getText();
58 String text = extractor.getText();
59 assertTrue(text.length() > 0);
61 // Check Basics
62 assertTrue(text.startsWith("Lorem ipsum dolor sit amet\n"));
63 assertTrue(text.endsWith("amet\n\n"));
65 // Just slides, no notes
66 text = extractor.getText(true, false);
67 assertEquals(
68 "Lorem ipsum dolor sit amet\n" +
69 "Nunc at risus vel erat tempus posuere. Aenean non ante.\n" +
70 "\n" +
71 "Lorem ipsum dolor sit amet\n" +
72 "Lorem\n" +
73 "ipsum\n" +
74 "dolor\n" +
75 "sit\n" +
76 "amet\n" +
77 "\n", text
80 // Just notes, no slides
81 text = extractor.getText(false, true);
82 assertEquals(
83 "\n\n\n\n", text
86 // Both
87 text = extractor.getText(true, true);
88 assertEquals(
89 "Lorem ipsum dolor sit amet\n" +
90 "Nunc at risus vel erat tempus posuere. Aenean non ante.\n" +
91 "\n\n\n" +
92 "Lorem ipsum dolor sit amet\n" +
93 "Lorem\n" +
94 "ipsum\n" +
95 "dolor\n" +
96 "sit\n" +
97 "amet\n" +
98 "\n\n\n", text
101 // Via set defaults
102 extractor.setSlidesByDefault(false);
103 extractor.setNotesByDefault(true);
104 text = extractor.getText();
105 assertEquals(
106 "\n\n\n\n", text