/** * tearDown method for test case * * @throws Exception if removePoll failed */ public void tearDown() throws Exception { pollmanager.stopService(); theDaemon.getLockssRepository(testau).stopService(); theDaemon.getHashService().stopService(); theDaemon.getDatagramRouterManager().stopService(); theDaemon.getRouterManager().stopService(); theDaemon.getSystemMetrics().stopService(); TimeBase.setReal(); for (int i = 0; i < testV1msg.length; i++) { if (testV1msg[i] != null) pollmanager.removePoll(testV1msg[i].getKey()); } super.tearDown(); }
public void setUp() throws Exception { super.setUp(); String tempDirPath = getTempDir().getAbsolutePath() + File.separator; ConfigurationUtil.setFromArgs(LockssRepositoryImpl.PARAM_CACHE_LOCATION, tempDirPath); theDaemon = getMockLockssDaemon(); theDaemon.getAlertManager(); theDaemon.getPluginManager().setLoadablePluginsReady(true); theDaemon.setDaemonInited(true); theDaemon.getPluginManager().startService(); theDaemon.getCrawlManager(); sau = PluginTestUtil.createAndStartSimAu(simAuConfig(tempDirPath)); nau = PluginTestUtil.createAndStartAu(PLUGIN_NAME, natureAuConfig()); }
public void setUp() throws Exception { super.setUp(); theDaemon = getMockLockssDaemon(); mgr = new MyRepositoryManager(); theDaemon.setRepositoryManager(mgr); mgr.initService(theDaemon); }
// Test the crawl rules for eLife public void testShouldCacheProperPages() throws Exception { String ROOT_URL = "http://highwire.org/"; Properties props = new Properties(); props.setProperty(BASE_URL_KEY, ROOT_URL); props.setProperty(VOL_KEY, "2015"); DefinableArchivalUnit au = null; try { au = makeAuFromProps(props); } catch (ConfigurationException ex) { } theDaemon.getLockssRepository(au); // Test for pages that should get crawled or not // permission page/start url shouldCacheTest(ROOT_URL + "lockss-manifest/vol_2015_manifest.html", true, au); shouldCacheTest(ROOT_URL + "clockss-manifest/vol_2015_manifest.html", false, au); shouldCacheTest(ROOT_URL + "manifest/year=2015", false, au); // toc page for a volume, issue shouldCacheTest(ROOT_URL + "content/2015", false, au); shouldCacheTest(ROOT_URL + "content/2015/1", true, au); shouldCacheTest(ROOT_URL + "content/2015/2.toc", true, au); // article files shouldCacheTest(ROOT_URL + "content/2015/1/2", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.abstract", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.extract", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.full", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.full.pdf", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.full.pdf+html", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.full-text.pdf+html", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2/DC1", true, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.print", false, au); shouldCacheTest(ROOT_URL + "content/2015/1/2.explore", false, au); shouldCacheTest(ROOT_URL + "content/2015/1/2/article-info", false, au); shouldCacheTest(ROOT_URL + "content/2015/1/2/submit?param=12", false, au); shouldCacheTest(ROOT_URL + "panels_ajax_tab/hw_tab_data/node:80746/1", true, au); shouldCacheTest(ROOT_URL + "panels_ajax_tab/hw_tab_art/node:80746/1", false, au); shouldCacheTest(ROOT_URL + "highwire/citation/12/ris", true, au); shouldCacheTest(ROOT_URL + "highwire/citation/9/1/ris", false, au); shouldCacheTest(ROOT_URL + "highwire/markup/113/expansion", true, au); shouldCacheTest(ROOT_URL + "sites/all/libraries/modernizr/modernizr.min.js", true, au); shouldCacheTest(ROOT_URL + "sites/default/files/js/js_0j8_f76rvZ212f4rg.js", true, au); shouldCacheTest(ROOT_URL + "sites/default/themes/hw/font/fontawesome-webfont.eot", true, au); shouldCacheTest(ROOT_URL + "sites/default/themes/font/fontawesome-webfont.eot", true, au); shouldCacheTest( ROOT_URL + "content/hw/suppl/2014/04/23/hw.02130.DC1/hw02130_Supplemental_files.zip", true, au); shouldCacheTest("http://cdn.cloudfront.net/content/2015/1/3/F1.medium.gif", true, au); shouldCacheTest("http://cdn.mathjax.org/mathjax/latest/MathJax.js", true, au); shouldCacheTest("https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js", true, au); shouldCacheTest("", false, au); // should not get crawled - LOCKSS shouldCacheTest("http://lockss.stanford.edu", false, au); }
MyMockLockssRepositoryImpl makeRepo(String root) { MockArchivalUnit mau = new MockArchivalUnit(); MyMockLockssRepositoryImpl repo = new MyMockLockssRepositoryImpl(root); theDaemon.setLockssRepository(repo, mau); repo.initService(theDaemon); repo.startService(); return repo; }
public void setUp() throws Exception { super.setUp(); theDaemon = getMockLockssDaemon(); theDaemon.startDaemon(); mau = new MockArchivalUnit(new MockPlugin(theDaemon)); tempDirPath = getTempDir().getAbsolutePath() + File.separator; configHistoryParams(tempDirPath); repository = (HistoryRepositoryImpl) HistoryRepositoryImpl.createNewHistoryRepository(mau); repository.initService(theDaemon); repository.startService(); if (idmgr == null) { idmgr = theDaemon.getIdentityManager(); idmgr.startService(); } testID1 = idmgr.stringToPeerIdentity("127.1.2.3"); testID2 = idmgr.stringToPeerIdentity("127.4.5.6"); }
public void setUp() throws Exception { super.setUp(); tempDirPath = getTempDir().getAbsolutePath() + File.separator; theDaemon = getMockLockssDaemon(); theDaemon.getAlertManager(); theDaemon.getPluginManager().setLoadablePluginsReady(true); theDaemon.getHashService(); MockSystemMetrics metrics = new MyMockSystemMetrics(); metrics.initService(theDaemon); theDaemon.setSystemMetrics(metrics); theDaemon.setDaemonInited(true); Properties props = new Properties(); props.setProperty(SystemMetrics.PARAM_HASH_TEST_DURATION, "1000"); props.setProperty(SystemMetrics.PARAM_HASH_TEST_BYTE_STEP, "1024"); props.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath); ConfigurationUtil.setCurrentConfigFromProps(props); pluginMgr = theDaemon.getPluginManager(); pluginMgr.startService(); theDaemon.getHashService().startService(); metrics.startService(); metrics.setHashSpeed(100); simPlugin = PluginTestUtil.findPlugin(SimulatedPlugin.class); }
private V3Poller makeV3Poller(String key) throws Exception { MockArchivalUnit mau = new MockArchivalUnit(); mau.setAuId("mock"); mau.getPlugin().initPlugin(daemon); PollSpec ps = new MockPollSpec(mau, "http://www.example.com/", null, null, Poll.V3_POLL); MockNodeManager nodeMgr = new MockNodeManager(); daemon.setNodeManager(nodeMgr, mau); return new V3Poller(ps, daemon, null, key, 20000, "SHA-1"); }
private void measureHashSpeed(SimulatedArchivalUnit sau) throws Exception { MessageDigest dig = null; try { dig = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException ex) { fail("No algorithm."); } CachedUrlSet set = sau.getAuCachedUrlSet(); CachedUrlSetHasher hasher = set.getContentHasher(dig); SystemMetrics metrics = theDaemon.getSystemMetrics(); int estimate = metrics.getBytesPerMsHashEstimate(hasher, dig); // should be protected against this being zero by MyMockSystemMetrics, // but otherwise use the proper calculation. This avoids test failure // due to really slow machines assertTrue(estimate > 0); long estimatedTime = set.estimatedHashDuration(); long size = ((Long) PrivilegedAccessor.getValue(set, "totalNodeSize")).longValue(); assertTrue(size > 0); System.out.println("b/ms: " + estimate); System.out.println("size: " + size); System.out.println("estimate: " + estimatedTime); assertEquals(estimatedTime, theDaemon.getHashService().padHashEstimate(size / estimate)); }
public void tearDown() throws Exception { theDaemon.getLockssRepository(sau1).stopService(); theDaemon.getNodeManager(sau1).stopService(); theDaemon.getPluginManager().stopService(); theDaemon.getHashService().stopService(); theDaemon.getSystemMetrics().stopService(); theDaemon.stopDaemon(); super.tearDown(); }
private void initRequiredServices() { theDaemon = getMockLockssDaemon(); pollmanager = new LocalPollManager(); pollmanager.initService(theDaemon); theDaemon.setPollManager(pollmanager); theDaemon.getPluginManager(); testau = PollTestPlugin.PTArchivalUnit.createFromListOfRootUrls(rootV1urls); PluginTestUtil.registerArchivalUnit(testau); String tempDirPath = null; try { tempDirPath = getTempDir().getAbsolutePath() + File.separator; } catch (IOException ex) { fail("unable to create a temporary directory"); } Properties p = new Properties(); p.setProperty(IdentityManager.PARAM_IDDB_DIR, tempDirPath + "iddb"); p.setProperty(LockssRepositoryImpl.PARAM_CACHE_LOCATION, tempDirPath); p.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath); p.setProperty(IdentityManager.PARAM_LOCAL_IP, "127.0.0.1"); p.setProperty(ConfigManager.PARAM_NEW_SCHEDULER, "false"); // XXX we need to disable verification of votes because the // voter isn't really there p.setProperty(V1Poll.PARAM_AGREE_VERIFY, "0"); p.setProperty(V1Poll.PARAM_DISAGREE_VERIFY, "0"); ConfigurationUtil.setCurrentConfigFromProps(p); idmgr = theDaemon.getIdentityManager(); idmgr.startService(); // theDaemon.getSchedService().startService(); theDaemon.getHashService().startService(); theDaemon.getDatagramRouterManager().startService(); theDaemon.getRouterManager().startService(); theDaemon.getSystemMetrics().startService(); theDaemon.getActivityRegulator(testau).startService(); theDaemon.setNodeManager(new MockNodeManager(), testau); pollmanager.startService(); }
public void testNumCurrentSuspectVersions() { MyMockLockssRepository repo = new MyMockLockssRepository(); MyAuSuspectUrlVersions asuv = new MyAuSuspectUrlVersions(); repo.setAsuv(asuv); daemon.setLockssRepository(repo, mau); AuState aus = new AuState(mau, historyRepo); assertEquals(0, aus.getNumCurrentSuspectVersions()); // ensure this isn't automatically recomputed, as that would happen // when historyRepo loads the object during startAuManagers, before the // AU is fully created. aus.setNumCurrentSuspectVersions(-1); assertEquals(-1, aus.getNumCurrentSuspectVersions()); asuv.setCountResult(17); aus.recomputeNumCurrentSuspectVersions(); assertEquals(17, aus.getNumCurrentSuspectVersions()); aus.incrementNumCurrentSuspectVersions(-1); assertEquals(16, aus.getNumCurrentSuspectVersions()); aus.setNumCurrentSuspectVersions(-1); asuv.setCountResult(6); aus.incrementNumCurrentSuspectVersions(-1); assertEquals(5, aus.getNumCurrentSuspectVersions()); }
public void tearDown() throws Exception { sau.deleteContentTree(); theDaemon.stopDaemon(); super.tearDown(); }