///////////////////////////////////////////////////////////////////////// 
Render and return partial output for one finished test case.

@param tc
351853
function(tc) {
            var t = this;
            var output = '';
            if (tc.getResult() != TestCase.UNTESTED) {

                output += '        <testcase name="' + encode(tc.getName()) + '"'
                    + ' time="' + (tc.getDuration() / 1000) + '">\n';

                if (tc.getResult() == TestCase.SKIPPED) {
                    output += '            <skipped></skipped>\n';
                }

                tc.getAssertions().forEach(
                    function(assertion) {
                        output += t.getAssertion(assertion);
                    }
                );

                var ge = tc.getGeneralError();
                if (ge) {
                    output += t.getError(ge);
                }

                output += '        </testcase>\n';
            }
            return output;
        }
1346970
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTabSet tabSet = (WTabSet) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:tabset");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendAttribute("type", getTypeAsString(tabSet.getType()));
		xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true");
		xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight());
		xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true");
		xml.appendOptionalAttribute("single",
				TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(),
				"true");
		if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) {
			xml.appendOptionalAttribute("groupName", tabSet.getGroupName());
		}
		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(tabSet, renderContext);

		paintChildren(tabSet, renderContext);

		xml.appendEndTag("ui:tabset");
	}
1279082
private void generateTCBasedData(List<TestCaseResult> allTestsList) {
        logger.entering(allTestsList);
        SummarizedData tempClass;
        SummarizedData tempGroupClass;
        Map<String, SummarizedData> mpClassData = new HashMap<String, SummarizedData>();
        int outputSheetRowCounter = 3;

        for (TestCaseResult tcResult : allTestsList) {

            // Segregating for class data
            String sTempClassName = tcResult.getClassName();

            // If class not already added to Class data, then create new ClassObject exists
            if (!mpClassData.containsKey(sTempClassName)) {
                tempClass = new SummarizedData();
                tempClass.setsName(sTempClassName);

            } else {
                tempClass = mpClassData.get(sTempClassName);
            }

            // Adding test to total count
            tempClass.incrementiTotal();

            // Adding all groups to map
            for (String sGroup : tcResult.getGroup()) {

                // Forming a key for the GroupClass map which is <GroupName><ClassName>
                String sGroupClassName = sGroup + sTempClassName;
                if (!mpGroupClassData.containsKey(sGroupClassName)) {
                    tempGroupClass = new SummarizedData();
                    tempGroupClass.setsName(sTempClassName);
                } else {
                    tempGroupClass = mpGroupClassData.get(sGroupClassName);
                }

                tempGroupClass.incrementiTotal();
                tempGroupClass.incrementCount(tcResult.getStatus());
                tempGroupClass.incrementDuration(tcResult.getDurationTaken());
                mpGroupClassData.put(sGroupClassName, tempGroupClass);
            }

            // Segregating for detailed Testcase Status wise data
            List<String> str = new ArrayList<String>();
            str.add(tcResult.getClassName());
            str.add(tcResult.getMethodName());
            str.add(tcResult.getTestDesc());
            str.add(tcResult.getGroup().toString());
            str.add(String.valueOf(tcResult.getDurationTaken()));
            str.add("'" + ReportSheetNames.TESTOUTPUTDETAILSREPORT.getName() + "'!B"
                    + Integer.toString(outputSheetRowCounter));

            List<String> outputStr = new ArrayList<String>();
            outputStr.add("Class Name:" + tcResult.getClassName());
            outputStr.add("Method/Testcase id:" + tcResult.getMethodName());
            outputStr.addAll(tcResult.getssmsg());

            // Based on status, incrementing class count and adding str to correct
            // list for TC detailed report
            switch (tcResult.getStatus()) {
                case ITestResult.FAILURE: {
                    tcFailedData.add(str);
                    // For failed cases adding data for defect description sheet
                    for (int iErrorCount = 0; iErrorCount < tcResult.getError().size(); iErrorCount++) {
                        List<String> tmpList = new ArrayList<String>();
                        tmpList.addAll(0, str);
                        tmpList.add(tcResult.getDefect().get(iErrorCount));
                        tmpList.add(tcResult.getError().get(iErrorCount));
                        outputStr.add("Stacktrace:" + tcResult.getError().get(iErrorCount));
                        tcDefectData.add(tmpList);
                    }
                    break;
                }
                case ITestResult.SUCCESS: {
                    tcPassedData.add(str);
                    break;
                }
                case ITestResult.SKIP: {
                    tcSkippedData.add(str);
                    break;
                }
                default: {
                    break;
                }
            }
            tcOutputData.add(outputStr);
            outputSheetRowCounter = outputSheetRowCounter + 1 + outputStr.size();

            tempClass.incrementCount(tcResult.getStatus());
            // Add to the total runtime of the class
            tempClass.setlRuntime(tempClass.getlRuntime() + tcResult.getDurationTaken());
            mpClassData.put(sTempClassName, tempClass);
        }
        lClasses.addAll(mpClassData.values());
        Collections.sort(lClasses);
        logger.exiting();
    }
438352
@Override
    public void complete(VirtualConnection vc, TCPWriteRequestContext wsc) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "complete() called: vc=" + vc);
        }
        HttpInboundServiceContextImpl mySC = (HttpInboundServiceContextImpl) vc.getStateMap().get(CallbackIDs.CALLBACK_HTTPISC);
        if (null != wsc) {
            wsc.setBuffers(null);
        }

        // access logging if the finishResponse API was used
        if (mySC.isMessageSent()) {
            mySC.logFinalResponse(mySC.getNumBytesWritten());
            HttpInvalidMessageException inv = mySC.checkResponseValidity();
            if (null != inv) {
                // response was invalid in some way... error scenario
                mySC.setPersistent(false);
                if (null != mySC.getAppWriteCallback()) {
                    mySC.getAppWriteCallback().error(vc, inv);
                }
                return;
            }
        }

        // if a callback exists above, pass along the complete. But if the
        // app channel didn't give us a callback (it doesn't care) then we
        // can't pass anything along and we stop further work here
        if (null != mySC.getAppWriteCallback()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Calling write complete callback of app channel.");
            }
            if (mySC.getResponseImpl().isTemporaryStatusCode()) {
                // allow other responses to follow a temporary one
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Temp response sent, resetting send flags");
                }
                mySC.resetWrite();
            }
            mySC.getAppWriteCallback().complete(vc);
        } else {
            // this is dangerous since we're not notifying the channel above
            // of the complete work, but they don't care since they didn't
            // give us a callback to use... hopefully they will continue this
            // connection properly.
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "No available app channel callback");
            }
        }
    }
103092
@Override
	protected void afterPaint(final RenderContext renderContext) {
		super.afterPaint(renderContext);

		if (this.isPressed() && renderContext instanceof WebXmlRenderContext) {
			PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();

			StringBuffer temp = dumpAll();
			writer.println("<br/><br/>");
			writer.println(temp);
		}
	}
545459
public void deleteCache(TemplateClass tc) {
        if (!writeEnabled()) return;
        try {
            File f = getCacheFile(tc);
            if (f.exists() && !f.delete()) {
                f.deleteOnExit();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
901909
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTab tab = (WTab) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:tab");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("open", tab.isOpen(), "true");
		xml.appendOptionalAttribute("disabled", tab.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", tab.isHidden(), "true");
		xml.appendOptionalAttribute("toolTip", tab.getToolTip());

		switch (tab.getMode()) {
			case CLIENT:
				xml.appendAttribute("mode", "client");
				break;
			case LAZY:
				xml.appendAttribute("mode", "lazy");
				break;
			case EAGER:
				xml.appendAttribute("mode", "eager");
				break;
			case DYNAMIC:
				xml.appendAttribute("mode", "dynamic");
				break;
			case SERVER:
				xml.appendAttribute("mode", "server");
				break;
			default:
				throw new SystemException("Unknown tab mode: " + tab.getMode());
		}

		if (tab.getAccessKey() != 0) {
			xml.appendAttribute("accessKey", String.valueOf(Character.
					toUpperCase(tab.getAccessKey())));
		}

		xml.appendClose();

		// Paint label
		tab.getTabLabel().paint(renderContext);

		// Paint content
		WComponent content = tab.getContent();

		xml.appendTagOpen("ui:tabcontent");
		xml.appendAttribute("id", tab.getId() + "-content");
		xml.appendClose();

		// Render content if not EAGER Mode or is EAGER and is the current AJAX trigger
		if (content != null && (TabMode.EAGER != tab.getMode() || AjaxHelper.isCurrentAjaxTrigger(
				tab))) {
			// Visibility of content set in prepare paint
			content.paint(renderContext);
		}

		xml.appendEndTag("ui:tabcontent");

		xml.appendEndTag("ui:tab");
	}
946356
@Override
	protected void afterPaint(final RenderContext renderContext) {
		super.afterPaint(renderContext);

		// UIC serialization stats
		UicStats stats = new UicStats(UIContextHolder.getCurrent());

		stats.analyseWC(this);

		if (renderContext instanceof WebXmlRenderContext) {
			PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();

			writer.println("<h2>Serialization Profile of UIC</h2>");
			UicStatsAsHtml.write(writer, stats);

			// ObjectProfiler
			writer.println("<h2>ObjectProfiler - " + getClass().getName() + "</h2>");
			writer.println("<pre>");

			try {
				writer.println(ObjectGraphDump.dump(this).toFlatSummary());
			} catch (Exception e) {
				LOG.error("Failed to dump component", e);
			}

			writer.println("</pre>");
		}
	}
1119597
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WStyledText text = (WStyledText) component;
		XmlStringBuilder xml = renderContext.getWriter();
		String textString = text.getText();

		if (textString != null && textString.length() > 0) {
			xml.appendTagOpen("ui:text");

			xml.appendOptionalAttribute("class", component.getHtmlClass());
			switch (text.getType()) {
				case EMPHASISED:
					xml.appendAttribute("type", "emphasised");
					break;

				case HIGH_PRIORITY:
					xml.appendAttribute("type", "highPriority");
					break;

				case LOW_PRIORITY:
					xml.appendAttribute("type", "lowPriority");
					break;

				case MEDIUM_PRIORITY:
					xml.appendAttribute("type", "mediumPriority");
					break;

				case ACTIVE_INDICATOR:
					xml.appendAttribute("type", "activeIndicator");
					break;

				case MATCH_INDICATOR:
					xml.appendAttribute("type", "matchIndicator");
					break;

				case INSERT:
					xml.appendAttribute("type", "insert");
					break;

				case DELETE:
					xml.appendAttribute("type", "delete");
					break;

				case MANDATORY_INDICATOR:
					xml.appendAttribute("type", "mandatoryIndicator");
					break;

				case PLAIN:
				default:
					xml.appendAttribute("type", "plain");
					break;
			}

			switch (text.getWhitespaceMode()) {
				case PARAGRAPHS:
					xml.appendAttribute("space", "paragraphs");
					break;

				case PRESERVE:
					xml.appendAttribute("space", "preserve");
					break;

				case DEFAULT:
					break;

				default:
					throw new IllegalArgumentException("Unknown white space mode: " + text.
							getWhitespaceMode());
			}

			xml.appendClose();

			if (WStyledText.WhitespaceMode.PARAGRAPHS.equals(text.getWhitespaceMode())) {
				textString = text.isEncodeText() ? WebUtilities.encode(textString) : HtmlToXMLUtil.unescapeToXML(textString);
				writeParagraphs(textString, xml);
			} else {
				xml.append(textString, text.isEncodeText());
			}

			xml.appendEndTag("ui:text");
		}
	}
766921
def render_template(template_name, context, format='png',
                    output=None, using=None, **options):
    
    # output stream, as required by casperjs_capture
    stream = BytesIO()
    out_f = None
    # the suffix=.html is a hack for phantomjs which *will*
    # complain about not being able to open source file
    # unless it has a 'html' extension.
    with NamedTemporaryFile(suffix='.html') as render_file:
        template_content = render_to_string(
            template_name,
            context,
            using=using,
        )
        # now, we need to replace all occurences of STATIC_URL
        # with the corresponding file://STATIC_ROOT, but only
        # if STATIC_URL doesn't contain a public URI (like http(s))
        static_url = getattr(settings, 'STATIC_URL', '')
        if settings.STATIC_ROOT and\
           static_url and not static_url.startswith('http'):
            template_content = template_content.replace(
                static_url,
                'file://%s' % settings.STATIC_ROOT
            )
        render_file.write(template_content.encode('utf-8'))
        # this is so that the temporary file actually gets filled
        # with the result.
        render_file.seek(0)

        casperjs_capture(
            stream,
            url='file://%s' % render_file.name,
            **options
        )

        # if no output was provided, use NamedTemporaryFile
        # (so it is an actual file) and return it (so that
        # after function ends, it gets automatically removed)
        if not output:
            out_f = NamedTemporaryFile()
        else:
            # if output was provided, write the rendered
            # content to it
            out_f = open(output, 'wb')
        out_f.write(stream.getvalue())
        out_f.seek(0)

        # return the output if NamedTemporaryFile was used
        if not output:
            return out_f
        else:
            # otherwise, just close the file.
            out_f.close()
637021
@SuppressWarnings("squid:S134")
    private void createHtmlReport(FilePath reportFolder,
                                  String testFolderPath,
                                  File artifactsDir,
                                  List<String> reportNames,
                                  TestResult testResult) throws IOException, InterruptedException {
        String archiveTestResultMode =
                _resultsPublisherModel.getArchiveTestResultsMode();
        boolean createReport = archiveTestResultMode.equals(ResultsPublisherModel.CreateHtmlReportResults.getValue());


        if (createReport) {
            File testFolderPathFile = new File(testFolderPath);
            FilePath srcDirectoryFilePath = new FilePath(reportFolder, HTML_REPORT_FOLDER);
            if (srcDirectoryFilePath.exists()) {
                FilePath srcFilePath = new FilePath(srcDirectoryFilePath, IE_REPORT_FOLDER);
                if (srcFilePath.exists()) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    srcFilePath.zip(baos);
                    File reportDirectory = new File(artifactsDir.getParent(), PERFORMANCE_REPORT_FOLDER);
                    if (!reportDirectory.exists()) {
                        reportDirectory.mkdir();
                    }
                    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
                    FilePath reportDirectoryFilePath = new FilePath(reportDirectory);
                    FilePath tmpZipFile = new FilePath(reportDirectoryFilePath, "tmp.zip");
                    tmpZipFile.copyFrom(bais);
                    bais.close();
                    baos.close();
                    tmpZipFile.unzip(reportDirectoryFilePath);
                    String newFolderName = org.apache.commons.io.FilenameUtils.getName(testFolderPathFile.getPath());
                    FileUtils.moveDirectory(new File(reportDirectory, IE_REPORT_FOLDER),
                            new File(reportDirectory, newFolderName));
                    tmpZipFile.delete();
                    outputReportFiles(reportNames, reportDirectory, testResult, false);
                }
            }
        }
    }
727749
private final String renderContentTemplate(final ST contentTemplate, final Map<String, Object> values, final ErrorBuffer error, boolean inErrorState) {
        if (contentTemplate != null) { // it has to be possible to use a layout without defining a template
            try (Writer sw = new StringBuilderWriter()) {
            
                final ErrorBuffer templateErrors = new ErrorBuffer();
                renderContentTemplate(contentTemplate, sw, values/*, language*/, templateErrors);
                
                // handle potential errors
                if (!templateErrors.errors.isEmpty() && !inErrorState) {
                    for (STMessage err : templateErrors.errors) {
                        if (err.error == ErrorType.INTERNAL_ERROR) {
                            log.warn("Reloading GroupDir as we have found a problem during rendering of template \"{}\"\n{}",contentTemplate.getName(), templateErrors.errors.toString());
                            //README when errors occur, try to reload the specified templates and try the whole thing again
                            // this often rectifies the problem
                            reloadGroup();
                            ST reloadedContentTemplate = readTemplate(contentTemplate.getName());
                            return renderContentTemplate(reloadedContentTemplate, values, error, true);
                        }
                    }
                }
    
                return sw.toString();
            } catch (IOException noMethodsThrowsIOE) { }
        }
        return "";
    }
1305762
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WText text = (WText) component;
		XmlStringBuilder xml = renderContext.getWriter();

		String textString = text.getText();

		if (textString != null) {
			if (text.isEncodeText()) {
				xml.print(WebUtilities.encode(textString));
			} else {
				// If we are outputting unencoded content it must be XML valid.
				xml.print(HtmlToXMLUtil.unescapeToXML(textString));
			}
		}
	}
716593
function(val, ctx, partials) {
      var cx = ctx[ctx.length - 1];
      var result = val.call(cx);
      if (typeof result == 'function') {
        result = result.call(cx);
      }
      result = coerceToString(result);

      if (this.c && ~result.indexOf("{\u007B")) {
        return this.c.compile(result, this.options).render(cx, partials);
      }

      return result;
    }
1214070
private function toOutput(\Throwable $t) {
    //Write to output
    $renderer = new \Nuki\Handlers\Http\Output\Renderers\RawRenderer();
    $response = new \Nuki\Handlers\Http\Output\Response($renderer);

    $content = get_class($t) . ': ';
    $content .= $t->getMessage();
    $content .= ' in ';
    $content .= $t->getFile() . ':' . $t->getLine();

    $renderer->setContent(new \Nuki\Models\IO\Output\Content($content));

    $response->httpStatusCode(\Nuki\Models\IO\Output\Http::HTTP_EXPECTATION_FAILED);

    $response->send();

    return;
  }
1167929
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WColumn col = (WColumn) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:column");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		int width = col.getWidth();
		xml.appendOptionalAttribute("width", width > 0, width);

		switch (col.getAlignment()) {
			case LEFT:
				// left is assumed if omitted
				break;

			case RIGHT:
				xml.appendAttribute("align", "right");
				break;

			case CENTER:
				xml.appendAttribute("align", "center");
				break;

			default:
				throw new IllegalArgumentException("Invalid alignment: " + col.getAlignment());
		}

		xml.appendClose();

		// Paint column contents
		paintChildren(col, renderContext);

		xml.appendEndTag("ui:column");
	}
1025311
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WRepeater repeater = (WRepeater) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:panel");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendClose();

		xml.appendTag("ui:content");
		paintRows(repeater, renderContext);
		xml.appendEndTag("ui:content");

		xml.appendEndTag("ui:panel");
	}