2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package tests.api.java.util;
20 import dalvik.annotation.TestTargetNew;
21 import dalvik.annotation.TestTargets;
22 import dalvik.annotation.TestLevel;
23 import dalvik.annotation.TestTargetClass;
25 import java.util.EventObject;
27 @TestTargetClass(EventObject.class)
28 public class EventObjectTest extends junit.framework.TestCase {
32 EventObject myEventObject;
35 * @tests java.util.EventObject#EventObject(java.lang.Object)
38 level = TestLevel.COMPLETE,
39 notes = "See setUp method.",
40 method = "EventObject",
41 args = {java.lang.Object.class}
43 public void test_ConstructorLjava_lang_Object() {
45 new EventObject(null);
46 fail ("IllegalArgumentException expected");
47 } catch (IllegalArgumentException e) {
53 * @tests java.util.EventObject#getSource()
56 level = TestLevel.COMPLETE,
61 public void test_getSource() {
62 // Test for method java.lang.Object java.util.EventObject.getSource()
63 assertTrue("Wrong source returned",
64 myEventObject.getSource() == myObject);
68 * @tests java.util.EventObject#toString()
71 level = TestLevel.COMPLETE,
76 public void test_toString() {
77 // Test for method java.lang.String java.util.EventObject.toString()
78 assertTrue("Incorrect toString returned: " + myEventObject.toString(),
79 myEventObject.toString().indexOf(
80 "java.util.EventObject[source=java.lang.Object@") == 0);
84 * Sets up the fixture, for example, open a network connection. This method
85 * is called before a test is executed.
87 protected void setUp() {
88 myObject = new Object();
89 myEventObject = new EventObject(myObject);
93 * Tears down the fixture, for example, close a network connection. This
94 * method is called after a test is executed.
96 protected void tearDown() {