1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 /***
38 * Test the max-link-hops setting.
39 *
40 * @author stack
41 * @version $Id: MaxLinkHopsSelfTest.java 4931 2007-02-21 18:48:17Z gojomo $
42 */
43 public class MaxLinkHopsSelfTest
44 extends SelfTestCase
45 {
46 /***
47 * Files to find as a list.
48 */
49 private static final List<File> FILES_TO_FIND =
50 Arrays.asList(new File[] {new File("2.html"),
51 new File("3.html"), new File("4.html"), new File("5.html")});
52
53 /***
54 * Files not to find as a list.
55 */
56 private static final List FILES_NOT_TO_FIND =
57 Arrays.asList(new File[] {new File("1.html"), new File("6.html")});
58
59 /***
60 * Assumption is that the setting for max-link-hops is less than this
61 * number.
62 */
63 private static final int MAXLINKHOPS = 5;
64
65
66 /***
67 * Test the max-link-hops setting is being respected.
68 */
69 public void stestMaxLinkHops()
70 throws AttributeNotFoundException, MBeanException, ReflectionException
71 {
72 assertInitialized();
73 CrawlScope scope =
74 (CrawlScope)getCrawlJob().getSettingsHandler()
75 .getModule(CrawlScope.ATTR_NAME);
76 int maxLinkHops =
77 ((Integer)scope.getAttribute(ClassicScope.ATTR_MAX_LINK_HOPS))
78 .intValue();
79 assertTrue("max-link-hops incorrect", MAXLINKHOPS == maxLinkHops);
80
81
82 assertTrue("File present on disk", filesExist(FILES_NOT_TO_FIND));
83
84
85 testFilesInArc(FILES_TO_FIND);
86 }
87 }
88