KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > config > EnvironmentParamsTest


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: EnvironmentParamsTest.java,v 1.8 2006/11/06 20:36:58 linda Exp $
7  */

8
9 package com.sleepycat.je.config;
10
11 import junit.framework.TestCase;
12
13 public class EnvironmentParamsTest extends TestCase {
14
15
16     private IntConfigParam intParam =
17         new IntConfigParam("param.int",
18                new Integer JavaDoc(2),
19                new Integer JavaDoc(10),
20                new Integer JavaDoc(5),
21                            false, // mutable
22
false, // for replication
23
"test int param");
24
25     private LongConfigParam longParam =
26         new LongConfigParam("param.long",
27                 new Long JavaDoc(2),
28                 new Long JavaDoc(10),
29                 new Long JavaDoc(5),
30                             false, // mutable
31
false, // for replication
32
"test long param");
33
34
35     /**
36      * Test param validation
37      */

38     public void testValidation() {
39         try {
40             ConfigParam param = new ConfigParam(null,
41                                                 "foo",
42                                                 false, // mutable
43
false, // for replication
44
"foo param");
45             fail("should disallow null name");
46         } catch (IllegalArgumentException JavaDoc e) {
47             // expected.
48
}
49
50         /* Test bounds. These are all invalid and should fail */
51         checkValidateParam(intParam, "1");
52         checkValidateParam(intParam, "11");
53         checkValidateParam(longParam, "1");
54         checkValidateParam(longParam, "11");
55     }
56
57     /* Helper to catch expected exceptions */
58     private void checkValidateParam(ConfigParam param, String JavaDoc value) {
59         try {
60             param.validateValue(value);
61             fail("Should throw exception");
62         } catch (IllegalArgumentException JavaDoc e) {
63             // expect this exception
64
}
65     }
66 }
67
Popular Tags