You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by pt...@apache.org on 2009/02/03 21:23:08 UTC

svn commit: r740413 - in /jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test: ArtifactStub.java CactifyMavenProjectStub.java TestCactifyEarMojo.java TestCactifyWarMojo.java

Author: ptahchiev
Date: Tue Feb  3 20:23:07 2009
New Revision: 740413

URL: http://svn.apache.org/viewvc?rev=740413&view=rev
Log:
Checkstyle improved.

Modified:
    jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/ArtifactStub.java
    jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/CactifyMavenProjectStub.java
    jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyEarMojo.java
    jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyWarMojo.java

Modified: jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/ArtifactStub.java
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/ArtifactStub.java?rev=740413&r1=740412&r2=740413&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/ArtifactStub.java (original)
+++ jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/ArtifactStub.java Tue Feb  3 20:23:07 2009
@@ -23,25 +23,56 @@
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
- * @author Edwin Punzalan
+ * Artifact stub to use in the maven2 tests.
+ * 
+ * @version $Id: ArtifactStub.java 238816 2004-02-29 16:36:46Z ptahchiev$
  */
 public class ArtifactStub
     extends DefaultArtifact
 {
-    public ArtifactStub( String groupId, String artifactId, String version, String packaging, String scope )
+    /**
+     * A constructor for the stub.
+     * 
+     * @param theGroupId to set
+     * @param theArtifactId to set
+     * @param theVersion to set
+     * @param thePackaging to set
+     * @param theScope to set
+     */
+    public ArtifactStub(String theGroupId, String theArtifactId, 
+            String theVersion, String thePackaging, String theScope)
     {
-        this( groupId, artifactId, version, packaging, null, scope );
+        this(theGroupId, theArtifactId, theVersion, thePackaging, 
+                null, theScope);
     }
 
-    public ArtifactStub( String groupId, String artifactId, String version, String packaging, String classifier, String scope )
+    /**
+     * Another constructor for the stub.
+     * 
+     * @param theGroupId to use
+     * @param theArtifactId to use
+     * @param theVersion to use
+     * @param thePackaging to use
+     * @param theClassifier to use
+     * @param theScope to use
+     */
+    public ArtifactStub(String theGroupId, String theArtifactId, 
+            String theVersion, String thePackaging, String theClassifier, 
+            String theScope)
     {
-        super( groupId, artifactId, VersionRange.createFromVersion( version ), scope, packaging,
-               classifier, new DefaultArtifactHandler( packaging ), false );
+        super(theGroupId, theArtifactId, 
+            VersionRange.createFromVersion(theVersion), theScope, thePackaging,
+            theClassifier, new DefaultArtifactHandler(thePackaging), false);
     }
 
+    /**
+     * @return File the file from the local repository 
+     * constructed with our data.
+     */
     public File getFile()
     {
-        return new File( PlexusTestCase.getBasedir() + "/target/local-repo", getArtifactId() + "-" + getVersion() + "." + getType() )
+        return new File(PlexusTestCase.getBasedir() + "/target/local-repo", 
+            getArtifactId() + "-" + getVersion() + "." + getType())
         {
             public long lastModified()
             {

Modified: jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/CactifyMavenProjectStub.java
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/CactifyMavenProjectStub.java?rev=740413&r1=740412&r2=740413&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/CactifyMavenProjectStub.java (original)
+++ jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/CactifyMavenProjectStub.java Tue Feb  3 20:23:07 2009
@@ -32,34 +32,63 @@
 import java.util.Properties;
 import java.util.List;
 import java.io.File;
-
+/**
+ * A maven project stub for our cactify purposes.
+ * 
+ * @version $Id: CactifyMavenProjectStub.java 238816 2004-02-29 16:36:46Z ptahchiev$
+ */
 public class CactifyMavenProjectStub extends MavenProjectStub 
 {
 
+    /**
+     * The groupId, artifactId and version for our plugin.
+     */
     private String groupId, artifactId, version;
 
+    /**
+     * The artifact object for our plugin.
+     */
     private Artifact artifact;
 
+    /**
+     * A set of artifacts we need.
+     */
     private Set artifacts;
 
+    /**
+     * The model of the pom.
+     */
     private Model model;
 
+    /**
+     * The base directory for the project.
+     */
     private File basedir;
 
+    /**
+     * @return the build for the project
+     */
     public Build getBuild()
     {
         return model.getBuild();
     }
 
+    /**
+     * @return of remote artifact repositories
+     */
     public List getRemoteArtifactRepositories()
     {
-        ArtifactRepository repository = new DefaultArtifactRepository( "central",
-                                             "file://" + PlexusTestCase.getBasedir() + "/src/test/remote-repo",
-                                             new DefaultRepositoryLayout() );
+        ArtifactRepository repository = new DefaultArtifactRepository(
+                "central", "file://" 
+                + PlexusTestCase.getBasedir() + "/src/test/remote-repo",
+                                             new DefaultRepositoryLayout());
 
-        return Collections.singletonList( repository );
+        return Collections.singletonList(repository);
     }
 
+    /**
+     * Constructor for our stub.
+     */
     public CactifyMavenProjectStub()
     {
         groupId = "cactify";
@@ -67,59 +96,77 @@
         version = "1.0";
     }
 
+    /**
+     * @return a set of dependency artifacts.
+     */
     public Set getDependencyArtifacts()
     {
         return Collections.singleton(
-            new DefaultArtifact( "cactify", "dependency-artifact", VersionRange.createFromVersion( "1.0" ),
-                                 Artifact.SCOPE_COMPILE, "jar", null, new DefaultArtifactHandler( "jar" ), false )
+            new DefaultArtifact("cactify", "dependency-artifact", 
+                    VersionRange.createFromVersion("1.0"),
+                    Artifact.SCOPE_COMPILE, "jar", null, 
+                    new DefaultArtifactHandler("jar"), false)
             );
     }
 
+    /**
+     * @return the base directory as a File.
+     */
     public File getBasedir()
     {
-        if ( basedir == null )
+        if (basedir == null)
         {
-            basedir = new File( PlexusTestCase.getBasedir() );
+            basedir = new File(PlexusTestCase.getBasedir());
         }
 
         return basedir;
     }
 
+    /**
+     * @return the artifact for the project.
+     */
     public Artifact getArtifact()
     {
-        if ( artifact == null )
+        if (artifact == null)
         {
-            artifact = new ArtifactStub( groupId, artifactId, version, "jar", Artifact.SCOPE_COMPILE );
+            artifact = new ArtifactStub(groupId, artifactId, version, "jar", 
+                    Artifact.SCOPE_COMPILE);
         }
 
         return artifact;
     }
 
+    /**
+     * @return the model of the project.
+     */
     public Model getModel()
     {
-        if ( model == null )
+        if (model == null)
         {
             model = new Model();
 
-            model.setProperties( new Properties() );
+            model.setProperties(new Properties());
 
-            model.setGroupId( getGroupId() );
+            model.setGroupId(getGroupId());
 
-            model.setArtifactId( getArtifactId() );
+            model.setArtifactId(getArtifactId());
 
-            model.setVersion( getVersion() );
+            model.setVersion(getVersion());
 
             Build build = new Build();
-            build.setFinalName( getArtifactId() + "-" + getVersion() );
-            model.setBuild( build );
+            build.setFinalName(getArtifactId() + "-" + getVersion());
+            model.setBuild(build);
         }
 
         return model;
     }
 
+    /**
+     * @return a set of artifacts.
+     */
     public Set getArtifacts()
     {
-        if ( artifacts == null )
+        if (artifacts == null)
         {
             artifacts = Collections.EMPTY_SET;
         }
@@ -127,43 +174,68 @@
         return artifacts;
     }
 
-    public void setArtifacts( Set artifacts )
-    {
-        this.artifacts = artifacts;
+    /**
+     * Setter for the artifacts.
+     * @param theArtifacts to set
+     */
+    public void setArtifacts(Set theArtifacts)
+    {
+        this.artifacts = theArtifacts;
     }
 
+    /**
+     * @return the properties.
+     */
     public Properties getProperties()
     {
         return new Properties();
     }
 
+    /**
+     * @return the groupId
+     */
     public String getGroupId()
     {
         return groupId;
     }
 
-    public void setGroupId( String groupId )
+    /**
+     * @param theGroupId for the project
+     */
+    public void setGroupId(String theGroupId)
     {
-        this.groupId = groupId;
+        this.groupId = theGroupId;
     }
 
+    /**
+     * @return the artifactId
+     */
     public String getArtifactId()
     {
         return artifactId;
     }
 
-    public void setArtifactId( String artifactId )
+    /**
+     * @param theArtifactId for the project.
+     */
+    public void setArtifactId(String theArtifactId)
     {
-        this.artifactId = artifactId;
+        this.artifactId = theArtifactId;
     }
 
+    /**
+     * @return the version of the project
+     */
     public String getVersion()
     {
         return version;
     }
 
-    public void setVersion( String version )
+    /**
+     * @param theVersion of the project
+     */
+    public void setVersion(String theVersion)
     {
-        this.version = version;
+        this.version = theVersion;
     }
 }

Modified: jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyEarMojo.java
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyEarMojo.java?rev=740413&r1=740412&r2=740413&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyEarMojo.java (original)
+++ jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyEarMojo.java Tue Feb  3 20:23:07 2009
@@ -30,7 +30,7 @@
 /**
  * Some unit tests for the <code>CactifyEarMojo</code> class.
  * 
- * @author ptahchiev
+ * @version $Id: TestCactifyEarMojo.java 238816 2004-02-29 16:36:46Z ptahchiev$
  */
 public class TestCactifyEarMojo extends AbstractMojoTestCase 
 {
@@ -41,6 +41,8 @@
     
     /**
      * Set-up method to instantiate the mojo.
+     * 
+     * @throws Exception if something nasty happens
      */
     public void setUp() throws Exception
     {
@@ -50,23 +52,26 @@
     
 
     /**
-     * Tests the mojo with absolutely no parameters specified
+     * Tests the mojo with absolutely no parameters specified.
+     * 
      * @throws Exception in case some error occurs
      */
     public void testCactifyEarWithNoParametersSpecified() throws Exception
     {
-        File testPom = new File(getBasedir(), "target/test-classes/unit/ear/basic-"
-                + "cactify-noparameters/plugin-config.xml");
-        CactifyEarMojo mojo = (CactifyEarMojo) lookupMojo("cactifyear", testPom);
+        File testPom = new File(getBasedir(), "target/test-classes/unit/ear/"
+                + "basic-cactify-noparameters/plugin-config.xml");
+        CactifyEarMojo mojo = 
+            (CactifyEarMojo) lookupMojo("cactifyear", testPom);
         assertNotNull(mojo);
         try 
         {
-        	mojo.execute();
-        	fail("Exception should have been raised!");
+            mojo.execute();
+            fail("Exception should have been raised!");
         } 
         catch (MojoExecutionException mex)
         {
-        	assertEquals("You need to specify [srcFile] attribute for cactification!", mex.getMessage());
+            assertEquals("You need to specify [srcFile] attribute for "
+                    + "cactification!", mex.getMessage());
         }
     }
 }
\ No newline at end of file

Modified: jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyWarMojo.java
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyWarMojo.java?rev=740413&r1=740412&r2=740413&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyWarMojo.java (original)
+++ jakarta/cactus/trunk/integration/maven2/src/test/java/org/apache/cactus/integration/maven2/test/TestCactifyWarMojo.java Tue Feb  3 20:23:07 2009
@@ -30,7 +30,7 @@
 /**
  * Some unit tests for the <code>CactifyWarMojo</code> class.
  * 
- * @author ptahchiev
+ * @version $Id: TestCactifyWarMojo.java 238816 2004-02-29 16:36:46Z ptahchiev$
  */
 public class TestCactifyWarMojo extends AbstractMojoTestCase 
 {
@@ -41,6 +41,8 @@
     
     /**
      * Set-up method to instantiate the mojo.
+     * 
+     * @throws Exception in case something bad happens
      */
     public void setUp() throws Exception
     {
@@ -52,8 +54,8 @@
      * Try to execute the mojo with no parameters set.
      * We should expect an exception to be raised.
      * 
-     * @throws MojoExecutionException
-     * @throws MojoFailureException
+     * @throws MojoExecutionException in case something bad happens
+     * @throws MojoFailureException in case something bad happens
      */
     public void testNeitherSrcNorVersionAttributeSuppliedAtInstantiation() 
         throws MojoExecutionException, MojoFailureException
@@ -63,7 +65,7 @@
             cactifyWarMojo.execute();
             fail("Should not come here.");
         }
-        catch(MojoExecutionException mojex)
+        catch (MojoExecutionException mojex)
         {
             assertEquals("You need to specify either the [srcFile] " +
                     "or the [version] attribute", mojex.getMessage());
@@ -74,7 +76,7 @@
      * Test if you supply no arguments in the pom.xml you will get an 
      * exception.
      * 
-     * @throws Exception
+     * @throws Exception in case some error occurs
      */
     public void testNoParametersSupplied()
     throws Exception
@@ -88,7 +90,7 @@
         {
             mojo.execute();
         }
-        catch(MojoExecutionException mojex)
+        catch (MojoExecutionException mojex)
         {
             assertEquals("You need to specify either the [srcFile] " +
                     "or the [version] attribute", mojex.getMessage());
@@ -105,7 +107,8 @@
 //    {
 //        File testPom = new File(getBasedir(), "target/test-classes/unit/"
 //               + "cactify-test-empty-src-file/plugin-config.xml");
-//        CactifyWarMojo mojo = (CactifyWarMojo) lookupMojo("cactifywar", testPom);
+//        CactifyWarMojo mojo = (CactifyWarMojo) lookupMojo("cactifywar", 
+//               testPom);
 //        assertNotNull(mojo);
 //        try
 //        {
@@ -113,15 +116,18 @@
 //        }
 //        catch(MojoExecutionException mx)
 //        {
-//            assertEquals("Failed to get the original web.xml", mx.getMessage());  
+//            assertEquals("Failed to get the original web.xml", 
+//                 mx.getMessage());  
 //        }
 //    }
     
     /**
      * Test that if we specify wrong version an appropriate excption is thrown.
-     * @throws Exception
+     * 
+     * @throws Exception in case some error occurs
      */
-    public void testIfVersionIsSetAndWrongMergeXmlParameterPassed() throws Exception
+    public void testIfVersionIsSetAndWrongMergeXmlParameterPassed() 
+    throws Exception
     {
         File testPom = new File(getBasedir(), "target/test-classes/unit/"
                 + "cactify-test-wrong-mergexml-specified/plugin-config.xml");
@@ -132,16 +138,18 @@
          {
              mojo.execute();
          }
-         catch(MojoExecutionException mx)
+         catch (MojoExecutionException mx)
          {
-             assertEquals("Could not merge deployment descriptors", mx.getMessage());  
+             assertEquals("Could not merge deployment descriptors", 
+                     mx.getMessage());  
          }
     }
     
     /**
      * Test that if we specify wrong srcFile parameter appropriate 
      * exception is thrown.
-     * @throws Exception
+     * 
+     * @throws Exception in case some error occurs
      */
     public void testWrongSrcParameterPassed() throws Exception
     {
@@ -154,9 +162,10 @@
          {
              mojo.execute();
          }
-         catch(MojoExecutionException mx)
+         catch (MojoExecutionException mx)
          {
-             assertEquals("Failed to get the original web.xml", mx.getMessage());  
+             assertEquals("Failed to get the original web.xml", 
+                     mx.getMessage());
          }
     }
     
@@ -179,7 +188,8 @@
 //         catch(MojoExecutionException mx)
 //         {
 //             //mx.printStackTrace();
-//             assertEquals("Failed to get the original web.xml", mx.getMessage());  
+//             assertEquals("Failed to get the original web.xml", 
+//                 mx.getMessage());  
 //         }
 //    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org