/// <summary> /// Adds the element. /// </summary> public void addElement(TraceElement newElement) { if (newElement == null) { return; } if (newElement.Type == TraceType.UNKNOWN) { return; } if (newElement.FileName == null) { return; } if (newElement.FileName.Length == 0) { return; } lock (_qeueLock) { elementQeue.Enqueue(newElement); } }
/// <summary> /// Shows the history of trace entry. /// </summary> private void showHistoryOfTraceEntry() { debug("MainWindow.showHistoryOfTraceEntry() - SelectedTraceElement Index : " + traceListBox.SelectedIndex); TraceElement activeTraceElement = traceElementList[traceListBox.SelectedIndex] as TraceElement; if (activeTraceElement == null) { debug("MainWindow.showHistoryOfTraceEntry() - SelectedTraceElement is NULL !!! ---"); return; } traceBindingList.Clear(); //fileContentBindingList.Clear(); debug("MainWindow.showHistoryOfTraceEntry() - File: " + activeTraceElement.FileName + " / Line: " + activeTraceElement.LineNumber); for (int i = 0; i < traceElementList.Count; i++) { if (activeTraceElement.FileName.CompareTo(traceElementList[i].FileName) != 0) { continue; } if (activeTraceElement.LineNumber != traceElementList[i].LineNumber) { continue; } traceBindingList.Add(new TraceGuiListItem(traceElementList[i])); } }
internal bool Answered() { TraceElement e = Trace.TraceCall(this, "Answered"); var result = Example3Test.B0; e.Result = result; return(result); }
internal Call Call(string number) { TraceElement e = Trace.TraceCall(this, "Call", number); var result = new Call(number); e.Result = result; return(result); }
public void visitTrace(TraceElement element, TestPosition position) { if (_executingPastDiscovery != null) { _traceTracker.AddTraceEntry(position, element.Message); } if (_executingCleanup != null) { throw new Exception("Attempted to call " + element + "() from within " + _executingCleanup); } }
/// <summary> /// Traces the GUI element. /// </summary> /// <param name="traceElement">The trace element.</param> public TraceGuiListItem(TraceElement traceElement) { type = traceElement.Type; codeLine = traceElement.CodeLine; fileName = traceElement.FileName; lineNumber = traceElement.LineNumber; dataByte = traceElement.getByte(); dataWord = traceElement.getWord(); dataLong = traceElement.getLong(); dataArray = traceElement.getArray(); }
/// <summary> /// Gets the next. /// </summary> /// <returns></returns> public TraceElement getNext() { TraceElement element = null;// new TraceElement(); lock (_qeueLock) { if (elementQeue.Count > 0) { element = elementQeue.Dequeue(); } } return(element); }
/// <summary> /// Loads the traces from interface. /// </summary> private void loadTracesFromInterface() { TraceElement traceElement = TracerFactory.getInstance().getInterface().getNextElement(); int elementCoutner = 0; while (traceElement != null) { elementCoutner += 1; // -------------------traceBindingList.Add(new TraceGuiListItem(traceElement)); traceElementList.Add(traceElement); traceElement = TracerFactory.getInstance().getInterface().getNextElement(); } labelTraceCount.Text = Convert.ToString(traceBindingList.Count); debug("MainWindow.loadTracesFromInterface() - New Element count: " + elementCoutner); }
private bool TrySetupServer(int tryIndex, AppDomain sandbox, RunFrame frame) { string baseAddress; string port = _portArranger.Reserve(); SecurityHelper.AddIpListen(); SecurityOptionElement securityElem = frame.GetFirstElement <SecurityOptionElement>(); if (securityElem != null) { SetupSecureEnvironment(securityElem.Certificate, port); baseAddress = string.Format(SecureBaseAddressTemplate, Environment.MachineName, port); frame.SetState(KeyIsSecuredServer, true); } else { baseAddress = string.Format(NormalBaseAddressTemplate, Environment.MachineName, port); frame.SetState(KeyIsSecuredServer, false); } // looking into the RunFrames and search for TraceElement. if it exists // set the tracer's type to the configuration otherwise skip this step TraceElement traceElem = frame.GetFirstElement <TraceElement>(); Type traceType = null; if (traceElem != null) { traceType = traceElem.TracerType; } KatanaSelfHostServerInitiator serverInitiator; // create initiator in the sandbox if (sandbox != null) { serverInitiator = sandbox.CreateInstanceAndUnwrap( typeof(KatanaSelfHostServerInitiator).Assembly.FullName, typeof(KatanaSelfHostServerInitiator).FullName) as KatanaSelfHostServerInitiator; } else { serverInitiator = new KatanaSelfHostServerInitiator(); } try { // set up the server serverInitiator.Setup( baseAddress, TypeDescriptor.GetDesignatedMethod <NuwaKatanaConfigurationAttribute>(), TypeDescriptor.ConfigureMethod, traceType, GetDefaultRouteTemplate()); } catch (Exception ex) { EventLog appLog = new System.Diagnostics.EventLog(); appLog.Source = "Nuwa Katana Self Host Test"; appLog.WriteEntry(string.Format("try index: {0}\nbase address: {1}\n message: {2}\n stack trace: {3}\n", tryIndex, baseAddress, ex.Message, ex.StackTrace), EventLogEntryType.Error); return(false); } frame.SetState(KeyReservedPort, port); frame.SetState(KeyBaseAddresss, baseAddress); frame.SetState(KeyServerInitiator, serverInitiator); return(true); }
private IDirectory GetAssemblyAndResourceDirectory(WebHostContext context) { var descriptor = context.TestType; var frame = context.Frame; var options = WebAppSetupOptions.GenerateDefaultOptions(); options.AddWebApiAssemblies(); options.AddRoute( new WebAPIRouteSetup( "api default", "api/{controller}/{action}", "new { action = " + typeof(RouteParameter).FullName + ".Optional }")); var deploymentDescriptor = context.Deployment; if (deploymentDescriptor.ScopePath != null) { var resourceAssembly = deploymentDescriptor.ScopeResourceType != null ? deploymentDescriptor.ScopeResourceType.Assembly : descriptor.TestAssembly; options.AddAssemblyAndReferences(resourceAssembly); options.AddTextFilesFromResources(resourceAssembly, deploymentDescriptor.ScopePath); } if (options.TextFiles.ContainsKey("web.config")) { options.UpdateWebConfig(WebConfigHelper.Load(options.TextFiles["web.config"])); } if (!descriptor.TestControllerTypes.Any()) { if (descriptor.TestAssembly == null) { throw new InvalidOperationException( "Neither Controller Types or test assembly is given to web-host strategy. " + "That will cause issue in runtime, because the assemblies contain the controller " + "will not be copied to IIS website bin folder. Please given Controller Type by " + "NuwaControllerAttribute."); } options.AddAssemblyAndReferences(descriptor.TestAssembly); } else { foreach (var ct in descriptor.TestControllerTypes) { options.AddAssemblyAndReferences(ct.Assembly); } } // set trace writer TraceElement traceElem = frame.GetFirstElement <TraceElement>(); if (traceElem != null) { options.TraceWriterType = traceElem.TracerType; } // set configure action if (descriptor.ConfigureMethod != null) { options.ConfigureMethod = descriptor.ConfigureMethod; options.AddAssemblyAndReferences(options.ConfigureMethod.Module.Assembly); } // TODO: are they used in all situation? // setup katana integration pipeline if (descriptor.GetDesignatedMethod <NuwaKatanaConfigurationAttribute>() != null) { options.AddAssemblyAndReferences(Assembly.Load("Microsoft.Owin.Host.SystemWeb")); options.UpdateWebConfig(config => { var method = descriptor.GetDesignatedMethod <NuwaKatanaConfigurationAttribute>(); config.AddAppSection( "owin:AppStartup", string.Format("{0}.{1}, {2}", method.DeclaringType.FullName, method.Name, method.DeclaringType.Assembly.GetName().Name)); }); } else if (EnableDefaultOwinWebApiConfiguration) { options.AddAssemblyAndReferences(Assembly.Load("Microsoft.Owin.Host.SystemWeb")); options.UpdateWebConfig(config => { config.AddAppSection( "owin:AppStartup", string.Format("{0}.{1}, {2}", typeof(WebBaseHostElement).FullName, "DefaultOwinWebApiConfiguration", typeof(WebBaseHostElement).Assembly.GetName().Name)); if (options.TraceWriterType != null) { config.AddAppSection( NuwaGlobalConfiguration.TraceWriterTypeKey, string.Format("{0}, {1}", options.TraceWriterType.FullName, options.TraceWriterType.Assembly.GetName().Name)); } if (options.ConfigureMethod != null) { config.AddAppSection( NuwaGlobalConfiguration.HttpConfigureKey, string.Format("{0}.{1}, {2}", options.ConfigureMethod.DeclaringType.FullName, options.ConfigureMethod.Name, options.ConfigureMethod.DeclaringType.Assembly.GetName().Name)); } }); } else { options.UpdateWebConfig(config => { config.AddAppSection( "owin:AutomaticAppStartup", "false"); }); } // update web.config if (descriptor.WebConfigMethod != null) { Action <WebConfigHelper> action = Delegate.CreateDelegate( typeof(Action <WebConfigHelper>), descriptor.WebConfigMethod) as Action <WebConfigHelper>; if (action != null) { options.UpdateWebConfig(action); } } // retrieve partial trust element options.UpdateWebConfig(webConfig => webConfig.ConfigureTrustLevel("Full")); var ramfarSetting = ConfigurationManager.AppSettings["runAllManagedModulesForAllRequests"]; if (ramfarSetting != null && string.Equals(ramfarSetting, "true", StringComparison.InvariantCultureIgnoreCase)) { options.UpdateWebConfig(webConfig => webConfig.AddRAMFAR(true)); } // Update deployment options if (descriptor.WebDeployConfigMethod != null) { descriptor.WebDeployConfigMethod.Invoke(null, new object[] { options }); } if (EnableGlobalAsax) { options.GenerateGlobalAsaxForCS(); } doAdditionalAssemblyAndREferences(); doAdditionalUpdateWebConfig(); return(options.ToDirectory()); }
public void visitTrace(TraceElement element, TestPosition position) { _runContext.State.visitTrace(element, position); }
protected override bool InitializeServer(RunFrame frame) { string baseAddress; string port; var sandbox = CreateFullTrustAppDomain(); frame.SetState(KeySandbox, sandbox); // load test assemly into sandbox if (sandbox != null && TypeDescriptor.TestAssembly != null) { sandbox.Load(TypeDescriptor.TestAssembly.GetName()); } // setup security strategy and base address port = _portArranger.Reserve(); SecurityHelper.AddIpListen(); SecurityOptionElement securityElem = frame.GetFirstElement <SecurityOptionElement>(); if (securityElem != null) { SetupSecureEnvironment(securityElem.Certificate, port); baseAddress = string.Format(SecureBaseAddressTemplate, Environment.MachineName, port); frame.SetState(KeyIsSecuredServer, true); } else { baseAddress = string.Format(NormalBaseAddressTemplate, Environment.MachineName, port); frame.SetState(KeyIsSecuredServer, false); } // looking into the RunFrames and search for TraceElement. if it exists // set the tracer's type to the configuration otherwise skip this step TraceElement traceElem = frame.GetFirstElement <TraceElement>(); Type traceType = null; if (traceElem != null) { traceType = traceElem.TracerType; } // create initiator in the sandbox KatanaSelfHostServerInitiator serverInitiator; if (sandbox != null) { serverInitiator = sandbox.CreateInstanceAndUnwrap( typeof(KatanaSelfHostServerInitiator).Assembly.FullName, typeof(KatanaSelfHostServerInitiator).FullName) as KatanaSelfHostServerInitiator; } else { serverInitiator = new KatanaSelfHostServerInitiator(); } // set up the server serverInitiator.Setup( baseAddress, TypeDescriptor.GetDesignatedMethod <NuwaKatanaConfigurationAttribute>(), TypeDescriptor.ConfigureMethod, traceType, GetDefaultRouteTemplate()); frame.SetState(KeyReservedPort, port); frame.SetState(KeyBaseAddresss, baseAddress); frame.SetState(KeyServerInitiator, serverInitiator); return(true); }
/// <summary> /// Executes this instance. /// </summary> public void execute() { markExecutionTime(); switch (actualTaskState) { default: case BasicTaskStates.TASK_STATE_ILDE: if (!getContext().TraceActive) { break; } if (getTraceTableRaw().getSize() == 0) { break; } debug("TracerFileLoadTask.execute() - Starting File loading"); actualTaskState = BasicTaskStates.TASK_STATE_INIT; break; case BasicTaskStates.TASK_STATE_INIT: actualTaskState = BasicTaskStates.TASK_STATE_RUNNING; break; case BasicTaskStates.TASK_STATE_RUNNING: if (!getContext().TraceActive) { debug("TracerFileLoadTask.execute() - Tracing not active anymore - go into idle"); actualTaskState = BasicTaskStates.TASK_STATE_ILDE; break; } while (getTraceTableRaw().getSize() != 0) { TraceElement traceElement = getTraceTableRaw().getNext(); if (traceElement.Type == TraceType.UNKNOWN) { continue; } string filePath = (getContext().BasicFilePath + traceElement.FileName).Replace("/", "\\"); debug("TracerFileLoadTask.execute() - Loading File: " + filePath); string[] fileContent = getFileFactory().getFileContentAsLineArray(filePath); if (fileContent.Length == 0) { debug(DEBUG_LEVEL.ERROR, "TracerFileLoadTask.execute() - File not found !!! --- (" + filePath + ")"); continue; } if (traceElement.LineNumber > fileContent.Length - 1) { debug(DEBUG_LEVEL.ERROR, "TracerFileLoadTask.execute() - Error reading file !!! --- (" + filePath + ")"); continue; } traceElement.CodeLine = fileContent[traceElement.LineNumber]; getTraceTable().addElement(traceElement); } this.invokeEvent(TracerEventType.NEW_TRACE_RECORD); break; } }
public void visitTrace(TraceElement element, TestPosition position) { }
public void visitTrace(TraceElement element, TestPosition position) { _runContext.AddTrace(element.Message); }