1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.maven.author.resolver;
18
19 import java.io.File;
20 import java.net.URL;
21
22 /**
23 * Unit test for the class JavadocAuthorResolver.
24 *
25 * @author Eric Ballet Baz
26 */
27 public class TestJavadocAuthorResolver extends AbstractTestAuthorResolver {
28
29 /**
30 * @see org.apache.maven.author.resolver.AbstractTestAuthorResolver#getAuthorResolverClass()
31 */
32 protected final Class getAuthorResolverClass() {
33 return JavadocAuthorResolver.class;
34 }
35
36 /**
37 * Test method resolveAuthors on a file without Javadoc author.
38 */
39 public final void testResolveAuthorWithoutJavadocAuthor() {
40 AuthorResolver resolver = instanciateAuthorResolver();
41
42 URL url = getClass().getClassLoader().getResource("SampleFileWithoutJavadocAuthor.java");
43 assertNotNull(url);
44
45 String[] authors = resolver.resolveAuthors(new File(url.getPath()));
46 assertNotNull(authors);
47 assertEquals(0, authors.length);
48 }
49
50 /**
51 * Test method resolveAuthors on a file with one Javadoc author.
52 */
53 public final void testResolveAuthorWithOneJavadocAuthor() {
54 AuthorResolver resolver = instanciateAuthorResolver();
55
56 URL url = getClass().getClassLoader().getResource("SampleFileWithOneJavadocAuthor.java");
57 assertNotNull(url);
58
59 String[] authors = resolver.resolveAuthors(new File(url.getPath()));
60 assertNotNull(authors);
61 assertEquals(1, authors.length);
62 assertEquals("Sample Author 1", authors[0]);
63 }
64
65 /**
66 * Test method resolveAuthors on a file with three Javadoc authors.
67 */
68 public final void testResolveAuthorWithThreeJavadocAuthors() {
69 AuthorResolver resolver = instanciateAuthorResolver();
70
71 URL url = getClass().getClassLoader().getResource("SampleFileWithThreeJavadocAuthors.java");
72 assertNotNull(url);
73
74 String[] authors = resolver.resolveAuthors(new File(url.getPath()));
75 assertNotNull(authors);
76 assertEquals(3, authors.length);
77
78 assertEquals("Sample Author 1", authors[0]);
79 assertEquals("Sample Author 3", authors[1]);
80 assertEquals("Sample Author 2", authors[2]);
81 }
82 }