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
21 import junit.framework.TestCase;
22
23 /**
24 * @author Eric Ballet Baz
25 */
26 public abstract class AbstractTestAuthorResolver extends TestCase {
27
28 protected abstract Class getAuthorResolverClass();
29
30 public final void testDefautConstructor() {
31 AuthorResolver authorResolver = instanciateAuthorResolver();
32 assertNotNull(authorResolver);
33 }
34
35 public final void testResolveAuthorsWithNullArgument() {
36 AuthorResolver authorResolver = instanciateAuthorResolver();
37
38 try {
39 authorResolver.resolveAuthors(null);
40 fail("An IllegalArgumentException should have been thrown");
41
42 } catch (IllegalArgumentException e) {
43
44 assertNotNull(e);
45 }
46 }
47
48 public final void testResolveAuthorsWithDirectoryArgument() {
49 AuthorResolver authorResolver = instanciateAuthorResolver();
50 File rootDirectory = new File("/");
51
52 try {
53 authorResolver.resolveAuthors(rootDirectory);
54 fail("An IllegalArgumentException should have been thrown");
55
56 } catch (IllegalArgumentException e) {
57
58 assertNotNull(e);
59 }
60 }
61
62 protected final AuthorResolver instanciateAuthorResolver() {
63 try {
64 return (AuthorResolver) getAuthorResolverClass().newInstance();
65 } catch (InstantiationException e) {
66 throw new RuntimeException(e);
67 } catch (IllegalAccessException e) {
68 throw new RuntimeException(e);
69 }
70 }
71 }