Repository navigation
Expand file tree
/
Copy pathIssue183Test.java
More file actions
77 lines (54 loc) · 1.69 KB
/
Copy pathIssue183Test.java
File metadata and controls
77 lines (54 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package org.mapdb;
import org.junit.Test;
import java.io.*;
import java.util.Map;
import static org.junit.Assert.assertEquals;
public class Issue183Test {
@Test
public void main(){
File f = UtilsTest.tempDbFile();
Map<String, String> map1;
TxMaker txMaker = DBMaker
.newFileDB(f)
.closeOnJvmShutdown()
.cacheDisable()
.makeTxMaker();
DB db = txMaker.makeTx();
map1 = db.createTreeMap("map1")
.valueSerializer(new StringSerializer())
.makeOrGet();
map1.put("foo", "bar");
db.commit();
db.close();
txMaker.close();
txMaker = DBMaker
.newFileDB(f)
.closeOnJvmShutdown()
.cacheDisable()
.makeTxMaker();
db = txMaker.makeTx();
map1 = db.createTreeMap("map1")
.valueSerializer(new StringSerializer())
.makeOrGet();
assertEquals("bar", map1.get("foo"));
map1.put("foo2", "bar2");
db.commit();
db.close();
txMaker.close();
}
private static final class StringSerializer implements Serializer<String>, Serializable {
private static final long serialVersionUID = -8356516782418439492L;
@Override
public void serialize(DataOutput out, String value) throws IOException {
out.writeUTF(value);
}
@Override
public String deserialize(DataInput in, int available) throws IOException {
return in.readUTF();
}
@Override
public int fixedSize() {
return -1;
}
}
}