You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/05/14 22:45:44 UTC
svn commit: r406425 - in
/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war:
PropertyUtilsTest.java WarExplodedMojoTest.java WarInPlaceMojoTest.java
stub/MavenProjectArtifactsStub.java stub/MavenProjectBasicStub.java
Author: brett
Date: Sun May 14 13:45:43 2006
New Revision: 406425
URL: http://svn.apache.org/viewcvs?rev=406425&view=rev
Log:
[MWAR-37] additional test cases
Submitted by: Marvin King
Modified:
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/PropertyUtilsTest.java
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectBasicStub.java
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/PropertyUtilsTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/PropertyUtilsTest.java?rev=406425&r1=406424&r2=406425&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/PropertyUtilsTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/PropertyUtilsTest.java Sun May 14 13:45:43 2006
@@ -16,12 +16,12 @@
* limitations under the License.
*/
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
import java.io.File;
import java.io.FileWriter;
import java.util.Properties;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-
public class PropertyUtilsTest
extends AbstractMojoTestCase
{
@@ -48,7 +48,7 @@
Properties prop = PropertyUtils.loadPropertyFile( basicProp, false, false );
assertTrue( prop.getProperty( "key" ).equals( "gani_man" ) );
- assertTrue( prop.getProperty( "ghost" ).equals("${non_existent}") );
+ assertTrue( prop.getProperty( "ghost" ).equals( "${non_existent}" ) );
}
public void testSystemProperties()
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java?rev=406425&r1=406424&r2=406425&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java Sun May 14 13:45:43 2006
@@ -25,6 +25,7 @@
import org.apache.maven.plugin.war.stub.ResourceStub;
import org.apache.maven.plugin.war.stub.SimpleWarArtifactStub;
import org.apache.maven.plugin.war.stub.TLDArtifactStub;
+import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.FileReader;
@@ -569,19 +570,37 @@
// configure mojo
this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
+
+ // destination file is already created manually containing an "error" string
+ // source is newer than the destination file
mojo.execute();
// validate operation
- File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
- File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
+
File expectedWEBINFDir = new File( webAppDirectory, "WEB-INF" );
File expectedMETAINFDir = new File( webAppDirectory, "META-INF" );
+ File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
+ File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() );
assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
- }
-
+ // 1st phase destination is older than source
+ // destination starts with a value of error replaced with a blank source
+ assertFalse( "source files not updated with new copy: " + expectedWebSourceFile.toString(),
+ "error".equals( FileUtils.fileRead( expectedWebSourceFile ) ) );
+
+// TODO: uncomment when lastModified problem is resolved
+// FileWriter writer = new FileWriter(expectedWebSourceFile);
+//
+// // 2nd phase destination is newer than source
+// // destination should not be replaced with an blank source
+// writer.write("newdata");
+// mojo.execute();
+// reader = new FileReader(expectedWebSourceFile);
+// reader.read(data);
+// assertTrue("source file updated with old copy: " +expectedWebSourceFile.toString(),String.valueOf(data).equals("newdata") ); }
+ }
}
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java?rev=406425&r1=406424&r2=406425&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java Sun May 14 13:45:43 2006
@@ -16,17 +16,17 @@
* limitations under the License.
*/
-import java.io.File;
-import java.util.LinkedList;
-
import org.apache.maven.plugin.war.stub.MavenProjectBasicStub;
import org.apache.maven.plugin.war.stub.ResourceStub;
+import java.io.File;
+import java.util.LinkedList;
+
public class WarInPlaceMojoTest
extends AbstractWarMojoTest
{
- protected static final String pomFilePath = getBasedir()
- + "/target/test-classes/unit/warexplodedinplacemojo/plugin-config.xml";
+ protected static final String pomFilePath =
+ getBasedir() + "/target/test-classes/unit/warexplodedinplacemojo/plugin-config.xml";
protected File getTestDirectory()
throws Exception
@@ -52,7 +52,6 @@
}
/**
- *
* @throws Exception
*/
public void testSimpleExplodedInplaceWar()
@@ -65,7 +64,7 @@
File classesDir = createClassesDir( testId, true );
File webAppResource = new File( getTestDirectory(), "resources" );
File sampleResource = new File( webAppResource, "pix/panis_na.jpg" );
- ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
+ ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
createFile( sampleResource );
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java?rev=406425&r1=406424&r2=406425&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectArtifactsStub.java Sun May 14 13:45:43 2006
@@ -50,10 +50,12 @@
String basedir = System.getProperty( "basedir" );
- artifacts.add( basedir +
- "/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar" );
- artifacts.add( basedir +
- "/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar" );
+ artifacts
+ .add( basedir +
+ "/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar" );
+ artifacts
+ .add( basedir +
+ "/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar" );
return artifacts;
}
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectBasicStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectBasicStub.java?rev=406425&r1=406424&r2=406425&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectBasicStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/MavenProjectBasicStub.java Sun May 14 13:45:43 2006
@@ -16,30 +16,28 @@
* limitations under the License.
*/
+import org.apache.maven.model.Organization;
+import org.apache.maven.project.MavenProject;
+
import java.io.File;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.apache.maven.model.Organization;
-
/**
* Stub
*/
public class MavenProjectBasicStub
- extends MavenProjectStub
+ extends MavenProject
{
protected String testRootDir;
protected Properties properties;
- protected SimpleWarArtifactStub artifact;
-
public MavenProjectBasicStub()
throws Exception
{
+ super( new ModelStub() );
properties = new Properties();
}
@@ -57,17 +55,8 @@
{
// create an isolated environment
// see setupTestEnvironment for details
- return new File( testRootDir );
- }
-
- public void setArtifact( SimpleWarArtifactStub _artifact )
- {
- artifact = _artifact;
- }
-
- public Artifact getArtifact()
- {
- return artifact;
+ //return new File( testRootDir );
+ return null;
}
public String getGroupId()