001 /* 002 * Copyright 2005,2009 Ivan SZKIBA 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.ini4j; 017 018 import org.ini4j.Registry.Type; 019 020 import static org.junit.Assert.assertEquals; 021 import static org.junit.Assert.assertNull; 022 import static org.junit.Assert.assertSame; 023 024 import org.junit.Test; 025 026 public class BasicRegistryKeyTest extends Ini4jCase 027 { 028 private static final String KEY = "key"; 029 private static final String DUMMY = "dummy"; 030 private static final String OPTION = "option"; 031 032 @Test public void testWrapped() throws Exception 033 { 034 BasicRegistry reg = new BasicRegistry(); 035 Registry.Key parent = reg.add(KEY); 036 Registry.Key child = parent.addChild(DUMMY); 037 038 assertSame(parent, child.getParent()); 039 assertSame(child, parent.getChild(DUMMY)); 040 Registry.Key kid = child.addChild(KEY); 041 042 assertSame(kid, parent.lookup(DUMMY, KEY)); 043 parent.put(OPTION, DUMMY); 044 parent.putType(OPTION, Type.REG_BINARY); 045 assertEquals(Type.REG_BINARY, parent.getType(OPTION)); 046 parent.removeType(OPTION); 047 assertNull(parent.getType(OPTION)); 048 parent.putType(OPTION, Type.REG_BINARY); 049 parent.remove(OPTION); 050 assertNull(parent.getType(OPTION)); 051 } 052 }