aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Azores <[email protected]>2013-09-04 12:22:16 -0400
committerAndrew Azores <[email protected]>2013-09-04 12:22:16 -0400
commitc72f8a72b8358c466e90b99a5dad2c5b7c653a38 (patch)
treeea4a55feb1eb155f6e64120dfb2a0bd357e89c6b /tests
parent3a58ec9fc80fe436c774c2579e683dcb62dde19c (diff)
parent954a988dde49b5ee6f154ddebbf7459341ccab1a (diff)
merging
Diffstat (limited to 'tests')
-rw-r--r--tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc15
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java60
2 files changed, 67 insertions, 8 deletions
diff --git a/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc b/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc
index bb2b376..b5c893c 100644
--- a/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc
+++ b/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc
@@ -66,16 +66,15 @@ SUITE(IcedTeaScriptableJavaObject) {
TEST(get_scriptable_java_object) {
MemoryLeakDetector leak_detector;
- NPObject* first_obj = IcedTeaScriptableJavaObject::get_scriptable_java_object(&dummy_npp, "DummyClass", "DummyInstance", false);
- browser_functions.releaseobject(first_obj);
+ /* Ensure freeing*/ {
+ NPObjectRef first_obj = IcedTeaScriptableJavaObject::get_scriptable_java_object(&dummy_npp, "DummyClass", "DummyInstance", false);
- /* After the first call, the object should be cached in the object map */
- NPObject* second_obj = IcedTeaScriptableJavaObject::get_scriptable_java_object(&dummy_npp, "DummyClass", "DummyInstance", false);
+ /* After the first call, the object should be cached in the object map */
+ NPObjectRef second_obj = IcedTeaScriptableJavaObject::get_scriptable_java_object(&dummy_npp, "DummyClass", "DummyInstance", false);
- /* Objects should be the same, because of caching */
- CHECK(first_obj == second_obj);
-
- browser_functions.releaseobject(second_obj);
+ /* Objects should be the same, because of caching */
+ CHECK(first_obj.get() == second_obj.get());
+ }
CHECK(leak_detector.memory_leaks() == 0);
}
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"));
+ }
}