01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Vadim L. Bogdanov
20: * @version $Revision$
21: */package javax.swing.text.html;
22:
23: import java.util.Arrays;
24:
25: import javax.swing.SwingTestCase;
26:
27: public class FormSubmitEventTest extends SwingTestCase {
28:
29: public FormSubmitEventTest(final String name) {
30: super (name);
31: }
32:
33: protected void setUp() throws Exception {
34: super .setUp();
35: }
36:
37: protected void tearDown() throws Exception {
38: super .tearDown();
39: }
40:
41: public void testGetData() {
42: if (!isHarmony()) {
43: return;
44: }
45:
46: String data = "data";
47: FormSubmitEvent.MethodType method = FormSubmitEvent.MethodType.GET;
48: FormSubmitEvent event = new FormSubmitEvent(new Object(), null,
49: null, null, null, null, method, data);
50:
51: assertSame(data, event.getData());
52: }
53:
54: public void testGetMethod() {
55: if (!isHarmony()) {
56: return;
57: }
58:
59: String data = "data";
60: FormSubmitEvent.MethodType method = FormSubmitEvent.MethodType.GET;
61: FormSubmitEvent event = new FormSubmitEvent(new Object(), null,
62: null, null, null, null, method, data);
63:
64: assertSame(method, event.getMethod());
65: }
66:
67: public void testMethodType() {
68: assertSame(FormSubmitEvent.MethodType.GET,
69: FormSubmitEvent.MethodType.valueOf("GET"));
70: assertSame(FormSubmitEvent.MethodType.POST,
71: FormSubmitEvent.MethodType.valueOf("POST"));
72: testExceptionalCase(new IllegalArgumentCase() {
73: public void exceptionalAction() throws Exception {
74: FormSubmitEvent.MethodType.valueOf("SOMETHING_ELSE");
75: }
76: });
77:
78: FormSubmitEvent.MethodType[] values = FormSubmitEvent.MethodType
79: .values();
80: assertEquals(2, values.length);
81: assertEquals(0, Arrays.asList(values).indexOf(
82: FormSubmitEvent.MethodType.GET));
83: assertEquals(1, Arrays.asList(values).indexOf(
84: FormSubmitEvent.MethodType.POST));
85: }
86: }
|