1 19 20 21 package org.netbeans.core.lookup; 22 23 24 import java.io.Serializable ; 25 import java.net.URL ; 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 import java.util.List ; 29 30 import org.openide.execution.Executor; 32 import org.openide.filesystems.FileObject; 33 import org.openide.filesystems.FileSystem; 34 import org.openide.filesystems.MultiFileSystem; 35 import org.openide.filesystems.XMLFileSystem; 36 import org.openide.loaders.DataFolder; 37 import org.openide.loaders.DataObject; 38 import org.openide.loaders.DataObjectNotFoundException; 39 import org.openide.loaders.FolderLookup; 40 import org.openide.ServiceType; 41 import org.openide.util.Lookup; 42 import org.openide.util.lookup.AbstractLookup; 43 44 import org.netbeans.core.NbTopManager; 45 import org.netbeans.core.xml.FileEntityResolver; 46 import org.netbeans.performance.Benchmark; 47 48 import org.xml.sax.SAXException ; 49 50 import junit.framework.TestSuite; 51 import junit.textui.TestRunner; 52 53 54 public class FolderLookupBenchmark extends Benchmark { 55 56 private static final String [] layerResources = new String [] { 57 "/org/netbeans/core/resources/ant.xml", "/org/netbeans/core/resources/applet.xml", "/org/netbeans/core/resources/autoupdate.xml", "/org/netbeans/core/resources/beans.xml", "/org/netbeans/core/resources/core.xml", "/org/netbeans/core/resources/debuggercore.xml", "/org/netbeans/core/resources/debuggerjpda.xml", "/org/netbeans/core/resources/debuggertools.xml", "/org/netbeans/core/resources/editor.xml", "/org/netbeans/core/resources/extbrowser.xml", "/org/netbeans/core/resources/form.xml", "/org/netbeans/core/resources/html.xml", "/org/netbeans/core/resources/httpserver.xml", "/org/netbeans/core/resources/i18n.xml", "/org/netbeans/core/resources/icebrowser.xml", "/org/netbeans/core/resources/image.xml", "/org/netbeans/core/resources/j2ee.xml", "/org/netbeans/core/resources/jarpackager.xml", "/org/netbeans/core/resources/javacvs.xml", "/org/netbeans/core/resources/javadoc.xml", "/org/netbeans/core/resources/java.xml", "/org/netbeans/core/resources/jndi.xml", "/org/netbeans/core/resources/objectbrowser.xml", "/org/netbeans/core/resources/projects.xml", "/org/netbeans/core/resources/properties.xml", "/org/netbeans/core/resources/rmi.xml", "/org/netbeans/core/resources/scripting.xml", "/org/netbeans/core/resources/text.xml", "/org/netbeans/core/resources/usersguide.xml", "/org/netbeans/core/resources/utilities.xml", "/org/netbeans/core/resources/vcscore.xml", "/org/netbeans/core/resources/vcsgeneric.xml", "/org/netbeans/core/resources/web-core.xml", "/org/netbeans/core/resources/web-templates.xml", "/org/netbeans/core/resources/web-tomcat.xml" }; 93 94 95 private FolderLookup fl; 96 97 98 private DataFolder df; 99 100 101 103 104 public FolderLookupBenchmark(java.lang.String testName) { 105 super(testName); 106 107 System.err.println("TopManager="+NbTopManager.get()); System.err.println("Lookup="+Lookup.getDefault()); } 110 111 112 113 public static void main(String [] args) { 114 TestRunner.run(new TestSuite(FolderLookupBenchmark.class)); 115 } 116 117 118 119 protected void setUp () 120 throws java.net.MalformedURLException , 121 SAXException , 122 DataObjectNotFoundException { 123 124 List systems = new ArrayList (layerResources.length); 125 126 for(int i = 0; i < layerResources.length; i++) { 127 ClassLoader cl = (ClassLoader )Lookup.getDefault().lookup(ClassLoader .class); 130 URL url = cl.getResource(layerResources[i]); 131 132 systems.add(new XMLFileSystem(url)); 133 } 134 135 FileObject services = new MultiFileSystem((FileSystem[])systems.toArray(new FileSystem[0])).getRoot().getFileObject("Services"); 136 137 df = (DataFolder)DataObject.find(services); 138 } 139 140 141 protected void tearDown () { 142 fl = null; 143 df = null; 144 } 146 147 153 154 155 public void testCreateFolderLookup() { 156 fl = new FolderLookup(df); 157 158 fl.getLookup(); 159 fl.instanceFinished(); 160 } 161 162 182 183 } 184 | Popular Tags |