1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.artifact.handler;
20
21 import java.io.File;
22 import java.util.List;
23
24 import org.codehaus.plexus.PlexusTestCase;
25 import org.codehaus.plexus.util.FileUtils;
26
27 public class ArtifactHandlerTest extends PlexusTestCase {
28 public void testAptConsistency() throws Exception {
29 File apt = getTestFile("src/site/apt/artifact-handlers.apt");
30
31 List<String> lines = FileUtils.loadFile(apt);
32
33 for (String line : lines) {
34 if (line.startsWith("||")) {
35 String[] cols = line.split("\\|\\|");
36 String[] expected = new String[] {
37 "",
38 "type",
39 "classifier",
40 "extension",
41 "packaging",
42 "language",
43 "added to classpath",
44 "includesDependencies",
45 ""
46 };
47
48 int i = 0;
49 for (String col : cols) {
50 assertEquals("Wrong column header", expected[i++], col.trim());
51 }
52 } else if (line.startsWith("|")) {
53 String[] cols = line.split("\\|");
54
55 String type = trimApt(cols[1]);
56 String classifier = trimApt(cols[2]);
57 String extension = trimApt(cols[3], type);
58 String packaging = trimApt(cols[4], type);
59 String language = trimApt(cols[5]);
60 String addedToClasspath = trimApt(cols[6]);
61 String includesDependencies = trimApt(cols[7]);
62
63 ArtifactHandler handler = lookup(ArtifactHandler.class, type);
64 assertEquals(type + " extension", handler.getExtension(), extension);
65 assertEquals(type + " packaging", handler.getPackaging(), packaging);
66 assertEquals(type + " classifier", handler.getClassifier(), classifier);
67 assertEquals(type + " language", handler.getLanguage(), language);
68 assertEquals(
69 type + " addedToClasspath", handler.isAddedToClasspath() ? "true" : null, addedToClasspath);
70 assertEquals(
71 type + " includesDependencies",
72 handler.isIncludesDependencies() ? "true" : null,
73 includesDependencies);
74 }
75 }
76 }
77
78 private String trimApt(String content, String type) {
79 String value = trimApt(content);
80 return "= type".equals(value) ? type : value;
81 }
82
83 private String trimApt(String content) {
84 content = content.replace('<', ' ').replace('>', ' ').trim();
85
86 return (content.length() == 0) ? null : content;
87 }
88 }