1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package org.apache.harmony.prefs.tests.java.util.prefs; 18 19import java.io.NotSerializableException; 20import java.util.prefs.NodeChangeEvent; 21import java.util.prefs.Preferences; 22 23import junit.framework.TestCase; 24 25import org.apache.harmony.testframework.serialization.SerializationTest; 26 27/** 28 * 29 */ 30public class NodeChangeEventTest extends TestCase { 31 32 NodeChangeEvent event; 33 34 public void testConstructor() { 35 event = new NodeChangeEvent(Preferences.systemRoot(), Preferences 36 .userRoot()); 37 assertSame(Preferences.systemRoot(), event.getParent()); 38 assertSame(Preferences.userRoot(), event.getChild()); 39 assertSame(Preferences.systemRoot(), event.getSource()); 40 } 41 42 public void testConstructorNullParam() { 43 try { 44 event = new NodeChangeEvent(null, Preferences.userRoot()); 45 fail(); 46 } catch (IllegalArgumentException e) { 47 } 48 49 event = new NodeChangeEvent(Preferences.systemRoot(), null); 50 assertSame(Preferences.systemRoot(), event.getParent()); 51 assertNull(event.getChild()); 52 assertSame(Preferences.systemRoot(), event.getSource()); 53 } 54 55 public void testSerialization() throws Exception { 56 57 event = new NodeChangeEvent(Preferences.systemRoot(), null); 58 59 try { 60 SerializationTest.copySerializable(event); 61 fail("No expected NotSerializableException"); 62 } catch (NotSerializableException e) { 63 } 64 } 65} 66