aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-extensions/net
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-11-27 14:11:13 +0100
committerJiri Vanek <[email protected]>2013-11-27 14:11:13 +0100
commit59233334144dca83fb017795d54d99636cccee81 (patch)
treea28c68f6af5745527ecd66e3620a440764ca2115 /tests/test-extensions/net
parentb8da03fd7a7aac183acebf7ccd26196ccafca9bc (diff)
Added null check when getting manifest attributes for case of jar without manifest
* netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: (getManifestAttribute) added check fo null manifest to prevent npe. * /tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java: added test for npe from getManifestAttribute * tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java: (createJarWithContents) enhanced to be able to create jar without manifest.
Diffstat (limited to 'tests/test-extensions/net')
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java b/tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java
index 828d6a5..1ce4935 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java
@@ -89,13 +89,25 @@ public class FileTestUtils {
}
/* Creates a jar in a temporary directory, with the given name & file contents */
+ static public void createJarWithoutManifestContents(File jarFile, File... fileContents) throws Exception{
+ createJarWithContents(jarFile, null, fileContents);
+ }
+
+ /* Creates a jar in a temporary directory, with the given name & file contents */
static public void createJarWithContents(File jarFile, Manifest manifestContents, File... fileContents)
throws Exception {
/* Manifest quite evilly ignores all attributes if we don't specify a version!
* Make sure it's set here. */
- manifestContents.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+ if (manifestContents != null){
+ manifestContents.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+ }
- JarOutputStream jarWriter = new JarOutputStream(new FileOutputStream(jarFile), manifestContents);
+ JarOutputStream jarWriter;
+ if (manifestContents == null){
+ jarWriter = new JarOutputStream(new FileOutputStream(jarFile));
+ } else {
+ jarWriter = new JarOutputStream(new FileOutputStream(jarFile), manifestContents);
+ }
for (File file : fileContents) {
jarWriter.putNextEntry(new JarEntry(file.getName()));
FileInputStream fileReader = new FileInputStream(file);