[workspace-commit] CVS update: MODIFIED: client

commit at globus.org commit at globus.org
Wed May 27 09:29:13 CDT 2009


, FileCleanupTestFixture.java, CloudMetaClientTest.java ...

  User: labisso 
  Date: 09/05/27 09:29:13

  Modified:    vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client
                        FileCleanupTestFixture.java CloudManagerTest.java
                        CloudMetaClientTest.java CloudDeploymentTest.java
  Log:
  Fixed FileCleanupTestFixture to actually remove all temp files on teardown
  
  Revision  Changes    Path
  1.2       +22 -9     workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/FileCleanupTestFixture.java
  
  http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/FileCleanupTestFixture.java.diff?r1=1.1&r2=1.2
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FileCleanupTestFixture.java
  ===================================================================
  RCS file: /home/globdev/CVS/globus-packages/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/FileCleanupTestFixture.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- FileCleanupTestFixture.java	26 May 2009 22:55:33 -0000	1.1
  +++ FileCleanupTestFixture.java	27 May 2009 14:29:13 -0000	1.2
  @@ -29,8 +29,11 @@
    * list will be deleted, followed by the directory.
    */
   public class FileCleanupTestFixture {
  -    File tempDir;
  -    ArrayList<File> tempFiles = new ArrayList<File>();
  +    public File getTempDir() {
  +        return tempDir;
  +    }
  +
  +    private File tempDir = null;
   
       @Before
       public void setup() throws Exception {
  @@ -55,14 +58,24 @@
   
       @After
       public void teardown() {
  -        for (int i = tempFiles.size()-1; i >= 0; i--) {
  -            File f = tempFiles.get(i);
  -            if (f.exists()) {
  -                f.delete();
  +        //dangerous!
  +        if (tempDir != null) {
  +            deleteDir(tempDir);
               }
           }
  -        if (tempDir != null) {
  -            tempDir.delete();
  +
  +    static boolean deleteDir(File dir) {
  +        if (dir.isDirectory()) {
  +            String[] children = dir.list();
  +            for (int i=0; i<children.length; i++) {
  +                boolean success = deleteDir(new File(dir, children[i]));
  +                if (!success) {
  +                    return false;
           }
       }
  +        }
  +
  +        return dir.delete();
  +    }
  +
   }
  
  
  
  1.2       +3 -4      workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudManagerTest.java
  
  http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudManagerTest.java.diff?r1=1.1&r2=1.2
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CloudManagerTest.java
  ===================================================================
  RCS file: /home/globdev/CVS/globus-packages/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudManagerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CloudManagerTest.java	26 May 2009 22:55:33 -0000	1.1
  +++ CloudManagerTest.java	27 May 2009 14:29:13 -0000	1.2
  @@ -35,7 +35,7 @@
           CloudManager manager;
           try {
               manager = new CloudManager(
  -                tempDir+ File.separator+"notarealdir");
  +                this.getTempDir()+ File.separator+"notarealdir");
           } catch (ParameterProblem e) {
               expected = e;
           }
  @@ -73,11 +73,11 @@
       }
   
       private CloudManager getManager() throws ParameterProblem {
  -        return new CloudManager(this.tempDir.getPath());
  +        return new CloudManager(this.getTempDir().getPath());
       }
   
       private void createFakeCloud(String name) throws Exception {
  -        File f = new File(tempDir.getPath()+File.separator+name);
  +        File f = new File(this.getTempDir().getPath()+File.separator+name);
           if (f.exists()) {
               throw new Exception("fake cloud already exists");
           }
  @@ -90,7 +90,6 @@
           props.put(Props.KEY_SSHFILE, "sandwich");
   
           TestUtil.writePropertiesToFile(props, f);
  -        tempFiles.add(f);
       }
   
   }
  
  
  
  1.2       +3 -7      workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudMetaClientTest.java
  
  http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudMetaClientTest.java.diff?r1=1.1&r2=1.2
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CloudMetaClientTest.java
  ===================================================================
  RCS file: /home/globdev/CVS/globus-packages/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudMetaClientTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CloudMetaClientTest.java	26 May 2009 22:55:33 -0000	1.1
  +++ CloudMetaClientTest.java	27 May 2009 14:29:13 -0000	1.2
  @@ -28,25 +28,22 @@
       @Test
       public void testRun() throws Throwable {
   
  +        File tempDir = this.getTempDir();
           Print print = new Print();
           CloudMetaClient client = new CloudMetaClient(print);
   
  -        File clusterFile = new File(this.tempDir, "cluster.xml");
  -        this.tempFiles.add(clusterFile);
  +        File clusterFile = new File(tempDir, "cluster.xml");
           TestUtil.writeSampleClusterToFile(clusterFile);
   
  -        File deployFile = new File(this.tempDir, "deploy.xml");
  -        this.tempFiles.add(deployFile);
  +        File deployFile = new File(tempDir, "deploy.xml");
           TestUtil.writeSampleDeployToFile(deployFile);
   
           File historyDir = new File(tempDir, "history");
  -        this.tempFiles.add(historyDir);
           if (!historyDir.mkdir()) {
               throw new Exception("failed to create history dir");
           }
   
           File cloudDir = new File(tempDir, "clouds");
  -        this.tempFiles.add(cloudDir);
           if (!cloudDir.mkdir()) {
               throw new Exception("failed to create cloud dir");
           }
  @@ -78,7 +75,6 @@
           Properties props = getCloudProps();
   
           File cloudFile = new File(cloudDir, cloudName);
  -        this.tempFiles.add(cloudFile);
           TestUtil.writePropertiesToFile(props, cloudFile);
       }
   
  
  
  
  1.2       +1 -7      workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudDeploymentTest.java
  
  http://viewcvs.globus.org/viewcvs.cgi/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudDeploymentTest.java.diff?r1=1.1&r2=1.2
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CloudDeploymentTest.java
  ===================================================================
  RCS file: /home/globdev/CVS/globus-packages/workspace/vm/service/client/java/source/tests/org/globus/workspace/cloud/meta/client/CloudDeploymentTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CloudDeploymentTest.java	26 May 2009 22:55:33 -0000	1.1
  +++ CloudDeploymentTest.java	27 May 2009 14:29:13 -0000	1.2
  @@ -44,17 +44,11 @@
           BrokerContactType broker = new BrokerContactType();
   
           final RunTask[] runTasks = deployment.generateRunTasks(broker,
  -            this.tempDir.getAbsolutePath(),
  +            this.getTempDir().getAbsolutePath(),
               60, new Print());
   
           assertEquals(deployment.getMembers().size(),  runTasks.length);
   
  -        //TODO this is littering the tmp directory right now
  -        // because it doesn't track the files created in the
  -        // generateRunTasks() routine and FileCleanupTestFixture
  -        // won't remove a dir with files
  -
  -
       }
       
       private MemberDeployment[] getMemberDeployments() throws Exception {
  
  
  



More information about the workspace-commit mailing list