diff options
author | Raja R Harinath <harinath@hurrynot.org> | 2005-07-11 15:46:03 +0400 |
---|---|---|
committer | Raja R Harinath <harinath@hurrynot.org> | 2005-07-11 15:46:03 +0400 |
commit | c0cc067f7c91fce62ba1dfd883a365a999ba41ae (patch) | |
tree | 539811da7ab9ffff20ddee004c5cec29964aa6fe /mcs/class/System.Configuration.Install | |
parent | b01f31990caa0ed89c60d2b8182af5d26d3bff20 (diff) |
* Makefile (NO_TEST): Set.
* System.Configuration.Install_test.dll.sources: Remove.
Stub-out code. Pending rewrite.
svn path=/trunk/mcs/; revision=47167
Diffstat (limited to 'mcs/class/System.Configuration.Install')
19 files changed, 315 insertions, 2177 deletions
diff --git a/mcs/class/System.Configuration.Install/ChangeLog b/mcs/class/System.Configuration.Install/ChangeLog index 2e77a14e551..1074f3704e1 100644 --- a/mcs/class/System.Configuration.Install/ChangeLog +++ b/mcs/class/System.Configuration.Install/ChangeLog @@ -1,13 +1,7 @@ -2005-04-08 Raja R Harinath <rharinath@novell.com> +2005-07-11 Raja R Harinath <rharinath@novell.com> - * Makefile (EXTRA_DISTFILES): Add support file - Test/.../InstallerAssembly.cs. - -2005-03-24 Muthu Kannan <t.manki@gmail.com> - - * Makefile (test-local): Create InstallerAssembly.dll for unit - tests. - * System.Configuration.Install_test.dll.sources: New file. + * Makefile (NO_TEST): Set. + * System.Configuration.Install_test.dll.sources: Remove. 2004-06-11 Gert Driesen <drieseng@users.sourceforge.net> diff --git a/mcs/class/System.Configuration.Install/Makefile b/mcs/class/System.Configuration.Install/Makefile index ae87300e0e6..f94fd6c8ce1 100644 --- a/mcs/class/System.Configuration.Install/Makefile +++ b/mcs/class/System.Configuration.Install/Makefile @@ -1,16 +1,9 @@ thisdir = class/System.Configuration.Install -SUBDIRS = include ../../build/rules.make LIBRARY = System.Configuration.Install.dll -LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:System.Xml.dll /r:System.Runtime.Serialization.Formatters.Soap.dll -TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) +LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:System.Xml.dll -EXTRA_DISTFILES = Test/ChangeLog Test/System.Configuration.Install/InstallerAssembly.cs +NO_TEST = yes include ../../build/library.make - -test-local run-test-local: Test/System.Configuration.Install/InstallerAssembly.dll - -Test/System.Configuration.Install/InstallerAssembly.dll: Test/System.Configuration.Install/InstallerAssembly.cs - $(CSCOMPILE) /t:library /r:System.Configuration.Install.dll /out:$@ $< diff --git a/mcs/class/System.Configuration.Install/System.Configuration.Install/AssemblyInstaller.cs b/mcs/class/System.Configuration.Install/System.Configuration.Install/AssemblyInstaller.cs index 9d3ac73f8fd..cb6deda2b33 100644 --- a/mcs/class/System.Configuration.Install/System.Configuration.Install/AssemblyInstaller.cs +++ b/mcs/class/System.Configuration.Install/System.Configuration.Install/AssemblyInstaller.cs @@ -1,11 +1,10 @@ -// AssemblyInstaller.cs -// System.Configuration.Install.AssemblyInstaller class implementation +// System.Configuration.Install.AssemblyInstaller.cs // // Author: -// Muthu Kannan (t.manki@gmail.com) +// Gert Driesen (drieseng@users.sourceforge.net) +// +// (C) Novell // -// (C) 2005 Novell, Inc. http://www.novell.com/ -// // // Permission is hereby granted, free of charge, to any person obtaining @@ -28,267 +27,110 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System; using System.Collections; using System.ComponentModel; using System.Reflection; -using System.Runtime.Serialization.Formatters.Soap; -using System.IO; -using System.Text; namespace System.Configuration.Install { - -public class AssemblyInstaller : Installer { - private string [] cmdLine; - private Assembly assembly; - private bool useNewContext; - private const string STATE_FILE_EXT = ".InstallState"; - - // Initialises private members - private void initFields () - { - UseNewContext = true; - } - - // Constructors - public AssemblyInstaller () - { - Assembly = null; - CommandLine = null; - - initFields(); - } - - public AssemblyInstaller (Assembly ass, string [] args) + public class AssemblyInstaller : Installer { - Assembly = ass; - CommandLine = args; - - initFields(); - } - - public AssemblyInstaller (string assFile, string [] args) - { - Path = assFile; - CommandLine = args; - - initFields(); - } - - // Properties - public Assembly Assembly { - get { - return assembly; + public AssemblyInstaller () + { } - set { - assembly = value; - } - } - public string [] CommandLine { - get { - return cmdLine; - } - set { - cmdLine = value; + public AssemblyInstaller (Assembly assembly, string[] commandLine) + { + _assembly = assembly; + _commandLine = commandLine; + _useNewContext = true; } - } - public override string HelpText { - get { - addSubInstallers (); - StringBuilder sb = new StringBuilder (); - foreach (Installer ins in Installers) - sb.Append (ins.HelpText + "\n"); - return sb.ToString (); + public AssemblyInstaller (string filename, string[] commandLine) + { + Path = System.IO.Path.GetFullPath (filename); + _commandLine = commandLine; + _useNewContext = true; } - } - public string Path { - get { - if (Assembly == null) - return null; - else - return Assembly.CodeBase.Substring (7); // remove leading 'file://' + [MonoTODO] + public static void CheckIfInstallable (string assemblyName) + { + throw new NotImplementedException (); } - set { - Assembly = Assembly.LoadFrom (value); - } - } - public bool UseNewContext { - get { - return useNewContext; + [MonoTODO] + public override void Commit (IDictionary savedState) + { + throw new NotImplementedException (); } - set { - if (value) - Context = new InstallContext (Path + ".InstallLog", null); - else - Context = new InstallContext (Path + ".InstallLog", CommandLine); - useNewContext = value; - } - } - // Methods - public static void CheckIfInstallable (string assemblyName) - { - if (! File.Exists (assemblyName)) - throw new Exception ("The path specified (" + assemblyName + ") does not exist."); - - Assembly ass = Assembly.LoadFrom (assemblyName); - if ((getInstallersFromAssembly (ass)).Length == 0) - throw new Exception ("Could not find any type with RunInstaller attribute set to True"); - } - - private void addSubInstallers () - { - // Return, if installers have already been filled - if (Installers.Count > 0) - return; - - foreach (Type t in getInstallersFromAssembly (Assembly)) { - Installer i = (Installer) Activator.CreateInstance (t); - i.Context = this.Context; - Installers.Add (i); + [MonoTODO] + public override void Install (IDictionary savedState) + { + throw new NotImplementedException (); } - } - - private static Type [] getInstallersFromAssembly (Assembly ass) - { - ArrayList insTypes = new ArrayList (); - foreach (Type t in ass.GetExportedTypes ()) { - object [] attribs = t.GetCustomAttributes (typeof (RunInstallerAttribute), false); - if (attribs.Length > 0) { - RunInstallerAttribute atr = (RunInstallerAttribute) attribs [0]; - if ((typeof (Installer)).IsAssignableFrom (t) && atr.Equals (RunInstallerAttribute.Yes)) - insTypes.Add (t); - } + [MonoTODO] + public override void Rollback (IDictionary savedState) + { + throw new NotImplementedException (); } - Type [] ret = new Type [insTypes.Count]; - for (int i = 0; i < insTypes.Count; ++i) - ret [i] = (Type) insTypes [i]; - return ret; - } - - private bool isInstallable () - { - try { - CheckIfInstallable (Path); - } catch (Exception e) { - Context.LogMessage ("Assembly " + Path + " does not have any public installers in it."); - return false; + [MonoTODO] + public override void Uninstall (IDictionary savedState) + { + throw new NotImplementedException (); } - return true; - } - public override void Install (IDictionary state) - { - // Make sure that the assembly is installable - if (! isInstallable ()) - return; - - addSubInstallers (); - - state = new Hashtable (); - string stateFile = System.IO.Path.ChangeExtension (this.Path, STATE_FILE_EXT); - try { - string logFilePath = Context.Parameters ["LogFile"]; - if (logFilePath != null && logFilePath != "") - Console.WriteLine ("Installation log for assembly " + Path + " is found at " + logFilePath); - Context.LogMessage ("Starting installation of assembly: " + Path); - base.Install (state); - } finally { - // Serialise state - FileStream file = new FileStream (stateFile, FileMode.Create, FileAccess.Write, FileShare.Read); - try { - SoapFormatter sf = new SoapFormatter (); - sf.Serialize (file, state); - } finally { - file.Close (); + public Assembly Assembly { + get { + return _assembly; + } + set { + _assembly = value; } } - Context.LogMessage ("Installation completed"); - } - - public override void Commit (IDictionary state) - { - // Make sure that the assembly is installable - if (! isInstallable ()) - return; - addSubInstallers (); - string stateFile = System.IO.Path.ChangeExtension (this.Path, STATE_FILE_EXT); - // Read serialised state - FileStream file = new FileStream (stateFile, FileMode.Open, FileAccess.Read, FileShare.Read); - try { - SoapFormatter sf = new SoapFormatter (); - state = (IDictionary) sf.Deserialize (file); - } finally { - file.Close (); + public string[] CommandLine { + get { + return _commandLine; + } + set { + _commandLine = value; + } } - Context.LogMessage ("Starting commit of assembly: " + Path); - base.Commit (state); - Context.LogMessage ("Commit completed"); - } - - public override void Rollback (IDictionary state) - { - // Make sure that the assembly is installable - if (! isInstallable ()) - return; - - addSubInstallers (); - string stateFile = System.IO.Path.ChangeExtension (this.Path, STATE_FILE_EXT); - - // Read serialised state - FileStream file = new FileStream (stateFile, FileMode.Open, FileAccess.Read, FileShare.Read); - try { - SoapFormatter sf = new SoapFormatter (); - state = (IDictionary) sf.Deserialize (file); - } finally { - file.Close (); + public override string HelpText { + get { + throw new NotImplementedException (); + } } + public string Path { + get { + if (_assembly == null) + return null; + + return _assembly.Location; + } + set { + if (value == null) + _assembly = null; - Context.LogMessage ("Starting rollback of assembly: " + Path); - base.Rollback (state); - - File.Delete (stateFile); - Context.LogMessage ("Rollback completed"); - } - - public override void Uninstall (IDictionary state) - { - // Make sure that the assembly is installable - if (! isInstallable ()) - return; - - addSubInstallers (); - string stateFile = System.IO.Path.ChangeExtension (this.Path, STATE_FILE_EXT); - - // Read serialised state - FileStream file = new FileStream (stateFile, FileMode.Open, FileAccess.Read, FileShare.Read); - try { - SoapFormatter sf = new SoapFormatter (); - state = (IDictionary) sf.Deserialize (file); - file.Close (); - } catch (Exception) { - state = null; + _assembly = Assembly.LoadFrom (value); + } + } + public bool UseNewContext { + get { + return _useNewContext; + } + set { + _useNewContext = value; + } } - string logFilePath = Context.Parameters ["LogFile"]; - if (logFilePath != null && logFilePath != "") - Console.WriteLine ("Installation log for assembly " + Path + " is found at " + logFilePath); - - Context.LogMessage ("Starting uninstallation of assembly: " + Path); - base.Uninstall (state); - - File.Delete (stateFile); - Context.LogMessage ("Uninstallation completed"); + private Assembly _assembly; + private string[] _commandLine; + private bool _useNewContext; } } - -} diff --git a/mcs/class/System.Configuration.Install/System.Configuration.Install/ChangeLog b/mcs/class/System.Configuration.Install/System.Configuration.Install/ChangeLog index 0a90e5eceda..fb392d37e21 100644 --- a/mcs/class/System.Configuration.Install/System.Configuration.Install/ChangeLog +++ b/mcs/class/System.Configuration.Install/System.Configuration.Install/ChangeLog @@ -1,22 +1,3 @@ -2005-04-07 Muthu Kannan <t.manki@gmail.com> - - * AssemblyInstaller.cs (UseNewContext): Set default path. - (Install,Commit,Rollback,Uninstall): Log events. - * Installer.cs (Install, Commit, Rollback,Uninstall): - Don't set installer context when invoking subinstallers. - * InstallContext.cs (ParseCommandLine): Fix handling of '--' - options. - * TransactedInstaller.cs (Install): Fix typo. - -2005-03-24 Muthu Kannan <t.manki@gmail.com> - - Near-complete implementation of System.Configuration.Install. - * Installer.cs: Implement. - * AssemblyInstaller.cs: Likewise. - * TransactedInstaller.cs: Likewise. - * InstallContext.cs: Likewise. - * InstallerCollection.cs: Likewise. - 2004-06-11 Gert Driesen <drieseng@users.sourceforge.net> * Installer.cs: use Type instead of string argument for diff --git a/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallContext.cs b/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallContext.cs index fc7e5b0012a..6ce2b08552e 100644 --- a/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallContext.cs +++ b/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallContext.cs @@ -1,10 +1,9 @@ -// InstallContext.cs -// System.Configuration.Install.InstallContext class implementation +// System.Configuration.Install.InstallContext.cs // // Author: -// Muthu Kannan (t.manki@gmail.com) +// Alejandro Sánchez Acosta <raciel@es.gnu.org> // -// (C) 2005 Novell, Inc. http://www.novell.com/ +// (C) Alejandro Sánchez Acosta // // @@ -29,111 +28,45 @@ // using System.Collections.Specialized; -using System.IO; namespace System.Configuration.Install { - -public class InstallContext { - private StringDictionary parameters; - - // Constructors - public InstallContext () : this (null, null) + public class InstallContext { - } - - public InstallContext (string logFilePath, string [] cmdLine) - { - parameters = ParseCommandLine(cmdLine); - - // Log file path specified in command line arguments - // has higher priority than the logFilePath argument - if (parameters.ContainsKey ("logFile")) { - logFilePath = parameters ["logFile"]; - parameters.Remove ("logFile"); + private StringDictionary parameters; + + [MonoTODO] + public InstallContext () { + throw new NotImplementedException (); } - if (logFilePath == null) - logFilePath = ""; - parameters.Add ("logFile", logFilePath); - } - - // Properties - public StringDictionary Parameters { - get { - return parameters; + [MonoTODO] + public InstallContext (string logFilePath, string[] commandLine) { + throw new NotImplementedException (); } - } - - // Methods - public bool IsParameterTrue (string paramName) - { - if (Parameters.ContainsKey (paramName)) { - string val = (Parameters [paramName]).ToLower (); - return val == "true" || val == "yes" || val == "1" || val == ""; - } else - return false; - } - - public void LogMessage (string message) - { - if (message == null) - return; - string logFilePath; - if ((logFilePath = parameters ["logFile"]) != "") { - StreamWriter logFile = new StreamWriter (logFilePath, true); - try { - logFile.WriteLine (message); - } finally { - logFile.Close (); + public StringDictionary Parameters { + get { + return parameters; } } - if (IsParameterTrue ("logToConsole")) - Console.WriteLine (message); - } - - internal void addToLog (Exception e) - { - LogMessage ("Exception: " + e.ToString ()); - if (e.InnerException != null) { - addToLog (e.InnerException); - return; + [MonoTODO] + public bool IsParameterTrue (string paramName) + { + throw new NotImplementedException (); } - LogMessage (e.StackTrace); - } - - protected static StringDictionary ParseCommandLine (string [] args) - { - string key, val; - - StringDictionary sd = new StringDictionary (); - if (args == null) - return sd; - - foreach (string a in args) { - // Remove leading / or - or -- - string x = a; // I am using x instead of a - if (a.StartsWith ("--")) - x = x.Substring (2); - else if (x.StartsWith ("/") || x.StartsWith ("-")) - x = x.Substring (1); - - int index; - if ((index = x.IndexOf ("=")) == -1) { - key = x; - val = ""; - } else { - key = x.Substring (0, index); - val = x.Substring (index + 1); - } - sd.Add (key, val); + [MonoTODO] + public void LogMessage (string message) + { + throw new NotImplementedException (); } - return sd; + [MonoTODO] + protected static StringDictionary ParseCommandLine (string[] args) + { + throw new NotImplementedException (); + } } } - -} diff --git a/mcs/class/System.Configuration.Install/System.Configuration.Install/Installer.cs b/mcs/class/System.Configuration.Install/System.Configuration.Install/Installer.cs index ba1d3f8e020..5a0058fe608 100644 --- a/mcs/class/System.Configuration.Install/System.Configuration.Install/Installer.cs +++ b/mcs/class/System.Configuration.Install/System.Configuration.Install/Installer.cs @@ -1,10 +1,9 @@ -// Installer.cs -// System.Configuration.Install.Installer class implementation +// System.Configuration.Install.Installer.cs // // Author: -// Muthu Kannan (t.manki@gmail.com) +// Alejandro Sánchez Acosta <raciel@es.gnu.org> // -// (C) 2005 Novell, Inc. http://www.novell.com/ +// Alejandro Sánchez Acosta // // @@ -28,312 +27,154 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System; +using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; -using System.Collections; namespace System.Configuration.Install { - -[DefaultEvent ("AfterInstall") ] + [DefaultEvent("AfterInstall")] #if (!NET_2_0) -// .NET 2.0 (Community Preview) no longer has this attribute -[Designer("Microsoft.VisualStudio.Configuration.InstallerDesigner, " + Consts.AssemblyMicrosoft_VisualStudio, typeof(IRootDesigner))] + // .NET 2.0 (Community Preview) no longer has this attribute + [Designer("Microsoft.VisualStudio.Configuration.InstallerDesigner, " + Consts.AssemblyMicrosoft_VisualStudio, typeof(IRootDesigner))] #endif -public class Installer : Component { - private const string LAST_INSTALLER = "__LastInstaller"; - private const string STATE_PREFIX = "__State-"; - - InstallContext context; - InstallerCollection children; - Installer parent; - - // Events - public event InstallEventHandler BeforeInstall; - public event InstallEventHandler AfterInstall; - public event InstallEventHandler Committing; - public event InstallEventHandler Committed; - public event InstallEventHandler BeforeRollback; - public event InstallEventHandler AfterRollback; - public event InstallEventHandler BeforeUninstall; - public event InstallEventHandler AfterUninstall; - - // Constructors - public Installer () + public class Installer : Component { - children = new InstallerCollection (this); - Parent = null; - Context = new InstallContext (); - } - - // Properties - [Browsable (false)] - [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] - public InstallContext Context { - get { - return context; - } - set { - context = value; - } - } - - public virtual string HelpText { - get { - return "Installer"; - } - } - - [Browsable (false)] - [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] - public InstallerCollection Installers { - get { - return children; + private InstallContext context; + private string helptext; + private InstallerCollection installers; + internal Installer parent; + + [MonoTODO] + public Installer () { + throw new NotImplementedException (); + } + + [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] + [BrowsableAttribute(false)] + public InstallContext Context { + get { + return context; + } + + set { + context = value; + } } - } - [Browsable (false)] - [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] - [TypeConverter ("System.Configuration.Design.InstallerParentConverter")] - public Installer Parent { - get { - return parent; - } - set { - if (Parent == value) - return; // do nothing - if (isInTree (value)) - throw new InvalidOperationException ( - "This operation will cause recursive parent/child relationship"); - parent = value; + public virtual string HelpText { + get { + return helptext; + } } - } - private bool isInTree (Installer ins) - { - if (ins == this) - return true; - foreach (Installer i in Installers) - if (i == ins) - return true; - else - return i.isInTree (ins); - return false; - } - - // Methods - public virtual void Install (IDictionary state) - { - if (state == null) - throw new ArgumentException ("State saver IDictionary cannot be null"); - - try { - OnBeforeInstall (state); - } catch (Exception e) { - Context.addToLog (e); - throw new Exception ("An error occurred while processing BeforeInstall event", e); + [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] + [BrowsableAttribute(false)] + public InstallerCollection Installers { + get { + return installers; + } } - int maxi = Installers.Count - 1; - int i = 0; - try { - for (i = 0; i <= maxi; ++i) { - IDictionary ht = new Hashtable (); - try { - Installers [i].Install (ht); - } finally { - state.Add (STATE_PREFIX + i.ToString(), ht); - } + [TypeConverter ("System.Configuration.Design.InstallerParentConverter")] + [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] + [BrowsableAttribute (false)] + public Installer Parent { + get { + return parent; + } + + set { + parent = value; } - } finally { - state.Add (LAST_INSTALLER, i > maxi ? maxi : i); } - - try { - OnAfterInstall (state); - } catch (Exception e) { - Context.addToLog (e); - throw new Exception ("An error occurred while processing AfterInstall event", e); + + [MonoTODO] + public virtual void Commit (IDictionary savedState) + { + throw new NotImplementedException (); } - } - - public virtual void Commit (IDictionary state) - { - if (state == null) - throw new ArgumentException ("State saver IDictionary cannot be null"); - if (state [LAST_INSTALLER] == null) - throw new ArgumentException ("Invalid or corrupt state saver"); - int lastInstaller = (int)state [LAST_INSTALLER]; - IDictionary [] states = new IDictionary [lastInstaller + 1]; - for (int i = 0; i <= lastInstaller; ++i) - if ((states [i] = (IDictionary)state [STATE_PREFIX + i.ToString()]) == null) - throw new ArgumentException ("Invalid or corrupt state saver"); - Exception caught = null; - try { - OnCommitting (state); - } catch (Exception e) { - Context.addToLog (e); - caught = e; + [MonoTODO] + public virtual void Install (IDictionary stateSaver) + { + throw new NotImplementedException (); } - for (int i = 0; i <= lastInstaller; ++i) { - try { - Installers [i].Commit (states [i]); - } catch (Exception e) { - caught = e; - Context.addToLog (e); - } + [MonoTODO] + protected virtual void OnAfterInstall (IDictionary savedState) + { + throw new NotImplementedException (); } - - try { - OnCommitted (state); - } catch (Exception e) { - Context.addToLog (e); - caught = e; + + [MonoTODO] + protected virtual void OnAfterRollback (IDictionary savedState) + { + throw new NotImplementedException (); } - if (caught != null) - throw new InstallException ("An error occurred while committing installation", caught); - } - - public virtual void Rollback (IDictionary state) - { - if (state == null) - throw new ArgumentException ("State saver IDictionary cannot be null"); - if (state [LAST_INSTALLER] == null) - throw new ArgumentException ("Invalid or corrupt state saver"); - int lastInstaller = (int)state [LAST_INSTALLER]; - IDictionary [] states = new IDictionary [lastInstaller + 1]; - for (int i = 0; i <= lastInstaller; ++i) - if ((states [i] = (IDictionary)state [STATE_PREFIX + i.ToString()]) == null) - throw new ArgumentException ("Invalid or corrupt state saver"); - - Exception caught = null; - try { - OnBeforeRollback (state); - } catch (Exception e) { - Context.addToLog (e); - caught = e; + [MonoTODO] + protected virtual void OnAfterUninstall (IDictionary savedState) + { + throw new NotImplementedException (); } - - for (int i = 0; i <= lastInstaller; ++i) { - try { - Installers [i].Rollback (states [i]); - } catch (Exception e) { - caught = e; - Context.addToLog (e); - } + + [MonoTODO] + protected virtual void OnBeforeInstall (IDictionary savedState) + { + throw new NotImplementedException (); } - - try { - OnAfterRollback (state); - } catch (Exception e) { - Context.addToLog (e); - caught = e; + + [MonoTODO] + protected virtual void OnBeforeRollback (IDictionary savedState) + { + throw new NotImplementedException (); } - if (caught != null) - throw new InstallException ("An error occurred while rolling back installation", caught); - } - - public virtual void Uninstall (IDictionary state) - { - int lastInstaller = -1; - IDictionary [] states; - if (state == null) { - lastInstaller = Installers.Count - 1; - states = new IDictionary [lastInstaller + 1]; - for (int i = 0; i <= lastInstaller; ++i) - states [i] = null; - } else { - if (state [LAST_INSTALLER] == null) - throw new ArgumentException ("Corrupt state saver"); - lastInstaller = (int)state [LAST_INSTALLER]; - if (lastInstaller != Installers.Count-1) - throw new ArgumentException ("Corrupt state saver"); - states = new IDictionary [lastInstaller + 1]; - for (int i = 0; i <= lastInstaller; ++i) - if ((states [i] = (IDictionary)state [STATE_PREFIX + i.ToString()]) == null) - throw new ArgumentException ("Corrupt state saver"); + [MonoTODO] + protected virtual void OnBeforeUninstall (IDictionary savedState) + { + throw new NotImplementedException (); } - - Exception caught = null; - try { - OnBeforeUninstall (state); - } catch (Exception e) { - Context.addToLog (e); - caught = e; + + [MonoTODO] + protected virtual void OnCommitted (IDictionary savedState) + { + throw new NotImplementedException (); } - - for (int i = 0; i <= lastInstaller; ++i) { - try { - Installers [i].Uninstall (states [i]); - } catch (Exception e) { - caught = e; - Context.addToLog (e); - } + + [MonoTODO] + protected virtual void OnCommitting (IDictionary savedState) + { + throw new NotImplementedException (); } - - try { - OnAfterUninstall (state); - } catch (Exception e) { - Context.addToLog (e); - caught = e; + + [MonoTODO] + public virtual void Rollback (IDictionary savedState) + { + throw new NotImplementedException (); } - if (caught != null) - throw new InstallException ("An error occurred during uninstallation", caught); - } - - protected virtual void OnBeforeInstall (IDictionary state) - { - if (BeforeInstall != null) - BeforeInstall (this, new InstallEventArgs (state)); - } - - protected virtual void OnAfterInstall (IDictionary state) - { - if (AfterInstall != null) - AfterInstall (this, new InstallEventArgs (state)); - } + [MonoTODO] + public virtual void Uninstall (IDictionary savedState) + { + throw new NotImplementedException (); + } + + public event InstallEventHandler AfterInstall; - protected virtual void OnCommitting (IDictionary state) - { - if (Committing != null) - Committing (this, new InstallEventArgs (state)); - } + public event InstallEventHandler AfterRollback; - protected virtual void OnCommitted (IDictionary state) - { - if (Committed != null) - Committed (this, new InstallEventArgs (state)); - } + public event InstallEventHandler AfterUninstall; - protected virtual void OnBeforeRollback (IDictionary state) - { - if (BeforeRollback != null) - BeforeRollback (this, new InstallEventArgs (state)); - } + public event InstallEventHandler BeforeInstall; - protected virtual void OnAfterRollback (IDictionary state) - { - if (AfterRollback != null) - AfterRollback (this, new InstallEventArgs (state)); - } + public event InstallEventHandler BeforeRollback; + + public event InstallEventHandler BeforeUninstall; - protected virtual void OnBeforeUninstall (IDictionary state) - { - if (BeforeUninstall != null) - BeforeUninstall (this, new InstallEventArgs (state)); - } + public event InstallEventHandler Committed; - protected virtual void OnAfterUninstall (IDictionary state) - { - if (AfterUninstall != null) - AfterUninstall (this, new InstallEventArgs (state)); + public event InstallEventHandler Committing; } } - -} diff --git a/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallerCollection.cs b/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallerCollection.cs index f1a4c6281ac..9d8b2c1ca6e 100644 --- a/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallerCollection.cs +++ b/mcs/class/System.Configuration.Install/System.Configuration.Install/InstallerCollection.cs @@ -1,10 +1,9 @@ -// InstallerCollection.cs -// System.Configuration.Install.InstallerCollection class implementation +// System.Configuration.Install.Installer.cs // // Author: -// Muthu Kannan (t.manki@gmail.com) +// Alejandro Sánchez Acosta <raciel@es.gnu.org> // -// (C) 2005 Novell, Inc. http://www.novell.com/ +// (C) Alejandro Sánchez Acosta // // @@ -32,84 +31,95 @@ using System.Collections; namespace System.Configuration.Install { - -public class InstallerCollection : CollectionBase { - private Installer parent; - - // Constructors - internal InstallerCollection (Installer parent) + public class InstallerCollection : CollectionBase { - this.parent = parent; - } + #region Constructors - // Properties - public Installer this [int index] { - get { - return (Installer)List [index]; + internal InstallerCollection(Installer owner) + { + this.owner = owner; } - set { - List [index] = value; + + #endregion Constructors + + + public Installer this[int index] { + get + { + return (Installer) base.List[index]; + } + set + { + base.List[index] = value; + } } - } - // Methods - public int Add (Installer installer) - { - return List.Add (installer); - } + public int Add (Installer value) { + return base.List.Add (value); + } - public void AddRange (Installer [] installers) - { - foreach (Installer ins in installers) - Add (ins); - } + public void AddRange (Installer[] value) { + if (value == null) + { + throw new ArgumentNullException ("value"); + } - public void AddRange (InstallerCollection installers) - { - foreach (Installer ins in installers) - Add (ins); - } + for (int counter = 0; counter < value.Length; counter++) + { + Add (value[counter]); + } + } + + public void AddRange (InstallerCollection value) { + if (value == null) + { + throw new ArgumentNullException ("value"); + } + + int itemCount = value.Count; + for (int counter = 0; counter < itemCount; counter++) + { + Add (value[counter]); + } + } - public bool Contains (Installer installer) - { - return List.Contains (installer); - } + public bool Contains (Installer value) { + return base.List.Contains (value); + } - public void CopyTo (Installer [] array, int index) - { - List.CopyTo (array, index); - } + public void CopyTo (Installer[] array, int index) { + base.List.CopyTo (array, index); + } + + public int IndexOf (Installer value) { + return base.List.IndexOf (value); + } - public int IndexOf (Installer installer) - { - return List.IndexOf (installer); - } + public void Insert (int index, Installer value) { + base.List.Insert (index, value); + } - public void Insert (int index, Installer installer) - { - List.Insert (index, installer); - } + protected override void OnInsert (int index, object value) { + ((Installer) value).parent = owner; + } - public void Remove (Installer installer) - { - List.Remove (installer); - } + protected override void OnRemove (int index, object value) { + ((Installer) value).parent = null; + } - protected override void OnInsert (int index, object val) - { - ((Installer)val).Parent = parent; - } + protected override void OnSet (int index, object oldValue, object newValue) { + ((Installer) oldValue).parent = null; + ((Installer) newValue).parent = owner; + } - protected override void OnRemove (int index, object val) - { - ((Installer)val).Parent = null; - } + public void Remove (Installer value) { + base.List.Remove(value); + } - protected override void OnSet (int index, object oldVal, object newVal) - { - ((Installer)oldVal).Parent = null; - ((Installer)newVal).Parent = parent; - } -} + #region Private Instance Fields + private Installer owner; + + #endregion Private Instance Fields + } } diff --git a/mcs/class/System.Configuration.Install/System.Configuration.Install/TransactedInstaller.cs b/mcs/class/System.Configuration.Install/System.Configuration.Install/TransactedInstaller.cs index f219e01a44f..9e628d1e18b 100644 --- a/mcs/class/System.Configuration.Install/System.Configuration.Install/TransactedInstaller.cs +++ b/mcs/class/System.Configuration.Install/System.Configuration.Install/TransactedInstaller.cs @@ -1,11 +1,10 @@ -// TransactedInstaller.cs -// System.Configuration.Install.TransactedInstaller class implementation +// System.Configuration.Install.TransactedInstaller.cs // // Author: -// Muthu Kannan (t.manki@gmail.com) +// Gert Driesen (drieseng@users.sourceforge.net) +// +// (C) Novell // -// (C) 2005 Novell, Inc. http://www.novell.com/ -// // // Permission is hereby granted, free of charge, to any person obtaining @@ -28,64 +27,24 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System; using System.Collections; namespace System.Configuration.Install { - -public class TransactedInstaller : Installer { - // Constructors - public TransactedInstaller () - { - } - - // Methods - public override void Install (IDictionary state) + public class TransactedInstaller : Installer { - if (state == null) - throw new ArgumentException ("State saver cannot be null"); - - try { - Context.LogMessage ("Starting transacted installation."); - base.Install (state); - } catch (Exception e) { - try { - Context.LogMessage ("Errors occurred during installation -- starting rollback."); - Context.addToLog (e); - Rollback (state); - } catch (Exception rbke) { - Context.LogMessage ("Rollback failed."); - Context.addToLog (rbke); - } - Context.LogMessage ("Rollback phase completed."); - throw new Exception ("Transacted installation failed.", e); + public TransactedInstaller () + { } - try { - Context.LogMessage ("Installation phase completed successfully -- starting commit."); - Commit (state); - } catch (Exception e) { - Context.LogMessage ("Commit failed."); - Context.addToLog (e); + [MonoTODO] + public override void Install (IDictionary savedState) + { } - Context.LogMessage ("Commit phase completed."); - } - public override void Uninstall (IDictionary state) - { - Context.LogMessage ("Uninstallation started."); - try { - base.Uninstall (state); - } catch (Exception e) { - if (e is ArgumentException) - throw e; - Context.LogMessage ("Errors occurred during uninstallation."); - Context.addToLog (e); - } finally { - Context.LogMessage ("Uninstallation completed."); + [MonoTODO] + public override void Uninstall (IDictionary savedState) + { } } } - -} diff --git a/mcs/class/System.Configuration.Install/System.Configuration.Install_test.dll.sources b/mcs/class/System.Configuration.Install/System.Configuration.Install_test.dll.sources deleted file mode 100644 index f4b1ef5f2e8..00000000000 --- a/mcs/class/System.Configuration.Install/System.Configuration.Install_test.dll.sources +++ /dev/null @@ -1,6 +0,0 @@ -System.Configuration.Install/InstallContextTest.cs -System.Configuration.Install/InstallerCollectionTest.cs -System.Configuration.Install/InstallEventArgsTest.cs -System.Configuration.Install/InstallerTest.cs -System.Configuration.Install/TransactedInstallerTest.cs -System.Configuration.Install/AssemblyInstallerTest.cs diff --git a/mcs/class/System.Configuration.Install/Test/ChangeLog b/mcs/class/System.Configuration.Install/Test/ChangeLog deleted file mode 100644 index 69d40d85359..00000000000 --- a/mcs/class/System.Configuration.Install/Test/ChangeLog +++ /dev/null @@ -1,25 +0,0 @@ -2003/04/15 Nick Drochak <ndrochak@gol.com> - - * System.Configuration.Install_test.build: use nunit version 2. - -2002-03-29 Nick Drochak <ndrochak@gol.com> - - * makefile.gnu: change 8 spaces to tabs - -2003-03-12 Martin Willemoes Hansen <mwh@sysrq.dk> - * Removed AllTests.cs, System.Configuration.Install/AllTests.cs - System.Configuration.Install/ChangeLog - * NUnit2ified makefile.gnu, system_configuration_install_linux_test.args, - * Added System.Configuration.Install/FakeTest.cs - -2002-07-15 Gonzalo Paniagua Javier <gonzalo@ximian.com> - * AllTests.cs: New file. - * System.Configuration.Install_test.build: modified randomly until it - works. - - Fixes 'make test'. - -2002-08-13 Jonathan Pryor <jonpryor@vt.edu> - * ChangeLog: Add change log to this directory - * System.Configuration.Install_test.build: Add build file to this directory. - diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/AssemblyInstallerTest.cs b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/AssemblyInstallerTest.cs deleted file mode 100644 index e04bfe3d603..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/AssemblyInstallerTest.cs +++ /dev/null @@ -1,180 +0,0 @@ -// AssemblyInstallerTest.cs -// NUnit Test Cases for System.Configuration.Install.Installer class -// -// Author: -// Muthu Kannan (t.manki@gmail.com) -// -// (C) 2005 Novell, Inc. http://www.novell.com/ -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using NUnit.Framework; -using System; -using System.Configuration.Install; -using System.Reflection; -using System.IO; -using System.Collections; - -namespace MonoTests.System.Configuration.Install -{ - -[TestFixture] -public class AssemblyInstallerTest { - private AssemblyInstaller ins; - private string[] args; - private Assembly testAssembly; - private const string testAssemblyPath = "Test/System.Configuration.Install/InstallerAssembly.dll"; - StringWriter log; - - [SetUp] - public void SetUp () - { - testAssembly = Assembly.LoadFrom (testAssemblyPath); - args = new string [] { "/Option1", "--Option2", "-Option3=val", "LogFile=", "LogToConsole" }; - ins = new AssemblyInstaller (testAssemblyPath, args); - ins.UseNewContext = false; - log = new StringWriter (); - log.NewLine = "\n"; - Console.SetOut (log); - } - - // Testing constructor with no arguments - [Test] - public void TestCtor01 () - { - AssemblyInstaller i = new AssemblyInstaller (); - Assert.AreEqual (null, i.Path, "#AINSaa01"); - Assert.AreEqual (null, i.Assembly, "#AINSaa02"); - } - - // Testing Assembly property and Path property - // I tried to write another test function that assigns Assembly propery - // and checks Path property value. But the problem I encountered was that - // the assembly path is something from temporary directory. So I could not - // do that. - [Test] - public void TestAssemblyAndPath () - { - AssemblyInstaller i = new AssemblyInstaller (); - i.Path = testAssemblyPath; - Assert.AreEqual (testAssembly, i.Assembly, "#AINSab01"); - } - - // Test CommandLine property - [Test] - public void TestCommandLine () - { - Assert.AreEqual (args, ins.CommandLine, "#AINSac01"); - } - - // Test HelpText property - [Test] - public void TestHelpText () - { - Assert.IsTrue (ins.HelpText.IndexOf ("This is help text from the installer.") != -1, "#AINSad01"); - } - - // Test Installers.Count propery - [Test] - public void TestInstallersCount () - { - string t = ins.HelpText; // calling this would update Installers collection - Assert.AreEqual (1, ins.Installers.Count, "#AINSae01"); - } - - // Test CheckIfInstallable method with non-existing assembly - [Test] - [ExpectedException (typeof (Exception))] - [Category ("NotDotNet")] - // It should throw Exception, as per documentation. - // But it throws FileNotFoundExceptionin Microsoft implementation - public void TestCheckIfInstallable01 () - { - AssemblyInstaller.CheckIfInstallable("NON-EXIST.dll"); - } - - // Test CheckIfInstallable method with non-installable assembly - [Test] - [ExpectedException (typeof (Exception))] - [Category ("NotDotNet")] - // It should throw Exception, as per documentation. - // But it throws InvalidOperationException in Microsoft implementation - public void TestCheckIfInstallable02 () - { - AssemblyInstaller.CheckIfInstallable ("../lib/default/System.Configuration.Install.dll"); - } - - // Test CheckIfInstallable method with installable assembly - [Test] - public void TestCheckIfInstallable03 () - { - AssemblyInstaller.CheckIfInstallable (testAssemblyPath); - } - - // Test Install method - [Test] - public void TestInstall () - { - ins.Install (new Hashtable ()); - string output = log.ToString (); - Assert.IsTrue (output.IndexOf (">>InstallerAssembly.Install called") != -1, "#AINSaf01"); - Assert.AreEqual (-1, output.IndexOf (">>This should not be called"), "#AINSaf02"); - } - - // Test Commit method - [Test] - public void TestCommit () - { - Hashtable ht = new Hashtable (); - ins.Install (ht); - ins.Commit (ht); - string output = log.ToString (); - Assert.IsTrue (output.IndexOf (">>InstallerAssembly.Install called") != -1, "#AINSag01"); - Assert.IsTrue (output.IndexOf (">>InstallerAssembly.Commit called") != -1, "#AINSag02"); - } - - // Test Rollback method - [Test] - public void TestRollback () - { - Hashtable ht = new Hashtable (); - ins.Install (ht); - ins.Rollback (ht); - string output = log.ToString (); - Assert.IsTrue (output.IndexOf (">>InstallerAssembly.Install called") != -1, "#AINSah01"); - Assert.IsTrue (output.IndexOf (">>InstallerAssembly.Rollback called") != -1, "#AINSah02"); - } - - // Test Uninstall method - [Test] - public void TestUninstall () - { - Hashtable ht = new Hashtable (); - ins.Install (ht); - ins.Uninstall (ht); - string output = log.ToString (); - Assert.IsTrue (output.IndexOf (">>InstallerAssembly.Uninstall called") != -1, "#AINSai01"); - } -} - -} diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/ChangeLog b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/ChangeLog deleted file mode 100644 index c36289733ff..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/ChangeLog +++ /dev/null @@ -1,15 +0,0 @@ -2005-03-24 Muthu Kannan <t.manki@gmail.com> - - * AssemblyInstallerTest.cs: New unit test. - * InstallContextTest.cs: Likewise. - * InstallerTest.cs: Likewise. - * InstallEventArgsTest.cs: Likewise. - * InstallerCollectionTest.cs: Likewise. - * TransactedInstallerTest.cs: Likewise. - * InstallerAssembly.cs: New. Used by AssemblyInstallerTest.cs. - -2002-07-15 Gonzalo Paniagua Javier <gonzalo@ximian.com> - - * AllTests.cs: New file. - * ChangeLog: New file. - diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallContextTest.cs b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallContextTest.cs deleted file mode 100644 index 1e7a974b89a..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallContextTest.cs +++ /dev/null @@ -1,84 +0,0 @@ -// InstallContextTest.cs -// NUnit Test Cases for System.Configuration.Install.InstallContext class -// -// Author: -// Muthu Kannan (t.manki@gmail.com) -// -// (C) 2005 Novell, Inc. http://www.novell.com/ -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using NUnit.Framework; -using System; -using System.Configuration.Install; -using System.Collections.Specialized; - -namespace MonoTests.System.Configuration.Install -{ - -[TestFixture] -public class TestInstallContext { - private InstallContext ic; - - // Create an instance to be used in tests - [SetUp] - public void SetUp () - { - string logFile = "./InstallContextTestLog.txt"; - string[] param = new string[] { - "/Option1=value1", - "-Option2=value2", - "-Option3", - "Option4", - "/Option5=True", - "/Option6=no" - }; - ic = new InstallContext (logFile, param); - } - - // Testing constructor with typical arguments - [Test] - public void TestCtor () - { - StringDictionary param; - - Assert.IsFalse (ic.Parameters == null, "#ICTXaa01"); - param = ic.Parameters; - Assert.IsTrue (param.ContainsKey ("Option1"), "#ICTXaa03"); - Assert.IsTrue (param.ContainsKey ("Option2"), "#ICTXaa04"); - Assert.IsTrue (param.ContainsKey ("Option3"), "#ICTXaa05"); - Assert.IsTrue (param.ContainsKey ("Option4"), "#ICTXaa06"); - Assert.IsTrue (param.ContainsKey ("Option5"), "#ICTXaa07"); - Assert.IsTrue (param.ContainsKey ("Option6"), "#ICTXaa08"); - Assert.AreEqual ("value1", param["Option1"], "#ICTXaa09"); - Assert.AreEqual ("value2", param["Option2"], "#ICTXaa10"); - Assert.AreEqual ("", param["Option3"], "#ICTXaa11"); - Assert.AreEqual ("", param["Option4"], "#ICTXaa12"); - Assert.AreEqual ("True", param["Option5"], "#ICTXaa13"); - Assert.AreEqual ("no", param["Option6"], "#ICTXaa14"); - Assert.IsTrue (ic.IsParameterTrue ("Option5"), "#ICTXaa15"); - Assert.IsFalse (ic.IsParameterTrue ("Option6"), "#ICTXaa16"); - } -} - -} diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallEventArgsTest.cs b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallEventArgsTest.cs deleted file mode 100644 index c4de75334f4..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallEventArgsTest.cs +++ /dev/null @@ -1,59 +0,0 @@ -// InstallEventArgsTest.cs -// NUnit Test Cases for System.Configuration.Install.InstallEventArgs class -// -// Author: -// Muthu Kannan (t.manki@gmail.com) -// -// (C) 2005 Novell, Inc. http://www.novell.com/ -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using NUnit.Framework; -using System; -using System.Collections; -using System.Configuration.Install; - -namespace MonoTests.System.Configuration.Install -{ - -[TestFixture] -public class InstallEventArgsTest { - // Test constructor with no arguments - [Test] - public void TestCtor01 () - { - InstallEventArgs iea = new InstallEventArgs (); - Assert.AreEqual (null, iea.SavedState, "#IEARaa01"); - } - - // Test constructor with argument - [Test] - public void TestCtor02 () - { - Hashtable ht = new Hashtable (); - InstallEventArgs iea = new InstallEventArgs (ht); - Assert.AreEqual (ht, iea.SavedState, "#IEARab01"); - } -} - -} diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerAssembly.cs b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerAssembly.cs deleted file mode 100644 index e78720afeac..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerAssembly.cs +++ /dev/null @@ -1,97 +0,0 @@ -// InstallerAssembly.cs -// This file contains an installable assembly's source code. -// -// Author: -// Muthu Kannan (t.manki@gmail.com) -// -// (C) 2005 Novell, Inc. http://www.novell.com/ -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.Configuration.Install; -using System.ComponentModel; - -namespace MonoTests.System.Configuration.Install -{ - -[RunInstaller (true)] -public class InstallerAssembly : Installer { - public override void Install (IDictionary state) - { - base.Install (state); - Context.LogMessage (">>InstallerAssembly.Install called"); - } - - public override void Commit (IDictionary state) - { - base.Commit (state); - Context.LogMessage (">>InstallerAssembly.Commit called"); - } - - public override void Rollback (IDictionary state) - { - base.Rollback (state); - Context.LogMessage (">>InstallerAssembly.Rollback called"); - } - - public override void Uninstall (IDictionary state) - { - base.Uninstall (state); - Context.LogMessage (">>InstallerAssembly.Uninstall called"); - } - - public override string HelpText { - get { - return "This is help text from the installer."; - } - } -} - -[RunInstaller (true)] -class PrivateInstaller : Installer { - public override void Install (IDictionary state) - { - base.Install (state); - Context.LogMessage (">>This should not be called"); - } -} - -[RunInstaller (false)] -public class NotToBeRun : Installer { - public override void Install (IDictionary state) - { - base.Install (state); - Context.LogMessage (">>This should not be called"); - } -} - -[RunInstaller (true)] -public class NotAnInstaller { - public void Install (IDictionary state) - { - } -} - -} diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerCollectionTest.cs b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerCollectionTest.cs deleted file mode 100644 index 4868b651da8..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerCollectionTest.cs +++ /dev/null @@ -1,205 +0,0 @@ -// InstallerCollectionTest.cs -// NUnit Test Cases for System.Configuration.Install.InstallContext class -// -// Author: -// Muthu Kannan (t.manki@gmail.com) -// -// (C) 2005 Novell, Inc. http://www.novell.com/ -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using NUnit.Framework; -using System; -using System.Configuration.Install; -using System.Collections.Specialized; - -namespace MonoTests.System.Configuration.Install -{ - -[TestFixture] -public class InstallerCollectionTest { - private TransactedInstaller ti; - private InstallerCollection ic; - - [SetUp] - public void SetUp () - { - Installer[] ins; - - ins = new AssemblyInstaller[3]; - ins[0] = new AssemblyInstaller (); - ins[1] = new AssemblyInstaller (); - ins[2] = new AssemblyInstaller (); - - ti = new TransactedInstaller (); - ic = ti.Installers; - ic.AddRange (ins); - } - - // Testing Add method - // In addition, it tests these members also: - // Count - // Item (int) // indexer - // Contains (Installer) - // IndexOf (Installer) - [Test] - public void TestAdd () - { - Installer[] ins; - InstallerCollection lic; - - lic = new TransactedInstaller ().Installers; - ins = new AssemblyInstaller[3]; - ins[0] = new AssemblyInstaller (); - ins[1] = new AssemblyInstaller (); - ins[2] = new AssemblyInstaller (); - - lic.Add (ins[0]); - lic.Add (ins[1]); - - Assert.AreEqual (2, lic.Count, "#ICOLaa01"); - Assert.AreEqual (ins[0], lic[0], "#ICOLaa02"); - Assert.AreEqual (ins[1], lic[1], "#ICOLaa03"); - Assert.IsTrue (lic.Contains (ins[0]), "#ICOLaa04"); - Assert.IsTrue (lic.Contains (ins[1]), "#ICOLaa05"); - Assert.IsFalse (lic.Contains (ins[2]), "#ICOLaa06"); - Assert.AreEqual (0, lic.IndexOf (ins[0]), "#ICOLaa07"); - Assert.AreEqual (1, lic.IndexOf (ins[1]), "#ICOLaa08"); - Assert.AreEqual (-1, lic.IndexOf (ins[2]), "#ICOLaa08"); - - lic.Add (ins[2]); - Assert.AreEqual (3, lic.Count, "#ICOLaa09"); - Assert.AreEqual (ins[0], lic[0], "#ICOLaa10"); - Assert.AreEqual (ins[1], lic[1], "#ICOLaa11"); - Assert.AreEqual (ins[2], lic[2], "#ICOLaa12"); - Assert.IsTrue (lic.Contains (ins[0]), "#ICOLaa13"); - Assert.IsTrue (lic.Contains (ins[1]), "#ICOLaa14"); - Assert.IsTrue (lic.Contains (ins[2]), "#ICOLaa15"); - Assert.AreEqual (0, lic.IndexOf (ins[0]), "#ICOLaa16"); - Assert.AreEqual (1, lic.IndexOf (ins[1]), "#ICOLaa17"); - Assert.AreEqual (2, lic.IndexOf (ins[2]), "#ICOLaa18"); - } - - // Testing AddRange method - [Test] - public void TestAddRange01 () - { - Installer[] ins; - InstallerCollection lic; - - lic = new TransactedInstaller ().Installers; - ins = new AssemblyInstaller[3]; - ins[0] = new AssemblyInstaller (); - ins[1] = new AssemblyInstaller (); - ins[2] = new AssemblyInstaller (); - - lic.AddRange (ins); - - Assert.AreEqual (3, lic.Count, "#ICOLab01"); - Assert.AreEqual (ins[0], lic[0], "#ICOLab02"); - Assert.AreEqual (ins[1], lic[1], "#ICOLab03"); - Assert.AreEqual (ins[2], lic[2], "#ICOLab04"); - Assert.IsTrue (lic.Contains (ins[0]), "#ICOLab05"); - Assert.IsTrue (lic.Contains (ins[1]), "#ICOLab06"); - Assert.IsTrue (lic.Contains (ins[2]), "#ICOLab07"); - Assert.AreEqual (0, lic.IndexOf (ins[0]), "#ICOLab08"); - Assert.AreEqual (1, lic.IndexOf (ins[1]), "#ICOLab09"); - Assert.AreEqual (2, lic.IndexOf (ins[2]), "#ICOLab10"); - } - - // Testing Clear method - [Test] - public void TestClear () - { - Assert.AreEqual (3, ic.Count, "#ICOLac01"); - ic.Clear (); - Assert.AreEqual (0, ic.Count, "#ICOLac02"); - } - - // Testing CopyTo method - [Test] - public void TestCopyTo () - { - Installer[] insa = new Installer[ti.Installers.Count]; - ic.CopyTo (insa, 0); - Assert.AreEqual (ic[0], insa[0], "#ICOLad01"); - Assert.AreEqual (ic[1], insa[1], "#ICOLad02"); - Assert.AreEqual (ic[2], insa[2], "#ICOLad03"); - } - - // Testing Insert method - [Test] - public void TestInsert () - { - Installer[] old = new Installer[ti.Installers.Count]; - ic.CopyTo (old, 0); - Installer insert = new AssemblyInstaller (); - ic.Insert (1, insert); - Assert.AreEqual (old[0], ic[0], "#ICOLae01"); - Assert.AreEqual (insert, ic[1], "#ICOLae02"); - Assert.AreEqual (old[1], ic[2], "#ICOLae03"); - Assert.AreEqual (old[2], ic[3], "#ICOLae04"); - } - - // Testing Remove method - [Test] - public void Remove () - { - Installer[] old = new Installer[ti.Installers.Count]; - ic.CopyTo (old, 0); - ic.Remove (old[1]); - Assert.AreEqual (old[0], ic[0], "#ICOLaf01"); - Assert.AreEqual (old[2], ic[1], "#ICOLaf02"); - Assert.AreEqual (2, ic.Count, "#ICOLaf03"); - } - - // Testing RemoveAt method -- normal execution - [Test] - public void RemoveAt01 () - { - Installer[] old = new Installer[ti.Installers.Count]; - ic.CopyTo (old, 0); - ic.RemoveAt (1); - Assert.AreEqual (old[0], ic[0], "#ICOLag01"); - Assert.AreEqual (old[2], ic[1], "#ICOLag02"); - Assert.AreEqual (2, ic.Count, "#ICOLag03"); - } - - // Testing RemoveAt method -- exception case - [Test] - [ExpectedException (typeof (ArgumentOutOfRangeException))] - public void RemoveAt02 () - { - ic.RemoveAt (-1); - } - - // Testing RemoveAt method -- exception case - [Test] - [ExpectedException (typeof (ArgumentOutOfRangeException))] - public void RemoveAt03 () - { - ic.RemoveAt (3); - } -} - -} diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerTest.cs b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerTest.cs deleted file mode 100644 index cae411b1c01..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/InstallerTest.cs +++ /dev/null @@ -1,363 +0,0 @@ -// InstallerTest.cs -// NUnit Test Cases for System.Configuration.Install.Installer class -// -// Author: -// Muthu Kannan (t.manki@gmail.com) -// -// (C) 2005 Novell, Inc. http://www.novell.com/ -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using NUnit.Framework; -using System; -using System.Collections; -using System.Configuration.Install; -using System.Threading; - -namespace MonoTests.System.Configuration.Install -{ - -[TestFixture] -public class InstallerTest { - private Installer ins; - private MyInstaller sub1, sub2; - private CallInfo BfInstEvt, AfInstEvt; - private CallInfo CommittingEvt, CommittedEvt; - private CallInfo BfRbackEvt, AfRbackEvt; - private CallInfo BfUninsEvt, AfUninsEvt; - private Hashtable state; - - [SetUp] - public void SetUp () - { - ins = new Installer (); - state = new Hashtable (); - sub1 = new MyInstaller (); - sub2 = new MyInstaller (); - - BfInstEvt = new CallInfo (); - AfInstEvt = new CallInfo (); - CommittingEvt = new CallInfo (); - CommittedEvt = new CallInfo (); - BfRbackEvt = new CallInfo (); - AfRbackEvt = new CallInfo (); - BfUninsEvt = new CallInfo (); - AfUninsEvt = new CallInfo ();; - - ins.Installers.Add (sub1); - ins.Installers.Add (sub2); - - ins.BeforeInstall += new InstallEventHandler (onBeforeInstall); - ins.AfterInstall += new InstallEventHandler (onAfterInstall); - ins.Committing += new InstallEventHandler (onCommitting); - ins.Committed += new InstallEventHandler (onCommitted); - ins.BeforeRollback += new InstallEventHandler (onBeforeRollback); - ins.AfterRollback += new InstallEventHandler (onAfterRollback); - ins.BeforeUninstall += new InstallEventHandler (onBeforeUninstall); - ins.AfterUninstall += new InstallEventHandler (onAfterUninstall); - } - - // Testing Install method with invalid argument - [Test] - [ExpectedException (typeof (ArgumentException))] - public void TestInstall01 () - { - ins.Install (null); - } - - // Testing Install method - [Test] - public void TestInstall02 () - { - ins.Install (state); - - Assert.IsTrue (sub1.ciInstall.methodCalled, "#INSTaa01"); - Assert.IsFalse (sub1.ciCommit.methodCalled, "#INSTaa02"); - Assert.IsFalse (sub1.ciRollback.methodCalled, "#INSTaa03"); - Assert.IsFalse (sub1.ciUninstall.methodCalled, "#INSTaa04"); - - Assert.IsTrue (sub2.ciInstall.methodCalled, "#INSTaa05"); - Assert.IsFalse (sub2.ciCommit.methodCalled, "#INSTaa06"); - Assert.IsFalse (sub2.ciRollback.methodCalled, "#INSTaa07"); - Assert.IsFalse (sub2.ciUninstall.methodCalled, "#INSTaa08"); - - Assert.IsTrue (sub1.ciInstall.timeOfCall > BfInstEvt.timeOfCall, - "#INSTaa09"); - Assert.IsTrue (sub2.ciInstall.timeOfCall > BfInstEvt.timeOfCall, - "#INSTaa10"); - Assert.IsTrue (sub1.ciInstall.timeOfCall < AfInstEvt.timeOfCall, - "#INSTaa11"); - Assert.IsTrue (sub2.ciInstall.timeOfCall < AfInstEvt.timeOfCall, - "#INSTaa12"); - } - - // Testing Commit method with null argument - [Test] - [ExpectedException (typeof (ArgumentException))] - public void TestCommit01 () - { - ins.Commit (null); - } - - // Testing Commit method with empty hashtable argument - [Test] - [ExpectedException (typeof (ArgumentException))] - public void TestCommit02 () - { - ins.Commit (state); - } - - // Testing Commit with proper arguments - [Test] - public void TestCommit03 () - { - TestInstall02 (); // Call Install method so that - // state hash table is prepared - ins.Commit (state); - - /* - Assert.IsTrue (sub1.ciInstall.methodCalled, "#INSTab01"); - Assert.IsTrue (sub1.ciCommit.methodCalled, "#INSTab02"); - Assert.IsFalse (sub1.ciRollback.methodCalled, "#INSTab03"); - Assert.IsFalse (sub1.ciUninstall.methodCalled, "#INSTab04"); - - Assert.IsTrue (sub2.ciInstall.methodCalled, "#INSTab05"); - Assert.IsTrue (sub2.ciCommit.methodCalled, "#INSTab06"); - Assert.IsFalse (sub2.ciRollback.methodCalled, "#INSTab07"); - Assert.IsFalse (sub2.ciUninstall.methodCalled, "#INSTab08"); - - Assert.IsTrue (sub1.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#INSTab09"); - Assert.IsTrue (sub2.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#INSTab10"); - Assert.IsTrue (sub1.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#INSTab11"); - Assert.IsTrue (sub2.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#INSTab12"); - */ - } - - // Testing Rollback method with null argument - [Test] - [ExpectedException (typeof (ArgumentException))] - public void TestRollback01 () - { - ins.Rollback (null); - } - - // Testing Rollback method with empty hashtable argument - [Test] - [ExpectedException (typeof (ArgumentException))] - public void TestRollback02 () - { - ins.Rollback (state); - } - - // Testing Rollback with proper arguments - [Test] - public void TestRollback03 () - { - TestInstall02 (); // Call Install method so that - // state hash table is prepared - ins.Rollback (state); - - Assert.IsTrue (sub1.ciInstall.methodCalled, "#INSTac01"); - Assert.IsFalse (sub1.ciCommit.methodCalled, "#INSTac02"); - Assert.IsTrue (sub1.ciRollback.methodCalled, "#INSTac03"); - Assert.IsFalse (sub1.ciUninstall.methodCalled, "#INSTac04"); - - Assert.IsTrue (sub2.ciInstall.methodCalled, "#INSTac05"); - Assert.IsFalse (sub2.ciCommit.methodCalled, "#INSTac06"); - Assert.IsTrue (sub2.ciRollback.methodCalled, "#INSTac07"); - Assert.IsFalse (sub2.ciUninstall.methodCalled, "#INSTac08"); - - Assert.IsTrue (sub1.ciRollback.timeOfCall > BfRbackEvt.timeOfCall, - "#INSTac09"); - Assert.IsTrue (sub2.ciRollback.timeOfCall > BfRbackEvt.timeOfCall, - "#INSTac10"); - Assert.IsTrue (sub1.ciRollback.timeOfCall < AfRbackEvt.timeOfCall, - "#INSTac11"); - Assert.IsTrue (sub2.ciRollback.timeOfCall < AfRbackEvt.timeOfCall, - "#INSTac12"); - } - - // Testing Uninstall method with proper argument - [Test] - public void TestUninstall01 () - { - TestInstall02 (); // Call Install method so that - // state hash table is prepared - ins.Uninstall (state); - - Assert.IsTrue (sub1.ciInstall.methodCalled, "#INSTad01"); - Assert.IsFalse (sub1.ciCommit.methodCalled, "#INSTad02"); - Assert.IsFalse (sub1.ciRollback.methodCalled, "#INSTad03"); - Assert.IsTrue (sub1.ciUninstall.methodCalled, "#INSTad04"); - - Assert.IsTrue (sub2.ciInstall.methodCalled, "#INSTad05"); - Assert.IsFalse (sub2.ciCommit.methodCalled, "#INSTad06"); - Assert.IsFalse (sub2.ciRollback.methodCalled, "#INSTad07"); - Assert.IsTrue (sub2.ciUninstall.methodCalled, "#INSTad08"); - - Assert.IsTrue (sub1.ciUninstall.timeOfCall > BfUninsEvt.timeOfCall, - "#INSTad09"); - Assert.IsTrue (sub2.ciUninstall.timeOfCall > BfUninsEvt.timeOfCall, - "#INSTad10"); - Assert.IsTrue (sub1.ciUninstall.timeOfCall < AfUninsEvt.timeOfCall, - "#INSTad11"); - Assert.IsTrue (sub2.ciUninstall.timeOfCall < AfUninsEvt.timeOfCall, - "#INSTad12"); - } - - // Testing Parent property - [Test] - public void TestParent01 () - { - Assert.AreEqual (ins, sub1.Parent, "#INSTae01"); - Assert.AreEqual (ins, sub2.Parent, "#INSTae02"); - } - - [Test] - [ExpectedException (typeof (InvalidOperationException))] - public void TestParent02 () - { - ins.Parent = sub1; - } - - [Test] - [ExpectedException (typeof (InvalidOperationException))] - public void TestParent03 () - { - Installer ins1 = new Installer (); - sub1.Installers.Add (ins1); - ins.Parent = ins1; - } - - [Test] - [ExpectedException (typeof (InvalidOperationException))] - public void TestParent04 () - { - Installer ins1 = new Installer (); - Installer ins2 = new Installer (); - ins1.Installers.Add (ins2); - sub1.Installers.Add (ins1); - ins.Parent = ins1; - } - - private void onBeforeInstall (object sender, InstallEventArgs e) - { - BfInstEvt.SetCalled (); - } - - private void onAfterInstall (object sender, InstallEventArgs e) - { - AfInstEvt.SetCalled (); - } - - private void onCommitting (object sender, InstallEventArgs e) - { - CommittingEvt.SetCalled (); - } - - private void onCommitted (object sender, InstallEventArgs e) - { - CommittedEvt.SetCalled (); - } - - private void onBeforeRollback (object sender, InstallEventArgs e) - { - BfRbackEvt.SetCalled (); - } - - private void onAfterRollback (object sender, InstallEventArgs e) - { - AfRbackEvt.SetCalled (); - } - - private void onBeforeUninstall (object sender, InstallEventArgs e) - { - BfUninsEvt.SetCalled (); - } - - private void onAfterUninstall (object sender, InstallEventArgs e) - { - AfUninsEvt.SetCalled (); - } - - private struct CallInfo - { - public bool methodCalled; - public DateTime timeOfCall; - private const int SLEEP_TIME = 60; // waiting time in ms - - public void SetCalled () - { - methodCalled = true; - // Wait for some time so that time comparison is effective - Thread.Sleep (SLEEP_TIME); - timeOfCall = DateTime.Now; - } - } - - // This is a custom installer base class - private class MyInstaller : Installer { - public CallInfo ciInstall; - public CallInfo ciCommit; - public CallInfo ciRollback; - public CallInfo ciUninstall; - - public MyInstaller () - { - ciInstall = new CallInfo (); - ciCommit = new CallInfo (); - ciRollback = new CallInfo (); - ciUninstall = new CallInfo (); - } - - public override void Install (IDictionary state) - { - base.Install (state); - ciInstall.SetCalled (); - } - - public override void Commit (IDictionary state) - { - base.Commit (state); - ciCommit.SetCalled (); - } - - public override void Rollback (IDictionary state) - { - base.Rollback (state); - ciRollback.SetCalled (); - } - - public override void Uninstall (IDictionary state) - { - base.Uninstall (state); - ciUninstall.SetCalled (); - } - } -} - -} diff --git a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/TransactedInstallerTest.cs b/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/TransactedInstallerTest.cs deleted file mode 100644 index 2c7fb66ab36..00000000000 --- a/mcs/class/System.Configuration.Install/Test/System.Configuration.Install/TransactedInstallerTest.cs +++ /dev/null @@ -1,380 +0,0 @@ -// TransactedInstallerTest.cs -// NUnit Test Cases for System.Configuration.Install.TransactedInstaller class -// -// Author: -// Muthu Kannan (t.manki@gmail.com) -// -// (C) 2005 Novell, Inc. http://www.novell.com/ -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using NUnit.Framework; -using System; -using System.Collections; -using System.Configuration.Install; -using System.Threading; - -namespace MonoTests.System.Configuration.Install -{ - -[TestFixture] -public class TransactedInstallerTest { - private Installer ins; - private MyInstaller sub1, sub2, sub3; - private CallInfo BfInstEvt, AfInstEvt; - private CallInfo CommittingEvt, CommittedEvt; - private CallInfo BfRbackEvt, AfRbackEvt; - private CallInfo BfUninsEvt, AfUninsEvt; - private Hashtable state; - - [SetUp] - public void SetUp () - { - ins = new TransactedInstaller (); - state = new Hashtable (); - sub1 = new SucceedInstaller (); - sub2 = new FailureInstaller (); - sub3 = new SucceedInstaller (); - - BfInstEvt = new CallInfo (); - AfInstEvt = new CallInfo (); - CommittingEvt = new CallInfo (); - CommittedEvt = new CallInfo (); - BfRbackEvt = new CallInfo (); - AfRbackEvt = new CallInfo (); - BfUninsEvt = new CallInfo (); - AfUninsEvt = new CallInfo (); - - ins.Installers.Add (sub1); - string [] cmdLine = new string [] { "/logToConsole=false" }; - ins.Context = new InstallContext ("", cmdLine); // no log file - - ins.BeforeInstall += new InstallEventHandler (onBeforeInstall); - ins.AfterInstall += new InstallEventHandler (onAfterInstall); - ins.Committing += new InstallEventHandler (onCommitting); - ins.Committed += new InstallEventHandler (onCommitted); - ins.BeforeRollback += new InstallEventHandler (onBeforeRollback); - ins.AfterRollback += new InstallEventHandler (onAfterRollback); - ins.BeforeUninstall += new InstallEventHandler (onBeforeUninstall); - ins.AfterUninstall += new InstallEventHandler (onAfterUninstall); - } - - // Testing Install method with invalid argument - [Test] - [ExpectedException (typeof (ArgumentException))] - [Category ("NotDotNet")] - // As per documentation, this should throw ArgumentException, - // but Microsoft implementation throws InvalidOperationException - public void TestInstall01 () - { - ins.Install (null); - } - - // Testing Install method -- successful installation - [Test] - public void TestInstall02 () - { - ins.Installers.Add (sub3); - ins.Install (state); - - Assert.IsTrue (sub1.ciInstall.methodCalled, "#TRINaa01"); - Assert.IsTrue (sub1.ciCommit.methodCalled, "#TRINaa02"); - Assert.IsFalse (sub1.ciRollback.methodCalled, "#TRINaa03"); - Assert.IsFalse (sub1.ciUninstall.methodCalled, "#TRINaa04"); - - Assert.IsTrue (sub3.ciInstall.methodCalled, "#TRINaa05"); - Assert.IsTrue (sub3.ciCommit.methodCalled, "#TRINaa06"); - Assert.IsFalse (sub3.ciRollback.methodCalled, "#TRINaa07"); - Assert.IsFalse (sub3.ciUninstall.methodCalled, "#TRINaa08"); - - Assert.IsTrue (sub1.ciInstall.timeOfCall > BfInstEvt.timeOfCall, - "#TRINaa09"); - Assert.IsTrue (sub3.ciInstall.timeOfCall > BfInstEvt.timeOfCall, - "#TRINaa10"); - Assert.IsTrue (sub1.ciInstall.timeOfCall < AfInstEvt.timeOfCall, - "#TRINaa11"); - Assert.IsTrue (sub3.ciInstall.timeOfCall < AfInstEvt.timeOfCall, - "#TRINaa12"); - - Assert.IsTrue (sub1.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#TRINaa13"); - Assert.IsTrue (sub3.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#TRINaa14"); - Assert.IsTrue (sub1.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#TRINaa15"); - Assert.IsTrue (sub3.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#TRINaa16"); - } - - // Testing Install method -- unsuccessful installation - [Test] - [ExpectedException (typeof (Exception))] - [Category ("NotDotNet")] - // As per documentation, this should throw Exception, - // but Microsoft implementation throws InvalidOperationException - public void TestInstall03 () - { - ins.Installers.Add (sub2); - ins.Install (state); - } - - // Testing Install method -- unsuccessful installation - // In this test case, we are testing rollback functionality - [Test] - public void TestInstall04 () - { - ins.Installers.Add (sub2); - try { - ins.Install (state); - } catch (Exception) { - // Ignore this exception - } - - Assert.IsTrue (sub1.ciInstall.methodCalled, "#TRINab01"); - Assert.IsFalse (sub1.ciCommit.methodCalled, "#TRINab02"); - Assert.IsTrue (sub1.ciRollback.methodCalled, "#TRINab03"); - Assert.IsFalse (sub1.ciUninstall.methodCalled, "#TRINab04"); - - Assert.IsTrue (sub2.ciInstall.methodCalled, "#TRINab05"); - Assert.IsFalse (sub2.ciCommit.methodCalled, "#TRINab06"); - Assert.IsTrue (sub2.ciRollback.methodCalled, "#TRINab07"); - Assert.IsFalse (sub2.ciUninstall.methodCalled, "#TRINab08"); - - Assert.IsTrue (sub1.ciInstall.timeOfCall > BfInstEvt.timeOfCall, - "#TRINab09"); - Assert.IsTrue (sub2.ciInstall.timeOfCall > BfInstEvt.timeOfCall, - "#TRINab10"); - - Assert.IsTrue (sub1.ciRollback.timeOfCall > BfRbackEvt.timeOfCall, - "#TRINab13"); - Assert.IsTrue (sub2.ciRollback.timeOfCall > BfRbackEvt.timeOfCall, - "#TRINab14"); - Assert.IsTrue (sub1.ciRollback.timeOfCall < AfRbackEvt.timeOfCall, - "#TRINab15"); - Assert.IsTrue (sub2.ciRollback.timeOfCall < AfRbackEvt.timeOfCall, - "#TRINab16"); - } - - // Testing Install method with null argument - [Test] - public void TestUninstall01 () - { - ins.Installers.Add (sub3); - ins.Install (state); - ins.Uninstall (null); - - Assert.IsTrue (sub1.ciInstall.methodCalled, "#TRINac01"); - Assert.IsTrue (sub1.ciCommit.methodCalled, "#TRINac02"); - Assert.IsFalse (sub1.ciRollback.methodCalled, "#TRINac03"); - Assert.IsTrue (sub1.ciUninstall.methodCalled, "#TRINac04"); - - Assert.IsTrue (sub3.ciInstall.methodCalled, "#TRINac05"); - Assert.IsTrue (sub3.ciCommit.methodCalled, "#TRINac06"); - Assert.IsFalse (sub3.ciRollback.methodCalled, "#TRINac07"); - Assert.IsTrue (sub3.ciUninstall.methodCalled, "#TRINac08"); - - Assert.IsTrue (sub1.ciUninstall.timeOfCall > BfUninsEvt.timeOfCall, - "#TRINac09"); - Assert.IsTrue (sub3.ciUninstall.timeOfCall > BfUninsEvt.timeOfCall, - "#TRINac10"); - Assert.IsTrue (sub1.ciUninstall.timeOfCall < AfUninsEvt.timeOfCall, - "#TRINac11"); - Assert.IsTrue (sub3.ciUninstall.timeOfCall < AfUninsEvt.timeOfCall, - "#TRINac12"); - - Assert.IsTrue (sub1.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#TRINac13"); - Assert.IsTrue (sub3.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#TRINac14"); - Assert.IsTrue (sub1.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#TRINac15"); - Assert.IsTrue (sub3.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#TRINac16"); - } - - // Testing Install method with corrupt argument - [Test] - [ExpectedException (typeof (ArgumentException))] - [Category ("NotDotNet")] - // As per documentation, this should throw ArgumentException, - // but Microsoft implementation throws NullReferenceException - public void TestUninstall02 () - { - ins.Installers.Add (sub3); - ins.Install (state); - state.Clear (); - ins.Uninstall (state); - } - - // Testing Install method with null argument - [Test] - public void TestUninstall03 () - { - ins.Installers.Add (sub3); - ins.Install (state); - ins.Uninstall (state); - - Assert.IsTrue (sub1.ciInstall.methodCalled, "#TRINad01"); - Assert.IsTrue (sub1.ciCommit.methodCalled, "#TRINad02"); - Assert.IsFalse (sub1.ciRollback.methodCalled, "#TRINad03"); - Assert.IsTrue (sub1.ciUninstall.methodCalled, "#TRINad04"); - - Assert.IsTrue (sub3.ciInstall.methodCalled, "#TRINad05"); - Assert.IsTrue (sub3.ciCommit.methodCalled, "#TRINad06"); - Assert.IsFalse (sub3.ciRollback.methodCalled, "#TRINad07"); - Assert.IsTrue (sub3.ciUninstall.methodCalled, "#TRINad08"); - - Assert.IsTrue (sub1.ciUninstall.timeOfCall > BfUninsEvt.timeOfCall, - "#TRINad09"); - Assert.IsTrue (sub3.ciUninstall.timeOfCall > BfUninsEvt.timeOfCall, - "#TRINad10"); - Assert.IsTrue (sub1.ciUninstall.timeOfCall < AfUninsEvt.timeOfCall, - "#TRINad11"); - Assert.IsTrue (sub3.ciUninstall.timeOfCall < AfUninsEvt.timeOfCall, - "#TRINad12"); - - Assert.IsTrue (sub1.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#TRINad13"); - Assert.IsTrue (sub3.ciCommit.timeOfCall > CommittingEvt.timeOfCall, - "#TRINad14"); - Assert.IsTrue (sub1.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#TRINad15"); - Assert.IsTrue (sub3.ciCommit.timeOfCall < CommittedEvt.timeOfCall, - "#TRINad16"); - } - - private void onBeforeInstall (object sender, InstallEventArgs e) - { - BfInstEvt.SetCalled (); - } - - private void onAfterInstall (object sender, InstallEventArgs e) - { - AfInstEvt.SetCalled (); - } - - private void onCommitting (object sender, InstallEventArgs e) - { - CommittingEvt.SetCalled (); - } - - private void onCommitted (object sender, InstallEventArgs e) - { - CommittedEvt.SetCalled (); - } - - private void onBeforeRollback (object sender, InstallEventArgs e) - { - BfRbackEvt.SetCalled (); - } - - private void onAfterRollback (object sender, InstallEventArgs e) - { - AfRbackEvt.SetCalled (); - } - - private void onBeforeUninstall (object sender, InstallEventArgs e) - { - BfUninsEvt.SetCalled (); - } - - private void onAfterUninstall (object sender, InstallEventArgs e) - { - AfUninsEvt.SetCalled (); - } - - private struct CallInfo - { - public bool methodCalled; - public DateTime timeOfCall; - private const int SLEEP_TIME = 60; // waiting time in ms - - public void SetCalled () - { - methodCalled = true; - // Wait for some time so that time comparison is effective - Thread.Sleep (SLEEP_TIME); - timeOfCall = DateTime.Now; - } - } - - // This is a custom installer base class - private class MyInstaller : Installer { - public CallInfo ciInstall; - public CallInfo ciCommit; - public CallInfo ciRollback; - public CallInfo ciUninstall; - - public MyInstaller () - { - ciInstall = new CallInfo (); - ciCommit = new CallInfo (); - ciRollback = new CallInfo (); - ciUninstall = new CallInfo (); - } - - public override void Install (IDictionary state) - { - base.Install (state); - ciInstall.SetCalled (); - } - - public override void Commit (IDictionary state) - { - base.Commit (state); - ciCommit.SetCalled (); - } - - public override void Rollback (IDictionary state) - { - base.Rollback (state); - ciRollback.SetCalled (); - } - - public override void Uninstall (IDictionary state) - { - base.Uninstall (state); - ciUninstall.SetCalled (); - } - } - - private class SucceedInstaller : MyInstaller { - // Nothing to override - } - - private class FailureInstaller : MyInstaller { - public override void Install (IDictionary state) - { - base.Install (state); - throw new Exception("I always fail."); - } - - public override void Uninstall (IDictionary state) - { - base.Uninstall (state); - throw new Exception("I always fail."); - } - } -} - -} diff --git a/mcs/class/System.Configuration.Install/Test/system_configuration_install_linux_test.args b/mcs/class/System.Configuration.Install/Test/system_configuration_install_linux_test.args deleted file mode 100644 index 6c67366cd3a..00000000000 --- a/mcs/class/System.Configuration.Install/Test/system_configuration_install_linux_test.args +++ /dev/null @@ -1 +0,0 @@ -System.Configuration.Install/FakeTest.cs |