001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexander T. Simbirtsev
019: * @version $Revision$
020: */package javax.swing.text.html;
021:
022: import java.net.URL;
023:
024: import javax.swing.BasicSwingTestCase;
025: import javax.swing.event.HyperlinkEvent.EventType;
026: import javax.swing.text.Element;
027:
028: public class HTMLFrameHyperlinkEventTest extends BasicSwingTestCase {
029:
030: HTMLFrameHyperlinkEvent event;
031:
032: /*
033: * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, Element, String)'
034: */
035: public void testHTMLFrameHyperlinkEventObjectEventTypeURLElementString()
036: throws Exception {
037: final Object source = new Object();
038: final EventType type = EventType.ENTERED;
039: final URL url = new URL("file:///");
040: final Element element = new HTMLDocument()
041: .getDefaultRootElement();
042: final String targetFrame = "targetFrame";
043:
044: HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(
045: source, type, url, element, targetFrame);
046: assertSame(source, event.getSource());
047: assertSame(type, event.getEventType());
048: assertSame(url, event.getURL());
049: assertSame(element, event.getSourceElement());
050: assertNull(event.getDescription());
051: assertSame(targetFrame, event.getTarget());
052:
053: event = new HTMLFrameHyperlinkEvent(source, type, null,
054: (Element) null, null);
055: assertSame(source, event.getSource());
056: assertSame(type, event.getEventType());
057: assertNull(event.getURL());
058: assertNull(event.getSourceElement());
059: assertNull(event.getDescription());
060: assertNull(event.getTarget());
061:
062: new NullPointerCase() {
063: public void exceptionalAction() throws Exception {
064: new HTMLFrameHyperlinkEvent(null, type, null,
065: (Element) null, null);
066: }
067: };
068: }
069:
070: /*
071: * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, String)'
072: */
073: public void testHTMLFrameHyperlinkEventObjectEventTypeURLString()
074: throws Exception {
075: final Object source = new Object();
076: final EventType type = EventType.ENTERED;
077: final URL url = new URL("file:///");
078: final String targetFrame = "targetFrame";
079:
080: HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(
081: source, type, url, targetFrame);
082: assertSame(source, event.getSource());
083: assertSame(type, event.getEventType());
084: assertSame(url, event.getURL());
085: assertNull(event.getSourceElement());
086: assertNull(event.getDescription());
087: assertSame(targetFrame, event.getTarget());
088:
089: event = new HTMLFrameHyperlinkEvent(source, type, null, null);
090: assertSame(source, event.getSource());
091: assertSame(type, event.getEventType());
092: assertNull(event.getURL());
093: assertNull(event.getSourceElement());
094: assertNull(event.getDescription());
095: assertNull(event.getTarget());
096:
097: new NullPointerCase() {
098: public void exceptionalAction() throws Exception {
099: new HTMLFrameHyperlinkEvent(null, type, null, null);
100: }
101: };
102: }
103:
104: /*
105: * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, String, String)'
106: */
107: public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringString()
108: throws Exception {
109: final Object source = new Object();
110: final EventType type = EventType.ENTERED;
111: final URL url = new URL("file:///");
112: final String targetFrame = "targetFrame";
113: final String descr = "description";
114:
115: HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(
116: source, type, url, descr, targetFrame);
117: assertSame(source, event.getSource());
118: assertSame(type, event.getEventType());
119: assertSame(url, event.getURL());
120: assertNull(event.getSourceElement());
121: assertSame(targetFrame, event.getTarget());
122: assertSame(descr, event.getDescription());
123:
124: event = new HTMLFrameHyperlinkEvent(source, type, null,
125: (String) null, (String) null);
126: assertSame(source, event.getSource());
127: assertSame(type, event.getEventType());
128: assertNull(event.getURL());
129: assertNull(event.getSourceElement());
130: assertNull(event.getDescription());
131: assertNull(event.getTarget());
132:
133: new NullPointerCase() {
134: public void exceptionalAction() throws Exception {
135: new HTMLFrameHyperlinkEvent(null, type, null,
136: (String) null, (String) null);
137: }
138: };
139: }
140:
141: /*
142: * Test method for 'javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent(Object, EventType, URL, String, Element, String)'
143: */
144: public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringElementString()
145: throws Exception {
146: final Object source = new Object();
147: final EventType type = EventType.ENTERED;
148: final URL url = new URL("file:///");
149: final Element element = new HTMLDocument()
150: .getDefaultRootElement();
151: final String targetFrame = "targetFrame";
152: final String descr = "description";
153:
154: HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(
155: source, type, url, descr, element, targetFrame);
156: assertSame(source, event.getSource());
157: assertSame(type, event.getEventType());
158: assertSame(url, event.getURL());
159: assertSame(element, event.getSourceElement());
160: assertSame(descr, event.getDescription());
161: assertSame(targetFrame, event.getTarget());
162:
163: event = new HTMLFrameHyperlinkEvent(source, type, null, null,
164: (Element) null, null);
165: assertSame(source, event.getSource());
166: assertSame(type, event.getEventType());
167: assertNull(event.getURL());
168: assertNull(event.getSourceElement());
169: assertNull(event.getDescription());
170: assertNull(event.getTarget());
171:
172: new NullPointerCase() {
173: public void exceptionalAction() throws Exception {
174: new HTMLFrameHyperlinkEvent(null, type, null, null,
175: (Element) null, null);
176: }
177: };
178: }
179: }
|