public void ConfigurationObjectIsNotModifiedIfThereArePolicyOverridesButGroupPoliciesAreDisabled()
        {
            OracleConnectionData connectionData = new OracleConnectionData();

            connectionData.Name = "data1";
            connectionData.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connectionData.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connectionData);

            MockRegistryKey machinePackageKey = new MockRegistryKey(false);

            machineKey.AddSubKey("data1", machinePackageKey);
            machinePackageKey.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                             "package13=prefix13; package14=prefix14; package15=prefix15");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(2, connectionData.Packages.Count);
            Assert.IsNotNull(connectionData.Packages.Get("package11"));
            Assert.AreEqual("prefix11", connectionData.Packages.Get("package11").Prefix);
            Assert.IsNotNull(connectionData.Packages.Get("package12"));
            Assert.AreEqual("prefix12", connectionData.Packages.Get("package12").Prefix);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackageKey));
        }
        public void Given()
        {
            // Setup connection strings
            configurationSource = new DictionaryConfigurationSource();
            var connectionStringsSection = new ConnectionStringsSection();

            connectionStringsSection.ConnectionStrings.Add(
                new ConnectionStringSettings
            {
                Name             = "myConnectionName",
                ConnectionString = "myConnectionString",
                ProviderName     = "System.Data.OracleClient"
            }
                );

            configurationSource.Add("connectionStrings", connectionStringsSection);

            // Setup oracle configuration sections
            var oracleConnectionData = new OracleConnectionData {
                Name = "myConnectionName"
            };

            oracleConnectionData.Packages.Add(new OraclePackageData("foo", "bar"));

            var oracleSettings = new OracleConnectionSettings();

            oracleSettings.OracleConnectionsData.Add(oracleConnectionData);
            configurationSource.Add(OracleConnectionSettings.SectionName, oracleSettings);


            settings = new DatabaseSyntheticConfigSettings(configurationSource.GetSection);
        }
        public void OracleConnectionWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled()
        {
            OracleConnectionData connectionData1 = new OracleConnectionData();

            connectionData1.Name = "data1";
            section.OracleConnectionsData.Add(connectionData1);
            OracleConnectionData connectionData2 = new OracleConnectionData();

            connectionData2.Name = "data2";
            section.OracleConnectionsData.Add(connectionData2);

            MockRegistryKey machinePackage1Key = new MockRegistryKey(false);

            machineKey.AddSubKey("data1", machinePackage1Key);
            machinePackage1Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false);
            MockRegistryKey machinePackage2Key = new MockRegistryKey(false);

            machineKey.AddSubKey("data2", machinePackage2Key);
            machinePackage2Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, true);
            machinePackage2Key.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                              "package24=prefix24");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(2, section.OracleConnectionsData.Count);
            Assert.IsNotNull(section.OracleConnectionsData.Get("data1"));
            Assert.IsNotNull(section.OracleConnectionsData.Get("data2"));

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackage1Key, machinePackage2Key));
        }
        /// <summary>
        /// Creates the <see cref="OracleConnectionSetting"/> instances that describe the configurationObject.
        /// </summary>
        /// <param name="connectionData">The configuration object for instances that must be managed.</param>
        /// <param name="wmiSettings">A collection to where the generated WMI objects are to be added.</param>
        public static void GenerateOracleConnectionSettingWmiObjects(OracleConnectionData connectionData,
                                                                     ICollection <ConfigurationSetting> wmiSettings)
        {
            string[] packages = GeneratePackagesArray(connectionData.Packages);

            wmiSettings.Add(new OracleConnectionSetting(connectionData, connectionData.Name, packages));
        }
        bool OverrideWithGroupPoliciesForOracleConnection(OracleConnectionData connectionData,
                                                          bool readGroupPolicies,
                                                          IRegistryKey machineKey,
                                                          IRegistryKey userKey)
        {
            if (readGroupPolicies)
            {
                IRegistryKey policyKey = machineKey ?? userKey;
                if (policyKey != null)
                {
                    if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value)
                    {
                        return(false);
                    }
                    try
                    {
                        String packagesOverride = policyKey.GetStringValue(PackagesPropertyName);

                        connectionData.Packages.Clear();
                        Dictionary <String, String> packagesDictionary = new Dictionary <string, string>();
                        KeyValuePairParser.ExtractKeyValueEntries(packagesOverride, packagesDictionary);
                        foreach (KeyValuePair <String, String> kvp in packagesDictionary)
                        {
                            connectionData.Packages.Add(new OraclePackageData(kvp.Key, kvp.Value));
                        }
                    }
                    catch (RegistryAccessException ex)
                    {
                        LogExceptionWhileOverriding(ex);
                    }
                }
            }

            return(true);
        }
        void IContainerPolicyCreator.CreatePolicies(
            IPolicyList policyList,
            string instanceName,
            ConfigurationElement configurationObject,
            IConfigurationSource configurationSource)
        {
            ConnectionStringSettings castConfigurationObject = (ConnectionStringSettings)configurationObject;
            IList <IOraclePackage>   packages = new IOraclePackage[0];
            OracleConnectionSettings oracleConnectionSettings = OracleConnectionSettings.GetSettings(configurationSource);

            if (oracleConnectionSettings != null)
            {
                OracleConnectionData oracleConnectionData
                    = oracleConnectionSettings.OracleConnectionsData.Get(castConfigurationObject.Name);
                if (oracleConnectionData != null)
                {
                    packages = new List <IOraclePackage>(from op in oracleConnectionData.Packages select(IOraclePackage) op);
                }
            }
            new PolicyBuilder <OracleDatabase, ConnectionStringSettings>(
                instanceName,
                castConfigurationObject,
                c => new OracleDatabase(c.ConnectionString, packages))
            .AddPoliciesToPolicyList(policyList);
        }
        public void Build()
        {
            ConnectionStringsSectionNode node = hierarchy.FindNodeByType(typeof(ConnectionStringsSectionNode)) as ConnectionStringsSectionNode;

            if (null == node)
            {
                LogError(hierarchy.RootNode, Resources.ExceptionMissingConnectionStrings);
                return;
            }

            for (int index = 0; index < oracleConnectionSettings.OracleConnectionsData.Count; ++index)
            {
                OracleConnectionData         oracleConnection     = oracleConnectionSettings.OracleConnectionsData.Get(index);
                ConnectionStringSettingsNode connectionStringNode = hierarchy.FindNodeByName(node, oracleConnection.Name) as ConnectionStringSettingsNode;
                if (null == connectionStringNode)
                {
                    LogError(node, string.Format(CultureInfo.CurrentUICulture, Resources.ExceptionConnectionStringMissing, oracleConnection.Name));
                    continue;
                }
                OracleConnectionElementNode oracleElementNode = new OracleConnectionElementNode();
                foreach (OraclePackageData packageData in oracleConnection.Packages)
                {
                    oracleElementNode.AddNode(new OraclePackageElementNode(packageData));
                }
                connectionStringNode.AddNode(oracleElementNode);
            }
        }
        public void DictionaryConfigurationSourceCanConfigureFactoryAndExecuteScalar()
        {
            DictionaryConfigurationSource source = new DictionaryConfigurationSource();

            DatabaseSettings setting = new DatabaseSettings();

            setting.DefaultDatabase = "OracleTest";
            ConnectionStringsSection connectionSection = new ConnectionStringsSection();

            connectionSection.ConnectionStrings.Add(new ConnectionStringSettings("OracleTest",
                                                                                 ConfigurationManager.AppSettings["oracleConnectionString"]
                                                                                 , "System.Data.OracleClient"));
            source.Add("connectionStrings", connectionSection);
            source.Add("dataConfiguration", setting);
            OracleConnectionSettings oracleSetting = new OracleConnectionSettings();
            OracleConnectionData     oracleData    = new OracleConnectionData();

            oracleData.Name = "OracleTest";
            oracleSetting.OracleConnectionsData.Add(oracleData);
            source.Add("oracleConnectionSettings", oracleSetting);

            DatabaseProviderFactory factory = new DatabaseProviderFactory(source);
            Database  db        = factory.Create("OracleTest");
            DbCommand dbCommand = db.GetStoredProcCommand("GetProductName");

            db.AddInParameter(dbCommand, "vProductId", DbType.Int32, 1);
            db.AddOutParameter(dbCommand, "vResult", DbType.StringFixedLength, 100);
            db.ExecuteScalar(dbCommand);
            Assert.AreEqual("Product1", db.GetParameterValue(dbCommand, "vResult").ToString().Trim());
        }
        /// <summary>
        /// Builds an instance of the concrete subtype of <see cref="T:Microsoft.Practices.EnterpriseLibrary.Data.Database"/> the receiver knows how to build, based on
        /// the provided connection string and any configuration information that might be contained by the
        /// <paramref name="configurationSource"/>.
        /// </summary>
        /// <param name="name">The name for the new database instance.</param>
        /// <param name="connectionStringSettings">The connection string for the new database instance.</param>
        /// <param name="configurationSource">The source for any additional configuration information.</param>
        /// <returns>The new database instance.</returns>
        public Database Assemble(string name, ConnectionStringSettings connectionStringSettings,
                                 IConfigurationSource configurationSource)
        {
            if (log.IsInfoEnabled)
            {
                log.Info("OdpNetDatabase 인스턴스를 생성하기 위해 환경설정 정보를 읽습니다..." +
                         "name=[{0}], connectionStringSettings=[{1}], configurationSource=[{2}]",
                         name, connectionStringSettings.ConnectionString, configurationSource);
            }

            var connectionSettings = OracleConnectionSettings.GetSettings(configurationSource);

            if (connectionSettings != null)
            {
                OracleConnectionData oraConnData = connectionSettings.OracleConnectionsData.Get(name);

                if (oraConnData != null)
                {
                    var packages = oraConnData.Packages.Cast <IOraclePackage>().ToArray();
                    return(new OdpNetDatabase(connectionStringSettings.ConnectionString, packages));
                }
            }

            return(new OdpNetDatabase(connectionStringSettings.ConnectionString));
        }
        public void CanGetExtraInformation()
        {
            ConnectionStringSettings data
                = new ConnectionStringSettings(name, "connection string;");

            OracleConnectionData oracleConnectionData = new OracleConnectionData();

            oracleConnectionData.Name = name;
            oracleConnectionData.Packages.Add(new OraclePackageData("package1", "pref1"));
            oracleConnectionData.Packages.Add(new OraclePackageData("package2", "pref2"));

            OracleConnectionSettings oracleConnectionSettings = new OracleConnectionSettings();

            oracleConnectionSettings.OracleConnectionsData.Add(oracleConnectionData);

            configurationSource.Add(OracleConnectionSettings.SectionName, oracleConnectionSettings);

            OracleDatabase database = (OracleDatabase)assembler.Assemble(data.Name, data, configurationSource);

            Assert.IsNotNull(database);
            Assert.AreSame(typeof(OracleDatabase), database.GetType());

            // can't access the packages - must resort to side effect
            DbCommand dBCommand = database.GetStoredProcCommand(OracleTestStoredProcedureInPackageWithTranslation);

            Assert.AreEqual((object)OracleTestTranslatedStoredProcedureInPackageWithTranslation, dBCommand.CommandText);
        }
        public void WmiSettingsAreGeneratedWithPolicyOverridesIfWmiIsEnabled()
        {
            OracleConnectionData connection1Data = new OracleConnectionData();

            connection1Data.Name = "data1";
            connection1Data.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connection1Data.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connection1Data);

            MockRegistryKey machinePackageKey = new MockRegistryKey(false);

            machineKey.AddSubKey("data1", machinePackageKey);
            machinePackageKey.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                             "package13=prefix13; package14=prefix14; package15=prefix15");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(OracleConnectionSetting), wmiSettings[0].GetType());

            Dictionary <String, String> packagesDictionary = new Dictionary <string, string>();

            foreach (String entry in ((OracleConnectionSetting)wmiSettings[0]).Packages)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, packagesDictionary);
            }
            Assert.AreEqual(3, packagesDictionary.Count);
            Assert.AreEqual("prefix13", packagesDictionary["package13"]);
            Assert.AreEqual("prefix14", packagesDictionary["package14"]);
            Assert.AreEqual("prefix15", packagesDictionary["package15"]);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackageKey));
        }
 public OracleConnectionSetting(OracleConnectionData sourceElement,
                                string name,
                                string[] packages)
     : base(sourceElement, name)
 {
     this.packages = packages;
 }
        public void CanDeserializeSerializedConfiguration()
        {
            OracleConnectionSettings rwSettings = new OracleConnectionSettings();

            OracleConnectionData rwOracleConnectionData = new OracleConnectionData();

            rwOracleConnectionData.Name = "name0";
            rwOracleConnectionData.Packages.Add(new OraclePackageData("package1", "pref1"));
            rwOracleConnectionData.Packages.Add(new OraclePackageData("package2", "pref2"));
            rwSettings.OracleConnectionsData.Add(rwOracleConnectionData);
            rwOracleConnectionData      = new OracleConnectionData();
            rwOracleConnectionData.Name = "name1";
            rwOracleConnectionData.Packages.Add(new OraclePackageData("package3", "pref3"));
            rwOracleConnectionData.Packages.Add(new OraclePackageData("package4", "pref4"));
            rwSettings.OracleConnectionsData.Add(rwOracleConnectionData);

            IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>();

            sections[OracleConnectionSettings.SectionName] = rwSettings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            OracleConnectionSettings roSettings = (OracleConnectionSettings)configurationSource.GetSection(OracleConnectionSettings.SectionName);

            Assert.AreEqual(2, roSettings.OracleConnectionsData.Count);
            Assert.AreEqual("name0", roSettings.OracleConnectionsData.Get(0).Name);
            Assert.AreEqual(2, roSettings.OracleConnectionsData.Get(0).Packages.Count);
        }
        public void Given()
        {
            var configurationSource = new DictionaryConfigurationSource();

            var oracleConnectionData = new OracleConnectionData {
                Name = "myConnectionName"
            };

            oracleConnectionData.Packages.Add(new OraclePackageData("foo", "bar"));
            var oracleSettings = new OracleConnectionSettings();

            oracleSettings.OracleConnectionsData.Add(oracleConnectionData);
            configurationSource.Add(OracleConnectionSettings.SectionName, oracleSettings);

            var databaseData = new OracleDatabaseData(
                new ConnectionStringSettings
            {
                Name             = "myConnectionName",
                ConnectionString = "myConnectionString",
                ProviderName     = "System.Data.Odbc"
            },
                configurationSource);

            registration = databaseData.GetRegistrations().First();
        }
Example #15
0
        public void ManageabilityProviderGeneratesProperAdmContent()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            OracleConnectionData data1 = new OracleConnectionData();

            section.OracleConnectionsData.Add(data1);
            data1.Name = "data1";
            data1.Packages.Add(new OraclePackageData("name1", "prefix1"));
            data1.Packages.Add(new OraclePackageData("name2", "pre;fix2"));
            OracleConnectionData data2 = new OracleConnectionData();

            section.OracleConnectionsData.Add(data2);
            data2.Name = "data2";

            MockAdmContentBuilder contentBuilder = new MockAdmContentBuilder();

            provider.InvokeAddAdministrativeTemplateDirectives(contentBuilder, section, configurationSource, "TestApp");

            MockAdmContent            content = contentBuilder.GetMockContent();
            IEnumerator <AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();

            Assert.IsTrue(categoriesEnumerator.MoveNext());
            Assert.AreEqual(Resources.DatabaseCategoryName, categoriesEnumerator.Current.Name);
            IEnumerator <AdmCategory> subCategoriesEnumerator = categoriesEnumerator.Current.Categories.GetEnumerator();

            Assert.IsTrue(subCategoriesEnumerator.MoveNext());
            Assert.AreEqual(Resources.OracleConnectionsCategoryName, subCategoriesEnumerator.Current.Name);
            IEnumerator <AdmPolicy> policiesEnumerator = subCategoriesEnumerator.Current.Policies.GetEnumerator();

            Assert.IsTrue(policiesEnumerator.MoveNext());
            Assert.AreEqual(String.Format(Resources.OracleConnectionPolicyNameTemplate, data1.Name),
                            policiesEnumerator.Current.Name);
            IEnumerator <AdmPart> oracleDataPartsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();

            Assert.IsTrue(oracleDataPartsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmEditTextPart), oracleDataPartsEnumerator.Current.GetType());
            Assert.IsNull(oracleDataPartsEnumerator.Current.KeyName);
            Assert.AreEqual(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                            oracleDataPartsEnumerator.Current.ValueName);
            Assert.AreEqual(Resources.OracleConnectionPackagesPartName,
                            oracleDataPartsEnumerator.Current.PartName);
            IDictionary <String, String> packages = new Dictionary <String, String>();

            KeyValuePairParser.ExtractKeyValueEntries(((AdmEditTextPart)oracleDataPartsEnumerator.Current).DefaultValue, packages);
            Assert.AreEqual(2, packages.Count);
            Assert.AreEqual("prefix1", packages["name1"]);
            Assert.AreEqual("pre;fix2", packages["name2"]);

            Assert.IsFalse(oracleDataPartsEnumerator.MoveNext());
            Assert.IsTrue(policiesEnumerator.MoveNext());
            Assert.IsFalse(policiesEnumerator.MoveNext());

            Assert.IsFalse(subCategoriesEnumerator.MoveNext());
            IEnumerator <AdmPolicy> sectionPoliciesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();

            Assert.IsFalse(sectionPoliciesEnumerator.MoveNext());
            Assert.IsFalse(categoriesEnumerator.MoveNext());
        }
 /// <summary>
 /// Creates the oracle connection file.
 /// </summary>
 /// <param name="app">The application.</param>
 public static void CreateOracleConnectionFile(this RivieraApplication app, OracleConnectionData data)
 {
     if (!File.Exists(app.OracleConnectionFile.FullName))
     {
         File.Create(app.OracleConnectionFile.FullName).Close();
     }
     data.Save(app.OracleConnectionFile.FullName);
     app.OracleConnection = data;
 }
        private static OracleConnectionSettings GenerateOracleConnectionSettings()
        {
            OracleConnectionSettings settings = new OracleConnectionSettings();
            OracleConnectionData     data     = new OracleConnectionData();

            data.Name = "Service_Dflt";
            data.Packages.Add(new OraclePackageData("PKGNORTHWIND", "NWND_"));
            data.Packages.Add(new OraclePackageData("PKGENTLIB", "RegionSelect"));
            settings.OracleConnectionsData.Add(data);
            return(settings);
        }
Example #18
0
        public void MultipleConfigurationObjectsAreModifiedIfThereArePolicyOverrides()
        {
            OracleConnectionData connection1Data = new OracleConnectionData();

            connection1Data.Name = "data1";
            connection1Data.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connection1Data.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connection1Data);

            OracleConnectionData connection2Data = new OracleConnectionData();

            connection2Data.Name = "data2";
            connection2Data.Packages.Add(new OraclePackageData("package21", "prefix21"));
            connection2Data.Packages.Add(new OraclePackageData("package22", "prefix22"));
            connection2Data.Packages.Add(new OraclePackageData("package23", "prefix23"));
            section.OracleConnectionsData.Add(connection2Data);

            OracleConnectionData connection3Data = new OracleConnectionData();

            connection3Data.Name = "data3";
            connection3Data.Packages.Add(new OraclePackageData("package31", "prefix31"));
            section.OracleConnectionsData.Add(connection3Data);

            MockRegistryKey machinePackage1Key = new MockRegistryKey(false);

            machineKey.AddSubKey("data1", machinePackage1Key);
            machinePackage1Key.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                              "package13=prefix13; package14=prefix14; package15=prefix15");
            MockRegistryKey machinePackage2Key = new MockRegistryKey(false);

            machineKey.AddSubKey("data2", machinePackage2Key);
            machinePackage2Key.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                              "package24=prefix24");

            provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(3, connection1Data.Packages.Count);
            Assert.IsNotNull(connection1Data.Packages.Get("package13"));
            Assert.AreEqual("prefix13", connection1Data.Packages.Get("package13").Prefix);
            Assert.IsNotNull(connection1Data.Packages.Get("package14"));
            Assert.AreEqual("prefix14", connection1Data.Packages.Get("package14").Prefix);
            Assert.IsNotNull(connection1Data.Packages.Get("package15"));
            Assert.AreEqual("prefix15", connection1Data.Packages.Get("package15").Prefix);

            Assert.AreEqual(1, connection2Data.Packages.Count);
            Assert.IsNotNull(connection2Data.Packages.Get("package24"));
            Assert.AreEqual("prefix24", connection2Data.Packages.Get("package24").Prefix);

            Assert.AreEqual(1, connection3Data.Packages.Count);
            Assert.IsNotNull(connection3Data.Packages.Get("package31"));
            Assert.AreEqual("prefix31", connection3Data.Packages.Get("package31").Prefix);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackage1Key, machinePackage2Key));
        }
        private void EnsureOracleConnectionData()
        {
            if (this.currentOracleConnectionData != null)
            {
                return;
            }
            OracleConnectionData oracleConnectionData = new OracleConnectionData();

            oracleConnectionData.Name        = this.ConnectionString.Name;
            this.currentOracleConnectionData = oracleConnectionData;
            this.currentOracleSettings.OracleConnectionsData.Add(this.currentOracleConnectionData);
        }
 private void EnsureOracleConnectionData()
 {
     if (currentOracleConnectionData != null)
     {
         return;
     }
     currentOracleConnectionData = new OracleConnectionData()
     {
         Name = ConnectionString.Name
     };
     currentOracleSettings.OracleConnectionsData.Add(currentOracleConnectionData);
 }
        public void WmiSettingsAreNotGeneratedIfWmiIsDisabled()
        {
            OracleConnectionData connection1Data = new OracleConnectionData();

            connection1Data.Name = "data1";
            connection1Data.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connection1Data.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connection1Data);

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, machineKey, userKey, false, wmiSettings);

            Assert.AreEqual(0, wmiSettings.Count);
        }
Example #22
0
        public static bool SaveChanges(OracleConnectionSetting setting, ConfigurationElement sourceElement)
        {
            OracleConnectionData        element            = (OracleConnectionData)sourceElement;
            Dictionary <String, String> packagesDictionary = new Dictionary <string, string>();

            foreach (string encodedKeyValuePair in setting.Packages)
            {
                KeyValuePairParser.ExtractKeyValueEntries(encodedKeyValuePair, packagesDictionary);
            }
            element.Packages.Clear();
            foreach (KeyValuePair <String, String> kvp in packagesDictionary)
            {
                element.Packages.Add(new OraclePackageData(kvp.Key, kvp.Value));
            }
            return(true);
        }
Example #23
0
        public static DictionaryConfigurationSource CreateConfigurationSource()
        {
            DictionaryConfigurationSource source = new DictionaryConfigurationSource();
            DatabaseSettings settings            = new DatabaseSettings();

            settings.DefaultDatabase = "Service_Dflt";
            OracleConnectionSettings oracleConnectionSettings = new OracleConnectionSettings();
            OracleConnectionData     data = new OracleConnectionData();

            data.Name = "OracleTest";
            data.Packages.Add(new OraclePackageData("TESTPACKAGE", "TESTPACKAGETOTRANSLATE"));
            oracleConnectionSettings.OracleConnectionsData.Add(data);
            source.Add(DatabaseSettings.SectionName, settings);
            source.Add(OracleConnectionSettings.SectionName, oracleConnectionSettings);
            return(source);
        }
        public void ConfigurationObjectIsNotModifiedIfThereAreNoPolicyOverrides()
        {
            OracleConnectionData connectionData = new OracleConnectionData();

            connectionData.Name = "data1";
            connectionData.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connectionData.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connectionData);

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(2, connectionData.Packages.Count);
            Assert.IsNotNull(connectionData.Packages.Get("package11"));
            Assert.AreEqual("prefix11", connectionData.Packages.Get("package11").Prefix);
            Assert.IsNotNull(connectionData.Packages.Get("package12"));
            Assert.AreEqual("prefix12", connectionData.Packages.Get("package12").Prefix);
        }
Example #25
0
        public void ConfigurationObjectIsNotModifiedIfPolicyOverridesAreNull()
        {
            OracleConnectionData connectionData = new OracleConnectionData();

            connectionData.Name = "data1";
            connectionData.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connectionData.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connectionData);

            provider.OverrideWithGroupPolicies(section, true, null, null);

            Assert.AreEqual(2, connectionData.Packages.Count);
            Assert.IsNotNull(connectionData.Packages.Get("package11"));
            Assert.AreEqual("prefix11", connectionData.Packages.Get("package11").Prefix);
            Assert.IsNotNull(connectionData.Packages.Get("package12"));
            Assert.AreEqual("prefix12", connectionData.Packages.Get("package12").Prefix);
        }
Example #26
0
        public OracleConnectionSettings Build()
        {
            oracleConnectionSettings = new OracleConnectionSettings();
            IList <ConfigurationNode> connections = hierarchy.FindNodesByType(typeof(OracleConnectionElementNode));

            for (int index = 0; index < connections.Count; ++index)
            {
                OracleConnectionData data = new OracleConnectionData();
                data.Name = connections[index].Parent.Name;
                foreach (OraclePackageElementNode node in connections[index].Nodes)
                {
                    data.Packages.Add(node.OraclePackageElement);
                }
                oracleConnectionSettings.OracleConnectionsData.Add(data);
            }
            return(oracleConnectionSettings);
        }
        public void SavesChangesToConfigurationObject()
        {
            OracleConnectionData sourceElement = new OracleConnectionData();

            sourceElement.Packages.Add(new OraclePackageData("foo", "bar"));
            sourceElement.Packages.Add(new OraclePackageData("foo2", "bar2"));
            List <ConfigurationSetting> settings = new List <ConfigurationSetting>(1);

            OracleConnectionSettingsWmiMapper.GenerateOracleConnectionSettingWmiObjects(sourceElement, settings);
            Assert.AreEqual(1, settings.Count);
            OracleConnectionSetting setting = settings[0] as OracleConnectionSetting;

            Assert.IsNotNull(setting);
            setting.Packages = new string[] { KeyValuePairEncoder.EncodeKeyValuePair("foo3", "bar3") };
            setting.Commit();
            Assert.AreEqual(1, sourceElement.Packages.Count);
            Assert.AreEqual("bar3", sourceElement.Packages.Get("foo3").Prefix);
        }
Example #28
0
        public Database Assemble(string name, ConnectionStringSettings connectionStringSettings, IConfigurationSource configurationSource)
        {
            OracleConnectionSettings oracleConnectionSettings = OracleConnectionSettings.GetSettings(configurationSource);

            if (oracleConnectionSettings != null)
            {
                OracleConnectionData oracleConnectionData = oracleConnectionSettings.OracleConnectionsData.Get(name);
                if (oracleConnectionData != null)
                {
                    IOraclePackage[] packages = new IOraclePackage[oracleConnectionData.Packages.Count];
                    int i = 0;
                    foreach (IOraclePackage package in oracleConnectionData.Packages)
                    {
                        packages[i++] = package;
                    }
                    return(new OracleDatabase(connectionStringSettings.ConnectionString, packages));
                }
            }
            return(new OracleDatabase(connectionStringSettings.ConnectionString));
        }
        public void Setup()
        {
            var configSource = new DictionaryConfigurationSource();

            var connectionStrings = new ConnectionStringsSection();

            connectionStrings.ConnectionStrings.Add(
                new ConnectionStringSettings("someSetting", "someConnectionString", "System.Data.OracleClient"));
            configSource.Add("connectionStrings", connectionStrings);

            var oracleConnectionData = new OracleConnectionData {
                Name = "someSetting"
            };

            oracleConnectionData.Packages.Add(new OraclePackageData("foo", "bar"));
            var oracleSettings = new OracleConnectionSettings();

            oracleSettings.OracleConnectionsData.Add(oracleConnectionData);
            configSource.Add(OracleConnectionSettings.SectionName, oracleSettings);

            configSettings = new DatabaseSyntheticConfigSettings(configSource.GetSection);
        }
        public static DictionaryConfigurationSource CreateConfigurationSource()
        {
            DictionaryConfigurationSource source = new DictionaryConfigurationSource();

            DatabaseSettings settings = new DatabaseSettings();

            settings.DefaultDatabase = "Service_Dflt";
            settings.ProviderMappings.Add(new DbProviderMapping("Oracle.ManagedDataAccess.Client", "EntLibContrib.Data.Oracle.ManagedDataAccess.OracleDatabase, EntLibContrib.Data.Oracle.ManagedDataAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"));

            OracleConnectionSettings oracleConnectionSettings = new OracleConnectionSettings();
            OracleConnectionData     data = new OracleConnectionData();

            data.Name = "OracleTest";
            data.Packages.Add(new OraclePackageData("TESTPACKAGE", "TESTPACKAGETOTRANSLATE"));
            data.Packages.Add(new OraclePackageData("PKGNORTHWIND", "NWND_"));
            data.Packages.Add(new OraclePackageData("PKGENTLIB", "RegionSelect"));
            oracleConnectionSettings.OracleConnectionsData.Add(data);

            source.Add(DatabaseSettings.SectionName, settings);
            source.Add(OracleConnectionSettings.SectionName, oracleConnectionSettings);

            return(source);
        }