1   /*
2    * Created by IntelliJ IDEA.
3    * User: owen
4    * Date: Nov 28, 2002
5    * Time: 1:33:01 PM
6    * CVS Revision: $Revision: 1.6 $
7    * Last CVS Commit: $Date: 2003/09/30 07:05:53 $
8    * Author of last CVS Commit: $Author: mcannon $
9    * To change this template use Options | File Templates.
10   */
11  package com.atlassian.core.util;
12  
13  import com.atlassian.core.util.HTMLUtils;
14  import junit.framework.TestCase;
15  
16  public class TestHTMLUtils extends TestCase
17  {
18      public TestHTMLUtils(String s)
19      {
20          super(s);
21      }
22  
23      public void testStripOutHtmlTags1()
24      {
25          String html = "<html> <head> <br> </head> <body> After some useful feedback from the Velocity-users mailing list, I have got the servlet that was causing me to pull hair out to actually work. So my original thesis about round tripping of Shift-JIS encoded strings into, and out of, Java's UTF-16 environment appear to be baseless.<br><br>I wish I could still find my original round-trippping-doesn't-work code, just so I could understand my errors. But, it is long gone. Blah.<br><br> [Later...] I think I remember the problem was actually 1.2.2's conversion ability. Hmmm. Oh well. Let us see how good 1.3.0 is (current production jdk for my deployment. Ack.)<br> </body> </html>";
26          String expectedHtml = "After some useful feedback from the Velocity-users mailing list, I have got the servlet that was causing me to pull hair out to actually work. So my original thesis about round tripping of Shift-JIS encoded strings into, and out of, Java's UTF-16 environment appear to be baseless.<br><br>I wish I could still find my original round-trippping-doesn't-work code, just so I could understand my errors. But, it is long gone. Blah.<br><br> [Later...] I think I remember the problem was actually 1.2.2's conversion ability. Hmmm. Oh well. Let us see how good 1.3.0 is (current production jdk for my deployment. Ack.)<br>";
27          String newHtml = HTMLUtils.stripOuterHtmlTags(html);
28          assertEquals(expectedHtml, newHtml);
29      }
30  
31  
32      public void testStripOutHtmlTags2()
33      {
34          String html = "After some useful feedback from the Velocity-users mailing list, I have got the servlet that was causing me to pull hair out to actually work. So my original thesis about round tripping of Shift-JIS encoded strings into, and out of, Java's UTF-16 environment appear to be baseless.<br><br>I wish I could still find my original round-trippping-doesn't-work code, just so I could understand my errors. But, it is long gone. Blah.<br><br> [Later...] I think I remember the problem was actually 1.2.2's conversion ability. Hmmm. Oh well. Let us see how good 1.3.0 is (current production jdk for my deployment. Ack.)<br>";
35          String newHtml = HTMLUtils.stripOuterHtmlTags(html);
36          assertEquals(html, newHtml);
37      }
38  
39      public void testStripOuterHtmlTags3()
40      {
41          String html = "<a href=\"http://www.thauvin.net/blog/news.jsp?date=2002-11-28#002\" style=\"color:gray\" name=\"002\" title=\"Thu, 28 Nov 2002 23:03:55 GMT\">[@002]</a> <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/personal.gif\" alt=\"me\" align=\"left\">Happy Turkey Day! I'm off to prepare my bird and bake a pie... <br> <br> <a href=\"http://www.thauvin.net/blog/news.jsp?date=2002-11-28#954\" style=\"color:gray\" name=\"954\" title=\"Thu, 28 Nov 2002 21:54:22 GMT\">[@954]</a> <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/humour.gif\" alt=\"humor\" align=\"left\"><a href=\"http://svt.se/hogafflahage/hogafflaHage_site/Kor/hestekor.swf\" target=\"_blank\"><b>Singing Horses</b></a> flash movie. <i>Click on each Horse to make him perform!</i> <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\">New <A href=\"http://www.javalobby.org/thread.jsp?forum=61&amp;thread=5908&amp;message=18511214\" target=\"_blank\"><b>JSR</b></a>'s: Java Compiler API and Class Compression Format. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\"><a href=\"http://www.javalobby.org/thread.jsp?forum=17&amp;thread=5905\" target=\"_blank\"><b>XML@Whiz 4.0</b></a>, IBM XML Certification Test Simulator released. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/blog.gif\" alt=\"blog\" align=\"left\">Matt &mdash; <a href=\"http://www.raibledesigns.com/page/rd/20021128#oslo_new_project_admin_tool\" target=\"_blank\"><b>Oslo</b></a> - New Project admin tool. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/blog.gif\" alt=\"blog\" align=\"left\">Sjoerd &mdash; <a href=\"http://w3future.com/weblog/2002/09/09.html#a129\" target=\"_blank\"><b>RSS to RDF</b></a> Converter. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/blog.gif\" alt=\"blog\" align=\"left\">Werner &mdash; using <a href=\"http://www.shiftat.com/blog/page/werner/20021128\" target=\"_blank\"><b>Clover</b></a> on deployed J2EE apps. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\"><a href=\"http://freshmeat.net/releases/104956/\" target=\"_blank\"><b>SuperWaba 3.3</b></a>, a JavaVM for PalmOS devices. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/news.gif\" alt=\"news\" align=\"left\">Anger as <a href=\"http://news.bbc.co.uk/go/rss/-/1/hi/business/2523757.stm\" target=\"_blank\"><b>Microsoft hires EU official</b></a>. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/news.gif\" alt=\"news\" align=\"left\"><a href=\"http://www.cnn.com/2002/TECH/internet/11/28/insult.worm/index.html\" target=\"_blank\"><b>New worm</b></a> adds insult to injury. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/news.gif\" alt=\"news\" align=\"left\"><a href=\"http://www.cnn.com/2002/TECH/science/11/28/dna.gifts/index.html\" target=\"_blank\"><b>DNA jewelry</b></a>: A gift that screams you. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\">The rise and rise of <a href=\"http://www.cw360.com/bin/bladerunner?REQSESS=zK54CC96&amp;2149REQEVENT=&amp;CARTI=117856&amp;CARTT=2&amp;CCAT=1&amp;CCHAN=15&amp;CFLAV=1\" target=\"_blank\"><b>Websphere</b></a>. <br> <br> <a href=\"http://www.thauvin.net/blog/news.jsp?date=2002-11-28#616\" style=\"color:gray\" name=\"616\" title=\"Thu, 28 Nov 2002 13:47:55 GMT\">[@616]</a> <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/personal.gif\" alt=\"me\" align=\"left\">Too many <b>Java blogs</b>? <br> <br> <a href=\"http://www.javablogs.com\" target=\"_blank\"><img src=\"http://www.thauvin.net/erik/images/blog/javablogserror.gif\" alt=\"JavaBlogs.Com Error\" border=\"0\"></a> <br> <br> <a href=\"http://www.thauvin.net/blog/news.jsp?date=2002-11-28#610\" style=\"color:gray\" name=\"610\" title=\"Thu, 28 Nov 2002 13:38:47 GMT\">[@610]</a> <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\"><A href=\"http://sourceforge.net/project/showfiles.php?group_id=55258\" target=\"_blank\"><b>Joost STX processor</b></a>, an open source implementation of the Streaming Transformation for XML language. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\"><a href=\"http://sourceforge.net/project/showfiles.php?group_id=47056\" target=\"_blank\"><b>Zaval File Search 1.3.0</b></a>, an open source local area network tool designed for fast file search on SMB shares and FTP servers. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/news.gif\" alt=\"news\" align=\"left\"><A href=\"http://www.wired.com/news/holidays/0,1882,56621,00.html\" target=\"_blank\"><b>Bond Gadgets</b></a> Not Just Movie Magic. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/win.gif\" alt=\"windows\" align=\"left\">mozilla.org's <A href=\"http://newsvac.newsforge.com/article.pl?sid=02/11/28/127203\" target=\"_blank\"><b>Phoenix</b></a> Project To Be Renamed. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/blog.gif\" alt=\"blog\" align=\"left\">Roman &mdash; <a href=\"http://freeroller.net:80/page/deep/20021128#java_libraries_all_at_one\" target=\"_blank\"><b>Java libraries</b></a> - all-at-one-place! <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/playboy.gif\" alt=\"playboy\" align=\"left\"><a href=\"http://saltyt.antville.org/stories/218506/\" target=\"_blank\"><b>My name is...</b></a> Oh, forget it. <br> <br> <a href=\"http://www.thauvin.net/blog/news.jsp?date=2002-11-28#499\" style=\"color:gray\" name=\"499\" title=\"Thu, 28 Nov 2002 10:59:47 GMT\">[@499]</a> <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/date.gif\" alt=\"today\" align=\"left\">Thanksgiving <a href=\"http://file.sugarqube.com/Cards/cken_Turkamiester.swf?PL=L500x375_68\" target=\"_blank\"><b>turkey flash animation</b></a>. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\"><A href=\"http://pharos.inria.fr/Java/display.jsp?id=c_11291\" target=\"_blank\"><b>Taglibtools</b></a>, a package of utility tools for custom tag library developers. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\"><A href=\"http://pharos.inria.fr/Java/display.jsp?id=c_11292\" target=\"_blank\"><b>Salsa</b></a>, a collection of Swing add-ons. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/news.gif\" alt=\"news\" align=\"left\"><a href=\"http://slashdot.org/articles/02/11/28/0032243.shtml?tid=153\" target=\"_blank\"><b>Amnesty Calls Shenannigans</b></a> on MS, Sun, Cisco. <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/tv.gif\" alt=\"tv\" align=\"left\"><a href=\"http://www.nytimes.com/2002/11/28/business/28ECHO.html?ex=1039150800&amp;en=926efea339a4f382&amp;ei=5040&amp;partner=MOREOVER\" target=\"_blank\"><b>EchoStar Plan to Get Hughes</b></a> Is Revised. <i>Dish Networks is trying to buy DirectTV.</i> <br> <br> <img src=\"http://www.thauvin.net/erik/images/blog/java.gif\" alt=\"java\" align=\"left\">Roman &mdash; <a href=\"http://freeroller.net:80/page/deep/20021128#guess_what_683_guess_what\" target=\"_blank\"><b>Guess-what 683</b></a> guess-what... <i>New IDEA build!</i>";
42          String newHtml = HTMLUtils.stripOuterHtmlTags(html);
43          assertEquals(html, newHtml);
44      }
45  }