From 61454c3a644d0cdef0cfd1aa8140dd9c81efa727 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Fri, 30 Aug 2013 11:02:08 -0400 Subject: Test case for PR1533 Add a unit test that checks the behaviour of JNLPFile when combining and filtering properties. 2013-08-29 Omair Majid * tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java (testPropertyRestrictions): New method. Check that properties in resources are are combined and filtered as approp --- .../unit/net/sourceforge/jnlp/JNLPFileTest.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'tests/netx/unit/net/sourceforge') 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 = "\n" + + "\n" + + " \n" + + " Parsing Test\n" + + " IcedTea\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " " + + " \n" + + " \n" + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + 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 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")); + } } -- cgit v1.2.3