text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<TITLE
>Data Display (Data Consumers)</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Inca 2.3 User's Guide"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Administering Inca with incat"
HREF="userguide-incat.html"><LINK
REL="NEXT"
TITLE="Reporters and Repositories"
HREF="userguide-reporters.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="inca.css">

Inca 2.3 User's Guide: [Single page, Multiple pages]

Prev		Next

6. Data Display (Data Consumers)

The data that the Inca depot stores, as with all database data, can be
    displayed in many ways.  An Inca data consumer is anything that retrieves data
    from the depot and displays it (e.g. a JSP, SQL query, CGI, etc.).

Data consumers can query the Inca depot to produce current and historical
    reports and graphs or customized status information.  The Inca depot has Perl
    and Java client APIs for its pre-defined queries (see Section 8).

The default data consumer is a Web ARchive (WAR)
      file that contains a collection of JavaServer Pages (JSP) and
      their associated files.  The WAR file is initially installed as
      <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/war/inca.war</TT
> and is deployed with Jetty when the consumer is started (e.g.
      ./bin/inca start consumer).  The default consumer creates a Jetty directory
      like <TT
CLASS="FILENAME"
>$INCA_DIST/var/jetty*/webapp</TT
> for each WAR file in
      <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/war</TT
> - custom WAR files can be dropped into
      the <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/war</TT
> directory and deployed by
      restarting the consumer.  Currently Inca WAR files cannot be deployed outside
      of the Inca consumer server (e.g. in Apache Tomcat).  The consumer will start
      on port 8080 unless the <TT
CLASS="FILENAME"
>$INCA_DIST/etc/jetty.xml</TT
> is edited
      as described in Section 6.7.

6.1. Current Data Pages

The default page header navigation contains
        links to tabular and map view result summaries for
        the sample suite.  To add other current
      pages under this heading (e.g. result summary tables for
        other suites, customize the
      <TT
CLASS="FILENAME"
>header.xsl</TT
> file as described in
      Section 6.5.3.

6.1.1. Tabular Suite Summary View

A summary table of suite results is created by
      passing the suiteName (e.g. sampleSuite) and resourceID
        (e.g. defaultGrid) parameters to
      <TT
CLASS="FILENAME"
>xslt.jsp</TT
> and adding
      <TT
CLASS="FILENAME"
>default.xsl</TT
> as the xsl parameter.
      More information about the consumer's JSP and XSL files is
      provided in Section 6.4.  For example,
      http://localhost:8080/inca/xslt.jsp?xsl=default.xsl&suiteName=sampleSuite&resourceID=defaultGrid
      produces the following image:

6.1.2. Map View using Google Map API

6.1.2.1. Overview

The map view provides a summary view of the current status
          of resources on a Google map.  For each resource, the summary view will
          provide the percentage of reports passed, number of passed reports, number
          of failed reports, and a list of the failed tests (with a link to the report
          details page).  A resource is represented on the map as a marker and colored
          red, green, or orange based on the number of tests that have passed and/or
          failed.  The figure below shows the Inca Google map view for the NEON
          testbed (four resources at SDSC and one resource at James Reserve).  All
          resources are passing their tests so every resource marker is green.

          Clicking on a marker will display an info window with the name of the
          resource and the status information as show below.

          Clicking on the "Toggle ping status" button will display the status of the
          cross-site ping test as show below.

6.1.2.2. Setting up Google Map View

          The Google Map View is generated by running the
          <TT
CLASS="FILENAME"
>google.xsl</TT
> stylesheet over the XML collected by
          <TT
CLASS="FILENAME"
>xslt.jsp</TT
>.  To load the Google map for your Inca
          default deployment, click on the "map of sampleSuite results" link
          underneath the "CURRENT DATA" menu item in the navigation bar.

Or you can view the map using the following url:

          http://yourhost:8080/inca/xslt.jsp?xsl=google.xsl&xmlFile=google.xml&suiteName=sampleSuite&resourceID=defaultGrid

          The tags "suiteName" and "resourceID" can be a comma delimited list to show
          the resource status for multiple suites.

          If this is your first time loading the page, you will see
          a Javascript alert box such as that below.

          To utilize the Google map server, you need a "Google Maps API key" for
          your Inca consumer.  To generate one, go the Google Maps API web page at
          http://www.google.com/apis/maps/signup.html
          and type in "http://yourHost:8080 in the
          "My web site URL" text box and click the "Generate API key" button.  A
          page will be generated displaying a new key for your server that looks
          something like this:
          ABQIAAAA_4IHDoSvxQqISMa1RKFLQBSSlCzupJMr-Xoh__duR37DAX9UVBRVn9-X9_4ILpmvilr4hN-QZU8pNQ.
          Next, open <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/xml/google.xml</TT
> and go to
          line 12.

          ...
          <!-- Google key for your Inca server.  Go to the following website and put
          http://yourservername:8080 in the "My web site URL" textbox at:
          http://www.google.com/apis/maps/signup.html -->
          <key>Insert key here</key>
          ...

Replace "Insert key here" with your new Google Maps API key as below
          and save the file.

          ...
          <!-- Google key for your Inca server.  Go to the following website and put
          http://yourservername:8080 in the "My web site URL" textbox at:
          http://www.google.com/apis/maps/signup.html -->
          <key>ABQIAAAA_4IHDoSvxQqISMa1RKFLQBSSlCzupJMr-Xoh__duR37DAX9UVBRVn9-X9_4ILpmvilr4hN-QZU8pNQ</key>
          ...

Next, reload the web page and the default configuration will show
          one resource (indicated by the orange marker) and the Inca logo as below.

Clicking on the orange marker will display an info box as below
          indicating "vtk-ngl_version" as the only test that has failed. Clicking on
          "vtk-ngl_version" will take you to the reporter details page.

6.1.2.3. Customizing the Google Map View

          The configuration information for the Google Map View is located in a
          XML file at <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/xml/google.xml</TT
>.
          Below is a list of customizations you can make to your Google display.

Customizations

<TT
CLASS="FILENAME"
>map size</TT
>

                The size of the Google map can be customized using the <width> and
                <height> tags on lines 14-15.  By default the map is 800x500.

                  13  <!-- The size of the map graphic (in pixels) that will be generated -->
                  14  <width>800</width>
                  15  <height>500</height>

<TT
CLASS="FILENAME"
>map center</TT
>

                The center of the map is expressed in latitude/longitude coordinates on
                lines 18-21.  By default, the center of the map corresponds to the
                center of the U.S.

                  17   <!-- The center of the map in latitude/longitude coordinates -->
                  18   <center>
                  19     <latitude>37</latitude>
                  20     <longitude>982</longitude>
                  21   </center>

<TT
CLASS="FILENAME"
>magnification level</TT
>

                The initial magnification or zoom level of the map is expressed as
                a number between 1 and 12 and is located on line 24.  A zoom level of 1
                will give you the entire world and a zoom level of 12 will allow you to
                read street names.  By default the initial zoom level is 4 which allows
                most of the U.S. to be viewed.

                  23   <!-- The initial zoom level of the map (higher is closer up) -->
                  24   <magnificationLevel>4</magnificationLevel>

<TT
CLASS="FILENAME"
>marker distance</TT
>

                If there is more than one resource at a particular site, the resources
                will be layed in a circle around the site center.  By default, the
                distance between the markers will be determined by the chosen
                magnificationLevel so that the markers do not overlap each other.  To
                increase or decrease the distance in between the markers (expressed in
                latitude/longitude), uncomment the <markerDist> tag on line 29.

                  26   <!-- The distance in between resource markers at a site.  A default value
                  27        is available based on the magnificationLevel.  To override the default,
                  28        uncommment the line below and set a new value
                  29   <markerDist>1.00</markerDist>
                  30   -->

<TT
CLASS="FILENAME"
>number of errors displayed in info window</TT
>

                If there are more than fifteen errors at a resource, only the first fifteen
                errors will be displayed in the info window that is displayed when a
                resource is clicked.  To override, edit the <maxErrors> tag on line
                33.

                  32   <!-- The maximum number of errors to display in the info window -->
                  33   <maxErrors>15</maxErrors>

<TT
CLASS="FILENAME"
>cross-site test line colors</TT
>

                If a suite contains a cross-site test, a button will be displayed below
                the map named "Toggle <testName> status".  When the button is
                clicked, the status of an individual cross-site test will be expressed as
                a line in between the source resource and the destination resource.
                The color of the line used to represent the test status can be customized.
                By default, green represents the test passed and red represents the test
                failed.  To change, edit lines 37-40.

                  35   <!-- For cross-site tests, a line will be displayed in between the 2 sites to
                  36        indicate the test status.  Customize the colors for pass fail below. -->
                  37   <line>
                  38     <pass>#228B22</pass>
                  39     <fail>#FF0000</fail>
                  40   </line>

<TT
CLASS="FILENAME"
>resource markers</TT
>

                A resource is represented by a Google marker and the color varies
                on the number of tests that it failed:
                all tests passed = , at least one test failed = ,
                all tests failed = .  Suppose you wanted to change the icons displayed to
                weather icons found at http://econym.googlepages.com/geicons.htm such as follows:
                all tests passed = , at least one test failed = ,
                all tests failed = .  Use the following steps:

Find the size of the icons and modify the tags <iconWidth> and
                      <iconHeight>.  These weather icons are 32x32 so we would change lines
                      46 and 47 as follows:

                        46     <iconWidth>32</iconWidth>
                        47     <iconHeight>32</iconHeight>

Pick the anchor point for the icon to be placed in relation to
                      the resource's place on the map.  Since we want the middle of
                      the icon to be placed on the map, we choose the coordinates (16, 16)
                      and modify line 50 as follows:

                        50     <iconAnchorCoord>16, 16</iconAnchorCoord>

Then we also need to determine the anchor point for the info
                      window to pop up relative to the icon.  Since we want the info window
                      to appear in the top middle, we choose the coordinates (16, 10) and
                      modify line 54 as follows:

                        54     <iconInfoWindowAnchorCoord>16, 10</iconInfoWindowAnchorCoord>

The three weather icons are located on the Google server at:
                      http://maps.google.com/mapfiles/kml/pal4/icon33.png,
                      http://maps.google.com/mapfiles/kml/pal4/icon34.png,
                      http://maps.google.com/mapfiles/kml/pal4/icon36.png.  Modify lines 61-67 as follows:

                        61  <iconUrlPrefix>http://maps.google.com/mapfiles/kml/pal4/icon</iconUrlPrefix>
                        62  <iconStatus>
                        63    <fail>36</fail>
                        64    <pass>33</pass>
                        65    <warn>34</warn>
                        66  </iconStatus>
                        67  <iconUrlSuffix>.png</iconUrlSuffix>

Finally, we specify the url to the shadow icon using
                      <shadowIconUrl>, <shadowIconWidth>, and
                      <shadowIconHeight> tags on lines 70-74 as follows:

                        69  <!-- Url of a icon to use for the shadow of the resource icon -->
                        70  <shadowIconUrl>http://maps.google.com/mapfiles/kml/pal4/icon36s.png</shadowIconUrl>
                        71
                        72  <!-- the size of the shadow icon -->
                        73  <shadowIconWidth>59</shadowIconWidth>
                        74  <shadowIconHeight>32</shadowIconHeight>

<TT
CLASS="FILENAME"
>sites</TT
>

                By default, resources will be displayed around in the map center.
                To specify a site (i.e., a location on the map with its resources), use
                the <site> tag from lines 80 to 111.  Provide a site name using the
                <name> tag, latitude/longitude coordinates using the <latitude>
                and <longitude> tags.  There are online tools, like
                CAIDA's NetGeo script,
                to help convert the IP addresses of your resources to latitude/longitude.
                Specify a list of resource names at a site using the <resource> tag.
                Optionally you can specify a logo for the site
                using the <logo> tag.  Specify the size of the logo (<width>
                and <height>), angle from 0 degrees (<angle>), and logo
                anchor coordinates (<logoAnchorX>, <logoAnchorY>) as
                shown in the below figure.

6.2. Historical Data Pages

All reporter data collected by Inca is stored in the depot.
        The depot can then be queried to produce graphs of historical information.
        Inca's default data consumer uses
        Cewolf,
        a JSP tag library for graphing based on
        JFreeChart.
        The default consumer includes a basic graph of the historical pass/fail status of
        reporter series and a graph of error message counts if there are
        any reporter errors.  The pass/fail status is either the
        comparitor status (if the series
        has a comparitor) or the reporter's exit status.

The section for historical data in the
        default page header has links to a series graphing form
         and a sample summary report for sampleSuite series.
       To link other historical
      pages under this heading (e.g. forms to select series from
        other suites, customize the
      <TT
CLASS="FILENAME"
>header.xsl</TT
> file as described in
      Section 6.5.3.

6.2.1. Graph Series Result History

Historical pass/fail status graphs and error frequency information can be
       displayed by the default consumer.
       If <TT
CLASS="FILENAME"
>graph.xsl</TT
> is used as the xsl parameter for the
        <TT
CLASS="FILENAME"
>xslt.jsp</TT
> script that displays suite results,
        a form will be generated to select suite series to graph.  For
        example, http://localhost:8080/inca/xslt.jsp?xsl=graph.xsl&suiteName=sampleSuite&resourceID=defaultGrid will generate:

        After selecting the "vtk-nvgl_version" series and
        clicking on the "graph" button in the form above,
        a graph page is shown with
        an XY plot of the pass/fail status of the selected
        series, a series pass/fail summary table, a bar graph of
        error message frequency (if the selected series have errors),
        a summary table of error messages, and a form to customize the graph
        further (as in the image below).
        This graph page is generated by the <TT
CLASS="FILENAME"
>graph.jsp</TT
>
        script with Cewolf tags.

Only two weeks of data are returned
        initially.  To query for all results, clear the "start date"
        field in the "customize graph" section and click "re-graph".
        To retrieve graphs more quickly, data point
        mouseover text and links to
        report details are turned off for the pass/fail graph.
        The data points can be made interactive by choosing "show mouseovers/hyperlinks"
        in the "customize graph" section and clicking on "re-graph".
        Clicking on interactive data points will lead to
        report details pages, mousing over them will show
        collection times and any error messages.

Multiple series can also be graphed together as in the image below.
      A table under each graph summarizes results for each series.

Graph pages for individual series are also linked from the report details pages.

6.2.2. Summary Reports

Historical summary reports with pass/fail status and error information
          can also be created for sets of series.  Summary reports are generated
        with <TT
CLASS="FILENAME"
>report.jsp</TT
> and configured by default with
       <TT
CLASS="FILENAME"
>webapps/xml/statusReport.xml</TT
>.

As a summary report example, the default consumer groups
        different combinations of sampleSuite series in
        <TT
CLASS="FILENAME"
>statusReport.xml</TT
> and displays the past two weeks
       of results using <TT
CLASS="FILENAME"
>report.jsp</TT
>'s startDate param.
       Each set of series has a title (e.g. Software Deployment Tests) for its
       grouping and the series nickname, resource name, and report label for
       each series in the group.  Create one or more custom reports by editing
       the groupings and titles.  The width and height of the graphs can also
       be adjusted in <TT
CLASS="FILENAME"
>webapps/xml/statusReport.xml</TT
>.
       See Section 6.4 for more
       details.  Depending on database size and the number of series
       included, summary reports may benefit from being pre-generated.

6.3. Info Pages

Currently the only informational page is a list of
      all running reporters in an inca deployment.  To link other informational
      pages under this heading, customize the
      <TT
CLASS="FILENAME"
>header.xsl</TT
> file as described in
      Section 6.5.3.

6.4. Description of Data Consumer Files

      There are five main JSP contained in the
      <TT
CLASS="FILENAME"
>inca.war</TT
>.
      The JSP generally return XML from depot and agent functions and
      apply XSL stylesheets to display HTML.  If the "xsl" parameter
      for the JSP is removed, the JSP prints the XML returned.

Table 2. Default Consumer JSP

<COL><COL><COL><COL>

Name

Purpose

Server Functions Called

Parameters

<TT
CLASS="FILENAME"
>index.jsp</TT
>

                Lists an installation's configured suites and resource
                names in an HTML form whose action is to display results
                for the selected suite and resource.  The consumer
                initially redirects to this page.

Depot's
                queryGuids()
                function for current suite configuration
                and agent's getConfig()
                function for cached resource configuration information.

xsl: stylesheet to format returned XML

e.g. http://localhost:8080/inca/index.jsp

<TT
CLASS="FILENAME"
>config.jsp</TT
>

                Prints description of deployed suites and series.
                Linked at the bottom of <TT
CLASS="FILENAME"
>index.jsp</TT
>

Agent's getCatalogAsXml()
                function for current catalog configuration and
                getConfig()
                function for cached suite configuration infomation.

xsl: stylesheet to format returned XML

e.g. http://localhost:8080/inca/config.jsp?xsl=config.xsl

<TT
CLASS="FILENAME"
>xslt.jsp</TT
>

                Displays current results for a set of suites or reporter details.
                This page is the action of the <TT
CLASS="FILENAME"
>index.jsp</TT
> form to display a single suite's results.

Agent's getCatalogAsXml()
                function for current catalog configuration and
                getConfig()
                function for cached suite configuration infomation.

suiteName: comma separated list of test suite
                    names to get data for

resourceID: comma separated list of resource group
                    names to get data for

instanceID: test instance ID number to get data for

configID: test configuration ID number to get data for

xmlFile: name of XML file whose contents will be appended to
                  cached depot results

xsl: name of stylesheet to format returned XML

e.g. http://localhost:8080/inca/xslt.jsp?suiteName=sampleSuite&resourceID=defaultGrid&xsl=default.xsl

<TT
CLASS="FILENAME"
>graph.jsp</TT
>

                Historical graphs of pass/fail status and error frequency.

Depot's queryHql()
                function to query for historical infomation.

testName: comma separated list of series nicknames to
                  get data for

resourceName: comma separated list of resources to
                  get data for

seriesLabel: comma separated list of legend labels

title: title of pass/fail status graph

alias: boolean for image anti-aliasing

legend: boolean for showing legend

legendAnchor: position of legend

height: graph height in pixels

width: graph width in pixels

mime: boolean for image MIME

xaxislabel: label for x-axis of pass/fail graph

xmin: date to start querying data for

xmax: date to stop querying data for

start: boolean for getting only past two weeks of data

yaxislabel: label for y-axis of pass/fail graph

ymin: y-axi4s min for pass/fail graph

ymax: y-axis max for pass/fail graph

ytick: tick increment for y-axis pass/fail graph

bgcolor: background color of graph images

map: boolean for showing graph links and mouseovers

e.g. http://localhost:8080/inca/graph.jsp?testName=ant_version&resourceName=localResource

<TT
CLASS="FILENAME"
>report.jsp</TT
>

                Summary report with graphs of pass/fail status and error frequency.

Depot's queryHql()
                function to query for historical infomation.

startDate: start date for summary report (gets complete history by default)

endDate: end date for summary report (current date by default)

xmlFile: name of xml file to configure report (<TT
CLASS="FILENAME"
>webapps/xml/statusReport.xml</TT
> by default)

e.g. http://localhost:8080/inca/report.jsp

        The default JSP scripts retrieve XML data from the
        agent and depot and then use the XSL stylesheets in
        <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/xsl</TT
> are used
           to transform the XML into HTML.
           The following stylesheets are installed
        with the default consumer:

Table 3. Default Consumer XSL

<COL><COL><COL>

Name

Applied To

Purpose

<TT
CLASS="FILENAME"
>index.xsl</TT
>

<TT
CLASS="FILENAME"
>index.jsp</TT
>

                  Lists all configured suite and resource names in an
                  HTML form whose action is to display results for the
                  selected suite and resource.

<TT
CLASS="FILENAME"
>config.xsl</TT
>

<TT
CLASS="FILENAME"
>config.jsp</TT
>

Prints description of deployed suites and series.

<TT
CLASS="FILENAME"
>default.xsl</TT
>

<TT
CLASS="FILENAME"
>xslt.jsp</TT
>

Prints table of suite(s) results.

<TT
CLASS="FILENAME"
>swStack.xsl</TT
>

<TT
CLASS="FILENAME"
>xslt.jsp</TT
>

Prints table of suite(s) results.  Uses XML file
                  to format table rows by software categories and packages.

<TT
CLASS="FILENAME"
>summary.xsl</TT
>

<TT
CLASS="FILENAME"
>xslt.jsp</TT
>

Prints summary results table with a list of
                  resources in the left column and
                  a list of the suite tests each resource is failing
                  in the right column.  Failing tests are listed by name
                  and by overall percentage passing in suite.
                  Uses XML file (<TT
CLASS="FILENAME"
>swStack.xml</TT
> by default) to get test groups.

<TT
CLASS="FILENAME"
>google.xsl</TT
>

<TT
CLASS="FILENAME"
>xslt.jsp</TT
>

Prints google map summary of current data.

<TT
CLASS="FILENAME"
>graph.xsl</TT
>

<TT
CLASS="FILENAME"
>xslt.jsp</TT
>

Prints form to select series to graph.

<TT
CLASS="FILENAME"
>instance.xsl</TT
>

<TT
CLASS="FILENAME"
>xslt.jsp</TT
>

Prints HTML table with report details.

<TT
CLASS="FILENAME"
>header.xsl</TT
>

<TT
CLASS="FILENAME"
>(included in most other xsl files)</TT
>

Prints HTML page header.

<TT
CLASS="FILENAME"
>footer.xsl</TT
>

(included in most other xsl files)

Prints HTML page footer with the Inca logo.

<TT
CLASS="FILENAME"
>legend.xsl</TT
>

(included in <TT
CLASS="FILENAME"
>default.xsl</TT
>
                  and <TT
CLASS="FILENAME"
>swStack.xsl</TT
>)

Prints a key to cell colors and text.

<TT
CLASS="FILENAME"
>inca-common.xsl</TT
>

(included in most other stylesheets)

Common templates for use in Inca stylesheets.

6.5. Changing the Look

6.5.1. Colors and Fonts

        Properties such as colors and fonts are controlled by the default CSS (Cascading Style Sheet) located in
        <TT
CLASS="FILENAME"
>$INCA_DIST/var/jetty*/webapp/css/inca.css</TT
>.  The drop down nav bar in the header is controlled by
        <TT
CLASS="FILENAME"
>$INCA_DIST/var/jetty*/webapp/css/nav.css</TT
>.
        For example, to change the color in the reporter detail pages header bar
        open <TT
CLASS="FILENAME"
>inca.css</TT
> and change lines 111-112 to:

.header {
          background-color: #D07651;

        The details pages will now look like:

For general information, visit the [ CSS tutorial ].

6.5.2. HTML Layout

        To modify the default HTML layout, edit the XSL stylesheet that is being applied to the JSP or create a new stylesheet
        in <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/xsl</TT
> and pass it to the JSP as the "xsl" parameter.
      The default JSP and XSL files are described in
      Section 6.4.

For general information about editing stylesheets,
        visit the [ XSL tutorial ].

6.5.2.1. Custom Values in HTML Table Cells

To display report values other
          than the default text of either a software version, "pass", or "error"
          on the suite results pages, edit <TT
CLASS="FILENAME"
>default.xsl</TT
>.

 For example, to change the default suite status to print the time successful
          reporters ran and a truncated error message for failures like:

Edit <TT
CLASS="FILENAME"
>default.xsl</TT
>, add a new variable for the custom table cell text and
          print the custom cell text rather than the default text:

188  <xsl:variable name="cellText">
            189    <xsl:choose>
            190      <xsl:when test="string($instance)=''">
            191        <xsl:value-of select="''" />
            192      </xsl:when>
            193      <xsl:when test="string($result/body)!=''
            194             and string($result/errorMessage)=''
            195             and ($comparitor='Success' or count($comparitor)=0)">
            196               passed:
            197        <!-- get yyyy-mm-dd from gmt timestamp -->
            198        <xsl:value-of select="substring($result/gmt, 1, 10)" />
            199        <!-- get HH:MM from gmt timestamp -->
            200        <xsl:value-of select="substring($result/gmt, 12, 5)" />
            201      </xsl:when>
            202      <xsl:otherwise>
            203               error:
            204        <xsl:value-of select="substring($result/errorMessage, 1, 30)" />
            205      </xsl:otherwise>
            206    </xsl:choose>
            207  </xsl:variable>
            208  <xsl:choose>
            209    <xsl:when test="$exit!=''">
            210      <td class="{$exit}">
            211        <a href="{$href}"><xsl:value-of select="$cellText"/></a>
            212        <xsl:if test="$url[matches(., 'markOld')]">

6.5.3. Custom Page Header

The default page header is generated by the inclusion of the
          <TT
CLASS="FILENAME"
>header.xsl</TT
> file in other xsl files.  The header
          is a navigation bar with drop down links to a set of default status
          pages:

The header's navigation bar is an HTML unordered list that is
        formatted with the <TT
CLASS="FILENAME"
>nav.css</TT
> stylesheet.  To add
        or remove links in the navigation bar, open <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/xsl/header.xsl</TT
>
          and change the appropriate link.  For example, to show a table of suite
          results for a new suite called "newSuite" on a new resource called "newResource":

57  <li><h2>Current Data</h2>
58    <ul>
59      <li>
60        <a href="'xslt.jsp?xsl=default.xsl&amp;suiteName=newSuite&amp;resourceID=newResource'">
61           table of newSuite results</a>
62      </li>

Any other link can be added or removed as a list element.  The
          stylesheet supports additional levels of nested list links.  Note that
          the top level list elements are displayed from bottom to top (i.e. "Current Data"
          is listed last in <TT
CLASS="FILENAME"
>header.xsl</TT
> but it is displayed
          further left than "Historical Data" and "Info" in the navigation bar).

Another example of customizing the HTML header would be to add a call to a custom header stylesheet in the
          "printBodyTitle" template.  Edit <TT
CLASS="FILENAME"
>inca-common.xsl</TT
>:

13  <xsl:include href="custom-header.xsl"/>
          ...
          24  <xsl:template name="printBodyTitle">
          25    <xsl:param name="title"/>
          26    <xsl:call-template name="custom-header"/>
          27    <xsl:variable name="datenow" select="date:new()" />
          28    <xsl:variable name="dateformat" select="sdf:new('MM-dd-yyyy hh:mm a (z)')"/>
          29    <table width="100%" border="0">
          30      <tr align="left">

Create a <TT
CLASS="FILENAME"
>$INCA_DIST/webapps/xsl/custom-header.xsl</TT
> like:

<?xml version="1.0" encoding="UTF-8"?>

          <!-- ================================================ -->
          <!-- Prints out custom header for Inca status pages   -->
          <!-- ================================================ -->
          <xsl:stylesheet version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns="http://www.w3.org/1999/xhtml">

          <xsl:template name="custom-header">
          <table class="header" width="100%">
          <tr>
          <td bgcolor="#003366">
          <img class="logo" src="img/header.jpg"/>
          </td>
          </tr>
          </table>
          <table class="menu" width="100%">
          ... custom navigation ...
          </table>
          </xsl:template>

          </xsl:stylesheet>

The resulting page would look something like:

6.6. Changing the Installation Location

You can install the data consumer in a non-default location (e.g. on a machine where the depot and agent are not running) if you:

          Copy the <TT
CLASS="FILENAME"
>incaInstall.sh</TT
> script to the machine where the consumer will run.

% wget http://inca.sdsc.edu/releases/2.3/incaInstall.sh

          Install consumer on the new machine:

% ./incaInstall.sh $INCA_DIST consumers

          Copy the consumer key, certificate, and trusted directory from the machine where the agent/depot are running (orig.machine)
          to the new machine:

% scp orig.machine:$ORIG_INCA_DIST/etc/consumerkey.pem $INCA_DIST/etc/; \
          scp orig.machine:$ORIG_INCA_DIST/etc/consumercert.pem $INCA_DIST/etc/;
          scp "orig.machine:$ORIG_INCA_DIST/etc/trusted/*" $INCA_DIST/etc/trusted/;

Edit the <TT
CLASS="FILENAME"
>$INCA_DIST/etc/common/inca.properties</TT
> local file and specify the full hostname
          of the machine where the agent and depot are running:

114 inca.consumer.agent=incas://agent.hostname:6323
            ...
            128 inca.consumer.depot=incas://depot.hostname:6324

 Start the consumer component on the new machine:

% cd $INCA_DIST; ./bin/inca start consumer

6.7. Changing the Port

      By default, the consumer is started on port 8080.  To change this, edit
      the etc/jetty.xml file and search for 'SocketListener'.  To change the
      port to say 8085, change the following line:

      <Set name="Port"><SystemProperty name="jetty.port" default="8080"/></Set>

to:

      <Set name="Port">8085</Set>

6.8. Enabling https

      By default, the consumer is configured as an http server.  To
      disable http and enable https, edit the <TT
CLASS="FILENAME"
>jetty.xml</TT
>
      file in <TT
CLASS="FILENAME"
>$INCA_DIST/etc</TT
> and

          comment out the section "Add and configure a HTTP listener to port 8080"

          uncomment the section "Add a HTTPS SSL listener on port 8443".

Note that the example below is to disable http and enable https.
    However, http and https can be enabled simultaneously if both sections are left uncommented.

      <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
      <!-- Add and configure a HTTP listener to port 8080                  -->
      <!-- The default port can be changed using: java -Djetty.port=80     -->
      <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
      <!--
      <Call name="addListener">
      <Arg>
      <New class="org.mortbay.http.SocketListener">
      <Set name="Port"><SystemProperty name="jetty.port"
      default="8080"/></Set>
      <Set name="PoolName">P1</Set>
      <Set name="MinThreads">20</Set>
      <Set name="MaxThreads">200</Set>
      <Set name="lowResources">50</Set>
      <Set name="MaxIdleTimeMs">30000</Set>
      <Set name="LowResourcePersistTimeMs">2000</Set>
      <Set name="acceptQueueSize">0</Set>
      <Set name="ConfidentialPort">8443</Set>
      <Set name="IntegralPort">8443</Set>
      </New>
      </Arg>
      </Call>
      -->

      <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
      <!-- Add a HTTPS SSL listener on port 8443                           -->
      <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
      <Call name="addListener">
      <Arg>
      <New class="org.mortbay.http.SslListener">
      <Set name="Port">8443</Set>
      <Set name="PoolName">P1</Set>
      <Set name="MaxIdleTimeMs">30000</Set>
      <Set name="lowResources">30</Set>
      <Set name="LowResourcePersistTimeMs">2000</Set>
      <Set name="Keystore">etc/consumerKeystore</Set>
      <Set name="KeyPassword">OBF:1v8w1v2h1wg01z0d1z0h1wfy1v1x1v9q</Set>
      <Set name="Password">OBF:1v8w1v2h1wg01z0d1z0h1wfy1v1x1v9q</Set>
      <Set name="HttpHandler">
      <New class="org.mortbay.http.handler.MsieSslHandler">
      <Set name="UserAgentSubString">MSIE 5</Set>
      </New>
      </Set>
      </New>
      </Arg>
      </Call>

Then restart the consumer.

      % ./bin/inca stop consumer; ./bin/inca start consumer

The https server will be on port 8443.

https://hostname:8443

By default, the https server will use the credential stored in
      <TT
CLASS="FILENAME"
>$INCA_DIST/etc/consumerKeystore</TT
>.  Its DN is
      "cn=Inca Consumer SSL, o=SDSC, l=San Diego, st=California, c=US".  If you'd
      like to generate a certificate with a different DN, run the keytool command as
      follows:

% rm -f etc/consumerKeystore; keytool -keystore etc/consumerKeystore \
      -alias jetty -genkey -keyalg RSA -dname your_DN

It will prompt you for a keystore password and a key password.  You can
      either make them different or use the same one.  If you use the password
      "consumer", no further changes are needed.  Otherwise, you will have to modify
      <Set name="KeyPassword"> and <Set name="Password"> in the
      "Add a HTTPS SSL listener on port 8443" section in <TT
CLASS="FILENAME"
>jetty.xml</TT
>.
      You can either put the password in there in plain text or obfuscate it using
      Jetty's password utility as follows:

% java -classpath lib/org.mortbay.jetty-5.1.10.jar:lib/commons-logging-1.0.4.jar \
        org.mortbay.util.Password your_password

It will output two lines such as follows:

      OBF:1v8w1v2h1wg01z0d1z0h1wfy1v1x1v9q
      MD5:1005b14bd29466723ace30d26f602f5b

Open <TT
CLASS="FILENAME"
>etc/jetty.xml</TT
> and replace the string beginning with OBF in both <Set
      name="KeyPassword"> and <Set name="Password"> with the string
      provided by Jetty's password utility:

      <Set name="KeyPassword">OBF:1v8w1v2h1wg01z0d1z0h1wfy1v1x1v9q</Set>
      <Set name="Password">OBF:1v8w1v2h1wg01z0d1z0h1wfy1v1x1v9q</Set>

6.9. Adding Password Protection

      By default, a password is not required for a user to access the status pages
      served by the consumer.  To require a password, edit <TT
CLASS="FILENAME"
>$INCA_DIST/etc/webdefault.xml</TT
>
      and uncomment the section "Require password authentication
      to access Inca status pages".  Note that there are two sections with that
      title -- one for http and the other for https.  Uncomment the appropriate
      section such as:

      <!-- ==================================================================== -->
      <!-- Require password authentication to access Inca status pages          -->
      <!--                        (http version)                                -->
      <!-- ==================================================================== -->
      <security-constraint>
      <web-resource-collection>
      <web-resource-name>Any User</web-resource-name>
      <url-pattern>/*</url-pattern>
      </web-resource-collection>
      <auth-constraint>
      <role-name>*</role-name>
      </auth-constraint>
      </security-constraint>

      <login-config>
      <auth-method>BASIC</auth-method>
      <realm-name>Inca Status Pages</realm-name>
      </login-config>

By default, the username and password for the pages will be "inca".  To
      change this, edit <TT
CLASS="FILENAME"
>$INCA_DIST/etc/realm.properties</TT
> and customize the
      username and password for your installation.  If you do not want to store the
      password in plain text, use Jetty's password utility described in Section 6.8.

Then restart the consumer.

% ./bin/inca stop consumer; ./bin/inca start consumer

The next time you view the status pages, you should see a login like:

Prev	Home	Next

Administering Inca with incat	 	Reporters and Repositories


text:
"""
This module contains the function that creates the fractal tree.
"""

import sys
import numpy as np
 #   from PlaneParameters import * #Network properties.
from Branch3D import *
from random import shuffle
from Mesh import Mesh

def Fractal_Tree_3D(param):
    """This fuction creates the fractal tree.
    Args:
        param (Parameters object): this object contains all the parameters that define the tree. See the parameters module documentation for details:

    Returns:
        branches (dict): A dictionary that contains all the branches objects.
        nodes (nodes object): the object that contains all the nodes of the tree.
    """
    #Read Mesh
    m=Mesh(param.meshfile)
    #Define the initial direction
    init_dir=(param.second_node-param.init_node)/np.linalg.norm(param.second_node-param.init_node)

    #Initialize the nodes object, contains the nodes and all the distance functions
    nodes=Nodes(param.init_node)
    #Project the first node to the mesh.
    point,tri=m.project_new_point(nodes.nodes[0])
    if tri>=0:
        init_tri=tri
    else:
        print('initial point not in mesh')
        sys.exit(0)
    #Initialize the dictionary that stores the branches objects
    branches={}
    last_branch=0
    #Compute the first branch
    branches[last_branch]=Branch(m,0,init_dir,init_tri,param.init_length,0.0,0.0,nodes,[0],int(param.init_length/param.l_segment))
    branches_to_grow=[]
    branches_to_grow.append(last_branch)

    ien=[]
    for i_n in range(len(branches[last_branch].nodes)-1):
        ien.append([branches[last_branch].nodes[i_n],branches[last_branch].nodes[i_n+1]])
    #To grow fascicles
    if param.Fascicles:
        brother_nodes=[]
        brother_nodes+=branches[0].nodes
        for i_branch in range(len(param.fascicles_angles)):
            last_branch+=1
            angle=param.fascicles_angles[i_branch]
            branches[last_branch]=Branch(m,branches[0].nodes[-1],branches[0].dir,branches[0].tri,param.fascicles_length[i_branch],angle,0.0,nodes,brother_nodes,int(param.fascicles_length[i_branch]/param.l_segment))
            brother_nodes+=branches[last_branch].nodes

            for i_n in range(len(branches[last_branch].nodes)-1):
                ien.append([branches[last_branch].nodes[i_n],branches[last_branch].nodes[i_n+1]])
        branches_to_grow=list(range(1,len(param.fascicles_angles)+1))

    for i in range(param.N_it):
        shuffle(branches_to_grow)
        new_branches_to_grow=[]
        for g in branches_to_grow:
            angle=-param.branch_angle*np.random.choice([-1,1])
            for j in range(2):
                brother_nodes=[]
                brother_nodes+=branches[g].nodes
                if j>0:
                    brother_nodes+=branches[last_branch].nodes

                #Add new branch
                last_branch+=1
                print(last_branch)
                l=param.length+np.random.normal(0,param.std_length)
                if l<param.min_length:
                    l=param.min_length
                branches[last_branch]=Branch(m,branches[g].nodes[-1],branches[g].dir,branches[g].tri,l,angle,param.w,nodes,brother_nodes,int(param.length/param.l_segment))
                #Add nodes to IEN
                for i_n in range(len(branches[last_branch].nodes)-1):
                    ien.append([branches[last_branch].nodes[i_n],branches[last_branch].nodes[i_n+1]])

                #Add to the new array
                if branches[last_branch].growing:
                    new_branches_to_grow.append(last_branch)

                branches[g].child[j]=last_branch
                angle=-angle
        branches_to_grow=new_branches_to_grow

    if param.save:
        if param.save_paraview:
            from ParaviewWriter import write_line_VTU
            print('Finished growing, writing paraview file')
            xyz=np.zeros((len(nodes.nodes),3))
            for i in range(len(nodes.nodes)):
                xyz[i,:]=nodes.nodes[i]
            write_line_VTU(xyz, ien, param.filename + '.vtu')

        np.savetxt(param.filename+'_ien.txt',ien,fmt='%d')
        np.savetxt(param.filename+'_xyz.txt',xyz)
        np.savetxt(param.filename+'_endnodes.txt',nodes.end_nodes,fmt='%d')

    return branches,nodes

redpajama_set_name: RedPajamaGithub


text:
package org.apache.reef.bridge.service.parameters;

import org.apache.reef.tang.annotations.Name;
import org.apache.reef.tang.annotations.NamedParameter;

/**
 * What command to use when starting bridge process.
 */
@NamedParameter(doc = "The command to launch bridge driver process",
    short_name = "command")
public final class DriverClientCommand implements Name<String> {
}


text:
package cc.factorie.variable

// Notes on class names for variables:
// "*Variable" are classes and mutable.
// "*Var" are trait counterparts, not yet committing to (im)mutability.
// Many but not all "*Var" traits do not yet commit to a value-storage mechanism.

// Some classes have a "bound" Value type member; others have an "assigned" (concrete, fixed) Value type member
// "*Variable" classes have assigned Value type
// "*Var" traits have bound Value type members
// "*VarWithValue[Foo]" traits Value type member assigned to Foo
// *Variables that are used as type arguments to Family and Template must have assigned Values in order for the Template to work
// because they must implement methods (such as statistics(Variable1#Value)) that concretely define Value.

/**Abstract superclass of all variables.  Don't need to know its value type to use it.

   You should never make a Var a Scala 'case class' because then
   it will get hashCode and equals methods dependent on its
   constructor arguments; but the FACTORIE library depends on being
   able to distinguish individual Var instances based on their
   machine address (i.e. System.identityHashCode).

   Similarly no Var should ever inherit from scala.collection.Iterable,
   even though its value may do so.  This prevents confusion between
   Model.factors(Var) and Model.factors(Iterable[Var]).
   @author Andrew McCallum */
trait Var extends Serializable {
  type Value <: Any

  /** Abstract method to return the value of this variable. */
  def value: Value

  /** Value comparisons (as distinct from variable pointer equality) */
  def ===(other: Var) = value == other.value
  def !==(other: Var) = value != other.value

  // TODO Is there a more standard way of getting this short name? -akm
  /** Return a string consisting of the class name without its package. */
  private def shortClassName = {
    var fields = this.getClass.getName.split('$')
    if (fields.length == 1)
      fields = this.getClass.getName.split('.')
    if (fields.last == "class")
      fields(fields.length - 2)
    else if ("1234567890".contains(fields.last))
     fields(fields.length-2)
    else
      fields.last
  }
  /** Return the string often used as a prefix of the toString representation of this variable. */
  def printName = shortClassName
  /** Return a short string representation of this variable, suitable for debugging messages. */
  override def toString = printName + "(_)"
}

/** A variable that has a Domain, with value type bound A.
    Since this trait also inherits from ValueBound,
    we ensure that the Value of the Var matches the Value of the Domain.
    @author Andrew McCallum */
trait VarWithDomain extends Var {
  /** Abstract method to return the domain of this variable. */
  def domain: Domain
}

// Various marker traits on Var

/** Used as a marker for variables whose value does not change once created.
    Be  careful to only use this in class definitions that cannot become mutable in subclasses.
    @author Andrew McCallum */
trait VarWithConstantValue extends Var

/** Used as a marker for variables whose value is a deterministic (non-stochastic) function of some other state,
    for example, a deterministic function of its DirectedModel parents.
    Note that this is an attribute of a variable, not a factor, because it refers to the fact that the
    variable's value changes automatically with changes to the parent variables' values.  How the automatic
    values are scored (whether they are given 0.0 or 1.0 extreme probabilities) is a different matter.
    This function is used in cc.factorie.directed.DirectedModel.extendedParents and extendedChildren.
    @author Andrew McCallum */
trait VarWithDeterministicValue extends Var

/** A Variable with a value that can be changed.
    @author Andrew McCallum */
trait MutableVar extends Var {
  def value: Value
  /** Assign a new value to this variable */
  def set(newValue:Value)(implicit d:DiffList): Unit
  final def :=(newValue:Value): Unit = set(newValue)(null)
}

/** A marker for Variables that declare themselves not to automatically change other Variables' values when they are changed.
    This trait may enable efficiencies for sampling, scoring and learning.
    @author Andrew McCallum */
trait NoVariableCoordination {
  this: Var =>
}

// Odd simple variable I wasn't sure where else to put. -akm

/** A Variable whose (constant) value is the Variable object itself.
    @author Andrew McCallum */
trait SelfVariable[This<:SelfVariable[This]] extends Var with VarWithConstantValue {
  this: This =>
  type Value = This
  final def value: This = this
}


text:
if SERVER then

  include "whitelist/sv_init.lua"

end

if CLIENT then

  include "whitelist/cl_init.lua"

end


text:
elavarasanlee.github.io
=======================


text:
@interface StandardTabItemsExampleController () <RKTabViewDelegate>
@property (nonatomic, strong) IBOutlet RKTabView *standardView;
@end

@implementation StandardTabItemsExampleController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title = @"Standard items example";

    RKTabItem *filtersTabItem = [RKTabItem createUsualItemWithImageEnabled:[UIImage imageNamed:@"tab_filters_enabled"] imageDisabled:[UIImage imageNamed:@"tab_filters_disabled"]];
    filtersTabItem.tabState = TabStateEnabled;

    RKTabItem *frameTabItem = [RKTabItem createUsualItemWithImageEnabled:[UIImage imageNamed:@"tab_frame_enabled"] imageDisabled:[UIImage imageNamed:@"tab_frame_disabled"]];
    RKTabItem *rotateTabItem = [RKTabItem createUsualItemWithImageEnabled:[UIImage imageNamed:@"tab_rotate_enabled"] imageDisabled:[UIImage imageNamed:@"tab_rotate_disabled"]];
    RKTabItem *contrastTabItem = [RKTabItem createUsualItemWithImageEnabled:[UIImage imageNamed:@"tab_contrast_enabled"] imageDisabled:[UIImage imageNamed:@"tab_contrast_disabled"]];
    RKTabItem *brightnessTabItem = [RKTabItem createUsualItemWithImageEnabled:[UIImage imageNamed:@"tab_brightness_enabled"] imageDisabled:[UIImage imageNamed:@"tab_brightness_disabled"]];
    RKTabItem *blurTabItem = [RKTabItem createUsualItemWithImageEnabled:[UIImage imageNamed:@"tab_blur_enabled"] imageDisabled:[UIImage imageNamed:@"tab_blur_disabled"]];

    self.standardView.horizontalInsets = HorizontalEdgeInsetsMake(25, 25);

    self.standardView.darkensBackgroundForEnabledTabs = YES;
    self.standardView.drawSeparators = YES;
    self.standardView.tabItems = @[filtersTabItem, frameTabItem, rotateTabItem, contrastTabItem, brightnessTabItem,  blurTabItem];
}

#pragma mark - RKTabViewDelegate

- (void)tabView:(RKTabView *)tabView tabBecameEnabledAtIndex:(NSUInteger)index tab:(RKTabItem *)tabItem {
    NSLog(@"Tab № %tu became enabled on tab view", index);
}

- (void)tabView:(RKTabView *)tabView tabBecameDisabledAtIndex:(NSUInteger)index tab:(RKTabItem *)tabItem {
    NSLog(@"Tab № %tu became disabled on tab view", index);
}

@end


text:
class Profile;

namespace toolbar_importer_utils {

// Currently the only configuration information we need is to check whether or
// not the user currently has their GAIA cookie.  This is done by the function
// exposed through the ToolbarImportUtils namespace.
void IsGoogleGAIACookieInstalled(const base::Callback<void(bool)>& callback,
                                 Profile* profile);

}  // namespace toolbar_importer_utils

#endif  // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_UTILS_H_


text:
/* global beforeEach, describe, it, expect, spyOn */
describe('object-bound/property', function () {
  var obj

  it('defines Object.prototype.bound', function () {
    expect(Object.prototype.hasOwnProperty('bound')).toBe(true)
  })

  describe('Object.prototype.bound', function () {
    var spyFoo, spyBar

    beforeEach(function () {
      obj = {
        f: 1,
        foo: function () { return this.f },

        b: 2,
        bar: function () { return this.b }
      }
      spyFoo = spyOn(obj.foo, 'bind').and.callThrough()
      spyBar = spyOn(obj.bar, 'bind').and.callThrough()
    })

    it('binds all methods', function () {
      obj.bound
      expect(spyFoo).toHaveBeenCalledWith(obj)
      expect(spyBar).toHaveBeenCalledWith(obj)
    })

    it('caches bound methods', function () {
      var foo = obj.bound.foo
      var bar = obj.bound.bar

      expect(foo).toBe(obj.bound.foo)
      expect(bar).toBe(obj.bound.bar)
    })

    it('re-caches bound methods once', function () {
      var oldBound = obj.bound
      var newBound = obj.bound.bound // trigger re-cache

      expect(newBound.foo).not.toBe(oldBound.foo)
      expect(newBound.foo).toBe(obj.bound.foo)

      expect(newBound.bar).not.toBe(oldBound.bar)
      expect(newBound.bar).toBe(obj.bound.bar)
    })

    it('re-caches bound methods many times', function () {
      expect(obj.bound.bound.foo).not.toBe(obj.bound.bound.foo)
      expect(obj.bound.bound.bar).not.toBe(obj.bound.bound.bar)
    })

  })

})


text:
package by.istin.android.xcore.processor;

import android.content.Context;

import by.istin.android.xcore.XCoreHelper.IAppServiceKey;
import by.istin.android.xcore.source.DataSourceRequest;
import by.istin.android.xcore.source.IDataSource;

public interface IProcessor<Result, DataSourceResult> extends IAppServiceKey {

	public Result execute(DataSourceRequest dataSourceRequest, IDataSource<DataSourceResult> dataSource, DataSourceResult dataSourceResult) throws Exception;

    public void cache(Context context, DataSourceRequest dataSourceRequest, Result result) throws Exception;

}


text:
'use strict'

var CategoryColors = require('./CategoryColors.js');

module.exports = class NeuralComputation {
  constructor(convnetjs, events, sections) {
    this.events = events;
    this.sections = sections;
    this.convnetjs = convnetjs;

    this.classes = CategoryColors.idToCategories.length;

    this.iterations = 50; // how many times to train
    this.width = 512;
    this.height = 512;

    this.neuralNets = [];
    this.trainers = [];
    this.sectionPoints = [];

    for (var i in this.sections) {
      this.neuralNets[i] = new this.convnetjs.Net();
      this.createLayer(this.neuralNets[i]);
      this.trainers[i] = this.createTrainer(this.neuralNets[i]);
      this.sectionPoints[i] = [];
    }

    // Fill up points for each section
    for (var event of events) {
      if (event.category == "None") {
        continue;
      }

      for (var i in this.sections) {
        var section = this.sections[i];
        if (
          event.longitude > section.topLeft.longitude &&
          event.longitude < section.bottomRight.longitude &&
          event.latitude < section.topLeft.latitude &&
          event.latitude > section.bottomRight.latitude
        ) {
          this.sectionPoints[i].push({category: event.category, longitude: event.longitude, latitude: event.latitude});
        }
      }

    }

  }

  createLayer(neuralNet) {
    var layer = [];
    layer.push({type: 'input', out_sx: 1, out_sy: 1, out_depth: 2});
    layer.push({type: 'fc', num_neurons: 13, activation: 'sigmoid'});
    layer.push({type: 'fc', num_neurons: 13, activation: 'sigmoid'});
    layer.push({type: 'softmax', num_classes: this.classes});
    neuralNet.makeLayers(layer);
  }

  createTrainer(neuralNet) {
    var trainer = new this.convnetjs.SGDTrainer(neuralNet, {
      learning_rate: 0.01,
      momentum: 0.1,
      batch_size: 10,
      l2_decay: 0.001
    });
    return trainer;
  }

  latLongToXY(latitude, longitude, width, height) {
    var x = (longitude+180)/360*width;
    var y = (-latitude+90)/180*height;

    return {x: x, y: y};
  }

  train() {
    for (var s in this.sections) {
      var section = this.sections[s];

      var neuralData = [];
      var neuralDataToCompare = [];
      var neuralLabels = [];

      var width = Math.abs(section.bottomRight.longitude - section.topLeft.longitude);
      var height = Math.abs(section.bottomRight.latitude - section.topLeft.latitude);

      var topLeft = this.latLongToXY(section.topLeft.latitude, section.topLeft.longitude, 1024, 1024);
      var bottomRight = this.latLongToXY(section.bottomRight.latitude, section.bottomRight.longitude, 1024, 1024);

      var canvasWidth = Math.abs(bottomRight.x - topLeft.x);
      var canvasHeight = Math.abs(bottomRight.y - topLeft.y);

      var points = this.sectionPoints[s];

      for (var point of points) {
        for (var r = 0; r < 5; r++) {
          var pos = this.latLongToXY(
            point.latitude + (Math.random()-0.5)*0,
            point.longitude + (Math.random()-0.5)*0,
            1024,
            1024
          );

          // console.log(pos.x, pos.y, topLeft.x, topLeft.y, pos.x - topLeft.x - canvasWidth/2, pos.y - topLeft.y - canvasHeight/2);
          // return;

          neuralData.push([
            ((pos.x - topLeft.x)/canvasWidth - 0.5)*6,
            ((pos.y - topLeft.y)/canvasHeight - 0.5)*6
          ]);

          neuralDataToCompare.push(neuralData[neuralData.length-1])

          neuralLabels.push(CategoryColors.categories[point.category].id);
        }
      }

      // Fill in data for areas without points
      for (var y = 0; y <= 10; y++) {
        xLoop:
        for (var x = 0; x <= 10; x++) {
          var _x = (x/10 - 0.5)*6;
          var _y = (y/10 - 0.5)*6;

          for (var i = 0; i < neuralDataToCompare.length; i++) {
            var pos = neuralDataToCompare[i];
            var dist = Math.sqrt(Math.pow(pos[0]-_x, 2) + Math.pow(pos[1]-_y, 2))
            if (dist < 0.4) {
              continue xLoop;
            }
          }

          neuralData.push([_x, _y]);
          neuralLabels.push(13);
        }
      }

      var neuralVolume = new this.convnetjs.Vol(1, 1, this.classes);
      for(var iters = 0; iters < this.iterations; iters++) { // run this 500 times
        for(var i = 0; i < neuralData.length; i++) {
          neuralVolume.w = neuralData[i];
          this.trainers[s].train(neuralVolume, neuralLabels[i]);
        }
      }
    }
  }

  draw(canvas) {
    var ctx = canvas.getContext('2d');

    for (var s in this.sections) {
      var section = this.sections[s];

      var topLeft = this.latLongToXY(section.topLeft.latitude, section.topLeft.longitude, canvas.width, canvas.height);
      var bottomRight = this.latLongToXY(section.bottomRight.latitude, section.bottomRight.longitude, canvas.width, canvas.height);

      var canvasWidth = Math.abs(bottomRight.x - topLeft.x);
      var canvasHeight = Math.abs(bottomRight.y - topLeft.y);

      var netResult = new this.convnetjs.Vol(1,1,this.classes);

      var segments = 1;

      for (var x = topLeft.x; x < bottomRight.x; x+=segments) {
        for (var y = topLeft.y; y < bottomRight.y; y+=segments) {
          netResult.w[0] = ((x - topLeft.x)/canvasWidth - 0.5)*6;
          netResult.w[1] = ((y - topLeft.y)/canvasHeight - 0.5)*6;
          var a = this.neuralNets[s].forward(netResult, false);

          // go through weights and see which weight is highest
          var curI = -1;
          var curWeight = -1;

          for (var j = 0; j < a.w.length; j++) {
            var weight = a.w[j];
            if (weight > curWeight) {
              curWeight = weight;
              curI = j;
            }
          }

          var type = curI;

          if (type >= 0) {
            ctx.fillStyle = this.rgb(CategoryColors.idToCategories[type].color);
            ctx.fillRect(Math.floor(x), Math.floor(y), segments, segments);
          }
        }
      }

      // draw data points;
      for(var point of this.sectionPoints[s]) {
        var point2D = this.latLongToXY(point.latitude, point.longitude, canvas.width, canvas.height);
        ctx.fillStyle = this.rgb(CategoryColors.categories[point.category].color);
        ctx.beginPath();
        ctx.arc(point2D.x, point2D.y, 5, 0, Math.PI*2, true);
        ctx.closePath();
        ctx.fill();
        ctx.stroke();
      }
    }
  }

  save(width, height, cb) {

    for (var x = 0; x < width; x++) {
      for (var y = 0; y < height; y++) {
        cb(x, y, 0, 0, 0);
      }
    }

    for (var s in this.sections) {
      var section = this.sections[s];

      var topLeft = this.latLongToXY(section.topLeft.latitude, section.topLeft.longitude, width, height);
      var bottomRight = this.latLongToXY(section.bottomRight.latitude, section.bottomRight.longitude, width, height);

      var canvasWidth = Math.abs(bottomRight.x - topLeft.x);
      var canvasHeight = Math.abs(bottomRight.y - topLeft.y);

      var netResult = new this.convnetjs.Vol(1,1,this.classes);

      var segments = 1;

      for (var x = topLeft.x; x < bottomRight.x; x+=segments) {
        for (var y = topLeft.y; y < bottomRight.y; y+=segments) {
          netResult.w[0] = ((x - topLeft.x)/canvasWidth - 0.5)*6;
          netResult.w[1] = ((y - topLeft.y)/canvasHeight - 0.5)*6;

          var a = this.neuralNets[s].forward(netResult, false);

          // go through weights and see which weight is highest
          var curI = -1;
          var curWeight = -1;

          for (var j = 0; j < a.w.length; j++) {
            var weight = a.w[j];
            if (weight > curWeight) {
              curWeight = weight;
              curI = j;
            }
          }

          var type = curI;

          if (type >= 0) {
            var color = CategoryColors.idToCategories[type].color;
            cb(Math.floor(x), Math.floor(y), color[0], color[1], color[2]);
          }
        }
      }
    }
  }

  loadJson(json) {
    console.log(json);
    for (var i in json) {
      console.log(this.sections[i]);
      this.neuralNets[i].fromJSON(json[i]);
    }
  }

  getJson() {
    var json = [];
    for (var i in this.neuralNets) {
      json[i] = this.neuralNets[i].toJSON();
    }

    return JSON.stringify({out: json});
  }

  rgb(arr) {
    return `rgb(${arr[0]},${arr[1]},${arr[2]})`;
  }
}


text:
using System.Web;
using System.Web.Mvc;
using Microsoft.Owin.Security;

namespace AspNetIdentityDependencyInjectionSample.Helpers
{
    public class ChallengeResult : HttpUnauthorizedResult
    {
        // Used for XSRF protection when adding external logins
        public const string XsrfKey = "XsrfId";

        public ChallengeResult(string provider, string redirectUri)
            : this(provider, redirectUri, null)
        {
        }

        public ChallengeResult(string provider, string redirectUri, string userId)
        {
            LoginProvider = provider;
            RedirectUri = redirectUri;
            UserId = userId;
        }

        public string LoginProvider { get; set; }
        public string RedirectUri { get; set; }
        public string UserId { get; set; }

        public override void ExecuteResult(ControllerContext context)
        {
            var properties = new AuthenticationProperties { RedirectUri = RedirectUri };
            if (UserId != null)
            {
                properties.Dictionary[XsrfKey] = UserId;
            }
            context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
        }
    }
}


text:
package com.microsoft.azure.management.appservice.v2016_03_01;

import com.microsoft.azure.arm.model.HasInner;
import com.microsoft.azure.arm.resources.models.HasManager;
import com.microsoft.azure.management.appservice.v2016_03_01.implementation.AppServiceManager;
import com.microsoft.azure.management.appservice.v2016_03_01.implementation.AnalysisDefinitionInner;

/**
 * Type representing AnalysisDefinition.
 */
public interface AnalysisDefinition extends HasInner<AnalysisDefinitionInner>, HasManager<AppServiceManager> {
    /**
     * @return the description value.
     */
    String description();

    /**
     * @return the id value.
     */
    String id();

    /**
     * @return the kind value.
     */
    String kind();

    /**
     * @return the name value.
     */
    String name();

    /**
     * @return the type value.
     */
    String type();

}


text: Rails.application.config.session_store :cookie_store, key: '_safe-walk_session'


text:
/*---------------------------------------------------------------------
* PathTests.cs - file description
* Version: 1.0
* Author:
* Created:
*
* Tests the basic functionality of Socket objects
* ---------------------------------------------------------------------*/

using System;
using System.Reflection;

using System.IO;

namespace FileSystemTest
{

    public class PathTests : IMFTestInterface
    {
        [SetUp]
        public InitializeResult Initialize()
        {
            Log.Comment("Adding set up for the tests");

            // delete the Path DOTNETMF_FS_EMULATION
            try { IOTests.IntializeVolume(); }
            catch { return InitializeResult.Skip; }
            return InitializeResult.ReadyToGo;
        }

        [TearDown]
        public void CleanUp()
        {
        }

        [TestMethod]
        public MFTestResults PathTest0_ChangeExtension()
        {
            bool testResult = false;

            try
            {
                string newPath = Path.ChangeExtension(@"pathtest\testdir\test.ext1", ".ext2");
                testResult = String.Equals(newPath, @"pathtest\testdir\test.ext2");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// If new extension is null, then file extension should be removed.
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_ChangeExtension1()
        {
            bool testResult = false;

            try
            {
                string newPath = Path.ChangeExtension(@"pathtest\testdir\test.ext1", null);
                testResult = String.Equals(newPath, @"pathtest\testdir\test");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// If path is null, it should be returned unmodified.
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_ChangeExtension2()
        {
            bool testResult = false;

            try
            {
                string newPath = Path.ChangeExtension(null, ".ext");
                testResult = (newPath == null);
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// If path is empty, it should be returned unmodified.
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_ChangeExtension3()
        {
            bool testResult = false;

            try
            {
                string newPath = Path.ChangeExtension("", ".ext");
                testResult = (newPath == "");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// If path is empty, it should be returned unmodified.
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_ChangeExtension4()
        {
            bool testResult = false;

            try
            {
                string newPath = Path.ChangeExtension("", ".ext");
                testResult = (newPath == "");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// Negative test case, path contains invalid character.
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_ChangeExtension5()
        {
            bool testResult = true;

            try
            {
                string newPath = Path.ChangeExtension(@"pathtest\testdir\test>.ext1", ".ext");
                testResult = false;
            }
            catch (Exception ex)
            {
                Log.Exception("Expected Exception", ex);
                testResult = true;
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// Extension does not contain dot.
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_ChangeExtension6()
        {
            bool testResult = false;

            try
            {
                string newPath = Path.ChangeExtension(@"pathtest\testdir\test.ext1", "ext");
                testResult = String.Equals(newPath, @"pathtest\testdir\test.ext");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest1_GetDirectoryName()
        {
            bool testResult = false;

            try
            {
                string dirName = Path.GetDirectoryName(@"pathtest\testdir\test.ext1");
                testResult = String.Equals(dirName, @"pathtest\testdir");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// Get parent directory name of a directory
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_GetDirectoryName1()
        {
            bool testResult = false;

            try
            {
                string dirName = Path.GetDirectoryName(@"pathtest\testdir");
                testResult = String.Equals(dirName, @"pathtest");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// Parent of root directory
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_GetDirectoryName2()
        {
            bool testResult = false;

            try
            {
                string dirName = Path.GetDirectoryName(IOTests.Volume.RootDirectory);
                testResult = String.Equals(dirName, @"\");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// Parent of root directory
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_GetDirectoryName3()
        {
            bool testResult = false;

            try
            {
                string dirName = Path.GetDirectoryName(@"");
            }
            catch (ArgumentException)
            {
                testResult = true;
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// Parent of root directory
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_GetDirectoryName4()
        {
            bool testResult = false;

            try
            {
                string dirName = Path.GetDirectoryName(null);
                testResult = (dirName == null);
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        /// <summary>
        /// Parent of root directory
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public MFTestResults PathTest_GetDirectoryName5()
        {
            bool testResult = true;

            try
            {
                string dirName = Path.GetDirectoryName(@"abc\abc>");
                testResult = false;
            }
            catch (Exception ex)
            {
                Log.Exception("Expected Exception", ex);
                testResult = true;
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetDirectoryName6()
        {
            bool testResult = true;

            try
            {
                string dirName = Path.GetDirectoryName(@"\\\abc\abc>");
                testResult = false;
            }
            catch (Exception ex)
            {
                Log.Exception("Expected Exception", ex);
                testResult = true;
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFullPath0()
        {
            bool testResult = false;

            try
            {
                string fullPath = Path.GetFullPath(@"dir1\dir2\file.ext");
                testResult = String.Equals(fullPath, IOTests.Volume.RootDirectory + @"\dir1\dir2\file.ext");

                Log.Comment(fullPath);
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFullPath1()
        {
            bool testResult = false;

            try
            {
                string fullPath = Path.GetFullPath(IOTests.Volume.RootDirectory + @"\dir1\dir2\file.ext");
                testResult = String.Equals(fullPath, IOTests.Volume.RootDirectory + @"\dir1\dir2\file.ext");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFullPath2()
        {
            bool testResult = false;

            try
            {
                string fullPath = Path.GetFullPath(IOTests.Volume.RootDirectory + @"\dir1\..\dir2\file.ext");
                testResult = String.Equals(fullPath, IOTests.Volume.RootDirectory + @"\dir2\file.ext");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetExtension1()
        {
            bool testResult = false;

            try
            {
                string ext = Path.GetExtension(@"pathtest\testdir\test");
                testResult = String.Equals(ext, "");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetExtension2()
        {
            bool testResult = false;

            try
            {
                string ext = Path.GetExtension(null);
                testResult = (ext == null);
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetExtension3()
        {
            bool testResult = true;

            try
            {
                try
                {
                    string ext = Path.GetExtension(@"pathtest\testdir\test>.txt");
                    testResult = false;
                }
                catch (ArgumentException ae) { /* pass case */ Log.Comment( "Got correct exception: res=" + testResult.ToString() + ", " + ae.Message ); }
            }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetExtension4()
        {
            bool testResult = false;

            try
            {
                string ext = Path.GetExtension(@"pathtest\testdir\test.txt.txt2.txt3");
                testResult = String.Equals(ext, ".txt3");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest4_GetFileName()
        {
            bool testResult = false;

            try
            {
                string fileName = Path.GetFileName(@"pathtest\testdir\test.ext2");
                testResult = String.Equals(fileName, "test.ext2");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFileName1()
        {
            bool testResult = false;

            try
            {
                string fileName = Path.GetFileName(@"pathtest\testdir\test.ext2\");
                testResult = String.Equals(fileName, "");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFileName2()
        {
            bool testResult = false;

            try
            {
                string fileName = Path.GetFileName(@"pathtest\testdir\test.ext2:");
            }
            catch (ArgumentException)
            {
                testResult = true;
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFileName3()
        {
            bool testResult = false;

            try
            {
                string fileName = Path.GetFileName(null);
                testResult = (fileName == null);
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFileName4()
        {
            bool testResult = true;

            try
            {
                string fileName = Path.GetFileName(@"pathtest\testdir\test.ext2>");
                testResult = false;
            }
            catch (ArgumentException ae) { /* pass case */ Log.Comment( "Got correct exception: res=" + testResult.ToString() + ", " + ae.Message ); }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest5_GetFileNameWithoutExtension()
        {
            bool testResult = false;

            try
            {
                string fileName = Path.GetFileNameWithoutExtension(@"pathtest\testdir\test.ext2");
                testResult = String.Equals(fileName, "test");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFileNameWithoutExtension1()
        {
            bool testResult = false;

            try
            {
                string fileName = Path.GetFileNameWithoutExtension(@"pathtest\testdir\test.ext.ext1.ext2");
                testResult = String.Equals(fileName, "test.ext.ext1");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFileNameWithoutExtension2()
        {
            bool testResult = false;

            try
            {
                string fileName = Path.GetFileNameWithoutExtension(@"pathtest\testdir\test");
                testResult = String.Equals(fileName, "test");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_GetFileNameWithoutExtension3()
        {
            bool testResult = true;

            try
            {
                string fileName = Path.GetFileNameWithoutExtension(@"pathtest\testdir\test>");
                testResult = false;
            }
            catch (ArgumentException ae) { /* pass case */ Log.Comment( "Got correct exception: res=" + testResult.ToString() + ", " + ae.Message ); }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest6_GetPathRoot()
        {
            bool testResult = false;

            try
            {
                string root = Path.GetPathRoot(@"pathtest\testdir\test.ext2");
                testResult = String.Equals(root, "");
            }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest7_HasExtension()
        {
            bool testResult = false;

            try
            {
                testResult = Path.HasExtension(@"pathtest\testdir\test.ext2");
            }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_HasExtension1()
        {
            bool testResult = false;

            try
            {
                testResult = !Path.HasExtension(@"pathtest\testdir\test");
            }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_HasExtension2()
        {
            bool testResult = false;

            try
            {
                testResult = !Path.HasExtension(@"pathtest\testdir\test.ext2\");
            }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest8_IsPathRooted()
        {
            bool testResult = false;

            try
            {
                testResult = Path.IsPathRooted(@"\pathtest\testdir\test.ext2");
            }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_IsPathRooted1()
        {
            bool testResult = false;

            try
            {
                testResult = !Path.IsPathRooted(@"pathtest\testdir\test");
            }
            catch (Exception ex)
            {
                testResult = false;
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_IsPathRooted2()
        {
            bool testResult = false;

            try
            {
                /// Weird situation, according to MSDN this may be valid.
                testResult = Path.IsPathRooted(@"\\\\\\");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_IsPathRooted3()
        {
            bool testResult = false;

            try
            {
                testResult = Path.IsPathRooted(@"\");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_IsPathRooted4()
        {
            bool testResult = false;

            try
            {
                testResult = Path.IsPathRooted(@"\COM1");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest9_Combine()
        {
            bool testResult = false;

            try
            {
                string path = Path.Combine(@"pathtest\testdir\test", "test2");
                testResult = String.Equals(path, @"pathtest\testdir\test\test2");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_Combine1()
        {
            bool testResult = false;

            try
            {
                string path = Path.Combine(@"pathtest\testdir\test", @"\test2");
                testResult = String.Equals(path, @"\test2");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_Combine2()
        {
            bool testResult = false;

            try
            {
                string path = Path.Combine(@"\pathtest\testdir\test", @"\test2");
                testResult = String.Equals(path, @"\test2");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_Combine3()
        {
            bool testResult = false;

            try
            {
                string path = Path.Combine(@"\pathtest\testdir\test", @"\test2 ");
                testResult = String.Equals(path, @"\test2 ");
                /// Note: There's some difference between MSDN documentation of this case, and actual behavior. Notice
                /// the whitespace after test2.
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_Combine4()
        {
            bool testResult = false;

            try
            {
                string path = Path.Combine(@"\pathtest\testdir\test", @"test2*.txt");
                testResult = String.Equals(path, @"\pathtest\testdir\test\test2*.txt");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_Combine5()
        {
            bool testResult = false;

            try
            {
                string path = Path.Combine(@"\pathtest\testdir\test", @"..\test2.txt");
                testResult = String.Equals(path, @"\pathtest\testdir\test\..\test2.txt");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_Combine6()
        {
            bool testResult = false;

            try
            {
                string path = Path.Combine(@"^*&)(_=@&#2.*(.txt", @"dir\test2.txt");
                testResult = String.Equals(path, @"^*&)(_=@&#2.*(.txt\dir\test2.txt");
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected Exception", ex);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        [TestMethod]
        public MFTestResults PathTest_Combine7()
        {
            bool testResult = true;

            try
            {
                string path = Path.Combine("//" + IOTests.Volume.Name + "//dir", @"dir\test2.txt");
                testResult = false;
            }
            catch (Exception ex)
            {
                Log.Exception("Expected Exception", ex);
                testResult = true;
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }

        public MFTestMethod[] Tests
        {
            get
            {
                return new MFTestMethod[]
                {
                    new MFTestMethod( PathTest0_ChangeExtension, "PathTest0_ChangeExtension" ),
                    new MFTestMethod( PathTest_ChangeExtension1, "PathTest_ChangeExtension1" ),
                    new MFTestMethod( PathTest_ChangeExtension2, "PathTest_ChangeExtension2" ),
                    new MFTestMethod( PathTest_ChangeExtension3, "PathTest_ChangeExtension3" ),
                    new MFTestMethod( PathTest_ChangeExtension4, "PathTest_ChangeExtension4" ),
                    new MFTestMethod( PathTest_ChangeExtension5, "PathTest_ChangeExtension5" ),
                    new MFTestMethod( PathTest_ChangeExtension6, "PathTest_ChangeExtension6" ),
                    new MFTestMethod( PathTest1_GetDirectoryName, "PathTest1_GetDirectoryName" ),
                    new MFTestMethod( PathTest_GetDirectoryName1, "PathTest_GetDirectoryName1" ),
                    new MFTestMethod( PathTest_GetDirectoryName2, "PathTest_GetDirectoryName2" ),
                    new MFTestMethod( PathTest_GetDirectoryName3, "PathTest_GetDirectoryName3" ),
                    new MFTestMethod( PathTest_GetDirectoryName4, "PathTest_GetDirectoryName4" ),
                    new MFTestMethod( PathTest_GetDirectoryName5, "PathTest_GetDirectoryName5" ),
                    new MFTestMethod( PathTest_GetDirectoryName6, "PathTest_GetDirectoryName6" ),
                    new MFTestMethod( PathTest_GetFullPath0, "PathTest_GetFullPath0" ),
                    new MFTestMethod( PathTest_GetFullPath1, "PathTest_GetFullPath1" ),
                    new MFTestMethod( PathTest_GetFullPath2, "PathTest_GetFullPath2" ),
                    new MFTestMethod( PathTest_GetExtension1, "PathTest_GetExtension1" ),
                    new MFTestMethod( PathTest_GetExtension2, "PathTest_GetExtension2" ),
                    new MFTestMethod( PathTest_GetExtension3, "PathTest_GetExtension3" ),
                    new MFTestMethod( PathTest_GetExtension4, "PathTest_GetExtension4" ),
                    new MFTestMethod( PathTest4_GetFileName, "PathTest4_GetFileName" ),
                    new MFTestMethod( PathTest_GetFileName1, "PathTest_GetFileName1" ),
                    new MFTestMethod( PathTest_GetFileName2, "PathTest_GetFileName2" ),
                    new MFTestMethod( PathTest_GetFileName3, "PathTest_GetFileName3" ),
                    new MFTestMethod( PathTest_GetFileName4, "PathTest_GetFileName4" ),
                    new MFTestMethod( PathTest5_GetFileNameWithoutExtension, "PathTest5_GetFileNameWithoutExtension" ),
                    new MFTestMethod( PathTest_GetFileNameWithoutExtension1, "PathTest_GetFileNameWithoutExtension1" ),
                    new MFTestMethod( PathTest_GetFileNameWithoutExtension2, "PathTest_GetFileNameWithoutExtension2" ),
                    new MFTestMethod( PathTest_GetFileNameWithoutExtension3, "PathTest_GetFileNameWithoutExtension3" ),
                    new MFTestMethod( PathTest6_GetPathRoot, "PathTest6_GetPathRoot" ),
                    new MFTestMethod( PathTest7_HasExtension, "PathTest7_HasExtension" ),
                    new MFTestMethod( PathTest_HasExtension1, "PathTest_HasExtension1" ),
                    new MFTestMethod( PathTest_HasExtension2, "PathTest_HasExtension2" ),
                    new MFTestMethod( PathTest8_IsPathRooted, "PathTest8_IsPathRooted" ),
                    new MFTestMethod( PathTest_IsPathRooted1, "PathTest_IsPathRooted1" ),
                    new MFTestMethod( PathTest_IsPathRooted2, "PathTest_IsPathRooted2" ),
                    new MFTestMethod( PathTest_IsPathRooted3, "PathTest_IsPathRooted3" ),
                    new MFTestMethod( PathTest_IsPathRooted4, "PathTest_IsPathRooted4" ),
                    new MFTestMethod( PathTest9_Combine, "PathTest9_Combine" ),
                    new MFTestMethod( PathTest_Combine1, "PathTest_Combine1" ),
                    new MFTestMethod( PathTest_Combine2, "PathTest_Combine2" ),
                    new MFTestMethod( PathTest_Combine3, "PathTest_Combine3" ),
                    new MFTestMethod( PathTest_Combine4, "PathTest_Combine4" ),
                    new MFTestMethod( PathTest_Combine5, "PathTest_Combine5" ),
                    new MFTestMethod( PathTest_Combine6, "PathTest_Combine6" ),
                    new MFTestMethod( PathTest_Combine7, "PathTest_Combine7" ),
                };
             }
        }
    }
}


text:
namespace base {
class TimeDelta;
}

namespace media {
class AudioBus;
}

namespace media {
namespace cast {

struct PcmAudioFrame;

// Produces AudioBuses of varying duration where each successive output contains
// the continuation of a single sine wave.
class TestAudioBusFactory {
 public:
  TestAudioBusFactory(int num_channels,
                      int sample_rate,
                      float sine_wave_frequency,
                      float volume);
  ~TestAudioBusFactory();

  // Creates a new AudioBus of the given |duration|, filled with the next batch
  // of sine wave samples.
  scoped_ptr<AudioBus> NextAudioBus(const base::TimeDelta& duration);

  // A reasonable test tone.
  static const int kMiddleANoteFreq = 440;

 private:
  const int num_channels_;
  const int sample_rate_;
  const float volume_;
  SineWaveAudioSource source_;

  DISALLOW_COPY_AND_ASSIGN(TestAudioBusFactory);
};

// Convenience function to convert an |audio_bus| to its equivalent
// PcmAudioFrame.
// TODO(miu): Remove this once all code has migrated to use AudioBus.  See
// comment in media/cast/cast_config.h.
scoped_ptr<PcmAudioFrame> ToPcmAudioFrame(const AudioBus& audio_bus,
                                          int sample_rate);

// Assuming |samples| contains a single-frequency sine wave (and maybe some
// low-amplitude noise), count the number of times the sine wave crosses
// zero.
int CountZeroCrossings(const std::vector<int16>& samples);

}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_TEST_UTILITY_AUDIO_UTILITY_H_