1 /* post.java -- |
|
2 Copyright (c) 2004 by Free Software Foundation, Inc. |
|
3 Written by Michael Koch <konqueror@gmx.de> |
|
4 |
|
5 This program is free software; you can redistribute it and/or modify |
|
6 it under the terms of the GNU General Public License as published |
|
7 by the Free Software Foundation, version 2. (see COPYING) |
|
8 |
|
9 This program is distributed in the hope that it will be useful, but |
|
10 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 GNU General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU General Public License |
|
15 along with this program; if not, write to the Free Software Foundation |
|
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA */ |
|
17 |
|
18 package gnu.testlet.java.net.URLConnection; |
|
19 |
|
20 import gnu.testlet.TestHarness; |
|
21 import gnu.testlet.Testlet; |
|
22 |
|
23 import java.net.*; |
|
24 import java.io.IOException; |
|
25 |
|
26 public class post implements Testlet |
|
27 { |
|
28 public void test(TestHarness h) |
|
29 { |
|
30 try |
|
31 { |
|
32 URL url = new URL("http://sources.redhat.com/mauve/testarea/index.html"); |
|
33 |
|
34 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
|
35 conn.setDoOutput(true); // overwrite default. |
|
36 |
|
37 h.check(conn.getRequestMethod(), "GET", "request method is 'GET'"); |
|
38 |
|
39 conn.getOutputStream(); |
|
40 |
|
41 h.check(conn.getRequestMethod(), "POST", "request method is 'POST'"); |
|
42 } |
|
43 catch (MalformedURLException e) |
|
44 { |
|
45 h.fail("Error in test header - Exception " + e); |
|
46 } |
|
47 catch (IOException e) |
|
48 { |
|
49 h.fail("IO error caught - " + e); |
|
50 } |
|
51 } |
|
52 } |
|