brett 2004/01/04 13:57:53
Modified: maven-model/src/test/org/apache/maven/model
DependencyTest.java
Log:
improve testing, remove stuff "to simple to fail"
add ASL
Revision Changes Path
1.3 +143 -36
maven-components/maven-model/src/test/org/apache/maven/model/DependencyTest.java
Index: DependencyTest.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-model/src/test/org/apache/maven/model/DependencyTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DependencyTest.java 2 Jan 2004 23:16:18 -0000 1.2
+++ DependencyTest.java 4 Jan 2004 21:57:53 -0000 1.3
@@ -1,12 +1,72 @@
package org.apache.maven.model;
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Maven" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Maven", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * ====================================================================
+ */
+
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.Map;
+import org.apache.maven.model.types.ArtifactType;
+
/**
+ * Test dependency element.
*
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
*
* @version $Id$
@@ -14,15 +74,22 @@
public class DependencyTest
extends TestCase
{
+
+ /** Dependency to test. */
+ private Dependency d;
+
public DependencyTest( String name )
{
super( name );
}
- public void testDefaults()
+ public void setUp()
{
- Dependency d = new Dependency();
+ d = new Dependency();
+ }
+ public void testDefaults()
+ {
assertEquals( "jar", d.getType() );
assertEquals( "jar", d.getExtension() );
@@ -37,57 +104,97 @@
assertEquals( "check default properties", 0, d.getProperties().size() );
}
- /**
- * @todo needs some work
- */
- public void testVersion()
+ public void testAddProperty()
{
- Dependency d = new Dependency();
+ d.addProperty( "foo", "bar" );
- d.setVersion( "version" );
+ assertEquals( "check add property", "bar", d.getProperties().get( "foo" ) );
+ }
- assertEquals( "version", d.getVersion() );
+ public void testSetProperties()
+ {
+ Map properties = new HashMap();
- d.setUrl( "url" );
+ properties.put( "name", "cheeky" );
- assertEquals( "url", d.getUrl() );
+ properties.put( "occupation", "proctologist" );
- d.setArtifact( "artifact" );
+ d.setProperties( properties );
- assertEquals( "artifact", d.getArtifact() );
+ assertEquals( "check set properties size", 2, d.getProperties().size() );
+ assertEquals( "check set properties elements", "cheeky",
d.getProperties().get( "name" ) );
+ }
+ public void testGetId()
+ {
+ d.setGroupId( "groupId" );
d.setArtifactId( "artifactId" );
+ assertEquals( "test id", "groupId:artifactId:jar", d.getId() );
+ }
- assertEquals( "artifactId", d.getArtifactId() );
-
+ public void testGetIdWithNonDefaultType()
+ {
d.setGroupId( "groupId" );
+ d.setArtifactId( "artifactId" );
+ d.setType( "ejb" );
+ assertEquals( "test ejb id", "groupId:artifactId:ejb", d.getId() );
+ }
- assertEquals( "groupId", d.getGroupId() );
-
- d.setType( "type" );
-
- assertEquals( "type", d.getType() );
-
- // d.setKind( "kind" );
-
- // assertEquals( "kind", d.getKind() );
-
- d.addProperty( "foo", "bar" );
-
- assertEquals( "bar", d.getProperties().get( "foo" ) );
+ public void testGetShortId()
+ {
+ d.setGroupId( "groupId" );
+ d.setArtifactId( "artifactId" );
+ assertEquals( "test short id", "groupId:artifactId", d.getShortId() );
+ }
- assertEquals( "groupId:artifactId:type", d.getId() );
+ public void testSetLegacyIdWithColon()
+ {
+ d.setId( "groupId:artifactId" );
+ assertEquals( "check group ID", "groupId", d.getGroupId() );
+ assertEquals( "check artifact ID", "artifactId", d.getArtifactId() );
+ }
- assertEquals( "groupId:artifactId", d.getShortId() );
+ public void testSetLegacyIdWithPlus()
+ {
+ d.setId( "groupId+artifactId" );
+ assertEquals( "check group ID", "groupId", d.getGroupId() );
+ assertEquals( "check artifact ID", "groupId-artifactId", d.getArtifactId()
);
+ }
- Map properties = new HashMap();
+ public void testSetLegacyId()
+ {
+ d.setId( "id" );
+ assertEquals( "check group ID", "id", d.getGroupId() );
+ assertEquals( "check artifact ID", "id", d.getArtifactId() );
+ }
- properties.put( "name", "cheeky" );
+ public void testGetArtifactWithNonJarExtension()
+ {
+ d.setArtifactId( "artifactId" );
+ d.setVersion( "version" );
+ d.setType( "tld" );
+ assertEquals( "check artifact", "artifactId-version.tld", d.getArtifact() );
+ }
- properties.put( "occupation", "proctologist" );
+ public void testGetArtifactWithType()
+ {
+ d.setArtifactId( "artifactId" );
+ d.setVersion( "version" );
+ d.setType( "ejb" );
+ assertEquals( "check artifact", "artifactId-version.jar", d.getArtifact() );
+ }
- d.setProperties( properties );
+ public void testGetArtifact()
+ {
+ d.setArtifactId( "artifactId" );
+ d.setVersion( "version" );
+ assertEquals( "check artifact", "artifactId-version.jar", d.getArtifact() );
+ }
- assertEquals( 2, d.getProperties().size() );
+ public void testGetArtifactFromSet()
+ {
+ d.setArtifact( "some-artifact.art" );
+ assertEquals( "check artifact", "some-artifact.art", d.getArtifact() );
}
}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]