cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r382176 - in /cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test: java/org/apache/cocoon/deployer/ java/org/apache/cocoon/deployer/block/ mocks/validDeploy-06/
Date Wed, 01 Mar 2006 22:15:29 GMT
Author: reinhard
Date: Wed Mar  1 14:15:25 2006
New Revision: 382176

URL: http://svn.apache.org/viewcvs?rev=382176&view=rev
Log:
make tests working when called from within a Maven 2 reactor build (it's a hack to make every
relative filesystem access absolute but the only possible solution ATM)

Modified:
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/BlockDeployerTest.java
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/block/BlockFactoryTest.java
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validDeploy-06/deploy.xml

Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java?rev=382176&r1=382175&r2=382176&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java
(original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java
Wed Mar  1 14:15:25 2006
@@ -3,6 +3,8 @@
 import java.io.File;
 import java.io.FileReader;
 
+import org.apache.cocoon.deployer.generated.deploy.x10.Block;
+import org.apache.cocoon.deployer.generated.deploy.x10.Deploy;
 import org.apache.cocoon.deployer.logger.ConsoleLogger;
 import org.apache.cocoon.deployer.logger.Logger;
 import org.apache.cocoon.deployer.util.FileUtils;
@@ -26,8 +28,8 @@
 
 public abstract class AbstractDeployerTestCase extends TestCase {
 
-	public final static String MOCKS_DIR = "./src/test/mocks";
-	public final static String OUTPUT_DIR = "./target/test";
+	public final static String MOCKS_DIR = "src/test/mocks";
+	public final static String OUTPUT_DIR = "target/test";
 	
 	/**
 	 * Code that is executed for each test.
@@ -44,7 +46,14 @@
 	 * @return the artifact as <code>java.io.File</code>
 	 */
 	public File getMockArtefact(String artifact) {
-		return new File(MOCKS_DIR, artifact);
+		String basedir = System.getProperty("basedir");
+		if(basedir != null || "".equals(basedir)) {
+			basedir = basedir + File.separator;
+		} else {
+			basedir = "." + File.separator;
+		}
+		System.out.println("basedir: " + basedir + MOCKS_DIR + ", artifact=" + artifact);
+		return new File(basedir + MOCKS_DIR, artifact);
 	}
 	
 	/**
@@ -73,13 +82,38 @@
 		}
 	}
     
+	/**
+	 * A simple method that creates a Deploy object.
+	 */
 	public org.apache.cocoon.deployer.generated.deploy.x10.Deploy getDeploy(String relativePath)

 		throws Exception {
 		return (org.apache.cocoon.deployer.generated.deploy.x10.Deploy) 
 			org.apache.cocoon.deployer.generated.deploy.x10.Deploy.unmarshal(
-			    new FileReader(new File(MOCKS_DIR, relativePath)));
+			    new FileReader(getMockArtefact(relativePath)));
+	}
+	
+	/**
+	 * Use this, to make the block location absolute. This is required for reactor Maven builds.
+	 */
+	protected Block absolutizeBlockLocation(Block deployBlock) {
+		System.out.println("loc: "+ deployBlock.getLocation());		
+		String basedir = System.getProperty("basedir");
+		if(basedir != null && deployBlock.getLocation() != null) {
+			deployBlock.setLocation(basedir + File.separator + deployBlock.getLocation());
+		}		
+		return deployBlock;
 	}
 	
+	/**
+	 * Change all block objects in a deploy object so that they use absolute paths.
+	 */
+	protected Deploy absolutizeDeploy(Deploy deploy) {
+		for(int i = 0; i < deploy.getBlock().length; i++) {
+			deploy.setBlock(i, absolutizeBlockLocation(deploy.getBlock(i)));
+		}
+		return deploy;
+	}	
+	
 	protected Logger getLogger() {
 		return new ConsoleLogger();
 	}
@@ -87,6 +121,8 @@
 	public void testDummy() {
 		// just exist for Maven surfire ;-)
 	}
+
+
 
 	
 }

Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/BlockDeployerTest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/BlockDeployerTest.java?rev=382176&r1=382175&r2=382176&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/BlockDeployerTest.java
(original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/BlockDeployerTest.java
Wed Mar  1 14:15:25 2006
@@ -30,8 +30,8 @@
 				this.getArtifactProviderInstance(),
 				new NullVariableResolver(),
 				new ConsoleLogger());
-		blockDeployer.deploy(
-			(Deploy) Deploy.unmarshal(new FileReader(this.getMockArtefact("validDeploy-04/deploy.xml"))));
+		Deploy deploy = (Deploy) Deploy.unmarshal(new FileReader(this.getMockArtefact("validDeploy-04/deploy.xml")));
+		blockDeployer.deploy(absolutizeDeploy(deploy));
 		System.out.println("x");
 		// assertions: ...
 		

Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/block/BlockFactoryTest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/block/BlockFactoryTest.java?rev=382176&r1=382175&r2=382176&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/block/BlockFactoryTest.java
(original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/block/BlockFactoryTest.java
Wed Mar  1 14:15:25 2006
@@ -18,12 +18,13 @@
 import java.io.File;
 
 import org.apache.cocoon.deployer.AbstractDeployerTestCase;
+import org.apache.cocoon.deployer.generated.deploy.x10.Block;
 
 public class BlockFactoryTest extends AbstractDeployerTestCase {
 	
 	private static final String VALID_BLOCK_01_JAR = "validBlock-01/valid-block-1.0.jar";
 	private static final String VALID_DEPLOY_01 = "validDeploy-01/deploy.xml";
-	private static final String VALID_DEPLOY_06 = "validDeploy-06/deploy.xml";;
+	private static final String VALID_DEPLOY_06 = "validDeploy-06/deploy.xml";
 
 	/**
 	 * Test if the passed block is a file and not a directory
@@ -78,15 +79,16 @@
 		assertEquals(b.getId(), "http://cocoon.apache.org/blocks/anyblock/1.0");
 
 		assertNotNull(block.getInputStream());
-		assertEquals( Block.BLOCK_NS_10, block.getNamespace());
+		assertEquals( org.apache.cocoon.deployer.block.Block.BLOCK_NS_10, block.getNamespace());
 		assertEquals("http://cocoon.apache.org/blocks/anyblock/1.0", block.getId());
 	}
 
 	public void testLocalBlockCreation() throws Exception {
-		LocalBlock block = BlockFactory.createLocalBlock(this.getDeploy(VALID_DEPLOY_06).getBlock(0),
".");
+		Block deployBlock = this.getDeploy(VALID_DEPLOY_06).getBlock(0);
+		LocalBlock block = BlockFactory.createLocalBlock(absolutizeBlockLocation(deployBlock),
"");
 		assertNotNull(block);
 		assertNotNull(block.getBlockDescriptor());
-		assertEquals( Block.BLOCK_NS_10, block.getNamespace());
+		assertEquals( org.apache.cocoon.deployer.block.Block.BLOCK_NS_10, block.getNamespace());
 		assertEquals("anyblock:anyblock-06:1.0", block.getId());	
 		assertTrue(new File(block.getBaseDirectory()).exists());
 	}

Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validDeploy-06/deploy.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validDeploy-06/deploy.xml?rev=382176&r1=382175&r2=382176&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validDeploy-06/deploy.xml
(original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validDeploy-06/deploy.xml
Wed Mar  1 14:15:25 2006
@@ -16,7 +16,7 @@
 -->
 <deploy xmlns="http://apache.org/cocoon/blocks/deploy/1.0">
   
-  <cocoon target-url=".target/test/validDeploy-02/myServer" 
+  <cocoon target-url="./target/test/validDeploy-02/myServer" 
     urn="org.apache.cocoon:cocoon-minimal-webapp:1.0-SNAPSHOT:war" exclusive="true"/>
   
   
   <block id="db" urn="validBlock-04:validBlock-04:1.0" location="src/test/mocks/validBlock-06/blockRoot"/>
 



Mime
View raw message