• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/test/scr037/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2009 Oracle.  All rights reserved.
5 *
6 */
7using System;
8using System.Collections.Generic;
9using System.IO;
10using System.Text;
11using System.Xml;
12using NUnit.Framework;
13using BerkeleyDB;
14
15namespace CsharpAPITest
16{
17	[TestFixture]
18	public class HashDatabaseConfigTest : DatabaseConfigTest
19	{
20		private string testFixtureHome;
21		private string testFixtureName;
22		private string testName;
23
24		[TestFixtureSetUp]
25		public void RunBeforeTests()
26		{
27			testFixtureName = "HashDatabaseConfigTest";
28			testFixtureHome = "./TestOut/" + testFixtureName;
29
30			Configuration.ClearDir(testFixtureHome);
31		}
32
33		[Test]
34		override public void TestConfigWithoutEnv()
35		{
36			testName = "TestConfigWithoutEnv";
37			XmlElement xmlElem = Configuration.TestSetUp(
38			    testFixtureName, testName);
39			HashDatabaseConfig hashConfig = new HashDatabaseConfig();
40			Config(xmlElem, ref hashConfig, true);
41			Confirm(xmlElem, hashConfig, true);
42		}
43
44
45		public static void Confirm(XmlElement xmlElement,
46		    HashDatabaseConfig hashDBConfig, bool compulsory)
47		{
48			DatabaseConfig dbConfig = hashDBConfig;
49			Confirm(xmlElement, dbConfig, compulsory);
50
51			// Confirm Hash database specific configuration.
52			Configuration.ConfirmCreatePolicy(xmlElement,
53			    "Creation", hashDBConfig.Creation, compulsory);
54			Configuration.ConfirmDuplicatesPolicy(xmlElement,
55			    "Duplicates", hashDBConfig.Duplicates, compulsory);
56			Configuration.ConfirmUint(xmlElement, "FillFactor",
57			    hashDBConfig.FillFactor, compulsory);
58			Configuration.ConfirmUint(xmlElement, "NumElements",
59			    hashDBConfig.TableSize, compulsory);
60		}
61
62		public static void Config(XmlElement xmlElement,
63		    ref HashDatabaseConfig hashDBConfig, bool compulsory)
64		{
65			uint fillFactor = new uint();
66			uint numElements = new uint();
67			DatabaseConfig dbConfig = hashDBConfig;
68			Config(xmlElement, ref dbConfig, compulsory);
69
70			// Configure specific fields/properties of Hash db
71			Configuration.ConfigCreatePolicy(xmlElement,
72			    "Creation", ref hashDBConfig.Creation,
73			    compulsory);
74			Configuration.ConfigDuplicatesPolicy(xmlElement,
75			    "Duplicates", ref hashDBConfig.Duplicates,
76			    compulsory);
77			if (Configuration.ConfigUint(xmlElement, "FillFactor",
78			    ref fillFactor, compulsory))
79				hashDBConfig.FillFactor = fillFactor;
80			if (Configuration.ConfigUint(xmlElement, "NumElements",
81			    ref numElements, compulsory))
82				hashDBConfig.TableSize = numElements;
83		}
84	}
85}
86