public void setUp()
        {
            anchorContainer = new TrustAnchorContainer();
            fixture         = new IdentityManagementFixture();

            // Create a directory and prepares two certificates.
            certificateDirectoryPath = new FileInfo(System.IO.Path.Combine(net.named_data.jndn.tests.integration_tests.IntegrationTestsCommon.getPolicyConfigDirectory().FullName, "test-cert-dir"));
            System.IO.Directory.CreateDirectory(certificateDirectoryPath.FullName);

            certificatePath1 = new FileInfo(System.IO.Path.Combine(certificateDirectoryPath.FullName, "trust-anchor-1.cert"));
            certificatePath2 = new FileInfo(System.IO.Path.Combine(certificateDirectoryPath.FullName, "trust-anchor-2.cert"));

            identity1    = fixture.addIdentity(new Name("/TestAnchorContainer/First"));
            certificate1 = identity1.getDefaultKey().getDefaultCertificate();
            fixture.saveCertificateToFile(certificate1,
                                          certificatePath1.FullName);

            identity2 = fixture
                        .addIdentity(new Name("/TestAnchorContainer/Second"));
            certificate2 = identity2.getDefaultKey().getDefaultCertificate();
            fixture.saveCertificateToFile(certificate2,
                                          certificatePath2.FullName);
        }
        public void testDynamicAnchorFromDirectory()
        {
            certificatePath2.delete();

            anchorContainer.insert("group",
                                   certificateDirectoryPath.FullName, 400.0d, true);

            Assert.AssertTrue(anchorContainer.find(identity1.getName()) != null);
            Assert.AssertTrue(anchorContainer.find(identity2.getName()) == null);
            Assert.AssertEquals(1, anchorContainer.getGroup("group").size());

            fixture.saveCertificateToFile(certificate2,
                                          certificatePath2.FullName);

            // Wait for the refresh period to expire. The dynamic anchors should remain.
            ILOG.J2CsMapping.Threading.ThreadWrapper.sleep(500);

            Assert.AssertTrue(anchorContainer.find(identity1.getName()) != null);
            Assert.AssertTrue(anchorContainer.find(identity2.getName()) != null);
            Assert.AssertEquals(2, anchorContainer.getGroup("group").size());

            if (certificateDirectoryPath.Exists)
            {
                /* foreach */
                // Delete files from a previous test.
                foreach (FileInfo file  in  certificateDirectoryPath.listFiles())
                {
                    file.delete();
                }
            }

            // Wait for the refresh period to expire. The dynamic anchors should be gone.
            ILOG.J2CsMapping.Threading.ThreadWrapper.sleep(500);

            Assert.AssertTrue(anchorContainer.find(identity1.getName()) == null);
            Assert.AssertTrue(anchorContainer.find(identity2.getName()) == null);
            Assert.AssertEquals(0, anchorContainer.getGroup("group").size());
        }