Home » displaytag-1.1.1-src » org » displaytag » decorator » [javadoc | source]

    1   package org.displaytag.decorator;
    2   
    3   import junit.framework.TestCase;
    4   
    5   
    6   /**
    7    * Test case for AutolinkColumnDecorator.
    8    * @author Fabrizio Giustina
    9    * @version $Revision: 912 $ ($Author: fgiust $)
   10    */
   11   public class AutolinkColumnDecoratorTest extends TestCase
   12   {
   13   
   14       /**
   15        * @see junit.framework.TestCase#getName()
   16        */
   17       public String getName()
   18       {
   19           return getClass().getName() + "." + super.getName();
   20       }
   21   
   22       /**
   23        * Test for [952129] column:autolink throwing exception.
   24        */
   25       public void testLongTextWithLink()
   26       {
   27           Object linked = new AutolinkColumnDecorator().decorate(
   28               "A large string of text. Foo bar. Foo bar. Foo bar. Foo bar. "
   29                   + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. "
   30                   + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. http://foo.bar.",
   31               null,
   32               null);
   33   
   34           assertEquals("A large string of text. Foo bar. Foo bar. Foo bar. Foo bar. "
   35               + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. "
   36               + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. <a href=\"http://foo.bar.\">http://foo.bar.</a>", linked);
   37       }
   38   
   39       /**
   40        * Test for [952129] column:autolink throwing exception.
   41        */
   42       public void testLongTextWithEmail()
   43       {
   44           Object linked = new AutolinkColumnDecorator().decorate(
   45               "A large string of text. Foo bar. Foo bar. Foo bar. Foo bar. "
   46                   + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. "
   47                   + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. foo@bar.com.",
   48               null,
   49               null);
   50   
   51           assertEquals("A large string of text. Foo bar. Foo bar. Foo bar. Foo bar. "
   52               + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. "
   53               + "Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. <a href=\"mailto:foo@bar.com.\">foo@bar.com.</a>", linked);
   54       }
   55   
   56       /**
   57        * Test for [952132 ] autolink garbling urls.
   58        */
   59       public void testGarbledUrl()
   60       {
   61           Object linked = new AutolinkColumnDecorator().decorate("http://foo.bar cat http://stoat", null, null);
   62   
   63           assertEquals(
   64               "<a href=\"http://foo.bar\">http://foo.bar</a> cat <a href=\"http://stoat\">http://stoat</a>",
   65               linked);
   66       }
   67   
   68       /**
   69        * Test simple link.
   70        */
   71       public void testSimpleLink()
   72       {
   73           Object linked = new AutolinkColumnDecorator().decorate("http://foo.bar", null, null);
   74   
   75           assertEquals("<a href=\"http://foo.bar\">http://foo.bar</a>", linked);
   76       }
   77   
   78       /**
   79        * Test simple https link.
   80        */
   81       public void testSimpleHttpsLink()
   82       {
   83           Object linked = new AutolinkColumnDecorator().decorate("https://foo.bar", null, null);
   84   
   85           assertEquals("<a href=\"https://foo.bar\">https://foo.bar</a>", linked);
   86       }
   87   
   88       /**
   89        * Test simple ftp link.
   90        */
   91       public void testSimpleFtpLink()
   92       {
   93           Object linked = new AutolinkColumnDecorator().decorate("ftp://foo.bar", null, null);
   94   
   95           assertEquals("<a href=\"ftp://foo.bar\">ftp://foo.bar</a>", linked);
   96       }
   97   
   98       /**
   99        * Test simple email.
  100        */
  101       public void testSimpleEmail()
  102       {
  103           Object linked = new AutolinkColumnDecorator().decorate("foo@bar.com", null, null);
  104           assertEquals("<a href=\"mailto:foo@bar.com\">foo@bar.com</a>", linked);
  105       }
  106   
  107       /**
  108        * Test simple link plus dot.
  109        */
  110       public void testSimpleLinkPlusDot()
  111       {
  112           Object linked = new AutolinkColumnDecorator().decorate("http://foo.bar .", null, null);
  113           assertEquals("<a href=\"http://foo.bar\">http://foo.bar</a> .", linked);
  114       }
  115   
  116       /**
  117        * Test no link.
  118        */
  119       public void testNoLink()
  120       {
  121           Object linked = new AutolinkColumnDecorator().decorate("aa://bb", null, null);
  122           assertEquals("aa://bb", linked);
  123       }
  124   
  125       /**
  126        * Test no link beginning.
  127        */
  128       public void testNoLinkBeginning()
  129       {
  130           Object linked = new AutolinkColumnDecorator().decorate("://bb", null, null);
  131           assertEquals("://bb", linked);
  132       }
  133   
  134   }

Home » displaytag-1.1.1-src » org » displaytag » decorator » [javadoc | source]