aboutsummaryrefslogtreecommitdiffstats
path: root/tests/netx/unit/net/sourceforge
diff options
context:
space:
mode:
authorOmair Majid <[email protected]>2013-08-30 11:02:08 -0400
committerOmair Majid <[email protected]>2013-08-30 11:02:08 -0400
commit61454c3a644d0cdef0cfd1aa8140dd9c81efa727 (patch)
tree663652345d54ab043d1979a9c58bb406e1a621b2 /tests/netx/unit/net/sourceforge
parent5e403e636e5ddea669f12019555f8392157e67c1 (diff)
Test case for PR1533
Add a unit test that checks the behaviour of JNLPFile when combining and filtering properties. 2013-08-29 Omair Majid <[email protected]> * tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java (testPropertyRestrictions): New method. Check that properties in resources are are combined and filtered as approp
Diffstat (limited to 'tests/netx/unit/net/sourceforge')
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java b/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java
index 1056ea2..1f517be 100644
--- a/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java
+++ b/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java
@@ -42,6 +42,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
+import java.util.Map;
import net.sourceforge.jnlp.JNLPFile.Match;
import net.sourceforge.jnlp.mock.MockJNLPFile;
@@ -148,4 +149,63 @@ public class JNLPFileTest {
Assert.assertEquals("Sample Test", jnlpFile.getTitle());
Assert.assertEquals(2, jnlpFile.getResources().getJARs().length);
}
+
+ @Test
+ public void testPropertyRestrictions() throws MalformedURLException, ParseException {
+ String jnlpContents = "<?xml version='1.0'?>\n" +
+ "<jnlp spec='1.5' href='foo' codebase='bar'>\n" +
+ " <information>\n" +
+ " <title>Parsing Test</title>\n" +
+ " <vendor>IcedTea</vendor>\n" +
+ " <offline-allowed/>\n" +
+ " </information>\n" +
+ " <resources>\n" +
+ " <property name='general' value='general'/>\n" +
+ " <property name='os' value='general'/>\n" +
+ " <property name='arch' value='general'/>\n" +
+ " </resources>\n" +
+ " <resources os='os1'>" +
+ " <property name='os' value='os1'/>\n" +
+ " </resources>\n" +
+ " <resources os='os1' arch='arch1'>" +
+ " <property name='arch' value='arch1'/>\n" +
+ " </resources>\n" +
+ " <resources os='os2' arch='arch2'>\n" +
+ " <property name='os' value='os2'/>\n" +
+ " <property name='arch' value='arch2'/>\n" +
+ " </resources>\n" +
+ " <installer-desc/>\n" +
+ "</jnlp>";
+
+ URL codeBase = new URL("http://www.redhat.com/");
+ InputStream is = new ByteArrayInputStream(jnlpContents.getBytes());
+ JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false,false,false));
+
+ ResourcesDesc resources;
+ Map<String,String> properties;
+
+ resources = jnlpFile.getResources(Locale.getDefault(), "os0", "arch0");
+ properties = resources.getPropertiesMap();
+ Assert.assertEquals("general", properties.get("general"));
+ Assert.assertEquals("general", properties.get("os"));
+ Assert.assertEquals("general", properties.get("arch"));
+
+ resources = jnlpFile.getResources(Locale.getDefault(), "os1", "arch0");
+ properties = resources.getPropertiesMap();
+ Assert.assertEquals("general", properties.get("general"));
+ Assert.assertEquals("os1", properties.get("os"));
+ Assert.assertEquals("general", properties.get("arch"));
+
+ resources = jnlpFile.getResources(Locale.getDefault(), "os1", "arch1");
+ properties = resources.getPropertiesMap();
+ Assert.assertEquals("general", properties.get("general"));
+ Assert.assertEquals("os1", properties.get("os"));
+ Assert.assertEquals("arch1", properties.get("arch"));
+
+ resources = jnlpFile.getResources(Locale.getDefault(), "os2", "arch2");
+ properties = resources.getPropertiesMap();
+ Assert.assertEquals("general", properties.get("general"));
+ Assert.assertEquals("os2", properties.get("os"));
+ Assert.assertEquals("arch2", properties.get("arch"));
+ }
}