01: /* MaxLinkHopsSelfTest
02: *
03: * Created on Feb 17, 2004
04: *
05: * Copyright (C) 2004 Internet Archive.
06: *
07: * This file is part of the Heritrix web crawler (crawler.archive.org).
08: *
09: * Heritrix is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU Lesser Public License as published by
11: * the Free Software Foundation; either version 2.1 of the License, or
12: * any later version.
13: *
14: * Heritrix is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: * GNU Lesser Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser Public License
20: * along with Heritrix; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: package org.archive.crawler.selftest;
24:
25: import java.io.File;
26: import java.util.Arrays;
27: import java.util.List;
28:
29: import javax.management.AttributeNotFoundException;
30: import javax.management.MBeanException;
31: import javax.management.ReflectionException;
32:
33: import org.archive.crawler.framework.CrawlScope;
34: import org.archive.crawler.scope.ClassicScope;
35:
36: /**
37: * Test the max-link-hops setting.
38: *
39: * @author stack
40: * @version $Id: MaxLinkHopsSelfTest.java 4931 2007-02-21 18:48:17Z gojomo $
41: */
42: public class MaxLinkHopsSelfTest extends SelfTestCase {
43: /**
44: * Files to find as a list.
45: */
46: private static final List<File> FILES_TO_FIND = Arrays
47: .asList(new File[] { new File("2.html"),
48: new File("3.html"), new File("4.html"),
49: new File("5.html") });
50:
51: /**
52: * Files not to find as a list.
53: */
54: private static final List FILES_NOT_TO_FIND = Arrays
55: .asList(new File[] { new File("1.html"), new File("6.html") });
56:
57: /**
58: * Assumption is that the setting for max-link-hops is less than this
59: * number.
60: */
61: private static final int MAXLINKHOPS = 5;
62:
63: /**
64: * Test the max-link-hops setting is being respected.
65: */
66: public void stestMaxLinkHops() throws AttributeNotFoundException,
67: MBeanException, ReflectionException {
68: assertInitialized();
69: CrawlScope scope = (CrawlScope) getCrawlJob()
70: .getSettingsHandler().getModule(CrawlScope.ATTR_NAME);
71: int maxLinkHops = ((Integer) scope
72: .getAttribute(ClassicScope.ATTR_MAX_LINK_HOPS))
73: .intValue();
74: assertTrue("max-link-hops incorrect",
75: MAXLINKHOPS == maxLinkHops);
76:
77: // Make sure file we're NOT supposed to find is actually on disk.
78: assertTrue("File present on disk",
79: filesExist(FILES_NOT_TO_FIND));
80:
81: // Ok. The file not to find exists. Lets see if it made it into arc.
82: testFilesInArc(FILES_TO_FIND);
83: }
84: }
|