KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > data > LinkUnitTest


1 /*
2  * $Id: LinkUnitTest.java,v 1.1 2004/08/05 01:29:18 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing.data;
9
10 import java.net.MalformedURLException JavaDoc;
11 import java.net.URL JavaDoc;
12
13 import junit.framework.Test;
14 import junit.framework.TestCase;
15 import junit.framework.TestSuite;
16
17 /**
18  * A JUnit test case for the Link class
19  */

20 public class LinkUnitTest extends TestCase {
21
22     private static String JavaDoc testText = "This is a foo";
23     private static String JavaDoc testTarget = "_blank";
24     private static String JavaDoc testTemplate = "http://bugz.sfbay/cgi-bin/showbug?cat=@{1}&subcat=@{2}";
25     private static String JavaDoc[] testArgs = { "java", "classes_beans" };
26     //
27
private static String JavaDoc testURLStr = "http://bugz.sfbay/cgi-bin/showbug?cat=java&subcat=classes_beans";
28
29     private static URL JavaDoc testURL = null;
30     
31     public LinkUnitTest() {
32     super("com.sun.jdnc.Link unit test");
33     }
34
35     protected void setUp() {
36     try {
37         testURL = new URL JavaDoc(testURLStr);
38     } catch (MalformedURLException JavaDoc ex) {
39         throw new RuntimeException JavaDoc(ex);
40     }
41     }
42
43     /**
44      * A simple test to ensure that values in the 3 arg ctor are preserved
45      */

46     public void testCtor1() {
47     Link link = new Link(testText, testTarget, testURL);
48
49     assertEquals(testText, link.getText());
50     assertEquals(testTarget, link.getTarget());
51     assertEquals(testURL, link.getURL());
52     }
53
54     /**
55      * Test the 4 arg ctor which will construct a URL using substitition
56      * in the last two args
57      */

58     public void testCtor2() {
59     Link link = new Link(testText, testTarget, testTemplate, testArgs);
60
61     assertEquals(testText, link.getText());
62     assertEquals(testTarget, link.getTarget());
63     assertEquals(testURL, link.getURL());
64     }
65 }
66
Popular Tags