public class TestDocumentProtection {
@Test
public void testShouldReadEnforcementProperties() throws Exception {
XWPFDocument documentWithoutDocumentProtectionTag = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedReadonlyProtection());
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedFillingFormsProtection());
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedCommentsProtection());
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedTrackedChangesProtection());
XWPFDocument documentWithoutEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection_tag_existing.docx");
assertFalse(documentWithoutEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithoutEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithoutEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithoutEnforcement.isEnforcedTrackedChangesProtection());
XWPFDocument documentWithReadonlyEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_readonly_no_password.docx");
assertTrue(documentWithReadonlyEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithReadonlyEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithReadonlyEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithReadonlyEnforcement.isEnforcedTrackedChangesProtection());
XWPFDocument documentWithFillingFormsEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_forms_no_password.docx");
assertTrue(documentWithFillingFormsEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithFillingFormsEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithFillingFormsEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithFillingFormsEnforcement.isEnforcedTrackedChangesProtection());
XWPFDocument documentWithCommentsEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_comments_no_password.docx");
assertFalse(documentWithCommentsEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithCommentsEnforcement.isEnforcedReadonlyProtection());
assertTrue(documentWithCommentsEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithCommentsEnforcement.isEnforcedTrackedChangesProtection());
XWPFDocument documentWithTrackedChangesEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_trackedChanges_no_password.docx");
assertFalse(documentWithTrackedChangesEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithTrackedChangesEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithTrackedChangesEnforcement.isEnforcedCommentsProtection());
assertTrue(documentWithTrackedChangesEnforcement.isEnforcedTrackedChangesProtection());
}