private void startAndStopRepo(RepoDaemonTest rdt) throws InterruptedException { Thread th = new Thread(rdt); th.start(); synchronized (this) { this.wait(); } rdt.shutdown(); th.join(); }
@Test public void testPolicyInitialization() throws Exception { Log.info(Log.FAC_TEST, "Starting testPolicyInitialization"); RepoDaemonTest rdt = new RepoDaemonTest( new String[] { "-root", _fileTestDir2, "-policy", _topdir + "/org/ccnx/ccn/repo/policyTest.xml", "-global", "/parc.com/csl/ccn/repositories/TestRepository" }, this); startAndStopRepo(rdt); File testFile = new File(_fileTestDir2 + "/" + LogStructRepoStoreProfile.CONTENT_FILE_PREFIX + "1"); long testLength = testFile.length(); startAndStopRepo(rdt); Assert.assertEquals(testLength, testFile.length()); RepoDaemonTest rdtNoChange = new RepoDaemonTest( new String[] { "-root", _fileTestDir2, "-global", "/parc.com/csl/ccn/repositories/TestRepository" }, this); Thread th = new Thread(rdtNoChange); th.start(); synchronized (this) { this.wait(); } checkNameSpace("/repoTest/data3", false); checkNameSpace("/testNameSpace/data1", true); rdtNoChange.shutdown(); th.join(); rdt = new RepoDaemonTest( new String[] { "-root", _fileTestDir2, "-prefix", "/policyTest/foo", "-global", "/parc.com/csl/ccn/repositories/TestRepository" }, this); startAndStopRepo(rdt); testLength = testFile.length(); startAndStopRepo(rdt); Assert.assertEquals(testLength, testFile.length()); th = new Thread(rdtNoChange); th.start(); synchronized (this) { this.wait(); } checkNameSpace("/testNameSpace/data1", false); checkNameSpace("/policyTest/foo/bar", true); rdtNoChange.shutdown(); th.join(); Log.info(Log.FAC_TEST, "Completed testPolicyInitialization"); }