Lines 41-60
Link Here
|
41 |
|
41 |
|
42 |
package org.netbeans.nbbuild; |
42 |
package org.netbeans.nbbuild; |
43 |
|
43 |
|
44 |
import java.io.ByteArrayOutputStream; |
|
|
45 |
import java.io.File; |
46 |
import java.io.FileOutputStream; |
47 |
import java.io.FileReader; |
48 |
import java.io.IOException; |
49 |
import java.io.InputStream; |
50 |
import java.util.Arrays; |
51 |
import java.util.StringTokenizer; |
52 |
import java.util.jar.JarEntry; |
53 |
import java.util.jar.JarOutputStream; |
54 |
import java.util.jar.Manifest; |
55 |
import java.util.zip.ZipEntry; |
56 |
import java.util.zip.ZipOutputStream; |
57 |
import junit.framework.*; |
58 |
|
44 |
|
59 |
import org.netbeans.junit.*; |
45 |
import org.netbeans.junit.*; |
60 |
|
46 |
|
Lines 68-73
Link Here
|
68 |
public FixDependenciesTest (String name) { |
54 |
public FixDependenciesTest (String name) { |
69 |
super (name); |
55 |
super (name); |
70 |
} |
56 |
} |
|
|
57 |
public void testCanFixXmlWsdlModel() throws Exception { |
58 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractResource("FixDependencies-xml.wsdl.model.xml"); |
59 |
|
60 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
61 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
62 |
"<project name=\"Replace Openide\" basedir=\".\" default=\"all\" >" + |
63 |
" <taskdef name=\"fix\" classname=\"org.netbeans.nbbuild.FixDependencies\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
64 |
"<target name=\"all\" >" + |
65 |
"<fix>" + |
66 |
" <replace codenamebase=\"org.openide.util\">" + |
67 |
" <module codenamebase=\"org.openide.util\" spec=\"8.0\" />" + |
68 |
" <module codenamebase=\"org.openide.util.lookup\" spec=\"8.0\" />" + |
69 |
" </replace>" + |
70 |
" <fileset dir=\"" + xml.getParent () + "\">" + |
71 |
" <include name=\"" + xml.getName () + "\" /> " + |
72 |
" </fileset>" + |
73 |
"</fix>" + |
74 |
"</target>" + |
75 |
"</project>" |
76 |
|
77 |
); |
78 |
|
79 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); |
80 |
String result = PublicPackagesInProjectizedXMLTest.readFile (xml); |
81 |
|
82 |
if (result.indexOf ("org.openide.util") == -1) { |
83 |
fail ("org.openide.util should be there: " + result); |
84 |
} |
85 |
if (result.indexOf ("org.openide.util.lookup") == -1) { |
86 |
fail ("org.openide.util.lookup should be there: " + result); |
87 |
} |
88 |
} |
89 |
public void testCanParseCoreKit () throws Exception { |
90 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractResource("FixDependencies-core.kit.xml"); |
91 |
|
92 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
93 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
94 |
"<project name=\"Replace Openide\" basedir=\".\" default=\"all\" >" + |
95 |
" <taskdef name=\"fix\" classname=\"org.netbeans.nbbuild.FixDependencies\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
96 |
"<target name=\"all\" >" + |
97 |
"<fix>" + |
98 |
" <replace codenamebase=\"org.openide.util\">" + |
99 |
" <module codenamebase=\"org.openide.util\" spec=\"8.0\" />" + |
100 |
" <module codenamebase=\"org.openide.util.lookup\" spec=\"8.0\" />" + |
101 |
" </replace>" + |
102 |
" <fileset dir=\"" + xml.getParent () + "\">" + |
103 |
" <include name=\"" + xml.getName () + "\" /> " + |
104 |
" </fileset>" + |
105 |
"</fix>" + |
106 |
"</target>" + |
107 |
"</project>" |
108 |
|
109 |
); |
110 |
|
111 |
String before = PublicPackagesInProjectizedXMLTest.readFile(xml); |
112 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); |
113 |
String after = PublicPackagesInProjectizedXMLTest.readFile(xml); |
114 |
|
115 |
assertEquals("No change", before, after); |
116 |
} |
117 |
public void testCanParseOpenideUtil () throws Exception { |
118 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractResource("FixDependencies-openide.util.xml"); |
119 |
|
120 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
121 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
122 |
"<project name=\"Replace Openide\" basedir=\".\" default=\"all\" >" + |
123 |
" <taskdef name=\"fix\" classname=\"org.netbeans.nbbuild.FixDependencies\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
124 |
"<target name=\"all\" >" + |
125 |
"<fix>" + |
126 |
" <replace codenamebase=\"org.openide.util\">" + |
127 |
" <module codenamebase=\"org.openide.util\" spec=\"8.0\" />" + |
128 |
" <module codenamebase=\"org.openide.util.lookup\" spec=\"8.0\" />" + |
129 |
" </replace>" + |
130 |
" <fileset dir=\"" + xml.getParent () + "\">" + |
131 |
" <include name=\"" + xml.getName () + "\" /> " + |
132 |
" </fileset>" + |
133 |
"</fix>" + |
134 |
"</target>" + |
135 |
"</project>" |
136 |
|
137 |
); |
138 |
|
139 |
String before = PublicPackagesInProjectizedXMLTest.readFile(xml); |
140 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); |
141 |
String after = PublicPackagesInProjectizedXMLTest.readFile(xml); |
142 |
|
143 |
assertEquals("No change", before, after); |
144 |
} |
145 |
public void testNoModuleDependenciesDoesNotCrash() throws Exception { |
146 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString( |
147 |
"<?xml version='1.0' encoding='UTF-8'?>" + |
148 |
"<project xmlns='http://www.netbeans.org/ns/project/1'>" + |
149 |
"<type>org.netbeans.modules.apisupport.project</type>" + |
150 |
"<configuration>" + |
151 |
"<data xmlns='http://www.netbeans.org/ns/nb-module-project/3'>" + |
152 |
"<code-name-base>org.netbeans.api.annotations.common</code-name-base>" + |
153 |
"<module-dependencies/>" + |
154 |
"<public-packages/>" + |
155 |
"</data>" + |
156 |
"</configuration>" + |
157 |
"</project>" |
158 |
); |
159 |
|
160 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
161 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
162 |
"<project name=\"Replace Openide\" basedir=\".\" default=\"all\" >" + |
163 |
" <taskdef name=\"fix\" classname=\"org.netbeans.nbbuild.FixDependencies\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
164 |
"<target name=\"all\" >" + |
165 |
"<fix>" + |
166 |
" <replace codenamebase=\"org.openide.util\">" + |
167 |
" <module codenamebase=\"org.openide.util\" spec=\"8.0\" />" + |
168 |
" <module codenamebase=\"org.openide.util.lookup\" spec=\"8.0\" />" + |
169 |
" </replace>" + |
170 |
" <fileset dir=\"" + xml.getParent () + "\">" + |
171 |
" <include name=\"" + xml.getName () + "\" /> " + |
172 |
" </fileset>" + |
173 |
"</fix>" + |
174 |
"</target>" + |
175 |
"</project>" |
176 |
|
177 |
); |
178 |
|
179 |
String before = PublicPackagesInProjectizedXMLTest.readFile(xml); |
180 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); |
181 |
String after = PublicPackagesInProjectizedXMLTest.readFile(xml); |
182 |
|
183 |
assertEquals("No change", before, after); |
184 |
} |
71 |
public void testReplaceOpenideDepWithSmallerOnes () throws Exception { |
185 |
public void testReplaceOpenideDepWithSmallerOnes () throws Exception { |
72 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString ( |
186 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString ( |
73 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
187 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
Lines 118-123
Link Here
|
118 |
fail ("Spec version must be updated to 6.2: " + result); |
232 |
fail ("Spec version must be updated to 6.2: " + result); |
119 |
} |
233 |
} |
120 |
} |
234 |
} |
|
|
235 |
|
236 |
public void testReplaceOpenideUtilWithUtilAndLookup () throws Exception { |
237 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString ( |
238 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
239 |
"<project>" + |
240 |
" <module-dependencies>" + |
241 |
" <dependency>" + |
242 |
" <code-name-base>org.openide.util</code-name-base>" + |
243 |
" <build-prerequisite/> " + |
244 |
" <compile-dependency/> " + |
245 |
" <run-dependency>" + |
246 |
" <specification-version>7.28</specification-version> " + |
247 |
" </run-dependency>" + |
248 |
" </dependency>" + |
249 |
" </module-dependencies>" + |
250 |
"</project>" |
251 |
); |
252 |
|
253 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
254 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
255 |
"<project name=\"Replace Openide\" basedir=\".\" default=\"all\" >" + |
256 |
" <taskdef name=\"fix\" classname=\"org.netbeans.nbbuild.FixDependencies\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
257 |
"<target name=\"all\" >" + |
258 |
"<fix>" + |
259 |
" <replace codenamebase=\"org.openide.util\">" + |
260 |
" <module codenamebase=\"org.openide.util\" spec=\"8.0\" />" + |
261 |
" <module codenamebase=\"org.openide.util.lookup\" spec=\"8.0\" />" + |
262 |
" </replace>" + |
263 |
" <fileset dir=\"" + xml.getParent () + "\">" + |
264 |
" <include name=\"" + xml.getName () + "\" /> " + |
265 |
" </fileset>" + |
266 |
"</fix>" + |
267 |
"</target>" + |
268 |
"</project>" |
269 |
|
270 |
); |
271 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); |
272 |
|
273 |
String result = PublicPackagesInProjectizedXMLTest.readFile (xml); |
274 |
|
275 |
if (result.indexOf ("org.openide.util") == -1) { |
276 |
fail ("org.openide.util should be there: " + result); |
277 |
} |
278 |
if (result.indexOf ("org.openide.util.lookup") == -1) { |
279 |
fail ("org.openide.util.lookup should be there: " + result); |
280 |
} |
281 |
|
282 |
int where; |
283 |
if ((where = result.indexOf ("<specification-version>8.0</specification-version>")) == -1) { |
284 |
fail ("Spec version must be updated to 8.0: " + result); |
285 |
} |
286 |
if (result.indexOf("<specification-version>8.0</specification-version>", where + 1) == -1) { |
287 |
fail ("Snd Spec version must be updated to 8.0: " + result); |
288 |
} |
289 |
} |
290 |
public void testDontReplaceNewerVersionOfItself() throws Exception { |
291 |
doDontReplaceNewerVersionOfItself("8.1"); |
292 |
} |
293 |
public void testDontReplaceNewerVersionOfItself9() throws Exception { |
294 |
doDontReplaceNewerVersionOfItself("9.0"); |
295 |
} |
296 |
|
297 |
private void doDontReplaceNewerVersionOfItself(String version) throws Exception { |
298 |
java.io.File xml = PublicPackagesInProjectizedXMLTest.extractString ( |
299 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
300 |
"<project>" + |
301 |
" <module-dependencies>" + |
302 |
" <dependency>" + |
303 |
" <code-name-base>org.openide.util</code-name-base>" + |
304 |
" <build-prerequisite/> " + |
305 |
" <compile-dependency/> " + |
306 |
" <run-dependency>" + |
307 |
" <specification-version>" + version + "</specification-version> " + |
308 |
" </run-dependency>" + |
309 |
" </dependency>" + |
310 |
" </module-dependencies>" + |
311 |
"</project>" |
312 |
); |
313 |
|
314 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
315 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
316 |
"<project name=\"Replace Openide\" basedir=\".\" default=\"all\" >" + |
317 |
" <taskdef name=\"fix\" classname=\"org.netbeans.nbbuild.FixDependencies\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
318 |
"<target name=\"all\" >" + |
319 |
"<fix>" + |
320 |
" <replace codenamebase=\"org.openide.util\">" + |
321 |
" <module codenamebase=\"org.openide.util\" spec=\"8.0\" />" + |
322 |
" <module codenamebase=\"org.openide.util.lookup\" spec=\"8.0\" />" + |
323 |
" </replace>" + |
324 |
" <fileset dir=\"" + xml.getParent () + "\">" + |
325 |
" <include name=\"" + xml.getName () + "\" /> " + |
326 |
" </fileset>" + |
327 |
"</fix>" + |
328 |
"</target>" + |
329 |
"</project>" |
330 |
|
331 |
); |
332 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); |
333 |
|
334 |
String result = PublicPackagesInProjectizedXMLTest.readFile (xml); |
335 |
|
336 |
if (result.indexOf ("org.openide.util") == -1) { |
337 |
fail ("org.openide.util should be there: " + result); |
338 |
} |
339 |
if (result.indexOf ("org.openide.util.lookup") >= 0) { |
340 |
fail ("org.openide.util.lookup should not be there: " + result); |
341 |
} |
342 |
|
343 |
if (result.indexOf ("<specification-version>" + version + "</specification-version>") == -1) { |
344 |
fail ("Spec version stays at updated to kept: " + result); |
345 |
} |
346 |
} |
121 |
|
347 |
|
122 |
|
348 |
|
123 |
public void testVerificationOfRemovedDependencies () throws Exception { |
349 |
public void testVerificationOfRemovedDependencies () throws Exception { |