1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.ini4j;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertSame;
21 import static org.junit.Assert.assertTrue;
22
23 import org.junit.Test;
24
25 public class BasicRegistryTest extends Ini4jCase
26 {
27 private static final String KEY = "key";
28 private static final String DUMMY = "dummy";
29 private static final String VERSION = "Windows Registry Editor Version 5.00";
30
31 @Test public void testVersion()
32 {
33 BasicRegistry reg = new BasicRegistry();
34
35 assertEquals(VERSION, reg.getVersion());
36 reg.setVersion(DUMMY);
37 assertEquals(DUMMY, reg.getVersion());
38 }
39
40 @Test public void testWrapped() throws Exception
41 {
42 BasicRegistry reg = new BasicRegistry();
43 Registry.Key key1 = reg.add(KEY);
44 Registry.Key key2 = reg.add(KEY);
45
46 assertNotNull(key1);
47 assertNotNull(key2);
48 assertTrue(reg.get(KEY) instanceof Registry.Key);
49 assertTrue(reg.get(KEY, 1) instanceof Registry.Key);
50 Registry.Key key3 = new BasicRegistryKey(reg, KEY);
51
52 assertSame(key1, reg.put(KEY, key3, 0));
53 assertSame(key2, reg.put(KEY, key3));
54 assertSame(key3, reg.remove(KEY, 1));
55 assertSame(key3, reg.remove(KEY));
56 key1 = reg.add(KEY);
57 assertSame(key1, reg.remove(key1));
58 }
59 }