Source Code Cross Referenced for INavigatorContentServiceTests.java in  » IDE-Eclipse » ui » org » eclipse » ui » tests » navigator » 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.navigator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 2007 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.navigator;
011:
012:        import java.util.HashMap;
013:        import java.util.Iterator;
014:        import java.util.Map;
015:        import java.util.Set;
016:
017:        import junit.framework.TestCase;
018:
019:        import org.eclipse.core.resources.IProject;
020:        import org.eclipse.core.resources.IWorkspaceRoot;
021:        import org.eclipse.core.resources.ResourcesPlugin;
022:        import org.eclipse.jface.viewers.ILabelProvider;
023:        import org.eclipse.jface.viewers.ITreeContentProvider;
024:        import org.eclipse.ui.IViewPart;
025:        import org.eclipse.ui.IWorkbenchPage;
026:        import org.eclipse.ui.IWorkbenchWindow;
027:        import org.eclipse.ui.PlatformUI;
028:        import org.eclipse.ui.internal.navigator.NavigatorContentService;
029:        import org.eclipse.ui.navigator.CommonViewer;
030:        import org.eclipse.ui.navigator.INavigatorContentDescriptor;
031:        import org.eclipse.ui.navigator.INavigatorContentExtension;
032:        import org.eclipse.ui.navigator.INavigatorContentService;
033:        import org.eclipse.ui.navigator.NavigatorContentServiceFactory;
034:        import org.eclipse.ui.tests.navigator.extension.TestContentProvider;
035:        import org.eclipse.ui.tests.navigator.util.TestWorkspace;
036:
037:        public class INavigatorContentServiceTests extends TestCase {
038:
039:            public static final String COMMON_NAVIGATOR_INSTANCE_ID = "org.eclipse.ui.tests.navigator.TestView";
040:
041:            public static final String TEST_EXTENSION_ID = "org.eclipse.ui.tests.navigator.testContent";
042:
043:            public static final String ENFORCE_HASCHILDREN_EXTENSION_ID = "org.eclipse.ui.tests.navigator.testHasChildren";
044:
045:            public static final String TEST_EXTENSION_2_ID = "org.eclipse.ui.tests.navigator.testContent2";
046:
047:            public static final String RESOURCE_EXTENSION_ID = "org.eclipse.ui.navigator.resourceContent";
048:
049:            private final Map expectedChildren = new HashMap();
050:
051:            private IProject project;
052:
053:            private INavigatorContentService contentService;
054:
055:            private CommonViewer viewer;
056:
057:            protected void setUp() throws Exception {
058:
059:                TestWorkspace.init();
060:
061:                IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
062:                project = root.getProject("Test");
063:                Map projectMap = new HashMap();
064:
065:                expectedChildren.put(project, (projectMap = new HashMap()));
066:
067:                projectMap.put(project.getFolder("src"), new HashMap());
068:                projectMap.put(project.getFolder("bin"), new HashMap());
069:                projectMap.put(project.getFile(".project"), null);
070:                projectMap.put(project.getFile(".classpath"), null);
071:                projectMap.put(project.getFile("model.properties"), null);
072:
073:                EditorTestHelper.showView(COMMON_NAVIGATOR_INSTANCE_ID, true);
074:
075:                IWorkbenchWindow activeWindow = PlatformUI.getWorkbench()
076:                        .getActiveWorkbenchWindow();
077:                IWorkbenchPage activePage = activeWindow.getActivePage();
078:
079:                IViewPart commonNavigator = activePage
080:                        .findView(COMMON_NAVIGATOR_INSTANCE_ID);
081:
082:                viewer = (CommonViewer) commonNavigator
083:                        .getAdapter(CommonViewer.class);
084:                viewer.expandAll();
085:
086:                contentService = viewer.getNavigatorContentService();
087:            }
088:
089:            protected void tearDown() throws Exception {
090:                super .tearDown();
091:            }
092:
093:            public void testFindValidExtensions() {
094:
095:                contentService.getActivationService()
096:                        .activateExtensions(
097:                                new String[] { TEST_EXTENSION_ID,
098:                                        RESOURCE_EXTENSION_ID }, true);
099:
100:                ITreeContentProvider contentServiceContentProvider = contentService
101:                        .createCommonContentProvider();
102:
103:                ILabelProvider contentServiceLabelProvider = contentService
104:                        .createCommonLabelProvider();
105:
106:                ITreeContentProvider[] rootContentProviders = ((NavigatorContentService) contentService)
107:                        .findRootContentProviders(ResourcesPlugin
108:                                .getWorkspace().getRoot());
109:
110:                assertEquals("Ensure there is only one root content provider.",
111:                        1, rootContentProviders.length);
112:
113:                Set projectContentExtensions = contentService
114:                        .findContentExtensionsByTriggerPoint(project);
115:
116:                assertEquals(
117:                        "Ensure there are two content providers for an IProject.",
118:                        2, projectContentExtensions.size());
119:
120:                boolean found = false;
121:                INavigatorContentExtension ext;
122:                for (Iterator i = projectContentExtensions.iterator(); i
123:                        .hasNext();) {
124:                    ext = (INavigatorContentExtension) i.next();
125:                    if (ext.getContentProvider() instanceof  TestContentProvider) {
126:
127:                        TestContentProvider testContentProvider = (TestContentProvider) ext
128:                                .getContentProvider();
129:                        Object[] projectChildren = testContentProvider
130:                                .getChildren(project);
131:                        assertEquals(
132:                                "There should be one test-type child of the project.",
133:                                1, projectChildren.length);
134:                        assertEquals("Parent", contentServiceLabelProvider
135:                                .getText(projectChildren[0]));
136:                        Object[] testRootChildren = contentServiceContentProvider
137:                                .getChildren(projectChildren[0]);
138:                        assertEquals(
139:                                "There should be one test-type child of the root test-type item.",
140:                                3, testRootChildren.length);
141:                        found = true;
142:                    }
143:                }
144:
145:                assertTrue("The test content provider was not found.", found);
146:
147:            }
148:
149:            public void testDeactivateTestExtension() {
150:
151:                contentService.getActivationService().activateExtensions(
152:                        new String[] { RESOURCE_EXTENSION_ID }, true);
153:
154:                contentService.createCommonContentProvider();
155:
156:                contentService.createCommonLabelProvider();
157:
158:                Set rootContentProviders = contentService
159:                        .findRootContentExtensions(ResourcesPlugin
160:                                .getWorkspace().getRoot());
161:
162:                assertEquals("Ensure there is only one root content provider.",
163:                        1, rootContentProviders.size());
164:
165:                Set projectContentExtensions = contentService
166:                        .findContentExtensionsByTriggerPoint(project);
167:
168:                assertEquals(
169:                        "Ensure there is one content provider for an IProject.",
170:                        1, projectContentExtensions.size());
171:
172:            }
173:
174:            public void testBindTestExtension() {
175:
176:                INavigatorContentService contentServiceWithProgrammaticBindings = NavigatorContentServiceFactory.INSTANCE
177:                        .createContentService(COMMON_NAVIGATOR_INSTANCE_ID);
178:                INavigatorContentDescriptor[] boundDescriptors = contentServiceWithProgrammaticBindings
179:                        .bindExtensions(new String[] { TEST_EXTENSION_2_ID },
180:                                false);
181:                contentServiceWithProgrammaticBindings
182:                        .getActivationService()
183:                        .activateExtensions(
184:                                new String[] { RESOURCE_EXTENSION_ID,
185:                                        TEST_EXTENSION_ID, TEST_EXTENSION_2_ID },
186:                                false);
187:
188:                assertEquals("One descriptor should have been returned.", 1,
189:                        boundDescriptors.length);
190:
191:                assertEquals(
192:                        "The declarative content service should have one fewer visible extension ids than the one created programmatically.",
193:                        contentService.getVisibleExtensionIds().length + 1,
194:                        contentServiceWithProgrammaticBindings
195:                                .getVisibleExtensionIds().length);
196:
197:                INavigatorContentDescriptor[] visibleDescriptors = contentServiceWithProgrammaticBindings
198:                        .getVisibleExtensions();
199:                boolean found = false;
200:                for (int i = 0; i < visibleDescriptors.length; i++)
201:                    if (TEST_EXTENSION_2_ID.equals(visibleDescriptors[i]
202:                            .getId()))
203:                        found = true;
204:                assertTrue(
205:                        "The programmatically bound extension should be bound.",
206:                        found);
207:
208:                Set enabledDescriptors = contentServiceWithProgrammaticBindings
209:                        .findContentExtensionsByTriggerPoint(project);
210:
211:                assertEquals("There should be a three extensions.", 3,
212:                        enabledDescriptors.size());
213:
214:            }
215:
216:            public void testTestExtensionVisibility() {
217:                assertTrue("The test extension should be visible.",
218:                        contentService.getViewerDescriptor()
219:                                .isVisibleContentExtension(TEST_EXTENSION_ID));
220:            }
221:
222:            public void testResourceExtensionVisibility() {
223:                assertTrue("The test extension should be visible.",
224:                        contentService.getViewerDescriptor()
225:                                .isVisibleContentExtension(
226:                                        RESOURCE_EXTENSION_ID));
227:            }
228:
229:            public void testVisibleExtensionIds() {
230:                String[] visibleIds = contentService.getVisibleExtensionIds();
231:
232:                assertEquals("There should be three visible extensions.", 3,
233:                        visibleIds.length);
234:
235:                for (int i = 0; i < visibleIds.length; i++) {
236:                    if (!TEST_EXTENSION_ID.equals(visibleIds[i])
237:                            && !RESOURCE_EXTENSION_ID.equals(visibleIds[i])
238:                            && !ENFORCE_HASCHILDREN_EXTENSION_ID
239:                                    .equals(visibleIds[i])) {
240:                        assertTrue("The extension id is invalid:"
241:                                + visibleIds[i], false);
242:                    }
243:                }
244:
245:                INavigatorContentDescriptor[] visibleDescriptors = contentService
246:                        .getVisibleExtensions();
247:
248:                for (int i = 0; i < visibleIds.length; i++) {
249:                    if (!TEST_EXTENSION_ID
250:                            .equals(visibleDescriptors[i].getId())
251:                            && !RESOURCE_EXTENSION_ID
252:                                    .equals(visibleDescriptors[i].getId())
253:                            && !ENFORCE_HASCHILDREN_EXTENSION_ID
254:                                    .equals(visibleDescriptors[i].getId())) {
255:                        assertTrue("The extension id is invalid:"
256:                                + visibleDescriptors[i].getId(), false);
257:                    }
258:                }
259:
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.