Changeset 418 for trunk/icedtea-web/tests/netx/unit
- Timestamp:
- Feb 11, 2013, 8:53:47 PM (13 years ago)
- Location:
- trunk/icedtea-web
- Files:
-
- 3 edited
- 41 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/icedtea-web
-
Property svn:mergeinfo
set to
/branches/vendor/sourceforge/icedtea-web/1.3 merged eligible /branches/vendor/sourceforge/icedtea-web/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java
r348 r418 39 39 40 40 import java.io.ByteArrayInputStream; 41 import java.io.IOException; 42 import java.io.StringReader; 43 import net.sourceforge.jnlp.annotations.KnownToFail; 41 44 42 import org.junit.After; 45 import net.sourceforge.nanoxml.XMLElement; 46 import net.sourceforge.nanoxml.XMLParseException; 47 43 48 import org.junit.Assert; 44 import org.junit.Before;45 49 import org.junit.Test; 46 50 47 51 /** Test various corner cases of the parser */ 48 52 public class ParserCornerCases { 53 54 @Test 55 public void testCdata() throws ParseException, XMLParseException, IOException { 56 String data = "<argument><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> <!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\"> <properties> <entry key=\"key\">value</entry> </properties> ]]></argument>"; 57 XMLElement elem = new XMLElement(); 58 elem.parseFromReader(new StringReader(data)); 59 XMLElement target = elem; 60 Assert.assertEquals("argument", target.getName()); 61 Assert.assertTrue("too small", target.getContent().length() > 20); 62 Assert.assertTrue(target.getContent().contains("xml")); 63 Assert.assertTrue(target.getContent().contains("DOCTYPE")); 64 Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>")); 65 66 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes())); 67 Assert.assertEquals("argument", node.getNodeName()); 68 String contents = node.getNodeValue(); 69 Assert.assertTrue(contents.contains("xml")); 70 Assert.assertTrue(contents.contains("DOCTYPE")); 71 Assert.assertTrue(contents.contains("<entry key=\"key\">value</entry>")); 72 } 73 74 @Test 75 public void testCdataNested() throws ParseException, XMLParseException, IOException { 76 String data = "<jnlp>\n" + 77 "<application-desc>\n" + 78 "<argument>\n" + 79 "<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> <!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\"> <properties> <entry key=\"key\">value</entry> </properties> ]]>" + 80 "</argument>\n" + 81 "<argument>1</argument>\n" + 82 "</application-desc>\n" + 83 "</jnlp>"; 84 XMLElement elem = new XMLElement(); 85 elem.parseFromReader(new StringReader(data)); 86 XMLElement target = (XMLElement) ((XMLElement) elem.enumerateChildren().nextElement()).enumerateChildren().nextElement(); 87 Assert.assertEquals("argument", target.getName()); 88 Assert.assertTrue("too small", target.getContent().length() > 20); 89 Assert.assertTrue(target.getContent().contains("xml")); 90 Assert.assertTrue(target.getContent().contains("DOCTYPE")); 91 Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>")); 92 93 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes())); 94 node = node.getFirstChild().getFirstChild(); 95 Assert.assertEquals("argument", node.getNodeName()); 96 String contents = node.getNodeValue(); 97 Assert.assertTrue(contents.contains("xml")); 98 Assert.assertTrue(contents.contains("DOCTYPE")); 99 Assert.assertTrue(contents.contains("<entry key=\"key\">value</entry>")); 100 } 101 102 @Test 103 @KnownToFail 104 public void testCDataFirstChild() throws XMLParseException, IOException { 105 String xml = "<?xml version=\"1.0\"?>\n" + 106 "<jnlp spec=\"1.5+\">\n" + 107 "<![CDATA[Text you want to escape goes here...<test> random tag test </test>]]>\n" + 108 "<information/>\n" + 109 "</jnlp>"; 110 XMLElement elem = new XMLElement(); 111 elem.parseFromReader(new StringReader(xml)); 112 } 113 114 @Test 115 @KnownToFail 116 public void testCDataSecondChild() throws XMLParseException, IOException { 117 String xml = "<?xml version=\"1.0\"?>\n" + 118 "<jnlp spec=\"1.5+\">\n" + 119 "<information/>\n" + 120 "<![CDATA[Text you want to escape goes here...<test> random tag test </test>]]>\n" + 121 "</jnlp>"; 122 XMLElement elem = new XMLElement(); 123 elem.parseFromReader(new StringReader(xml)); 124 } 125 49 126 @Test 50 127 public void testUnsupportedSpecNumber() throws ParseException { … … 72 149 73 150 @Test 151 public void testCommentInElements2() throws ParseException { 152 String malformedJnlp = "<?xml?><jnlp <!-- comment --> spec='1.0'> </jnlp>"; 153 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes())); 154 Parser p = new Parser(null, null, root, false, false); 155 Assert.assertEquals("1.0", p.getSpecVersion().toString()); 156 } 157 158 @Test 159 @KnownToFail 74 160 public void testCommentInAttributes() throws ParseException { 75 161 String malformedJnlp = "<?xml?><jnlp spec='<!-- something -->'></jnlp>"; … … 82 168 public void testNestedComments() throws ParseException { 83 169 String malformedJnlp = "<?xml?>" + 84 "<jnlp><information><description>" + 170 "<jnlp><information><title>testNestedComments</title>" + 171 "<vendor>IcedTea</vendor><description>" + 85 172 "<!-- outer <!-- inner --> -->" + 86 173 "</description></information></jnlp>"; … … 89 176 Assert.assertEquals(" -->", p.getInfo(root).get(0).getDescription()); 90 177 } 178 179 @Test 180 public void testDoubleDashesInComments() throws ParseException { 181 String malformedJnlp = "<?xml?>" + 182 "<jnlp> <!-- \n" + 183 " -- a very very long and \n" + 184 " -- multiline comment \n" + 185 " -- that contains double dashes \n" + 186 " -->\n" + 187 " <information/>" + 188 "</jnlp>"; 189 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes())); 190 Parser p = new Parser(null, null, root, false, false); 191 } 192 91 193 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserMalformedXml.java
r348 r418 43 43 import java.io.InputStreamReader; 44 44 import java.io.IOException; 45 import net.sourceforge.jnlp.annotations.KnownToFail; 45 46 46 47 import org.junit.BeforeClass; … … 75 76 76 77 @Test 78 @KnownToFail 77 79 public void testMalformedArguments() throws ParseException { 78 80 String malformedJnlp = originalJnlp.replace("arg2</argument", "arg2<argument"); … … 81 83 82 84 @Test 85 @KnownToFail 83 86 public void testTagNotClosed() throws ParseException { 84 87 String malformedJnlp = originalJnlp.replace("</jnlp>", "<jnlp>"); … … 87 90 88 91 @Test 92 @KnownToFail 89 93 public void testUnquotedAttributes() throws ParseException { 90 94 String malformedJnlp = originalJnlp.replace("'jnlp.jnlp'", "jnlp.jnlp");
Note:
See TracChangeset
for help on using the changeset viewer.