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 package org.apache.commons.configuration.plist; 018 019 import org.apache.commons.configuration.AbstractConfiguration; 020 import org.apache.commons.configuration.event.AbstractTestConfigurationEvents; 021 import org.junit.Test; 022 023 /** 024 * A base test class for testing the events generated by the plist 025 * configurations. This class especially checks events related to the special 026 * handling of byte arrays. 027 * 028 * @version $Id: AbstractTestPListEvents.java 1225901 2011-12-30 19:37:46Z oheger $ 029 */ 030 public abstract class AbstractTestPListEvents extends 031 AbstractTestConfigurationEvents 032 { 033 /** Constant for the name of the byte array property. */ 034 private static final String TEST_PROPBYTE = "byteData"; 035 036 /** Constant for the test byte array used for testing. */ 037 private static final byte[] TEST_DATA = 038 { 1, 2, 3 }; 039 040 /** 041 * Tests the events generated by an added byte array property. 042 */ 043 @Test 044 public void testAddByteArrayPropertyEvent() 045 { 046 config.addProperty(TEST_PROPBYTE, TEST_DATA); 047 l.checkEvent(AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_PROPBYTE, 048 TEST_DATA, true); 049 l.checkEvent(AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_PROPBYTE, 050 TEST_DATA, false); 051 l.done(); 052 } 053 054 /** 055 * Tests the events generated by setting a byte array property. 056 */ 057 @Test 058 public void testSetByteArrayPropertyEvent() 059 { 060 config.setProperty(TEST_PROPBYTE, TEST_DATA); 061 l.checkEvent(AbstractConfiguration.EVENT_SET_PROPERTY, TEST_PROPBYTE, 062 TEST_DATA, true); 063 l.checkEvent(AbstractConfiguration.EVENT_SET_PROPERTY, TEST_PROPBYTE, 064 TEST_DATA, false); 065 l.done(); 066 } 067 }