Author: reinhard Date: Sun Oct 17 22:35:04 2004 New Revision: 54989 Modified: cocoon/whiteboard/block-deployer/test/junit/org/apache/cocoon/blockdeployer/repository/ApplicationServerLocatorTest.java Log: improve error handling
Modified: cocoon/whiteboard/block-deployer/test/junit/org/apache/cocoon/blockdeployer/repository/ApplicationServerLocatorTest.java ============================================================================== --- cocoon/whiteboard/block-deployer/test/junit/org/apache/cocoon/blockdeployer/repository/ApplicationServerLocatorTest.java (original) +++ cocoon/whiteboard/block-deployer/test/junit/org/apache/cocoon/blockdeployer/repository/ApplicationServerLocatorTest.java Sun Oct 17 22:35:04 2004 @@ -19,6 +19,8 @@ import java.io.FileInputStream; import java.io.InputStream; +import jodd.file.FileUtil; + import org.apache.cocoon.blockdeployer.Constants; import org.apache.cocoon.blockdeployer.LogEnabledTestCase; import org.apache.cocoon.blockdeployer.block.RemoteBlock; @@ -30,28 +32,29 @@ */ public class ApplicationServerLocatorTest extends LogEnabledTestCase { - private static final String EXAMPLES_DIR = "build/junit/aslt"; - private void setupExamples() { - File examplesDir = new File(Constants.VALID_LOCATION_1); - // copy all files to examples dir - + new File(Constants.TMP_VALID_ASL_1).mkdirs(); + FileUtil.copyDir(Constants.VALID_ASL_1, Constants.TMP_VALID_ASL_1); } private void removeExamples() { - + FileUtil.deleteDir(Constants.TMP_VALID_ASL_1); } public void testDeploy() throws Exception { // create a wiring MockControl blockControl = MockControl.createControl(Wiring.class); Wiring wiring = (Wiring) blockControl.getMock(); - - // first hack to run the deploy method - ApplicationServerLocator asl = new ApplicationServerLocator(new File(Constants.VALID_ASL_1), wiring, this.logger); + // copy examples into tmp location + setupExamples(); + // first hack to run the deploy method + ApplicationServerLocator asl = new ApplicationServerLocator(new File(Constants.TMP_VALID_ASL_1), wiring, this.logger); RemoteBlock b[] = new RemoteBlock[1]; b[0] = createBlockMock(null); asl.deploy(b); + // clean up + // removeExamples(); + } private RemoteBlock createBlockMock(String file) throws Exception { @@ -66,9 +69,9 @@ try { block.getStream(); InputStream is = new FileInputStream( - Constants.VALID_LOCATION_1 + "/" + + Constants.VALID_LOCATION_1 + File.separator + Constants.AVAILABLE_VALID_WEBMAIL1343_BLOCKPATH + - "/" + Constants.AVAILABLE_VALID_WEBMAIL1343_BLOCKFILE) ; + File.separator + Constants.AVAILABLE_VALID_WEBMAIL1343_BLOCKFILE) ; blockControl.setReturnValue(is); } catch (Exception e) { throw e;