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 78 79 80 81
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2002,2010 Oracle. All rights reserved.
*
* $Id: EnvironmentParamsTest.java,v 1.15.2.2 2010/01/04 15:30:43 cwl Exp $
*/
package com.sleepycat.je.config;
import junit.framework.TestCase;
import com.sleepycat.je.EnvironmentConfig;
public class EnvironmentParamsTest extends TestCase {
private IntConfigParam intParam =
new IntConfigParam("param.int",
new Integer(2),
new Integer(10),
new Integer(5),
false, // mutable
false);// for replication
private LongConfigParam longParam =
new LongConfigParam("param.long",
new Long(2),
new Long(10),
new Long(5),
false, // mutable
false);// for replication
private ConfigParam mvParam =
new ConfigParam("some.mv.param.#", null, true /* mutable */,
false /* for replication */);
/**
* Test param validation.
*/
public void testValidation() {
assertTrue(mvParam.isMultiValueParam());
try {
new ConfigParam(null, "foo", false /* mutable */,
false /* for replication */);
fail("should disallow null name");
} catch (IllegalArgumentException e) {
// expected.
}
/* Test bounds. These are all invalid and should fail */
checkValidateParam(intParam, "1");
checkValidateParam(intParam, "11");
checkValidateParam(longParam, "1");
checkValidateParam(longParam, "11");
}
/**
* Check that an invalid parameter isn't mistaken for a multivalue
* param.
*/
public void testInvalidVsMultiValue() {
try {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setConfigParam("je.maxMemory.stuff", "true");
fail("Should throw exception");
} catch (IllegalArgumentException IAE) {
// expected
}
}
/* Helper to catch expected exceptions */
private void checkValidateParam(ConfigParam param, String value) {
try {
param.validateValue(value);
fail("Should throw exception");
} catch (IllegalArgumentException e) {
// expect this exception
}
}
}
|