You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jg...@apache.org on 2005/04/26 00:59:36 UTC
svn commit: r164681 - in /geronimo/trunk/modules/tomcat-builder: project.xml
src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Author: jgenender
Date: Mon Apr 25 15:59:35 2005
New Revision: 164681
URL: http://svn.apache.org/viewcvs?rev=164681&view=rev
Log:
Changed unit test to use commons io to copy directory structure instead.
Modified:
geronimo/trunk/modules/tomcat-builder/project.xml
geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Modified: geronimo/trunk/modules/tomcat-builder/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/project.xml?rev=164681&r1=164680&r2=164681&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/project.xml (original)
+++ geronimo/trunk/modules/tomcat-builder/project.xml Mon Apr 25 15:59:35 2005
@@ -280,6 +280,13 @@
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons_io_version}</version>
+ <url>http://jakarta.apache.org/commons/io/</url>
+ </dependency>
+
+ <dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>${ant_version}</version>
Modified: geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=164681&r1=164680&r2=164681&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java (original)
+++ geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java Mon Apr 25 15:59:35 2005
@@ -18,15 +18,11 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.URI;
import java.net.URL;
-import java.nio.channels.FileChannel;
-import java.util.Collections;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -41,6 +37,7 @@
import junit.framework.TestCase;
+import org.apache.commons.io.FileUtils;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
import org.apache.geronimo.deployment.DeploymentContext;
@@ -289,76 +286,17 @@
}
}
- public void recursiveCopy(File src, File dest) throws IOException {
-
- if (!src.exists()) {
- return;
- }
-
- if (src.isDirectory()) {
- // Create destination directory
- dest.mkdirs();
-
- // Go trough the contents of the directory
- String list[] = src.list();
- for (int i = 0; i < list.length; i++) {
- recursiveCopy(new File(src, list[i]), new File(dest, list[i]));
- }
-
- } else {
- copyFile(src, dest, -1);
- }
- }
-
- public boolean copyFile(File src, File dest, long extent)
- throws FileNotFoundException, IOException {
- boolean result = false;
- if (dest.exists()) {
- dest.delete();
- }
- FileInputStream fis = null;
- FileOutputStream fos = null;
- FileChannel fcin = null;
- FileChannel fcout = null;
- try {
- // Get channels
- fis = new FileInputStream(src);
- fos = new FileOutputStream(dest);
- fcin = fis.getChannel();
- fcout = fos.getChannel();
- if (extent < 0) {
- extent = fcin.size();
- }
-
- // do the file copy
- long trans = fcin.transferTo(0, extent, fcout);
- if (trans < extent) {
- result = false;
- }
- result = true;
- } catch (IOException e) {
- // Add more info to the exception. Preserve old stacktrace.
- IOException newE = new IOException("Copying "
- + src.getAbsolutePath() + " to " + dest.getAbsolutePath()
- + " with extent " + extent + " got IOE: " + e.getMessage());
- newE.setStackTrace(e.getStackTrace());
- throw newE;
- } finally {
- // finish up
- if (fcin != null) {
- fcin.close();
- }
- if (fcout != null) {
- fcout.close();
- }
- if (fis != null) {
- fis.close();
- }
- if (fos != null) {
- fos.close();
+ public void recursiveCopy(File src, File dest) throws IOException {
+ Collection files = FileUtils.listFiles(src,null,true);
+ Iterator iterator = files.iterator();
+ while(iterator.hasNext()){
+ File file = (File) iterator.next();
+ if (file.getAbsolutePath().indexOf(".svn") < 0){
+ String pathToFile = file.getPath();
+ String relativePath = pathToFile.substring(src.getPath().length(), pathToFile.length());
+ FileUtils.copyFileToDirectory(file,new File(dest.getPath() + relativePath));
}
}
- return result;
}
protected void setUp() throws Exception {