Source Code Cross Referenced for OpenNavigatorFolderTest.java in  » IDE-Eclipse » ui » org » eclipse » ui » tests » performance » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui » org.eclipse.ui.tests.performance 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.tests.performance;
011:
012:        import java.io.ByteArrayInputStream;
013:        import java.io.ByteArrayOutputStream;
014:        import java.io.IOException;
015:        import java.net.URL;
016:        import java.util.zip.ZipEntry;
017:        import java.util.zip.ZipInputStream;
018:        import junit.framework.Assert;
019:        import org.eclipse.core.resources.IFile;
020:        import org.eclipse.core.resources.IProject;
021:        import org.eclipse.core.resources.ResourcesPlugin;
022:        import org.eclipse.core.runtime.CoreException;
023:        import org.eclipse.core.runtime.NullProgressMonitor;
024:        import org.eclipse.core.runtime.Platform;
025:        import org.eclipse.test.performance.PerformanceTestCase;
026:        import org.eclipse.ui.IViewPart;
027:        import org.eclipse.ui.IWorkbenchPage;
028:        import org.eclipse.ui.PartInitException;
029:        import org.eclipse.ui.PlatformUI;
030:        import org.eclipse.ui.views.navigator.ResourceNavigator;
031:        import org.osgi.framework.Bundle;
032:
033:        /**
034:         * This class/test was originally written for WTP bug 106158, and adapted to a
035:         * generic "platform" test case, since some of the problem was due to bug
036:         * 107121
037:         * 
038:         * Thanks for Jeffrey Liu (jeffliu@ca.ibm.com) who wrote the test for WTP.
039:         * 
040:         * And, thanks to Eric Glass <ericglass@maximus.com> for opening bug 106158
041:         * (100% CPU for over 3 minutes opening a directory in the Navigator view with
042:         * over 2000 HTML files) https://bugs.eclipse.org/bugs/show_bug.cgi?id=106158
043:         * and for providing 2500 "generic" HTML files for the original test case in
044:         * WTP.
045:         * 
046:         * modified by David Williams for platform level test that does not depend on
047:         * WTP or, for that matter, any meaningful content type. The content type
048:         * assumed there is designed simply to "take a while" to complete, if asked
049:         * for its properties.
050:         * 
051:         * Note, since this test companion "ContentDescriberForTestsOnly", simply uses
052:         * "sleep" to simulate computations, it only effects Elapsed Time (not CPU
053:         * Time).
054:         * 
055:         */
056:        public class OpenNavigatorFolderTest extends PerformanceTestCase {
057:            /*
058:             * performance testcase for bug 106158
059:             * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106158
060:             */
061:            public void testOpenNavigatorFolder() {
062:                IProject project = createProject("testViewAndContentTypeProject");
063:                Bundle bundle = Platform.getBundle("org.eclipse.ui.tests");
064:                URL url = bundle.getEntry("data/testContentType.zip");
065:                ZipInputStream zis = null;
066:                try {
067:                    zis = new ZipInputStream(url.openStream());
068:                    ZipEntry entry = zis.getNextEntry();
069:                    while (entry != null) {
070:                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
071:                        try {
072:                            byte[] b = new byte[2048];
073:                            int read = zis.read(b);
074:                            while (read != -1) {
075:                                baos.write(b, 0, read);
076:                                read = zis.read(b);
077:                            }
078:                        } catch (IOException e) {
079:                            Assert.fail(e.getMessage());
080:                        } finally {
081:                            try {
082:                                baos.close();
083:                            } catch (IOException e) {
084:                                Assert.fail(e.getMessage());
085:                            }
086:                        }
087:                        IFile file = project.getFile(entry.getName());
088:                        ByteArrayInputStream bais = new ByteArrayInputStream(
089:                                baos.toByteArray());
090:                        try {
091:                            if (!file.exists())
092:                                file.create(bais, true,
093:                                        new NullProgressMonitor());
094:                            else
095:                                file.setContents(bais, true, false,
096:                                        new NullProgressMonitor());
097:                        } catch (CoreException e) {
098:                            Assert.fail(e.getMessage());
099:                        } finally {
100:                            try {
101:                                bais.close();
102:                            } catch (IOException e) {
103:                                Assert.fail(e.getMessage());
104:                            }
105:                        }
106:                        entry = zis.getNextEntry();
107:                    }
108:                } catch (IOException e) {
109:                    Assert.fail(e.getMessage());
110:                } finally {
111:                    try {
112:                        if (zis != null) {
113:                            zis.close();
114:                        }
115:                    } catch (IOException e) {
116:                        Assert.fail(e.getMessage());
117:                    }
118:                }
119:                startMeasuring();
120:                IWorkbenchPage activePage = PlatformUI.getWorkbench()
121:                        .getActiveWorkbenchWindow().getActivePage();
122:                IViewPart view = null;
123:                try {
124:                    view = activePage
125:                            .showView("org.eclipse.ui.views.ResourceNavigator");
126:                } catch (PartInitException e) {
127:                    Assert.fail(e.getMessage());
128:                }
129:                ResourceNavigator navigatorView = null;
130:                try {
131:                    navigatorView = (ResourceNavigator) view;
132:                } catch (ClassCastException e) {
133:                    Assert.fail(e.getMessage());
134:                }
135:                navigatorView.getTreeViewer().expandAll();
136:                stopMeasuring();
137:                commitMeasurements();
138:                assertPerformance();
139:            }
140:
141:            private IProject createProject(String name) {
142:                IProject project = ResourcesPlugin.getWorkspace().getRoot()
143:                        .getProject(name);
144:                if (!project.exists()) {
145:                    try {
146:                        project.create(new NullProgressMonitor());
147:                        project.open(new NullProgressMonitor());
148:                    } catch (CoreException e) {
149:                        Assert.fail(e.getMessage());
150:                    }
151:                }
152:                return project;
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.