KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > loaders > DataFolderSlowDeletionTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.loaders;
21
22 import org.openide.filesystems.*;
23 import java.beans.*;
24 import org.netbeans.junit.*;
25
26 /** Test the complexity of deleting N files in a folder without recognized
27  * DataOjects (which may as well be tested on deleting secondary files
28  * of a recognized DataObject).
29  *
30  * The test may need slight tweaking of the timing constants for reliability.
31  *
32  * @author Petr Nejedly
33  */

34 public class DataFolderSlowDeletionTest extends LoggingTestCaseHid {
35     private FileObject folder;
36     // just holders
37
private FileObject[] children;
38     private DataFolder df;
39     private DataObject do0;
40     
41
42     /** Creates new DataFolderSlowDeletionTest */
43     public DataFolderSlowDeletionTest (String JavaDoc name) {
44         super (name);
45     }
46     
47     /**
48      * @return a speedSuite configured as to allow 2x linear slowdown between
49      * 10-fold increase of the paratemer
50      */

51     public static NbTestSuite suite () {
52         return NbTestSuite.linearSpeedSuite(DataFolderSlowDeletionTest.class, 2, 3);
53     }
54     
55     /**
56      * Prepares a filesystem with a prepopulated folder of N files, where N
57      * is extracted from the test name.
58      * @throws java.lang.Exception
59      */

60     protected void setUp() throws Exception JavaDoc {
61         clearWorkDir();
62         TestUtilHid.destroyLocalFileSystem(getName());
63         
64         int count = getTestNumber ();
65         String JavaDoc[] resources = new String JavaDoc[count];
66         for (int i=0; i<resources.length; i++) resources[i] = "folder/file" + i + ".txt";
67         FileSystem fs = TestUtilHid.createLocalFileSystem(getWorkDir(), resources);
68         folder = fs.findResource("folder");
69         
70         // convert to masterfs
71
folder = FileUtil.toFileObject(FileUtil.toFile(folder));
72         
73         
74         children = folder.getChildren();
75         df = DataFolder.findFolder (folder);
76         do0 = DataObject.find(children[0]);
77     }
78     
79     
80     
81     /**
82      *
83      * @throws java.lang.Exception
84      */

85     private void performSlowDeletionTest () throws Exception JavaDoc {
86         folder.delete();
87     }
88     
89     /**
90      * Preheat the infrastructure so the lower end is measured already JITed
91      * @throws java.lang.Exception
92      */

93     public void testSlowDeletionPrime1000() throws Exception JavaDoc {
94         performSlowDeletionTest();
95     }
96
97     /**
98      *
99      * @throws java.lang.Exception
100      */

101     public void testSlowDeletion1000() throws Exception JavaDoc {
102         performSlowDeletionTest();
103     }
104
105     public void testSlowDeletion3000() throws Exception JavaDoc {
106         performSlowDeletionTest();
107     }
108     
109 }
110
Popular Tags