/// <summary>Constructor.</summary>
        /// <param name="info">Log metadata object.</param>
        public EmailOutput(LogInfo info)
        {
            // Process the metadata on construction to fail before any tests are run on critical error.
            this.msg = new StringBuilder(200);
            this.address    = info.OutputData.GetCredential(CredentialType.ADDRESS);
            this.from       = info.OutputData.GetCredential(CredentialType.EMAIL_FROM);
            this.to         = info.OutputData.GetCredential(CredentialType.EMAIL_TO);
            this.subject    = info.OutputData.GetOptionalCredential(CredentialType.EMAIL_SUBJECT, "");
            this.user       = info.OutputData.GetOptionalCredential(CredentialType.USER, "");
            this.password   = info.OutputData.GetOptionalCredential(CredentialType.PASSWORD, "");

            if (this.subject.Length == 0) {
            this.subject = "Test Result " + TestEngine.GetInstance().GetRunId();
            }

            String tmp = info.OutputData.GetOptionalCredential(CredentialType.PORT, "");
            if (tmp.Length > 0) {
            try {
                this.port = Int32.Parse(tmp);
            }
            catch(Exception) {
                throw new InputException(
                    "Cannot convert PORT output credential:" + tmp + " into a port number");
            }
            }
        }
        /// <summary>Constructor.</summary>
        /// <param name="info">Log metadata object.</param>
        public FileOutput(LogInfo info)
        {
            this.info = info;

            fileName = this.info.OutputData.Name;
            if (this.info.OutputData.IsUniqueName) {
            fileName = fileName + TestEngine.GetInstance().GetRunId();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Implements the method from IQueryable. Allows the objects data to be querried.
 /// </summary>
 /// <param name="columnDef">Column metadata.</param>
 /// <param name="info">Log metadata.</param>
 /// <returns>The string format of the data indexed by the column's metadata.</returns>
 public String GetValue(ColumnDef columnDef, LogInfo info)
 {
     if (columnDef.Name.CompareTo("SuccessCount") == 0) {
     return Convert.ToString(this.successCount);
     }
     else if (columnDef.Name.CompareTo("FailInitCount") == 0) {
     return Convert.ToString(this.failInitCount);
     }
     else if (columnDef.Name.CompareTo("FailSetupCount") == 0) {
     return Convert.ToString(this.failSetupCount);
     }
     else if (columnDef.Name.CompareTo("FailTestCount") == 0) {
     return Convert.ToString(this.failTestCount);
     }
     else if (columnDef.Name.CompareTo("FailCleanupCount") == 0) {
     return Convert.ToString(this.failCleanupCount);
     }
     else if (columnDef.Name.CompareTo("NotExistCount") == 0) {
     return Convert.ToString(this.notExistCount);
     }
     else if (columnDef.Name.CompareTo("UncheckedExceptionCount") == 0) {
     return Convert.ToString(this.exceptionCount);
     }
     else if (columnDef.Name.CompareTo("JavaErrorCount") == 0) {
     return Convert.ToString(this.assertCount);
     }
     else if (columnDef.Name.CompareTo("TotalCount") == 0) {
     return Convert.ToString(
             this.failInitCount + this.failSetupCount + this.failCleanupCount +
             this.failTestCount + this.successCount   + this.notExistCount + exceptionCount +
             this.assertCount
         );
     }
     else if (columnDef.Name.CompareTo("RunId") == 0) {
     // Do NOT do a truncate check against the run id.  The output would become useless to identify.
     // Better let it to fail on length limit.
     return new StringBuilder()
         .Append(info.SyntaxData.StringDelimiter)
         .Append(TestEngine.GetInstance().GetRunId())
         .Append(info.SyntaxData.StringDelimiter)
         .ToString();
     }
     else
     {
     StringBuilder sb = new StringBuilder( 200 );
     sb.Append( "Illegal column name:" ).Append(columnDef.Name);
     sb.Append( " - Allowable values are:" );
     sb.Append( "SuccessCount, FailInitCount, FailSetupCount, FailTestCount, " );
     sb.Append( "FailCleanupCount, NotExistCount, RunId, TotalCount" );
     throw new InputException( sb.ToString() );
     }
 }
 /// <summary>Creates the appropriate IOutputable derived object.</summary>
 /// <param name="info">The data necessary to create the object.</param>
 /// <returns>The IOutputable object.</returns>
 /// <exception cref="InputException"/>
 public static IOutputable Create(LogInfo info)
 {
     switch (info.OutputData.Type) {
     case OutputType.CONSOLE:
     return new ConsoleOutput();
     case OutputType.FILE:
     return new FileOutput(info);
     case OutputType.ODBC:
     return new OdbcOutput(info);
     case OutputType.EMAIL:
     return new EmailOutput(info);
     default:
     throw new InputException(InvalidEnumMessage.Get(info.OutputData.Type));
     }
 }
Beispiel #5
0
 /// <summary>Constructor to create a new LogInfo metadata oject.</summary>
 /// <param name="name">The name of the Log.</param>
 /// <param name="type">The type of the Log.</param>
 /// <param name="LogSuccessCases">Flag to indicate if successful test cases are logged.</param>
 /// <param name="syntax">The Log output syntax. Like SQL or CVS.</param>
 /// <param name="columnDefs">List of Definitions information for each field logged.</param>
 /// <param name="outputInfo">Creation information for the Log's Output object.</param>
 public LogInfo(
 String name, 
 LogType type, 
 bool logSuccessCases,
 LogSyntaxInfo syntax, 
 List<ColumnDef> columnDefs,
 OutputInfo outputInfo,
 LogInfo summaryLogInfo)
 {
     this.Name = name;
     this.Type = type;
     this.LogSuccessCases = logSuccessCases;
     this.SyntaxData = syntax;
     this.ColumnDefs = columnDefs;
     this.OutputData = outputInfo;
     this.SummaryLogInfo = summaryLogInfo;
 }
Beispiel #6
0
 /// <summary>Constructor.</summary>
 /// <param name="info">Log metadata.</param>
 public TextLog(LogInfo info)
     : base(info)
 {
     this.logInfo = info;
 }
 // Wrap string data in string delimiters quotes.
 private string WrapStringData(string str, ColumnDef columnDef, LogInfo info)
 {
     return new StringBuilder(25)
     .Append(info.SyntaxData.StringDelimiter)
     .Append(this.TrimToSize(str, columnDef))
     .Append(info.SyntaxData.StringDelimiter).ToString();
 }
 // Assemble the verbose buffer message.
 private string BuildVerboseBufferStr(ColumnDef columnDef, LogInfo info)
 {
     //TODO Look at moving this to an output level object.
     StringBuilder sb = new StringBuilder();
     sb.Append(info.SyntaxData.StringDelimiter);
     if (this.VerboseBuffer.Length > 0)
     {
     StringBuilder tmpSb = new StringBuilder();
     tmpSb.Append(info.OutputData.NewLineSequence)
         .Append("-----------------------------------").Append(info.OutputData.NewLineSequence)
         .Append(this.VerboseBuffer.ToString())
         .Append(info.OutputData.NewLineSequence);
     sb.Append(this.TrimToSize(tmpSb.ToString(), columnDef));
     }
     return sb.Append(info.SyntaxData.StringDelimiter).ToString();
 }
        /// <summary>
        /// Implements the ILogable interface GetValue.  This allows the object to be queried for 
        /// its values.
        /// </summary>
        /// <param name="columnDef">Column metadata.</param>
        /// <param name="info">Log metadata</param>
        /// <returns>The string representation of the queried data field.</returns>
        public String GetValue(ColumnDef columnDef, LogInfo info)
        {
            if (columnDef.Name.CompareTo("Identifier") == 0) {
            return this.WrapStringData(this.Id, columnDef, info);
            }
            else if (columnDef.Name.CompareTo("Description") == 0) {
            return this.WrapStringData(this.desc, columnDef, info);
            }
            else if (columnDef.Name.CompareTo("Status") == 0) {
            return this.WrapStringData(this.Status.ToString(), columnDef, info);
            }
            else if (columnDef.Name.CompareTo("Message") == 0) {
            return this.WrapStringData(this.MsgBuffer.ToString(), columnDef, info);
            }
            else if (columnDef.Name.CompareTo("InitTime") == 0) {
            return Convert.ToString(this.initTime);
            }
            else if (columnDef.Name.CompareTo("SetupTime") == 0) {
            return Convert.ToString(this.setupTime);
            }
            else if (columnDef.Name.CompareTo("ExecTime") == 0) {
            return Convert.ToString(this.execTime);
            }
            else if (columnDef.Name.CompareTo("CleanupTime") == 0) {
            return Convert.ToString(this.cleanupTime);
            }
            else if (columnDef.Name.CompareTo("RunId") == 0) {
            // Do NOT truncate run id or output could be useless as identifier. Better let it to fail.
            return new StringBuilder()
                .Append(info.SyntaxData.StringDelimiter)
                .Append(TestEngine.GetInstance().GetRunId())
                .Append(info.SyntaxData.StringDelimiter).ToString();
            }
            else if (columnDef.Name.CompareTo("VerboseMessage") == 0) {
            return this.BuildVerboseBufferStr(columnDef, info);
            }
            else
            {
            StringBuilder sb = new StringBuilder( 200 );
            sb.Append("Illegal column name:").Append(columnDef.Name)
                .Append(" - Allowable values are:")
                .Append("ID, Description, Status, InitTime,SetupTime, ExecTime, CleanupTime, RunId Message, VerboseMessage");
            throw new InputException(sb.ToString());

            // TODO - Replace with our own exceptions.
            throw new System.ArgumentException(sb.ToString());
            }
        }
 /// <summary>Constructor.</summary>
 /// <param name="info">Log info used to intialise the output.</param>
 public OdbcOutput(LogInfo info)
 {
     this.info = info;
 }
Beispiel #11
0
 /// <summary>Constructor.</summary>
 /// <param name="info">Log metadata.</param>
 public SqlLog(LogInfo info)
     : base(info)
 {
     builder = new SqlBuilder(info);
 }
Beispiel #12
0
        private int successCount = 0; // Counter for successful tests.

        #endregion Fields

        #region Constructors

        /// <summary>Constructor.</summary>
        /// <param name="info">The metadata to create the data logging.</param>
        public Log(LogInfo info)
        {
            this.logInfo    = info;
            this.output     = OutputFactory.Create(this.logInfo);
            this.summaryLog = LogFactory.Create(this.logInfo.SummaryLogInfo);
        }