ZMSFileMTLSChangeLogStore implements ChangeLogStore { @Override public List<String> getLocalDomainList() { return changeLogStoreCommon.getLocalDomainList(); } ZMSFileMTLSChangeLogStore(String rootDirectory, final String keyPath, final String certPath,
                                     final String trustStorePath, final String trustStorePassword); @Override boolean supportsFullRefresh(); @Override SignedDomain getLocalSignedDomain(String domainName); @Override SignedDomain getServerSignedDomain(String domainName); @Override void removeLocalDomain(String domainName); @Override void saveLocalDomain(String domainName, SignedDomain signedDomain); @Override List<String> getLocalDomainList(); @Override Set<String> getServerDomainList(); @Override SignedDomains getServerDomainModifiedList(); @Override void setLastModificationTimestamp(String newLastModTime); @Override SignedDomains getUpdatedSignedDomains(StringBuilder lastModTimeBuffer);  }
@Test public void testGetLocalDomainListEmpty() throws InterruptedException, IOException, KeyRefresherException { ZMSFileMTLSChangeLogStore fstore = new ZMSFileMTLSChangeLogStore(FSTORE_PATH, keyPath, certPath, trustStorePath, trustStorePassword); List<String> ls = fstore.getLocalDomainList(); assertTrue(ls.isEmpty()); }
@Test public void testGetLocalDomainListError() throws InterruptedException, IOException, KeyRefresherException { ZMSFileMTLSChangeLogStore fstore = new ZMSFileMTLSChangeLogStore(FSTORE_PATH, keyPath, certPath, trustStorePath, trustStorePassword); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); File dir = Mockito.spy(cstore.rootDir); Mockito.when(dir.list()).thenReturn(null); cstore.rootDir = dir; List<String> ls = fstore.getLocalDomainList(); assertTrue(ls.isEmpty()); }
@Test public void testGetLocalDomainListSingle() throws IOException, KeyRefresherException, InterruptedException { File rootDir = new File(FSTORE_PATH); rootDir.mkdirs(); Struct lastModStruct = new Struct(); lastModStruct.put("lastModTime", 1001); File file = new File(FSTORE_PATH, ".lastModTime"); Path path = Paths.get(file.toURI()); Files.write(path, JSON.bytes(lastModStruct)); ZMSFileMTLSChangeLogStore fstore = new ZMSFileMTLSChangeLogStore(FSTORE_PATH, keyPath, certPath, trustStorePath, trustStorePassword); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 1); assertTrue(ls.contains("test1")); }
@Test public void testGetLocalDomainListMultiple() throws InterruptedException, IOException, KeyRefresherException { ZMSFileMTLSChangeLogStore fstore = new ZMSFileMTLSChangeLogStore(FSTORE_PATH, keyPath, certPath, trustStorePath, trustStorePassword); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test2", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test3", JSON.bytes(data)); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 3); assertTrue(ls.contains("test1")); assertTrue(ls.contains("test2")); assertTrue(ls.contains("test3")); }
@Test public void testGetLocalDomainListHidden() throws InterruptedException, IOException, KeyRefresherException { ZMSFileMTLSChangeLogStore fstore = new ZMSFileMTLSChangeLogStore(FSTORE_PATH, keyPath, certPath, trustStorePath, trustStorePassword); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put(".test2", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put(".test3", JSON.bytes(data)); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 1); assertTrue(ls.contains("test1")); }
@Test public void testGetLocalDomainListDelete() throws InterruptedException, IOException, KeyRefresherException { ZMSFileMTLSChangeLogStore fstore = new ZMSFileMTLSChangeLogStore(FSTORE_PATH, keyPath, certPath, trustStorePath, trustStorePassword); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test2", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test3", JSON.bytes(data)); cstore.delete("test2"); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 2); assertTrue(ls.contains("test1")); assertTrue(ls.contains("test3")); }