KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > parsing > CachingFolderArchiveTest


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java.source.parsing;
21
22 import java.util.TreeSet JavaDoc;
23 import java.util.jar.JarFile JavaDoc;
24 import javax.tools.JavaFileObject;
25 import junit.extensions.TestSetup;
26 import junit.framework.*;
27 import java.io.File JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Collection JavaDoc;
31 import java.util.Collections JavaDoc;
32 import java.util.Enumeration JavaDoc;
33 import java.util.HashMap JavaDoc;
34 import java.util.Iterator JavaDoc;
35 import java.util.LinkedList JavaDoc;
36 import java.util.List JavaDoc;
37 import java.util.Map JavaDoc;
38 import java.util.Set JavaDoc;
39 import java.util.zip.ZipEntry JavaDoc;
40 import java.util.zip.ZipFile JavaDoc;
41 import org.netbeans.modules.java.source.TestUtil;
42
43 /**
44  *
45  * @author Petr Hrebejk
46  */

47 public class CachingFolderArchiveTest extends TestCase {
48     
49     protected static Setup setup;
50     private CachingArchiveProvider archiveProvider;
51         
52     public CachingFolderArchiveTest(String JavaDoc testName) {
53         super(testName);
54     }
55
56     protected void setUp() throws Exception JavaDoc {
57         archiveProvider = new CachingArchiveProvider();
58     }
59
60     protected void tearDown() throws Exception JavaDoc {
61     }
62
63     public static Test suite() {
64         setup = new Setup( new TestSuite( CachingFolderArchiveTest.class ) );
65         return setup;
66     }
67      
68     protected Archive createArchive() {
69         return new FolderArchive( setup.rtFolder );
70     }
71     
72     // Test methods ------------------------------------------------------------
73

74 // public void testGetFiles() {
75
// GoldenArchive ga = new GoldenArchive( setup.rtFolder );
76
// Archive a = createArchive();
77
// assertEquals( "Collections should be equal.", "", ga.getFilesDiff( a ) );
78
// }
79

80 // public void testGetFilesInFolder() {
81
// GoldenArchive ga = new GoldenArchive( setup.rtFolder );
82
// Archive a = createArchive();
83
//
84
// Iterator<String> folders = ga.getFolders();
85
// while( folders.hasNext() ) {
86
// String folderName = folders.next();
87
// assertEquals( "Collections from folder: "+ folderName + " should be equal.", "", ga.getFilesDiff( folderName, a ) );
88
// }
89
// }
90

91 // public void testGetFolders() {
92
// GoldenArchive ga = new GoldenArchive( setup.rtFolder );
93
// Archive a = createArchive();
94
// assertEquals( "Collections should be equal.", "", ga.getFoldersDiff( a ) );
95
// }
96

97 // public void testGetFoldresInFolder() {
98
// GoldenArchive ga = new GoldenArchive( setup.rtFolder );
99
// Archive a = createArchive();
100
//
101
// Iterator<String> folders = ga.getFolders();
102
// while( folders.hasNext() ) {
103
// String folderName = folders.next();
104
// assertEquals( "Collections from folder: "+ folderName +" should be equal.", "", ga.getFoldersDiff( folderName, a ) );
105
// }
106
//
107
// }
108

109     // Innerclasses ------------------------------------------------------------
110

111     static class Setup extends TestSetup {
112         
113         public File JavaDoc workDir;
114         public File JavaDoc rtFile;
115         public File JavaDoc rtFolder;
116         public CachingArchiveProvider archiveProvider;
117         
118         public Setup( Test test ) {
119             super( test );
120         }
121         
122         protected void tearDown() throws Exception JavaDoc {
123             TestUtil.removeWorkFolder( workDir );
124             super.tearDown();
125         }
126
127         protected void setUp() throws Exception JavaDoc {
128             super.setUp();
129             workDir = TestUtil.createWorkFolder();
130             TestUtil.copyFiles( TestUtil.getJdkDir(), workDir, TestUtil.RT_JAR );
131             rtFile = new File JavaDoc( workDir, TestUtil.RT_JAR );
132             JarFile JavaDoc rtJar = new JarFile JavaDoc( rtFile );
133
134             rtFolder = new File JavaDoc( workDir, "rtFolder" );
135             TestUtil.unzip( rtJar, rtFolder );
136             
137             archiveProvider = new CachingArchiveProvider();
138         }
139         
140     }
141            
142 }
143
Popular Tags