geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r503955 - in /geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild: config/projects/Geronimo_CTS/report/ config/projects/Geronimo_CTS/report/resources/ system/util/
Date Tue, 06 Feb 2007 02:00:30 GMT
Author: jdillon
Date: Mon Feb  5 18:00:29 2007
New Revision: 503955

URL: http://svn.apache.org/viewvc?view=rev&rev=503955
Log:
Replaced velocity with groovy's SimpleTemplateEngine for templating, as velocity does not
dereference some of the more magical groovy objects (like proxies and expando)
Updated the testcase template to include all details and render into package directory

Added:
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl
  (with props)
Removed:
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/macros.vm
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.vm
Modified:
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/Template.groovy
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/TemplateEngine.groovy

Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy?view=diff&rev=503955&r1=503954&r2=503955
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy
(original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/ReportGenerator.groovy
Mon Feb  5 18:00:29 2007
@@ -23,8 +23,6 @@
 
 package gbuild.config.projects.Geronimo_CTS.report
 
-import groovy.xml.MarkupBuilder
-
 import gbuild.system.LogSupport
 import gbuild.system.util.LazyProxy
 import gbuild.system.util.Sorting
@@ -80,7 +78,6 @@
         
         // Setup the template engine
         def engine = new TemplateEngine('gbuild/config/projects/Geronimo_CTS/report/resources')
-        engine.libraries = [ 'macros.vm' ]
         
         // Process each result archive
         archives.each { archive ->
@@ -134,13 +131,12 @@
             def renderTestCase = { testCase ->
                 log.info "Processing testcase: $testCase.name"
                 
-                def template = engine.getTemplate('testcase.vm')
+                def template = engine.getTemplate('testcase.tmpl')
                 template.params.testCase = testCase
                 
-                def basedir = new File(targetDir, testCase.name.replace('.', '/').replace('#',
'_'))
-                ant.mkdir(dir: basedir)
+                def file = new File(targetDir, testCase.name.replace('.', '/').replace('#',
'_') + '.html')
+                ant.mkdir(dir: file.parentFile)
                 
-                def file = new File(basedir, 'index.html')
                 template.render(file)
             }
             

Added: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl?view=auto&rev=503955
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl
(added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl
Mon Feb  5 18:00:29 2007
@@ -0,0 +1,133 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//
+// $Id$
+//
+%>
+<html>
+<head>
+    <title>$testCase.name</title>
+</head>
+<body>
+    <div class="testcase">
+        <h1>TestCase: $testCase.name</h1>
+        
+        <!-- TODO: Include links to iteration -->
+        
+        <!-- TODO: Include links to anchors below for easy access -->
+        
+        <div class="testcase-summary">
+            <h2>Summary</h2>
+            
+            <table>
+                <tr>
+                    <td>Name:</td>
+                    <td>$testCase.name</td>
+                </tr>
+                <tr>
+                    <td>Class:</td>
+                    <td>$testCase.className</td>
+                </tr>
+                <tr>
+                    <td>Test:</td>
+                    <td>$testCase.testName</td>
+                </tr>
+                <tr>
+                    <td>Started:</td>
+                    <td>$testCase.started</td>
+                </tr>
+                <tr>
+                    <td>Ended:</td>
+                    <td>$testCase.ended</td>
+                </tr>
+                <tr>
+                    <td>Duration:</td>
+                    <td>$testCase.duration</td>
+                </tr>
+                
+                <tr>
+                    <td>Status:</td>
+                    <td>$testCase.status.text</td>
+                </tr>
+                <tr>
+                    <td>Passed:</td>
+                    <td>$testCase.status.passed</td>
+                </tr>
+                
+                <% if (!testCase.status.passed) { %>
+                <tr>
+                    <td>Failure Reason:</td>
+                    <td>$testCase.status.reason</td>
+                </tr>
+                <% } %>
+            </table>
+        </div>
+        
+        <% def renderProperties = { name -> %>
+            <table>
+            <% for (entry in testCase.result[name]) { %>
+                <tr>
+                    <td>$entry.key</td>
+                    <td>$entry.value</td>
+                </tr>
+            <% } %>
+            </table>
+        <% } %>
+        
+        <div class="testcase-details">
+            <h2>Details</h2>
+            
+            <h3>Test Description</h3>
+            
+            <% renderProperties('testdescription') %>
+            
+            <h3>Environment</h3>
+            
+            <% renderProperties('environment') %>
+            
+            <h3>Test Result</h3>
+            
+            <% renderProperties('testresult') %>
+            
+            <h2>Sections</h2>
+            
+            <%
+            testCase.result.sections.each { name, section ->
+                out.println "<h3>$name</h3>"
+                
+                section.streams.each { ignore, stream ->
+                    out.println "<h4>$stream.name ($stream.lines lines, $stream.chars
chars)</h4>"
+                    if (stream.lines > 0) {
+                        out.println "<pre>$stream.data</pre>"
+                    }
+                    //
+                    // TODO: else print some warning about no data
+                    //
+                }
+            }
+            %>
+        </div>
+    </div>
+    
+    <!-- TODO: Add links to top of page -->
+
+</body>
+</html>

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/resources/testcase.tmpl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/Template.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/Template.groovy?view=diff&rev=503955&r1=503954&r2=503955
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/Template.groovy
(original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/Template.groovy
Mon Feb  5 18:00:29 2007
@@ -33,7 +33,7 @@
 import org.apache.velocity.VelocityContext
 
 /**
- * Wrapper around a Velocity template.
+ * Helper to render a template.
  */
 class Template extends LogSupport
 {
@@ -41,9 +41,9 @@
     
     Map params = [:]
     
-    private org.apache.velocity.Template template
+    private groovy.text.Template template
     
-    def Template(String name, org.apache.velocity.Template template) {
+    def Template(String name, groovy.text.Template template) {
         assert name
         assert template
         
@@ -56,16 +56,10 @@
         
         log.debug "Rendering template: $name"
         
-        def context = new VelocityContext()
-        
-        params.each {
-            context.put(it.key, it.value)
-        }
-        
         def watch = new StopWatch()
         watch.start()
         
-        template.merge(context, writer)
+        template.make(params).writeTo(writer)
         
         log.debug "Rendered template in $watch"
     }

Modified: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/TemplateEngine.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/TemplateEngine.groovy?view=diff&rev=503955&r1=503954&r2=503955
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/TemplateEngine.groovy
(original)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/system/util/TemplateEngine.groovy
Mon Feb  5 18:00:29 2007
@@ -23,53 +23,49 @@
 
 package gbuild.system.util
 
+import groovy.text.SimpleTemplateEngine
+
 import gbuild.system.LogSupport
 
 import org.apache.commons.lang.time.StopWatch
 
-import org.apache.velocity.app.VelocityEngine
-
 /**
- * Helper to render templates with Velocity.
+ * Helper to create templates.
  */
 class TemplateEngine extends LogSupport
 {
-    private VelocityEngine velocity = new VelocityEngine()
+    private SimpleTemplateEngine engine = new SimpleTemplateEngine()
     
-    // Lazy initialized to allow nicer API to installing libraries
-    private boolean initialized = false
+    private URL baseurl
     
-    def TemplateEngine(basepath) {
-        def url = getClass().classLoader.getResource(basepath)
-        assert url
-        assert url.protocol == 'file'
-        
-        def basedir = url.path
-        log.info "Base dir: $basedir"
+    private Map cache = [:]
+    
+    def TemplateEngine(String basepath) {
+        assert basepath
         
-        velocity.setProperty('resource.loader', 'file')
-        velocity.setProperty('file.resource.loader.description', 'Velocity File Resource
Loader')
-        velocity.setProperty('file.resource.loader.class', 'org.apache.velocity.runtime.resource.loader.FileResourceLoader')
-        velocity.setProperty('file.resource.loader.path', basedir)
-        velocity.setProperty('file.resource.loader.cache', 'false')
-        velocity.setProperty('file.resource.loader.modificationCheckInterval', '2')
+        if (!basepath.endsWith('/')) {
+            basepath += '/'
+        }
         
-        velocity.setProperty('runtime.log.logsystem.class', 'org.apache.velocity.runtime.log.NullLogSystem')
+        baseurl = getClass().classLoader.getResource(basepath)
+        assert baseurl
     }
     
-    def setLibraries(List libs) {
-        assert libs
-        assert !initialized
+    Template getTemplate(String name) {
+        assert name
         
-        velocity.setProperty('velocimacro.library', libs.join(','))
-    }
-    
-    Template getTemplate(name) {
-        if (!initialized) {
-            velocity.init()
-            initialized = true
+        def tmpl = cache[name]
+        if (!tmpl) {
+            def url = new URL(baseurl, name)
+            log.info "Creating new template: $name, from: $url"
+            
+            tmpl = engine.createTemplate(url)
+            cache[name] = tmpl
+        }
+        else {
+            log.info "Using cached template: $name"
         }
         
-        return new Template(name, velocity.getTemplate(name))
+        return new Template(name, tmpl)
     }
 }



Mime
View raw message