Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / test / csharp / MPoolConfigTest.cs
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2009, 2012 Oracle and/or its affiliates.  All rights reserved.
5  *
6  */
7 using System;
8 using System.Collections;
9 using System.Collections.Generic;
10 using System.IO;
11 using System.Text;
12 using System.Xml;
13 using NUnit.Framework;
14 using BerkeleyDB;
15
16 namespace CsharpAPITest
17 {
18         [TestFixture]
19         public class MPoolConfigTest : CSharpTestFixture
20         {
21                 [TestFixtureSetUp]
22                 public void SetUpTestFixture()
23                 {
24                         testFixtureName = "MPoolConfigTest";
25                         base.SetUpTestfixture();
26                 }
27
28                 [Test]
29                 public void TestConfig()
30                 {
31                         testName = "TestConfig";
32                         SetUpTest(false);
33
34                         // Config and confirm mpool subsystem configuration.
35                         MPoolConfig mpoolConfig = new MPoolConfig();
36                         XmlElement xmlElem = Configuration.TestSetUp(
37                             testFixtureName, testName);
38                         Config(xmlElem, ref mpoolConfig, true);
39                         Confirm(xmlElem, mpoolConfig, true);
40                 }
41
42                 public static void Confirm(XmlElement
43                     xmlElement, MPoolConfig mpoolConfig, bool compulsory)
44                 {
45                         Configuration.ConfirmCacheSize(xmlElement, 
46                             "CacheSize", mpoolConfig.CacheSize, compulsory);
47                         Configuration.ConfirmCacheSize(xmlElement,
48                             "MaxCacheSize", mpoolConfig.MaxCacheSize, 
49                             compulsory);
50                         Configuration.ConfirmInt(xmlElement, "MaxOpenFiles",
51                             mpoolConfig.MaxOpenFiles, compulsory);
52                         Configuration.ConfirmUint(xmlElement,
53                             "MMapSize",
54                             mpoolConfig.MMapSize, compulsory);
55                         Configuration.ConfirmMaxSequentialWrites(xmlElement,
56                             "MaxSequentialWrites",
57                             mpoolConfig.SequentialWritePause, 
58                             mpoolConfig.MaxSequentialWrites, compulsory);
59                 }
60
61                 public static void Config(XmlElement
62                     xmlElement, ref MPoolConfig mpoolConfig, bool compulsory)
63                 {
64                         uint uintValue = new uint();
65                         int intValue = new int();
66
67                         Configuration.ConfigCacheInfo(xmlElement,
68                             "CacheSize", ref mpoolConfig.CacheSize, compulsory);
69                         Configuration.ConfigCacheInfo(xmlElement,
70                             "MaxCacheSize", ref mpoolConfig.MaxCacheSize, 
71                             compulsory);
72                         if (Configuration.ConfigInt(xmlElement, "MaxOpenFiles",
73                             ref intValue, compulsory))
74                                 mpoolConfig.MaxOpenFiles = intValue;
75                         Configuration.ConfigMaxSequentialWrites(
76                             xmlElement, "MaxSequentialWrites", mpoolConfig,
77                             compulsory);
78                         if (Configuration.ConfigUint(xmlElement,
79                             "MMapSize", ref uintValue, compulsory))
80                                 mpoolConfig.MMapSize = uintValue;
81                 }
82         }
83 }