You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by mi...@apache.org on 2003/05/23 14:53:26 UTC
cvs commit: maven-new/core/src/java/org/apache/maven/artifact/factory DefaultArtifactFactory.java
michal 2003/05/23 05:53:26
Modified: core/src/test/org/apache/maven TestUtils.java
core/src/java/org/apache/maven/artifact/factory
DefaultArtifactFactory.java
Added: core/src/test/org/apache/maven/artifact/factory
DefaultArtifactFactoryTest.java
Log:
added Sketch of DefaultArtifactFactoryTest
Revision Changes Path
1.2 +58 -26 maven-new/core/src/test/org/apache/maven/TestUtils.java
Index: TestUtils.java
===================================================================
RCS file: /home/cvs/maven-new/core/src/test/org/apache/maven/TestUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestUtils.java 23 May 2003 10:36:05 -0000 1.1
+++ TestUtils.java 23 May 2003 12:53:26 -0000 1.2
@@ -56,6 +56,11 @@
package org.apache.maven;
import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+
+import org.apache.maven.project.Project;
+import org.apache.maven.project.builder.DefaultProjectUnmarshaller;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -63,29 +68,56 @@
*/
public class TestUtils
{
- /**
- * Basedir for all file I/O. Important when running tests from
- * the reactor.
- */
- public final static String BASEDIR = System.getProperty("basedir");
-
- /**
- * Get test input file.
- *
- * @param path Path to test input file.
- */
- public static String getTestFile(String path)
- {
- return new File(BASEDIR, path).getAbsolutePath();
- }
-
- /**
- * Get test input file.
- *
- * @param path Path to test input file.
- */
- public static String getTestFile(String basedir, String path)
- {
- return new File(BASEDIR, path).getAbsolutePath();
- }
+ /**
+ * Basedir for all file I/O. Important when running tests from
+ * the reactor.
+ */
+ public final static String BASEDIR = System.getProperty("basedir");
+
+ /**
+ * Get test input file.
+ *
+ * @param path Path to test input file.
+ */
+ public static String getTestFile(String path)
+ {
+ return new File(BASEDIR, path).getAbsolutePath();
+ }
+
+ /**
+ * Get test input file.
+ *
+ * @param path Path to test input file.
+ */
+ public static String getTestFile(String basedir, String path)
+ {
+ return new File(BASEDIR, path).getAbsolutePath();
+ }
+
+
+ /**
+ *
+ * @param path
+ * @return
+ * @throws Exception
+ */
+ public static Project getProjectSample(String path) throws Exception
+ {
+ return getProjectSample(BASEDIR, path);
+ }
+
+ /**
+ * @todo do we need to close a reader?
+ * @param basedir
+ * @param path
+ * @return
+ */
+ private static Project getProjectSample(String basedir, String path) throws Exception
+ {
+ String testDocument = basedir + path;
+ DefaultProjectUnmarshaller projectUnmarshaller = new DefaultProjectUnmarshaller();
+ Reader reader = new FileReader( testDocument );
+ Project project = projectUnmarshaller.parse(reader);
+ return project;
+ }
}
1.1 maven-new/core/src/test/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
Index: DefaultArtifactFactoryTest.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 MavenSession" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache MavenSession", 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/>.
*
* ====================================================================
*/
package org.apache.maven.artifact.factory;
import java.util.List;
import junit.framework.TestCase;
import org.apache.maven.TestUtils;
import org.apache.maven.artifact.layout.DefaultRepositoryLayout;
import org.apache.maven.project.Project;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: DefaultArtifactFactoryTest.java,v 1.1 2003/05/23 12:53:26 michal Exp $
*/
public class DefaultArtifactFactoryTest extends TestCase
{
private DefaultArtifactFactory artifactFactory = null;
/**
* Constructor for DefaultArtifactFactoryTest.
* @param String testName
*/
public DefaultArtifactFactoryTest(String testName)
{
super(testName);
}
private Object lookup(String role)
{
return null;
}
/**
* @see junit.framework.TestCase#setUp()
*/
public void setUp() throws Exception
{
super.setUp();
artifactFactory = new DefaultArtifactFactory();
DefaultRepositoryLayout repositoryLayout =
new DefaultRepositoryLayout();
repositoryLayout.initialize();
artifactFactory.setRepositoryLayout(repositoryLayout);
}
public void testCreateArtifacts()
{
Project project = null;
try
{
project = TestUtils.getProjectSample("/src/test-input/project.xml");
}
catch (Exception e)
{
String msg = "Cannot get project sample: " + e.getMessage();
fail(msg);
}
List artifacts = null;
try
{
artifacts = artifactFactory.createArtifacts(project);
}
catch (Exception e)
{
String msg =
"Failed to create list of artifacts: " + e.getMessage();
fail(msg);
}
// Check if we have required number of artifacts
int expectedNumberOfArtifacts = 4;
int actualNumberOfArtifacts = artifacts.size();
String msg1 = "Artifact list has unexpected size";
assertEquals(msg1, expectedNumberOfArtifacts, actualNumberOfArtifacts);
}
}
1.4 +11 -1 maven-new/core/src/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
Index: DefaultArtifactFactory.java
===================================================================
RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultArtifactFactory.java 23 May 2003 10:36:05 -0000 1.3
+++ DefaultArtifactFactory.java 23 May 2003 12:53:26 -0000 1.4
@@ -153,6 +153,16 @@
return artifacts;
}
+
+ /**
+ * Allows to set arbitray repository layout
+ * @param repositoryLayout RepositoryLayout which will be used
+ */
+ public void setRepositoryLayout(RepositoryLayout repositoryLayout)
+ {
+ this.repositoryLayout = repositoryLayout;
+ }
+
/**
* @param artifact
* @return
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org