Source Code Cross Referenced for SourceTests.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » build » internal » tests » 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 » Eclipse plug in development » org.eclipse.pde.build.internal.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2007 IBM Corporation and others. All rights reserved. This
003:         * program and the accompanying materials are made available under the terms of
004:         * the Eclipse Public License v1.0 which accompanies this distribution, and is
005:         * available at http://www.eclipse.org/legal/epl-v10.html
006:         * 
007:         * Contributors: IBM Corporation - initial API and implementation
008:         ******************************************************************************/package org.eclipse.pde.build.internal.tests;
009:
010:        import java.io.*;
011:        import java.util.*;
012:        import java.util.jar.Manifest;
013:
014:        import junit.framework.Test;
015:        import junit.framework.TestSuite;
016:
017:        import org.eclipse.core.resources.IFile;
018:        import org.eclipse.core.resources.IFolder;
019:        import org.eclipse.core.runtime.Platform;
020:        import org.eclipse.pde.build.tests.BuildConfiguration;
021:        import org.eclipse.pde.build.tests.PDETestCase;
022:        import org.eclipse.update.core.model.FeatureModelFactory;
023:        import org.osgi.framework.FrameworkUtil;
024:
025:        public class SourceTests extends PDETestCase {
026:
027:            public static Test suite() {
028:                return new TestSuite(SourceTests.class);
029:            }
030:
031:            public void testBug114150() throws Exception {
032:                IFolder buildFolder = newTest("114150");
033:
034:                Properties buildProperties = BuildConfiguration
035:                        .getBuilderProperties(buildFolder);
036:                Utils.storeBuildProperties(buildFolder, buildProperties);
037:
038:                runBuild(buildFolder);
039:
040:                Set entries = new HashSet();
041:                entries.add("eclipse/features/a.feature.sdk_1.0.0/feature.xml");
042:                entries
043:                        .add("eclipse/features/a.feature.source_1.0.0/feature.xml");
044:                entries
045:                        .add("eclipse/plugins/a.feature.source_1.0.0/src/a.plugin_1.0.0/src.zip");
046:                assertZipContents(buildFolder, "I.TestBuild/a.feature.sdk.zip",
047:                        entries);
048:
049:                entries.add("eclipse/features/a.feature_1.0.0/feature.xml");
050:                entries.add("eclipse/plugins/a.plugin_1.0.0.jar");
051:                assertZipContents(buildFolder, "I.TestBuild/a.feature.zip",
052:                        entries);
053:            }
054:
055:            // test that generated source fragments have a proper platform filter
056:            public void testBug184517() throws Exception {
057:                IFolder buildFolder = newTest("184517");
058:                IFolder features = Utils.createFolder(buildFolder, "features");
059:
060:                //generate an SDK feature
061:                Utils.generateFeature(buildFolder, "sdk", new String[] {
062:                        "org.eclipse.rcp", "org.eclipse.rcp.source" }, null);
063:                Properties properties = new Properties();
064:                properties.put("generate.feature@org.eclipse.rcp.source",
065:                        "org.eclipse.rcp");
066:                IFolder sdk = features.getFolder("sdk");
067:                Utils.storeBuildProperties(sdk, properties);
068:
069:                String os = Platform.getOS();
070:                String ws = Platform.getWS();
071:                String arch = Platform.getOSArch();
072:
073:                //getScriptGenerationProperties sets buildDirectory to buildFolder by default
074:                properties = BuildConfiguration.getScriptGenerationProperties(
075:                        buildFolder, "feature", "sdk");
076:                properties.put("configs", os + "," + ws + "," + arch);
077:                generateScripts(buildFolder, properties);
078:
079:                String fragmentName = "org.eclipse.rcp.source." + os + "." + ws
080:                        + "." + arch;
081:                IFolder fragment = buildFolder.getFolder("plugins/"
082:                        + fragmentName);
083:
084:                // check the manifest for a correct platform filter
085:                assertResourceFile(fragment, "META-INF/MANIFEST.MF");
086:                InputStream stream = new BufferedInputStream(fragment.getFile(
087:                        "META-INF/MANIFEST.MF").getLocationURI().toURL()
088:                        .openStream());
089:                Manifest manifest = new Manifest(stream);
090:                stream.close();
091:
092:                String filter = manifest.getMainAttributes().getValue(
093:                        "Eclipse-PlatformFilter");
094:                assertTrue(filter.length() > 0);
095:                properties = new Properties();
096:                properties.put("osgi.os", os);
097:                properties.put("osgi.ws", ws);
098:                properties.put("osgi.arch", arch);
099:                assertTrue(FrameworkUtil.createFilter(filter).match(properties));
100:            }
101:
102:            // test that '<' and '>' are properly escaped in generated source feature
103:            // Also tests bug 191756: features with empty <license> entries
104:            public void testbug184920() throws Exception {
105:                //the provided resource features/a.feature/feature.xml contains &lt;foo!&gt; 
106:                //which must be handled properly
107:                IFolder buildFolder = newTest("184920");
108:
109:                Properties properties = BuildConfiguration
110:                        .getScriptGenerationProperties(buildFolder, "feature",
111:                                "a.feature.sdk");
112:                //191756: This will NPE if empty license entry is a problem 
113:                generateScripts(buildFolder, properties);
114:
115:                assertResourceFile(buildFolder,
116:                        "features/a.feature.source/feature.xml");
117:                IFile feature = buildFolder
118:                        .getFile("features/a.feature.source/feature.xml");
119:
120:                FeatureModelFactory factory = new FeatureModelFactory();
121:                InputStream stream = new BufferedInputStream(feature
122:                        .getLocationURI().toURL().openStream());
123:                try {
124:                    //this will throw an exception if feature.xml is not valid
125:                    factory.parseFeature(stream);
126:                } finally {
127:                    stream.close();
128:                }
129:            }
130:
131:            // test that source can come before the feature it is based on
132:            public void testBug179616A() throws Exception {
133:                IFolder buildFolder = newTest("179616A");
134:                IFolder bundleFolder = Utils.createFolder(buildFolder,
135:                        "plugins/a.bundle");
136:                IFolder sdkFolder = Utils.createFolder(buildFolder,
137:                        "features/sdk");
138:
139:                Utils.generateBundle(bundleFolder, "a.bundle");
140:                //add some source to a.bundle
141:                File src = new File(bundleFolder.getLocation().toFile(),
142:                        "src/a.java");
143:                src.getParentFile().mkdir();
144:                FileOutputStream stream = new FileOutputStream(src);
145:                stream.write("//L33T CODEZ\n".getBytes());
146:                stream.close();
147:
148:                Utils.generateFeature(buildFolder, "rcp", null,
149:                        new String[] { "a.bundle" });
150:
151:                Utils.generateFeature(buildFolder, "sdk", new String[] {
152:                        "rcp.source", "rcp" }, null);
153:                Properties properties = new Properties();
154:                properties.put("generate.feature@rcp.source", "rcp");
155:                Utils.storeBuildProperties(sdkFolder, properties);
156:
157:                Utils.generateAllElements(buildFolder, "sdk");
158:                Utils.storeBuildProperties(buildFolder, BuildConfiguration
159:                        .getBuilderProperties(buildFolder));
160:                runBuild(buildFolder);
161:
162:                Set entries = new HashSet();
163:                entries
164:                        .add("eclipse/plugins/rcp.source_1.0.0/src/a.bundle_1.0.0/src.zip");
165:                assertZipContents(buildFolder, "I.TestBuild/eclipse.zip",
166:                        entries);
167:            }
168:
169:            public void testBug179616B() throws Exception {
170:                IFolder buildFolder = newTest("179616B");
171:                IFolder bundleFolder = Utils.createFolder(buildFolder,
172:                        "plugins/a.bundle");
173:                IFolder singleFolder = Utils.createFolder(buildFolder,
174:                        "features/single");
175:
176:                Utils.generateBundle(bundleFolder, "a.bundle");
177:                File src = new File(bundleFolder.getLocation().toFile(),
178:                        "src/a.java");
179:                src.getParentFile().mkdir();
180:                FileOutputStream stream = new FileOutputStream(src);
181:                stream.write("//L33T CODEZ\n".getBytes());
182:                stream.close();
183:
184:                Utils.generateFeature(buildFolder, "single", null,
185:                        new String[] { "single.source", "a.bundle" });
186:                Properties properties = new Properties();
187:                properties.put("generate.plugin@single.source", "single");
188:                Utils.storeBuildProperties(singleFolder, properties);
189:
190:                Utils.generateAllElements(buildFolder, "single");
191:                Utils.storeBuildProperties(buildFolder, BuildConfiguration
192:                        .getBuilderProperties(buildFolder));
193:                runBuild(buildFolder);
194:
195:                Set entries = new HashSet();
196:                entries
197:                        .add("eclipse/plugins/single.source_1.0.0/src/a.bundle_1.0.0/src.zip");
198:                assertZipContents(buildFolder, "I.TestBuild/eclipse.zip",
199:                        entries);
200:            }
201:
202:            // Test the use of plugin@foo;unpack="false" in the generate.feature property 
203:            public void testBug107372() throws Exception {
204:                IFolder buildFolder = newTest("107372");
205:                IFolder bundleA = Utils.createFolder(buildFolder,
206:                        "plugins/bundleA");
207:                IFolder bundleDoc = Utils.createFolder(buildFolder,
208:                        "plugins/bundleDoc");
209:                IFolder sdk = Utils.createFolder(buildFolder, "features/sdk");
210:
211:                Utils.generateBundle(bundleA, "bundleA");
212:                File src = new File(bundleA.getLocation().toFile(),
213:                        "src/a.java");
214:                src.getParentFile().mkdir();
215:                FileOutputStream outputStream = new FileOutputStream(src);
216:                outputStream.write("//L33T CODEZ\n".getBytes());
217:                outputStream.close();
218:
219:                Utils.generateBundle(bundleDoc, "bundleDoc");
220:                src = new File(bundleDoc.getLocation().toFile(), "src/a.java");
221:                src.getParentFile().mkdir();
222:                outputStream = new FileOutputStream(src);
223:                outputStream.write("//L33T CODEZ\n".getBytes());
224:                outputStream.close();
225:
226:                //generate an SDK feature
227:                Utils.generateFeature(buildFolder, "sdk", new String[] { "rcp",
228:                        "rcp.source" }, null);
229:                Properties properties = new Properties();
230:                properties.put("generate.feature@rcp.source",
231:                        "rcp,plugin@bundleDoc;unpack=\"false\"");
232:                Utils.storeBuildProperties(sdk, properties);
233:
234:                //RCP Feature
235:                Utils.generateFeature(buildFolder, "rcp", null,
236:                        new String[] { "bundleA" });
237:
238:                Utils.generateAllElements(buildFolder, "sdk");
239:                Utils.storeBuildProperties(buildFolder, BuildConfiguration
240:                        .getBuilderProperties(buildFolder));
241:                runBuild(buildFolder);
242:
243:                //bundleDoc only gets in the build by being added to the generated source feature,
244:                //check that it is there in the result and is in jar form.
245:                Set entries = new HashSet();
246:                entries.add("eclipse/plugins/bundleDoc_1.0.0.jar");
247:                assertZipContents(buildFolder, "I.TestBuild/eclipse.zip",
248:                        entries);
249:            }
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.