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.tests.java.util.prefs; 18 19import java.io.NotSerializableException; 20import java.util.prefs.NodeChangeEvent; 21import java.util.prefs.Preferences; 22import junit.framework.TestCase; 23import org.apache.harmony.testframework.serialization.SerializationTest; 24 25/** 26 * 27 */ 28public class NodeChangeEventTest extends TestCase { 29 30 NodeChangeEvent event; 31 32 public void testConstructor() { 33 event = new NodeChangeEvent(Preferences.systemRoot(), Preferences 34 .userRoot()); 35 assertSame(Preferences.systemRoot(), event.getParent()); 36 assertSame(Preferences.userRoot(), event.getChild()); 37 assertSame(Preferences.systemRoot(), event.getSource()); 38 } 39 40 public void testConstructorNullParam() { 41 try { 42 event = new NodeChangeEvent(null, Preferences.userRoot()); 43 fail(); 44 } catch (IllegalArgumentException e) { 45 } 46 47 event = new NodeChangeEvent(Preferences.systemRoot(), null); 48 assertSame(Preferences.systemRoot(), event.getParent()); 49 assertNull(event.getChild()); 50 assertSame(Preferences.systemRoot(), event.getSource()); 51 } 52 53 public void testSerialization() throws Exception { 54 55 event = new NodeChangeEvent(Preferences.systemRoot(), null); 56 57 try { 58 SerializationTest.copySerializable(event); 59 fail("No expected NotSerializableException"); 60 } catch (NotSerializableException e) { 61 } 62 } 63} 64