Revision: 7106
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7106&view=rev
Author:   dnaber
Date:     2012-05-30 17:09:32 +0000 (Wed, 30 May 2012)
Log Message:
-----------
add test to check url escaping in API output

Modified Paths:
--------------
    trunk/JLanguageTool/src/test/org/languagetool/tools/StringToolsTest.java

Modified: 
trunk/JLanguageTool/src/test/org/languagetool/tools/StringToolsTest.java
===================================================================
--- trunk/JLanguageTool/src/test/org/languagetool/tools/StringToolsTest.java    
2012-05-30 16:55:38 UTC (rev 7105)
+++ trunk/JLanguageTool/src/test/org/languagetool/tools/StringToolsTest.java    
2012-05-30 17:09:32 UTC (rev 7106)
@@ -23,6 +23,8 @@
 import junit.framework.TestCase;
 
 import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -167,6 +169,31 @@
         "</matches>\n", xml);
   }
 
+  public void testRuleMatchesWithUrlToXML() throws IOException {
+    final List<RuleMatch> matches = new ArrayList<RuleMatch>();
+    final String text = "This is an test sentence. Here's another sentence 
with more text.";
+    final RuleMatch match = new RuleMatch(new AvsAnRule(null) {
+      @Override
+      public URL getUrl() {
+        try {
+          return new URL("http://server.org?id=1&foo=bar";);
+        } catch (MalformedURLException e) {
+          throw new RuntimeException(e);
+        }
+      }
+    }, 8, 10, "myMessage");
+    match.setColumn(99);
+    match.setEndColumn(100);
+    match.setLine(44);
+    match.setEndLine(45);
+    matches.add(match);
+    final String xml = StringTools.ruleMatchesToXML(matches, text, 5, 
StringTools.XmlPrintMode.NORMAL_XML);
+    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+            "<matches>\n" +
+            "<error fromy=\"44\" fromx=\"98\" toy=\"45\" tox=\"99\" 
ruleId=\"EN_A_VS_AN\" msg=\"myMessage\" replacements=\"\" context=\"...s is an 
test...\" contextoffset=\"8\" errorlength=\"2\" 
url=\"http://server.org?id=1&amp;foo=bar\"/>\n" +
+            "</matches>\n", xml);
+  }
+
   public void testRuleMatchesToXMLEscapeBug() throws IOException {
     final List<RuleMatch> matches = new ArrayList<RuleMatch>();
     final String text = "This is \"an test sentence. Here's another sentence 
with more text.";

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to