Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 63742 invoked from network); 6 Feb 2007 02:00:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Feb 2007 02:00:54 -0000 Received: (qmail 95201 invoked by uid 500); 6 Feb 2007 02:01:01 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 95181 invoked by uid 500); 6 Feb 2007 02:01:01 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 95170 invoked by uid 99); 6 Feb 2007 02:01:01 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2007 18:01:01 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2007 18:00:51 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 6F1E81A981A; Mon, 5 Feb 2007 18:00:31 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070206020031.6F1E81A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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$ +// +%> + + + $testCase.name + + +
+

TestCase: $testCase.name

+ + + + + +
+

Summary

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% if (!testCase.status.passed) { %> + + + + + <% } %> +
Name:$testCase.name
Class:$testCase.className
Test:$testCase.testName
Started:$testCase.started
Ended:$testCase.ended
Duration:$testCase.duration
Status:$testCase.status.text
Passed:$testCase.status.passed
Failure Reason:$testCase.status.reason
+
+ + <% def renderProperties = { name -> %> + + <% for (entry in testCase.result[name]) { %> + + + + + <% } %> +
$entry.key$entry.value
+ <% } %> + +
+

Details

+ +

Test Description

+ + <% renderProperties('testdescription') %> + +

Environment

+ + <% renderProperties('environment') %> + +

Test Result

+ + <% renderProperties('testresult') %> + +

Sections

+ + <% + testCase.result.sections.each { name, section -> + out.println "

$name

" + + section.streams.each { ignore, stream -> + out.println "

$stream.name ($stream.lines lines, $stream.chars chars)

" + if (stream.lines > 0) { + out.println "
$stream.data
" + } + // + // TODO: else print some warning about no data + // + } + } + %> +
+
+ + + + + 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) } }