Lines 125-130
Link Here
|
125 |
fail ("File does not seem to be signed: " + jar); |
125 |
fail ("File does not seem to be signed: " + jar); |
126 |
} |
126 |
} |
127 |
} |
127 |
} |
|
|
128 |
|
129 |
public void testGenerateJNLPAndUnSignedJarForSimpleModule() throws Exception { |
130 |
Manifest m; |
131 |
|
132 |
m = ModuleDependenciesTest.createManifest (); |
133 |
m.getMainAttributes ().putValue ("OpenIDE-Module", "org.my.module/3"); |
134 |
File simpleJar = generateJar (new String[0], m); |
135 |
|
136 |
File parent = simpleJar.getParentFile (); |
137 |
File output = new File(parent, "output"); |
138 |
File ks = generateKeystore("jnlp", "netbeans-test"); |
139 |
|
140 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
141 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
142 |
"<project name=\"Test Arch\" basedir=\".\" default=\"all\" >" + |
143 |
" <taskdef name=\"jnlp\" classname=\"org.netbeans.nbbuild.MakeJNLP\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
144 |
"<target name=\"all\" >" + |
145 |
" <mkdir dir='" + output + "' />" + |
146 |
" <jnlp dir='" + output + "' alias='jnlp' storepass='netbeans-test' keystore='" + ks + "' signjars='false' >" + |
147 |
" <modules dir='" + parent + "' >" + |
148 |
" <include name='" + simpleJar.getName() + "' />" + |
149 |
" </modules>" + |
150 |
" </jnlp>" + |
151 |
"</target>" + |
152 |
"</project>" |
153 |
); |
154 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { "-verbose" }); |
155 |
|
156 |
assertFilenames(output, "org-my-module.jnlp", "org-my-module/s0.jar"); |
157 |
|
158 |
File jnlp = new File(output, "org-my-module.jnlp"); |
159 |
String res = ModuleDependenciesTest.readFile (jnlp); |
160 |
|
161 |
assertTrue ("Component JNLP type: " + res, res.indexOf ("<component-desc/>") >= 0); |
162 |
assertTrue ("We support all permitions by default: " + res, res.indexOf ("<all-permissions/>") >= 0); |
163 |
|
164 |
Matcher match = Pattern.compile(".*codebase=['\\\"]([^'\\\"]*)['\\\"]").matcher(res); |
165 |
assertTrue("codebase is there", match.find()); |
166 |
assertEquals("one group found", 1, match.groupCount()); |
167 |
String base = match.group(1); |
168 |
|
169 |
assertEquals("By default the dest directory is $$codebase: ", "$$codebase", base); |
170 |
|
171 |
File jar = new File(output, "org-my-module/s0.jar"); |
172 |
JarFile signed = new JarFile(jar); |
173 |
Enumeration it = signed.entries(); |
174 |
while (it.hasMoreElements()) { |
175 |
JarEntry entry = (JarEntry)it.nextElement(); |
176 |
if (entry.getName().endsWith(".SF")) { |
177 |
fail ("File should not be signed: " + jar); |
178 |
} |
179 |
} |
180 |
|
181 |
} |
128 |
|
182 |
|
129 |
public void testTheLocalizedAutoupdateProblem() throws Exception { |
183 |
public void testTheLocalizedAutoupdateProblem() throws Exception { |
130 |
String UTfile = |
184 |
String UTfile = |
Lines 338-343
Link Here
|
338 |
} |
392 |
} |
339 |
} |
393 |
} |
340 |
fail ("File does not seem to be signed: " + jar); |
394 |
fail ("File does not seem to be signed: " + jar); |
|
|
395 |
} |
396 |
} |
397 |
|
398 |
public void testGenerateJNLPAndUnSignedJarForSimpleLocalizedModule() throws Exception { |
399 |
Manifest m; |
400 |
|
401 |
m = ModuleDependenciesTest.createManifest (); |
402 |
m.getMainAttributes ().putValue ("OpenIDE-Module", "org.my.module/3"); |
403 |
File simpleJar = generateJar ("modules/", new String[0], m, null); |
404 |
|
405 |
File parent = simpleJar.getParentFile (); |
406 |
File localizedJarCZ = generateJar("modules/locale/", new String[0], ModuleDependenciesTest.createManifest(), null); |
407 |
assertEquals("There need to have the same name", simpleJar.getName(), localizedJarCZ.getName()); |
408 |
assertTrue("Successful rename", localizedJarCZ.renameTo(new File(localizedJarCZ.getParent(), "0_cs.jar"))); |
409 |
|
410 |
File localizedJarZH = generateJar("modules/locale/", new String[0], ModuleDependenciesTest.createManifest(), null); |
411 |
assertEquals("There need to have the same name", simpleJar.getName(), localizedJarZH.getName()); |
412 |
assertTrue("Successful rename", localizedJarZH.renameTo(new File(localizedJarCZ.getParent(), "0_zh_CN.jar"))); |
413 |
|
414 |
File localizedJarJA = generateJar("modules/locale/", new String[0], ModuleDependenciesTest.createManifest(), null); |
415 |
assertEquals("There need to have the same name", simpleJar.getName(), localizedJarJA.getName()); |
416 |
assertTrue("Successful rename", localizedJarJA.renameTo(new File(localizedJarCZ.getParent(), "0_ja.jar"))); |
417 |
|
418 |
File updateTracking = new File(getWorkDir(), "update_tracking"); |
419 |
updateTracking.mkdirs(); |
420 |
assertTrue("Created", updateTracking.isDirectory()); |
421 |
|
422 |
File trackingFile = new File(updateTracking, "org-my-module.xml"); |
423 |
FileWriter w = new FileWriter(trackingFile); |
424 |
w.write( |
425 |
"<?xml version='1.0' encoding='UTF-8'?>\n" + |
426 |
"<module codename='org.my.module/3'>\n" + |
427 |
"<module_version specification_version='3.22' origin='installer' last='true' install_time='1124194231878'>\n" + |
428 |
"<file name='modules/" + simpleJar.getName() + "' crc='3245456472'/>\n" + |
429 |
"<file name='config/Modules/org-my-module.xml' crc='43434' />\n" + |
430 |
"<file name='modules/locale/0_cs.jar' crc='454244' />\n" + |
431 |
"<file name='modules/locale/0_ja.jar' crc='779831' />\n" + |
432 |
"<file name='modules/locale/0_zh_CN.jar' crc='475345' />\n" + |
433 |
" </module_version>\n" + |
434 |
"</module>\n" |
435 |
); |
436 |
w.close(); |
437 |
|
438 |
|
439 |
File output = new File(parent, "output"); |
440 |
File ks = generateKeystore("jnlp", "netbeans-test"); |
441 |
|
442 |
java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( |
443 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
444 |
"<project name=\"Test Arch\" basedir=\".\" default=\"all\" >" + |
445 |
" <taskdef name=\"jnlp\" classname=\"org.netbeans.nbbuild.MakeJNLP\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>" + |
446 |
"<target name=\"all\" >" + |
447 |
" <mkdir dir='" + output + "' />" + |
448 |
" <jnlp dir='" + output + "' alias='jnlp' storepass='netbeans-test' keystore='" + ks + "' verify='true' signjars='false' >" + |
449 |
" <modules dir='" + parent + "' >" + |
450 |
" <include name='" + simpleJar.getName() + "' />" + |
451 |
" </modules>" + |
452 |
" </jnlp>" + |
453 |
"</target>" + |
454 |
"</project>" |
455 |
); |
456 |
PublicPackagesInProjectizedXMLTest.execute (f, new String[] { "-verbose" }); |
457 |
|
458 |
assertFilenames(output, "org-my-module.jnlp", |
459 |
"org-my-module/0.jar", |
460 |
"org-my-module/locale-0_cs.jar", |
461 |
"org-my-module/locale-0_zh_CN.jar", |
462 |
"org-my-module/locale-0_ja.jar"); |
463 |
|
464 |
File jnlp = new File(output, "org-my-module.jnlp"); |
465 |
String res = ModuleDependenciesTest.readFile (jnlp); |
466 |
|
467 |
assertTrue ("Component JNLP type: " + res, res.indexOf ("<component-desc/>") >= 0); |
468 |
assertTrue ("We support all permissions by default: " + res, res.indexOf ("<all-permissions/>") >= 0); |
469 |
|
470 |
Matcher match = Pattern.compile(".*codebase=['\\\"]([^'\\\"]*)['\\\"]").matcher(res); |
471 |
assertTrue("codebase is there", match.find()); |
472 |
assertEquals("one group found", 1, match.groupCount()); |
473 |
String base = match.group(1); |
474 |
|
475 |
assertEquals("By default the dest directory is $$codebase: ", "$$codebase", base); |
476 |
|
477 |
assertResource(res, "cs", "org-my-module/locale-0_cs.jar"); |
478 |
assertResource(res, "ja", "org-my-module/locale-0_ja.jar"); |
479 |
assertResource(res, "zh_CN", "org-my-module/locale-0_zh_CN.jar"); |
480 |
|
481 |
for (File jar : new File(output, "org-my-module").listFiles()) { |
482 |
if (!jar.getName().endsWith(".jar")) { |
483 |
continue; |
484 |
} |
485 |
|
486 |
JarFile signed = new JarFile(jar); |
487 |
Enumeration it = signed.entries(); |
488 |
while (it.hasMoreElements()) { |
489 |
JarEntry entry = (JarEntry)it.nextElement(); |
490 |
if (entry.getName().endsWith(".SF")) { |
491 |
fail ("File does not seem to be signed: " + jar); |
492 |
} |
493 |
} |
341 |
} |
494 |
} |
342 |
} |
495 |
} |
343 |
|
496 |
|