ZMSFileChangeLogStoreCommon { void setupFilePermissions(File file, Set<PosixFilePermission> perms) { try { filesHelper.setPosixFilePermissions(file, perms); } catch (IOException ex) { error("unable to setup file with permissions: " + ex.getMessage()); } } ZMSFileChangeLogStoreCommon(final String rootDirectory); boolean supportsFullRefresh(); SignedDomain getLocalSignedDomain(final String domainName); SignedDomain getServerSignedDomain(ZMSClient zmsClient, final String domainName); void removeLocalDomain(String domainName); void saveLocalDomain(String domainName, SignedDomain signedDomain); synchronized T get(String name, Class<T> classType); synchronized void put(String name, byte[] data); synchronized void delete(String name); List<String> getLocalDomainList(); Set<String> getServerDomainList(ZMSClient zmsClient); SignedDomains getServerDomainModifiedList(ZMSClient zmsClient); String retrieveLastModificationTime(); void setLastModificationTimestamp(String newLastModTime); String retrieveTagHeader(Map<String, List<String>> responseHeaders); SignedDomains getUpdatedSignedDomains(ZMSClient zmsClient, StringBuilder lastModTimeBuffer); public String lastModTime; }
@Test public void testSetFilePermissionsException() throws IOException { ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); FilesHelper helper = Mockito.mock(FilesHelper.class); Mockito.when(helper.setPosixFilePermissions(Mockito.any(), Mockito.any())) .thenThrow(new IOException("io exception")); fstore.filesHelper = helper; try { File file = new File(FSTORE_PATH, "domain"); Set<PosixFilePermission> perms = EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE); fstore.setupFilePermissions(file, perms); fail(); } catch (Exception ex) { assertTrue(true); } }