01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: http://www.apache.org/licenses/LICENSE-2.0
10:
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:
18: package org.apache.poi.hslf;
19:
20: import junit.framework.TestCase;
21:
22: import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
23: import org.apache.poi.hslf.record.*;
24:
25: /**
26: * Tests that HSLFSlideShow does the right thing with an encrypted file
27: *
28: * @author Nick Burch (nick at torchbox dot com)
29: */
30: public class TestEncryptedFile extends TestCase {
31: // A non encrypted file
32: private String ss_ne;
33: // An encrypted file, with encrypted properties
34: private String ss_e;
35: // An encrypted file, without encrypted properties
36: private String ss_np_e;
37: // An encrypted file, with a 56 bit key
38: private String ss_56_e;
39:
40: public TestEncryptedFile() throws Exception {
41: String dirname = System.getProperty("HSLF.testdata.path");
42:
43: ss_ne = dirname + "/basic_test_ppt_file.ppt";
44: ss_e = dirname + "/Password_Protected-hello.ppt";
45: ss_np_e = dirname + "/Password_Protected-np-hello.ppt";
46: ss_56_e = dirname + "/Password_Protected-56-hello.ppt";
47: }
48:
49: public void testLoadNonEncrypted() throws Exception {
50: HSLFSlideShow hss = new HSLFSlideShow(ss_ne);
51:
52: assertNotNull(hss);
53: }
54:
55: public void testLoadEncrypted() throws Exception {
56: try {
57: new HSLFSlideShow(ss_e);
58: fail();
59: } catch (EncryptedPowerPointFileException e) {
60: // Good
61: }
62:
63: try {
64: new HSLFSlideShow(ss_np_e);
65: fail();
66: } catch (EncryptedPowerPointFileException e) {
67: // Good
68: }
69:
70: try {
71: new HSLFSlideShow(ss_56_e);
72: fail();
73: } catch (EncryptedPowerPointFileException e) {
74: // Good
75: }
76: }
77: }
|