blob: 9866ed49307481d59e848f870a0ea8f03423d12f (
plain)
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
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*
* $Id: TestSameDbt.java,v 1.4 2002/01/23 14:29:51 bostic Exp $
*/
/*
* Simple test for get/put of specific values.
*/
package com.sleepycat.test;
import com.sleepycat.db.*;
import java.io.FileNotFoundException;
public class TestSameDbt
{
public static void main(String[] args)
{
try {
Db db = new Db(null, 0);
db.open(null, "my.db", null, Db.DB_BTREE, Db.DB_CREATE, 0644);
// try reusing the dbt
Dbt keydatadbt = new Dbt("stuff".getBytes());
int gotexcept = 0;
try {
db.put(null, keydatadbt, keydatadbt, 0);
}
catch (DbException dbe) {
System.out.println("got expected Db Exception: " + dbe);
gotexcept++;
}
if (gotexcept != 1) {
System.err.println("Missed exception");
System.out.println("** FAIL **");
}
else {
System.out.println("Test succeeded.");
}
}
catch (DbException dbe) {
System.err.println("Db Exception: " + dbe);
}
catch (FileNotFoundException fnfe) {
System.err.println("FileNotFoundException: " + fnfe);
}
}
}
|