1 package org.apache.maven.artifact; 2 3 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 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 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 |