Skip to content

Commit

Permalink
#74201980 added a unit test to verify opening and saving containers w…
Browse files Browse the repository at this point in the history
…ithout data files
  • Loading branch information
Rainer Villido authored and Rainer Villido committed Feb 1, 2016
1 parent 4716424 commit a1c7926
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/org/digidoc4j/impl/bdoc/AsicFacadeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package org.digidoc4j.impl.bdoc;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.digidoc4j.*;
Expand All @@ -22,6 +23,7 @@
import org.digidoc4j.testutils.TestSigningHelper;
import org.digidoc4j.utils.Helper;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
Expand Down Expand Up @@ -1761,6 +1763,23 @@ public void bdocTM_OcspResponderCert_shouldContainResponderCertIdAttribute() thr
assertTrue(signatureContainsOcspResponderCertificate(xAdESSignature));
}

@Test
public void savingContainerWithoutSignatures_shouldNotThrowException() throws Exception {
Container container = create();
container.addDataFile("testFiles/test.txt", "text/plain");
assertTrue(container.getSignatures().isEmpty());
assertEquals(1, container.getDataFiles().size());
assertTrue(container.validate().isValid());
String containerPath = testFolder.newFile().getPath();
container.saveAsFile(containerPath);
Container savedContainer = open(containerPath);
assertTrue(savedContainer.getSignatures().isEmpty());
assertEquals(1, container.getDataFiles().size());
byte[] expectedDataFileBytes = FileUtils.readFileToByteArray(new File("testFiles/test.txt"));
byte[] actualDataFileBytes = savedContainer.getDataFiles().get(0).getBytes();
Assert.assertArrayEquals(expectedDataFileBytes, actualDataFileBytes);
}

private void assertSignatureContains(BDocSignature signature, String name) {
assertNotNull(findSignedFile(signature, name));
}
Expand Down

0 comments on commit a1c7926

Please sign in to comment.