KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > artifact > DefaultArtifactTest


1 package org.apache.maven.artifact;
2
3 /*
4  * Copyright 2001-2006 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import junit.framework.TestCase;
20
21 import org.apache.maven.artifact.handler.MockArtifactHandler;
22 import org.apache.maven.artifact.versioning.VersionRange;
23
24 public class DefaultArtifactTest
25     extends TestCase
26 {
27
28     private DefaultArtifact artifact;
29
30     private String JavaDoc groupId = "groupid", artifactId = "artifactId", version = "1.0", scope = "scope", type = "type",
31         classifier = "classifier";
32
33     private VersionRange versionRange;
34
35     private MockArtifactHandler artifactHandler;
36
37     protected void setUp()
38         throws Exception JavaDoc
39     {
40         super.setUp();
41         artifactHandler = new MockArtifactHandler();
42         versionRange = VersionRange.createFromVersion( version );
43         artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler );
44     }
45
46     public void testGetDependencyConflictId()
47     {
48         assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() );
49     }
50
51     public void testGetDependencyConflictIdNullGroupId()
52     {
53         artifact.setGroupId( null );
54         assertEquals( null + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() );
55     }
56
57     public void testGetDependencyConflictIdNullClassifier()
58     {
59         artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler );
60         assertEquals( groupId + ":" + artifactId + ":" + type, artifact.getDependencyConflictId() );
61     }
62
63     public void testGetDependencyConflictIdNullScope()
64     {
65         artifact.setScope( null );
66         assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() );
67     }
68
69     public void testToString()
70     {
71         assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope,
72                       artifact.toString() );
73     }
74
75     public void testToStringNullGroupId()
76     {
77         artifact.setGroupId( null );
78         assertEquals( artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() );
79     }
80
81     public void testToStringNullClassifier()
82     {
83         artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler );
84         assertEquals( groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact.toString() );
85     }
86
87     public void testToStringNullScope()
88     {
89         artifact.setScope( null );
90         assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version, artifact.toString() );
91     }
92
93 }
94
Popular Tags