maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r394816 - in /maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source: ./ stubs/
Date Tue, 18 Apr 2006 01:31:58 GMT
Author: oching
Date: Mon Apr 17 18:31:56 2006
New Revision: 394816

URL: http://svn.apache.org/viewcvs?rev=394816&view=rev
Log:
PR:MSOURCES-3

Created test cases using testing harness plugin. Also created project stubs used for testing.

Added:
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/CustomConfigurationMavenProjectStub.java
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/DefaultConfigurationMavenProjectStub.java
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/InvalidPackagingMavenProjectStub.java
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/SourcePluginArtifactStub.java
Modified:
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java

Added: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java?rev=394816&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java
Mon Apr 17 18:31:56 2006
@@ -0,0 +1,191 @@
+package org.apache.maven.plugin.source;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.archiver.zip.ZipEntry;
+import org.codehaus.plexus.archiver.zip.ZipFile;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
+ */
+public class JarDefaultSourceMojoTest
+    extends AbstractMojoTestCase
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp();
+        
+    }
+
+    public void testDefaultConfiguration()
+        throws Exception
+    {
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/default-configuration/default-configuration-config.xml"
);
+
+        try
+        {
+            JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo( "jar", testPom
);
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        //check if the jar file exists
+        File sourceJar =
+            new File( getBasedir(), "target/test/unit/default-configuration/target/default-configuration-sources.jar"
);
+        assertTrue( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
+
+        ZipFile jar = new ZipFile( sourceJar );
+        Enumeration entries = jar.getEntries();
+        assertTrue( entries.hasMoreElements() );
+
+        if ( entries.hasMoreElements() )
+        {
+            ZipEntry entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "default-configuration.properties" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "def/configuration/App.java" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "def/configuration/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "def/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/" );
+        }
+
+    }
+
+
+    public void testCustomConfiguration()
+        throws Exception
+    {
+
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/custom-configuration/custom-configuration-config.xml"
);
+
+        try
+        {
+            JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo( "jar", testPom
);
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        //check if the jar file exists
+        File sourceJar =
+            new File( getBasedir(), "target/test/unit/custom-configuration/target/custom-configuration-sources.jar"
);
+        assertTrue( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
+
+        //verify the contents of the jar file
+        ZipFile jar = new ZipFile( sourceJar );
+        Enumeration entries = jar.getEntries();
+        assertTrue( entries.hasMoreElements() );
+
+        if ( entries.hasMoreElements() )
+        {
+            ZipEntry entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "custom-configuration.properties" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "custom/configuration/App.java" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "custom/configuration/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "custom/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/" );
+        }
+
+
+    }
+
+    public void testInvalidPackaging()
+        throws Exception
+    {
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/invalid-packaging/invalid-packaging-config.xml"
);
+
+        try
+        {
+            JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo( "jar", testPom
);
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        File sourceJar =
+            new File( getBasedir(), "target/test/unit/invalid-packaging/target/invalid-packaging-sources.jar"
);
+        assertFalse( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
+
+    }
+
+    public void testGetterMethods()
+        throws Exception
+    {
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/custom-configuration/custom-configuration-config.xml"
);
+
+        try
+        {
+            JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo( "jar", testPom
);
+            mojo.execute();
+            assertNotNull( mojo.getPackaging() );
+            assertNotNull( mojo.getProject() );
+            assertNotNull( mojo.getExecutedProject() );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+
+    }
+
+}

Added: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java?rev=394816&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java
Mon Apr 17 18:31:56 2006
@@ -0,0 +1,168 @@
+package org.apache.maven.plugin.source;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.archiver.zip.ZipEntry;
+import org.codehaus.plexus.archiver.zip.ZipFile;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
+ */
+public class JarTestSourceMojoTest
+    extends AbstractMojoTestCase
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp();
+        
+    }
+
+
+    public void testDefaultConfiguration()
+        throws Exception
+    {
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/default-configuration/default-configuration-config.xml"
);
+
+        try
+        {
+            JarTestSourceMojo mojo = (JarTestSourceMojo) lookupMojo( "test-jar", testPom
);
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        //check if the jar file exists
+        File sourceJar = new File( getBasedir(),
+                                   "target/test/unit/default-configuration/target/default-configuration-test-sources.jar"
);
+        assertTrue( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
+
+        ZipFile jar = new ZipFile( sourceJar );
+        Enumeration entries = jar.getEntries();
+        assertTrue( entries.hasMoreElements() );
+
+        if ( entries.hasMoreElements() )
+        {
+            ZipEntry entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "test-default-configuration.properties" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "def/configuration/AppTest.java" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "def/configuration/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "def/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/" );
+        }
+
+    }
+
+    public void testCustomConfiguration()
+        throws Exception
+    {
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/custom-configuration/custom-configuration-config.xml"
);
+
+        try
+        {
+            JarTestSourceMojo mojo = (JarTestSourceMojo) lookupMojo( "test-jar", testPom
);
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        //check if the jar file exists
+        File sourceJar = new File( getBasedir(),
+                                   "target/test/unit/custom-configuration/target/custom-configuration-test-sources.jar"
);
+        assertTrue( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
+
+        //verify the contents of the jar file
+        ZipFile jar = new ZipFile( sourceJar );
+        Enumeration entries = jar.getEntries();
+        assertTrue( entries.hasMoreElements() );
+
+        if ( entries.hasMoreElements() )
+        {
+            ZipEntry entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "test-custom-configuration.properties" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "custom/configuration/AppTest.java" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "custom/configuration/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "custom/" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+
+            entry = (ZipEntry) entries.nextElement();
+            assertEquals( entry.getName(), "META-INF/" );
+        }
+
+
+    }
+
+    public void testInvalidPackaging()
+        throws Exception
+    {
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/invalid-packaging/invalid-packaging-config.xml"
);
+
+        try
+        {
+            JarTestSourceMojo mojo = (JarTestSourceMojo) lookupMojo( "test-jar", testPom
);
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        File sourceJar =
+            new File( getBasedir(), "target/test/unit/invalid-packaging/target/invalid-packaging-test-sources.jar"
);
+        assertFalse( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
+
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+
+    }
+}

Modified: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java?rev=394816&r1=394815&r2=394816&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java
(original)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java
Mon Apr 17 18:31:56 2006
@@ -35,14 +35,12 @@
 
         Archiver archiver = (Archiver) lookup( Archiver.ROLE, "jar" );
 
-        File outputFile = getTestFile( "target/source-bundler-test/normal.jar" );
+        File outputFile = getTestFile( "target/test/unit/default-configuration/default-configuration.jar"
);
 
-        File sourceDirectories[] = {
-            getTestFile( "src/test/projects/normal/src/main/java" ),
-            getTestFile( "src/test/projects/normal/src/main/resources" ),
-            getTestFile( "src/test/projects/normal/src/test/java" ),
-            getTestFile( "src/test/projects/normal/src/test/resources" ),
-        };
+        File sourceDirectories[] = {getTestFile( "src/test/resources/unit/default-configuration/src/main/java"
),
+            getTestFile( "src/test/resources/unit/default-configuration/src/main/resources"
),
+            getTestFile( "src/test/resources/unit/default-configuration/src/test/java" ),
+            getTestFile( "src/test/resources/unit/default-configuration/src/test/resources"
),};
 
         if ( outputFile.exists() )
         {

Added: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/CustomConfigurationMavenProjectStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/CustomConfigurationMavenProjectStub.java?rev=394816&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/CustomConfigurationMavenProjectStub.java
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/CustomConfigurationMavenProjectStub.java
Mon Apr 17 18:31:56 2006
@@ -0,0 +1,135 @@
+package org.apache.maven.plugin.source.stubs;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
+ */
+public class CustomConfigurationMavenProjectStub
+    extends MavenProjectStub
+{
+
+    private Build build;
+
+    private List resources;
+
+    private List testResources;
+
+    private Artifact parentArtifact;
+
+    private List attachedArtifacts;
+
+    public CustomConfigurationMavenProjectStub()
+    {
+        setGroupId( "custom.configuration" );
+        setArtifactId( "custom-configuration" );
+        setVersion( "1.0-SNAPSHOT" );
+        setName( "Custom Configuration" );
+        setUrl( "http://maven.apache.org" );
+        setInceptionYear( "2006" );
+        setDescription( "Test project with source plugin configuration set in the pom." );
+
+        String basedir = getBasedir().getAbsolutePath();
+        List compileSourceRoots = new ArrayList();
+        compileSourceRoots.add( basedir + "/src/test/resources/unit/custom-configuration/src/main/java"
);
+        setCompileSourceRoots( compileSourceRoots );
+
+        List resources = new ArrayList();
+        Resource resource = new Resource();
+        resource.setDirectory( basedir + "/src/test/resources/unit/custom-configuration/src/main/resources"
);
+        resources.add( resource );
+        setResources( resources );
+
+        List testSourceRoots = new ArrayList();
+        testSourceRoots.add( basedir + "/src/test/resources/unit/custom-configuration/src/test/java"
);
+        setTestCompileSourceRoots( testSourceRoots );
+
+        List testResources = new ArrayList();
+        resource = new Resource();
+        resource.setDirectory( basedir + "/src/test/resources/unit/custom-configuration/src/test/resources"
);
+        testResources.add( resource );
+        setTestResources( testResources );
+
+        Artifact artifact = new SourcePluginArtifactStub( getGroupId(), getArtifactId(),
getVersion(), getPackaging() );
+        artifact.hasClassifier();
+
+        setArtifact( artifact );
+    }
+
+    public Build getBuild()
+    {
+        return build;
+    }
+
+    public void setBuild( Build build )
+    {
+        this.build = build;
+    }
+
+    public List getResources()
+    {
+        return resources;
+    }
+
+    public void setResources( List resources )
+    {
+        this.resources = resources;
+    }
+
+    public List getTestResources()
+    {
+        return testResources;
+    }
+
+    public void setTestResources( List testResources )
+    {
+        this.testResources = testResources;
+    }
+
+    public void setParentArtifact( Artifact parentArtifact )
+    {
+        this.parentArtifact = parentArtifact;
+    }
+
+    public Artifact getParentArtifact()
+    {
+        return parentArtifact;
+    }
+
+    public void addAttachedArtifact( Artifact artifact )
+    {
+        if ( attachedArtifacts == null )
+        {
+            attachedArtifacts = new ArrayList();
+        }
+        attachedArtifacts.add( artifact );
+    }
+
+    public List getAttachedArtifacts()
+    {
+        return attachedArtifacts;
+    }
+
+}

Added: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/DefaultConfigurationMavenProjectStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/DefaultConfigurationMavenProjectStub.java?rev=394816&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/DefaultConfigurationMavenProjectStub.java
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/DefaultConfigurationMavenProjectStub.java
Mon Apr 17 18:31:56 2006
@@ -0,0 +1,141 @@
+package org.apache.maven.plugin.source.stubs;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
+ */
+public class DefaultConfigurationMavenProjectStub
+    extends MavenProjectStub
+{
+
+    private Build build;
+
+    private List resources;
+
+    private List testResources;
+
+    private Artifact parentArtifact;
+
+    private List attachedArtifacts;
+
+    public DefaultConfigurationMavenProjectStub()
+    {
+        setGroupId( "default.configuration" );
+        setArtifactId( "default-configuration" );
+        setVersion( "1.0-SNAPSHOT" );
+        setName( "Maven Source Plugin Default Configuration" );
+        setPackaging( "jar" );
+        setUrl( "http://maven.apache.org" );
+        setInceptionYear( "2006" );
+        setDescription( "Test Project that contains the default configuration." );
+
+        Build build = new Build();
+        build.setFinalName( "default-configuration" );
+        build.setDirectory( getBasedir() + "/target/test/unit/default-configuration/target"
);
+
+        setBuild( build );
+
+        String basedir = getBasedir().getAbsolutePath();
+        List compileSourceRoots = new ArrayList();
+        compileSourceRoots.add( basedir + "/src/test/resources/unit/default-configuration/src/main/java"
);
+        setCompileSourceRoots( compileSourceRoots );
+
+        List resources = new ArrayList();
+        Resource resource = new Resource();
+        resource.setDirectory( basedir + "/src/test/resources/unit/default-configuration/src/main/resources"
);
+        resources.add( resource );
+        setResources( resources );
+
+        List testSourceRoots = new ArrayList();
+        testSourceRoots.add( basedir + "/src/test/resources/unit/default-configuration/src/test/java"
);
+        setTestCompileSourceRoots( testSourceRoots );
+
+        List testResources = new ArrayList();
+        resource = new Resource();
+        resource.setDirectory( basedir + "/src/test/resources/unit/default-configuration/src/test/resources"
);
+        testResources.add( resource );
+        setTestResources( testResources );
+
+        Artifact artifact = new SourcePluginArtifactStub( getGroupId(), getArtifactId(),
getVersion(), getPackaging() );
+        artifact.hasClassifier();
+
+        setArtifact( artifact );
+    }
+
+    public Build getBuild()
+    {
+        return build;
+    }
+
+    public void setBuild( Build build )
+    {
+        this.build = build;
+    }
+
+    public List getResources()
+    {
+        return resources;
+    }
+
+    public void setResources( List resources )
+    {
+        this.resources = resources;
+    }
+
+    public List getTestResources()
+    {
+        return testResources;
+    }
+
+    public void setTestResources( List testResources )
+    {
+        this.testResources = testResources;
+    }
+
+    public void setParentArtifact( Artifact parentArtifact )
+    {
+        this.parentArtifact = parentArtifact;
+    }
+
+    public Artifact getParentArtifact()
+    {
+        return parentArtifact;
+    }
+
+    public void addAttachedArtifact( Artifact artifact )
+    {
+        if ( attachedArtifacts == null )
+        {
+            attachedArtifacts = new ArrayList();
+        }
+        attachedArtifacts.add( artifact );
+    }
+
+    public List getAttachedArtifacts()
+    {
+        return attachedArtifacts;
+    }
+}

Added: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/InvalidPackagingMavenProjectStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/InvalidPackagingMavenProjectStub.java?rev=394816&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/InvalidPackagingMavenProjectStub.java
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/InvalidPackagingMavenProjectStub.java
Mon Apr 17 18:31:56 2006
@@ -0,0 +1,139 @@
+package org.apache.maven.plugin.source.stubs;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
+ */
+public class InvalidPackagingMavenProjectStub
+    extends MavenProjectStub
+{
+    private Build build;
+
+    private List resources;
+
+    private List testResources;
+
+    private Artifact parentArtifact;
+
+    private List attachedArtifacts;
+
+    public InvalidPackagingMavenProjectStub()
+    {
+        setGroupId( "invalid.packaging" );
+        setArtifactId( "invalid-packaging" );
+        setVersion( "1.0-SNAPSHOT" );
+        setName( "Invalid Packaging" );
+        setPackaging( "jar" );
+        setUrl( "http://maven.apache.org" );
+        setInceptionYear( "2006" );
+        setDescription( "Test project with invalid packaging." );
+
+        Build build = new Build();
+        build.setFinalName( "invalid-packaging" );
+
+        setBuild( build );
+
+        String basedir = getBasedir().getAbsolutePath();
+        List compileSourceRoots = new ArrayList();
+        compileSourceRoots.add( basedir + "/src/test/resources/unit/invalid-packaging/src/main/java"
);
+        setCompileSourceRoots( compileSourceRoots );
+
+        List resources = new ArrayList();
+        Resource resource = new Resource();
+        resource.setDirectory( basedir + "/src/test/resources/unit/invalid-packaging/src/main/resources"
);
+        resources.add( resource );
+        setResources( resources );
+
+        List testSourceRoots = new ArrayList();
+        testSourceRoots.add( basedir + "/src/test/resources/unit/invalid-packaging/src/test/java"
);
+        setTestCompileSourceRoots( testSourceRoots );
+
+        List testResources = new ArrayList();
+        resource = new Resource();
+        resource.setDirectory( basedir + "/src/test/resources/unit/invalid-packaging/src/test/resources"
);
+        testResources.add( resource );
+        setTestResources( testResources );
+
+        Artifact artifact = new SourcePluginArtifactStub( getGroupId(), getArtifactId(),
getVersion(), getPackaging() );
+        artifact.hasClassifier();
+
+        setArtifact( artifact );
+    }
+
+    public Build getBuild()
+    {
+        return build;
+    }
+
+    public void setBuild( Build build )
+    {
+        this.build = build;
+    }
+
+    public List getResources()
+    {
+        return resources;
+    }
+
+    public void setResources( List resources )
+    {
+        this.resources = resources;
+    }
+
+    public List getTestResources()
+    {
+        return testResources;
+    }
+
+    public void setTestResources( List testResources )
+    {
+        this.testResources = testResources;
+    }
+
+    public void setParentArtifact( Artifact parentArtifact )
+    {
+        this.parentArtifact = parentArtifact;
+    }
+
+    public Artifact getParentArtifact()
+    {
+        return parentArtifact;
+    }
+
+    public void addAttachedArtifact( Artifact artifact )
+    {
+        if ( attachedArtifacts == null )
+        {
+            attachedArtifacts = new ArrayList();
+        }
+        attachedArtifacts.add( artifact );
+    }
+
+    public List getAttachedArtifacts()
+    {
+        return attachedArtifacts;
+    }
+}

Added: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/SourcePluginArtifactStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/SourcePluginArtifactStub.java?rev=394816&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/SourcePluginArtifactStub.java
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/stubs/SourcePluginArtifactStub.java
Mon Apr 17 18:31:56 2006
@@ -0,0 +1,97 @@
+package org.apache.maven.plugin.source.stubs;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+
+/**
+ * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
+ */
+public class SourcePluginArtifactStub
+    extends ArtifactStub
+{
+    private String groupId;
+
+    private String artifactId;
+
+    private String version;
+
+    private String packaging;
+
+    private VersionRange versionRange;
+
+    public SourcePluginArtifactStub( String groupId, String artifactId, String version, String
packaging )
+    {
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.version = version;
+        this.packaging = packaging;
+        versionRange = VersionRange.createFromVersion( version );
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setPackaging( String packaging )
+    {
+        this.packaging = packaging;
+    }
+
+    public String getPackaging()
+    {
+        return packaging;
+    }
+
+    public VersionRange getVersionRange()
+    {
+        return versionRange;
+    }
+
+    public void setVersionRange( VersionRange versionRange )
+    {
+        this.versionRange = versionRange;
+    }
+
+}



Mime
View raw message