### Question:
FileContentDelegate { public String retrieveDeploymentSHA(File deployment, File resourceDataDirectory) { String sha = null; if (deployment.isDirectory()) { File propertiesFile = new File(resourceDataDirectory, SHA256_FILE); if (propertiesFile.exists()) { FileInputStream propertiesInputStream = null; try { propertiesInputStream = new FileInputStream(propertiesFile); Properties prop = new Properties(); prop.load(propertiesInputStream); sha = prop.getProperty(RHQ_SHA_256); } catch (IOException e) { throw new RuntimeException("Error retrieving artifact's SHA256.", e); } finally { if (propertiesInputStream != null) { try { propertiesInputStream.close(); } catch (IOException e) { log.error("Failed to close input stream.", e); } } } } if (sha == null) { sha = this.saveDeploymentSHA(deployment, resourceDataDirectory); } } else { sha = this.computeSHAForArchivedContent(deployment); } return sha; } FileContentDelegate();  FileContentDelegate(File directory, String fileEnding); String getFileEnding(); File getDirectory(); void createContent(PackageDetails details, File content, boolean unzip); InputStream getContent(PackageDetails details); void deleteContent(PackageDetails details); Set<ResourcePackageDetails> discoverDeployedPackages(); String retrieveDeploymentSHA(File deployment, File resourceDataDirectory); String saveDeploymentSHA(File originalArchive, File deployment, File resourceDataDirectory); String saveDeploymentSHA(File deployment, File resourceDataDirectory);  }### Answer:
@Test public void testGetShaExplodedWithoutManifest() throws Exception { File deploymentDirectory = new File(this.getClass().getResource("/").getFile() + "deploymentDirectory"); deleteRecursive(deploymentDirectory); File sampleWithoutManifestWar = new File(this.getClass().getResource("/sampleWithoutManifest.war").getFile()); Assert.assertTrue(sampleWithoutManifestWar.exists()); ZipUtil.unzipFile(sampleWithoutManifestWar, deploymentDirectory); FileContentDelegate objectUnderTest = new FileContentDelegate(deploymentDirectory, null); String actualShaReturned = objectUnderTest.retrieveDeploymentSHA(deploymentDirectory, resourceDataDirectory); File sha256File = new File(resourceDataDirectory, "application.sha256"); Assert.assertTrue(sha256File.exists()); Assert.assertNotEquals(sha256File.length(), 0, "Empty SHA256 file!!"); InputStream propertiesFileInputStream = new FileInputStream(sha256File); Properties prop = new Properties(); prop.load(propertiesFileInputStream); String storedSha256Attribute = prop.getProperty("RHQ-Sha256"); propertiesFileInputStream.close(); Assert.assertEquals(storedSha256Attribute, "bff7f7d63ae8e4f1efebb54fa727effe1b1a8246492ad9c36779d79a9771fb2b"); Assert.assertEquals(actualShaReturned, "bff7f7d63ae8e4f1efebb54fa727effe1b1a8246492ad9c36779d79a9771fb2b"); }
@Test public void testGetShaZipped() throws Exception { File sampleWithoutManifestWar = new File(this.getClass().getResource("/sampleWithoutManifest.war").getFile()); Assert.assertTrue(sampleWithoutManifestWar.exists()); FileContentDelegate objectUnderTest = new FileContentDelegate(sampleWithoutManifestWar, null); String actualShaReturned = objectUnderTest.retrieveDeploymentSHA(sampleWithoutManifestWar, resourceDataDirectory); MessageDigestGenerator digest = new MessageDigestGenerator(MessageDigestGenerator.SHA_256); String expectedSHA256 = digest.calcDigestString(sampleWithoutManifestWar); Assert.assertEquals(actualShaReturned, expectedSHA256); }