aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
diff options
context:
space:
mode:
authorAndrew C. Oliver <acoliver@apache.org>2007-07-02 08:10:28 +0000
committerAndrew C. Oliver <acoliver@apache.org>2007-07-02 08:10:28 +0000
commita68e4bd7fdd527141817a9e43b56b32edbfd81fd (patch)
treeccfd44cecb4ef4a48371b166ae83b5c1e902716c /src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
parent62432eae1ed5ea8a61e569a31517ecafde0d2254 (diff)
downloadpoi-a68e4bd7fdd527141817a9e43b56b32edbfd81fd.tar.gz
poi-a68e4bd7fdd527141817a9e43b56b32edbfd81fd.zip
Now can protect sheets with a password. So everyone may cease whining about it
already :-) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@552425 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
index 2a8561ebd6..6d7feef3b3 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
@@ -26,6 +26,7 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.HCenterRecord;
import org.apache.poi.hssf.record.ProtectRecord;
+import org.apache.poi.hssf.record.PasswordRecord;
import org.apache.poi.hssf.record.SCLRecord;
import org.apache.poi.hssf.record.VCenterRecord;
import org.apache.poi.hssf.record.WSBoolRecord;
@@ -38,6 +39,7 @@ import org.apache.poi.util.TempFile;
*
*
* @author Glen Stampoultzis (glens at apache.org)
+ * @author Andrew C. Oliver (acoliver apache org)
*/
public class TestHSSFSheet
@@ -242,6 +244,20 @@ public class TestHSSFSheet
assertTrue(hssfSheet.getProtect());
}
+ public void testProtectSheet() {
+ short expected = (short)0xfef1;
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet s = wb.createSheet();
+ s.protectSheet("abcdefghij");
+ Sheet sheet = s.getSheet();
+ ProtectRecord protect = sheet.getProtect();
+ PasswordRecord pass = sheet.getPassword();
+ assertTrue("protection should be on",protect.getProtect());
+ assertTrue("object protection should be on",sheet.isProtected()[1]);
+ assertTrue("scenario protection should be on",sheet.isProtected()[2]);
+ assertEquals("well known value for top secret hash should be "+Integer.toHexString(expected).substring(4),expected,pass.getPassword());
+ }
+
public void testZoom()
throws Exception