continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r699203 - /continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
Date Fri, 26 Sep 2008 07:27:30 GMT
Author: ctan
Date: Fri Sep 26 00:27:30 2008
New Revision: 699203

URL: http://svn.apache.org/viewvc?rev=699203&view=rev
Log:
[CONTINUUM-1815] fixed unit test

Modified:
    continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java?rev=699203&r1=699202&r2=699203&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
Fri Sep 26 00:27:30 2008
@@ -30,7 +30,12 @@
 import org.apache.maven.continuum.model.scm.ScmResult;
 import org.apache.maven.continuum.project.ContinuumProjectState;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
 import java.util.Calendar;
+import java.util.List;
 
 public class DefaultBuildControllerTest
     extends AbstractContinuumTest
@@ -75,6 +80,7 @@
         buildResult2.setState( ContinuumProjectState.OK );
         buildResult2.setBuildDefinition( bd1 );
         buildResultDao.addBuildResult( project1, buildResult2 );
+        createPomFile( getProjectDao().getProjectWithAllDetails( projectId1 ) );
 
         Project project2 = createProject( "project2" );
         ProjectDependency dep1 = new ProjectDependency();
@@ -92,7 +98,8 @@
         project2.setState( ContinuumProjectState.OK );
         projectId2 = addProject( project2 ).getId();
         buildDefinitionId2 = buildDefinitionDao.getDefaultBuildDefinition( projectId2 ).getId();
-
+        createPomFile( getProjectDao().getProjectWithAllDetails( projectId2 ) );
+        
         controller = (DefaultBuildController) lookup( BuildController.ROLE );
     }
 
@@ -176,4 +183,72 @@
         assertEquals( 1, context.getModifiedDependencies().size() );
         assertTrue( controller.shouldBuild( context ) );
     }
+
+    private File getWorkingDirectory()
+        throws Exception
+    {
+        File workingDirectory = getTestFile( "target/working-directory" );
+        
+        if ( !workingDirectory.exists() )
+        {
+            workingDirectory.mkdir();
+        }
+        
+        return workingDirectory;
+    }
+    
+    private File getWorkingDirectory( Project project )
+        throws Exception
+    {
+        File projectDir = new File( getWorkingDirectory(), Integer.toString( project.getId()
) );
+
+        if ( !projectDir.exists() )
+        {
+            projectDir.mkdirs();
+            System.out.println( "projectdirectory created" + projectDir.getAbsolutePath()
);
+        }
+
+        return projectDir;
+    }
+    
+    private void createPomFile( Project project )
+        throws Exception
+    {
+        File pomFile = new File( getWorkingDirectory( project ), "pom.xml" );
+        
+        BufferedWriter out = new BufferedWriter( new FileWriter( pomFile ) );
+        out.write( "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" " +
+        		   "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
+        		   "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
);
+        out.write( "<modelVersion>4.0.0</modelVersion>\n" );
+        out.write( "<groupId>" + project.getGroupId() + "</groupId>\n" );
+        out.write( "<artifactId>" + project.getArtifactId() + "</artifactId>\n"
);
+        out.write( "<version>" + project.getVersion() + "</version>\n" );
+        out.write( "<scm>\n" );
+        out.write( "<connection>" + "scm:local|" + getWorkingDirectory().getAbsolutePath()
+ 
+                   "|" + project.getId() + "</connection>\n" );
+        out.write( "</scm>" );
+
+        if ( project.getDependencies().size() > 0 )
+        {
+            out.write( "<dependencies>\n" );
+
+            List<ProjectDependency> dependencies = project.getDependencies();
+
+            for ( ProjectDependency dependency : dependencies )
+            {
+                out.write( "<dependency>\n" );
+                out.write( "<groupId>" + dependency.getGroupId() + "</groupId>\n"
);
+                out.write( "<artifactId>" + dependency.getArtifactId() + "</artifactId>\n"
);
+                out.write( "<version>" + dependency.getVersion() + "</version>\n"
);
+                out.write( "</dependency>\n" );
+            }
+            out.write( "</dependencies>\n" );
+        }
+
+        out.write( "</project>" );
+        out.close();
+        
+        System.out.println( "pom file created" );
+    }
 }



Mime
View raw message