1 package org.apache.maven.dist;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import junit.framework.TestCase;
22
23 import org.apache.maven.MavenException;
24 import org.apache.maven.project.Project;
25 import org.apache.maven.repository.ArtifactTypeHandler;
26
27 /**
28 * This will do until wagon debuts.
29 *
30 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
31 * @version $Id: DistributionArtifactTypeHandlerTest.java 532339 2007-04-25 12:28:56Z ltheussl $
32 */
33 public class DistributionArtifactTypeHandlerTest extends TestCase
34 {
35 /** A test version string. */
36 private static final String VERSION = "VERSION";
37
38 /** A test project. */
39 private Project project;
40
41 /** A test ArtifactTypeHandler. */
42 private ArtifactTypeHandler handler;
43
44 /** JUnit setup: initialize project and handler. */
45 public void setUp() throws Exception
46 {
47 project = new Project();
48 project.setGroupId( "groupId" );
49 project.setArtifactId( "artifactId" );
50 handler = new DistributionArtifactTypeHandler();
51 }
52
53 /** Test constructRepositoryDirectoryPath. */
54 public void testConstructRepositoryDirectoryPath()
55 throws Exception
56 {
57 assertEquals( "check artifact directory", "groupId/distributions/",
58 handler.constructRepositoryDirectoryPath( "distribution-targz",
59 project ) );
60 assertEquals( "check artifact directory", "groupId/distributions/",
61 handler.constructRepositoryDirectoryPath( "distribution-tarbz2",
62 project ) );
63 assertEquals( "check artifact directory", "groupId/distributions/",
64 handler.constructRepositoryDirectoryPath( "distribution-zip",
65 project ) );
66 assertEquals( "check artifact directory", "groupId/distributions/",
67 handler.constructRepositoryDirectoryPath(
68 "distribution-src-targz", project ) );
69 assertEquals( "check artifact directory", "groupId/distributions/",
70 handler.constructRepositoryDirectoryPath(
71 "distribution-src-tarbz2", project ) );
72 assertEquals( "check artifact directory", "groupId/distributions/",
73 handler.constructRepositoryDirectoryPath( "distribution-src-zip",
74 project ) );
75 }
76
77 /** Test constructRepositoryFullPath. */
78 public void testConstructRepositoryFullPath()
79 throws Exception
80 {
81 try
82 {
83 handler.constructRepositoryFullPath( "foo", project, VERSION );
84 fail( "expected exception" );
85 }
86 catch ( MavenException expected )
87 {
88 assertTrue( "expected exception", true );
89 }
90
91 try
92 {
93 handler.constructRepositoryFullPath( "distribution", project,
94 VERSION );
95 fail( "expected exception" );
96 }
97 catch ( MavenException expected )
98 {
99 assertTrue( "expected exception", true );
100 }
101
102 assertEquals( "check artifact path",
103 "groupId/distributions/artifactId-VERSION.tar.gz",
104 handler.constructRepositoryFullPath( "distribution-targz", project,
105 VERSION ) );
106 assertEquals( "check artifact path",
107 "groupId/distributions/artifactId-VERSION.tar.bz2",
108 handler.constructRepositoryFullPath( "distribution-tarbz2",
109 project, VERSION ) );
110 assertEquals( "check artifact path",
111 "groupId/distributions/artifactId-VERSION.zip",
112 handler.constructRepositoryFullPath( "distribution-zip", project,
113 VERSION ) );
114 assertEquals( "check artifact path",
115 "groupId/distributions/artifactId-VERSION-src.tar.gz",
116 handler.constructRepositoryFullPath( "distribution-src-targz",
117 project, VERSION ) );
118 assertEquals( "check artifact path",
119 "groupId/distributions/artifactId-VERSION-src.tar.bz2",
120 handler.constructRepositoryFullPath( "distribution-src-tarbz2",
121 project, VERSION ) );
122 assertEquals( "check artifact path",
123 "groupId/distributions/artifactId-VERSION-src.zip",
124 handler.constructRepositoryFullPath( "distribution-src-zip",
125 project, VERSION ) );
126 }
127 }