KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > taskblocks > bugzilla > BugzillaSubmitterTest


1 /*
2  * Copyright (C) Jakub Neubauer, 2007
3  *
4  * This file is part of TaskBlocks
5  *
6  * TaskBlocks is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * TaskBlocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */

19
20 package taskblocks.bugzilla;
21
22 import java.io.FileNotFoundException JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.net.MalformedURLException JavaDoc;
25 import java.net.UnknownHostException JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import javax.xml.parsers.ParserConfigurationException JavaDoc;
30
31 import org.xml.sax.SAXException JavaDoc;
32
33
34 import junit.framework.TestCase;
35
36 public class BugzillaSubmitterTest extends TestCase {
37     
38     public void notestSubmit() {
39         Map JavaDoc<String JavaDoc, String JavaDoc> formData = new HashMap JavaDoc<String JavaDoc, String JavaDoc>();
40         formData.put(BugzillaSubmitter.KEYWORDS, "Plan");
41         formData.put(BugzillaSubmitter.PRODUCT, "TestProduct");
42         formData.put(BugzillaSubmitter.VERSION, "unspecified");
43         formData.put(BugzillaSubmitter.COMPONENT, "TestComponent");
44         formData.put(BugzillaSubmitter.HARDWARE, "All");
45         formData.put(BugzillaSubmitter.OS, "All");
46         formData.put(BugzillaSubmitter.PRIORITY, "P2");
47         formData.put(BugzillaSubmitter.SEVERITY, "enhancement");
48         formData.put(BugzillaSubmitter.STATUS, "NEW");
49         formData.put(BugzillaSubmitter.ASSIGNED_TO, "j.neubauer@cz.gmc.net");
50         formData.put(BugzillaSubmitter.SUMMARY, "Test Bug");
51         formData.put(BugzillaSubmitter.DESCRIPTION, "Description of Test Bug");
52         formData.put(BugzillaSubmitter.ESTIMATED_TIME, "16");
53         formData.put(BugzillaSubmitter.STATUS_WHITEBOARD, "230407-240407");
54         formData.put(BugzillaSubmitter.BLOCKS, "1,2");
55
56         try {
57             String JavaDoc bugId = new BugzillaSubmitter().submit(
58                     "http://jakubpc/bugzilla-3.0", "j.neubauer@cz.gmc.net", "heslo",
59                     formData);
60             System.out.println("Submitted bug #" + bugId);
61         } catch (UnknownHostException JavaDoc e) {
62             System.err.println("Unknown host: " + e.getMessage());
63             System.exit(2);
64         } catch (FileNotFoundException JavaDoc e) {
65             System.err.println("Page not found: " + e.getMessage());
66             System.exit(2);
67         } catch (IOException JavaDoc e) {
68             System.err.println(e.getClass().getSimpleName() + ": " + e.getMessage());
69             System.exit(2);
70         } catch (Exception JavaDoc e) {
71             System.err.println(e.getMessage());
72             System.exit(2);
73         }
74     }
75     
76     public void testQuery() {
77         try {
78             String JavaDoc result = new BugzillaSubmitter().query("http://wi", "j.neubauer@gmc.net", "abba", new String JavaDoc[] {"31396", "31397"});
79             
80             System.out.println(result);
81         } catch (MalformedURLException JavaDoc e) {
82             System.err.println(e.getMessage());
83             System.exit(2);
84         } catch (IOException JavaDoc e) {
85             System.err.println(e.getMessage());
86             System.exit(2);
87         } catch (SAXException JavaDoc e) {
88             System.err.println(e.getMessage());
89             System.exit(2);
90         } catch (ParserConfigurationException JavaDoc e) {
91             System.err.println(e.getMessage());
92             System.exit(2);
93         }
94     }
95     
96
97 }
98
Popular Tags