KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > XMLAutoupdateTypeTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.autoupdate;
21
22 import junit.framework.TestCase;
23 import junit.framework.*;
24 import java.net.MalformedURLException JavaDoc;
25 import java.net.URL JavaDoc;
26 import java.net.URLEncoder JavaDoc;
27 import java.text.MessageFormat JavaDoc;
28 import java.util.StringTokenizer JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.util.Collections JavaDoc;
31 import java.util.MissingResourceException JavaDoc;
32 import java.util.ResourceBundle JavaDoc;
33 import org.openide.util.NbBundle;
34 import org.openide.filesystems.FileObject;
35 import org.openide.filesystems.FileStateInvalidException;
36 import org.openide.filesystems.FileSystem;
37 import org.openide.util.HelpCtx;
38
39 /**
40  *
41  * @author Jirka Rechtacek
42  */

43 public class XMLAutoupdateTypeTest extends TestCase {
44     
45     public XMLAutoupdateTypeTest (String JavaDoc testName) {
46         super (testName);
47     }
48
49     protected void setUp () throws Exception JavaDoc {
50     }
51
52     public static Test suite () {
53         TestSuite suite = new TestSuite(XMLAutoupdateTypeTest.class);
54         
55         return suite;
56     }
57
58     public void testGetUrlSpec () {
59         XMLAutoupdateType instance = new XMLAutoupdateType();
60         
61         String JavaDoc expResult = instance.getDefaultURL ();
62         String JavaDoc result = instance.getUrlSpec();
63         assertEquals(expResult, result);
64     }
65
66     public void testSetCorrectUrlSpec () {
67         String JavaDoc spec = "http://localhost/updates.xml";
68         
69         XMLAutoupdateType instance = new XMLAutoupdateType();
70         instance.setUrlSpec(spec);
71         
72         assertEquals (spec, instance.getUrlSpec ());
73     }
74
75     public void testSetWrongUrlSpec () {
76         String JavaDoc spec = "dummy.xml";
77         
78         XMLAutoupdateType instance = new XMLAutoupdateType();
79         
80         String JavaDoc old = instance.getUrlSpec ();
81         
82         try {
83             instance.setUrlSpec(spec);
84             fail ("IllegalArgumentException should be thrown.");
85         } catch (IllegalArgumentException JavaDoc iae) {
86             // correct, it's expected exception
87
}
88         
89         assertEquals (old, instance.getUrlSpec ());
90     }
91
92     public void testGetURL () throws MalformedURLException JavaDoc {
93         XMLAutoupdateType instance = new XMLAutoupdateType();
94         
95         URL JavaDoc expResult = new URL JavaDoc (instance.getUrlSpec ());
96         URL JavaDoc result = instance.getURL();
97         assertEquals(expResult, result);
98         
99         // TODO add your test code below by replacing the default call to fail.
100
}
101
102     public void testSetURL () throws MalformedURLException JavaDoc {
103         URL JavaDoc url = new URL JavaDoc ("http://localhost/updates.xml");
104         
105         XMLAutoupdateType instance = new XMLAutoupdateType();
106         instance.setURL(url);
107         
108         assertEquals (url, instance.getURL ());
109     }
110
111 }
112
Popular Tags