You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Alex Lumpov (JIRA)" <ji...@apache.org> on 2015/03/18 17:04:38 UTC
[jira] [Comment Edited] (TAP5-2468) Tapestry & Cobertura
[ https://issues.apache.org/jira/browse/TAP5-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14367355#comment-14367355 ]
Alex Lumpov edited comment on TAP5-2468 at 3/18/15 4:04 PM:
------------------------------------------------------------
to fix it you can replace in org.apache.tapestry5.ioc.internal.DefaultModuleDefImpl
{code:java}
private void removeSyntheticMethods(Set<Method> methods)
{
Iterator<Method> iterator = methods.iterator();
while (iterator.hasNext())
{
Method m = iterator.next();
if (m.isSynthetic() || m.getName().startsWith("$"))
{
iterator.remove();
}
}
}
{code}
by
{code:java}
private void removeSyntheticMethods(Set<Method> methods)
{
Iterator<Method> iterator = methods.iterator();
while (iterator.hasNext())
{
Method m = iterator.next();
if (m.isSynthetic() || m.getName().startsWith("$") || m.getName().startsWith("__cobertura"))
{
iterator.remove();
}
}
}
{code}
Similar to what Howard did for Scala
{code}
SHA-1: 30a6c8e44a7a140260457eb4b28f30d615e62fe9
* TAP5-927: Cannot use Scala for Tapestry IOC Modules
git-svn-id: https://svn.apache.org/repos/asf/tapestry/tapestry5/trunk@896600 13f79535-47bb-0310-9956-ffa450edef68
{code}
was (Author: alexlumpov):
to fix it you can replace in org.apache.tapestry5.ioc.internal.DefaultModuleDefImpl
{code:java}
private void removeSyntheticMethods(Set<Method> methods)
{
Iterator<Method> iterator = methods.iterator();
while (iterator.hasNext())
{
Method m = iterator.next();
if (m.isSynthetic() || m.getName().startsWith("$"))
{
iterator.remove();
}
}
}
{code}
by
{code:java}
private void removeSyntheticMethods(Set<Method> methods)
{
Iterator<Method> iterator = methods.iterator();
while (iterator.hasNext())
{
Method m = iterator.next();
if (m.isSynthetic() || m.getName().startsWith("$") || m.getName().startsWith("__cobertura"))
{
iterator.remove();
}
}
}
{code}
Similar to what Howard did for Scala
> Tapestry & Cobertura
> --------------------
>
> Key: TAP5-2468
> URL: https://issues.apache.org/jira/browse/TAP5-2468
> Project: Tapestry 5
> Issue Type: Bug
> Components: tapestry-ioc
> Affects Versions: 5.4, 5.3.8
> Reporter: Alex Lumpov
> Attachments: coberturatest.zip
>
>
> cobertura adds utility methods to test classes
> but tapestry throws RuntimeException when it finds these methods in a module class.
> Here is an example project using cobertura.
> {code:java}
> package ru.alexlumpov.coberturatest;
> import org.apache.tapestry5.ioc.ServiceBinder;
> public class MyModule {
> public static void bind(ServiceBinder binder) {
> binder.bind(MyService.class);
> }
> }
> {code}
> {code:java}
> package ru.alexlumpov.coberturatest;
> public class MyService {
> public String getHello() {
> return "Hello";
> }
> }
> {code}
> {code:java}
> package ru.alexlumpov.coberturatest;
> import org.apache.tapestry5.ioc.Registry;
> import org.apache.tapestry5.ioc.RegistryBuilder;
> import org.junit.Assert;
> import org.junit.Test;
> public class MyServiceTest extends Assert {
> @Test
> public void testGetHello() {
> Registry registry = RegistryBuilder.buildAndStartupRegistry(MyModule.class);
> MyService service = registry.getObject(MyService.class, null);
> assertEquals("Hello", service.getHello());
> }
> }
> {code}
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>ru.alexlumpov</groupId>
> <artifactId>coberturatest</artifactId>
> <version>1.0-SNAPSHOT</version>
>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <maven.compiler.source>1.6</maven.compiler.source>
> <maven.compiler.target>1.6</maven.compiler.target>
> </properties>
>
> <dependencies>
> <dependency>
> <groupId>org.apache.tapestry</groupId>
> <artifactId>tapestry-ioc</artifactId>
> <version>5.3.8</version>
> <exclusions>
> <exclusion>
> <groupId>log4j</groupId>
> <artifactId>log4j</artifactId>
> </exclusion>
> <exclusion>
> <groupId>org.slf4j</groupId>
> <artifactId>slf4j-log4j12</artifactId>
> </exclusion>
> </exclusions>
> </dependency>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>4.12</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>cobertura-maven-plugin</artifactId>
> <version>2.7</version>
> <executions>
> <execution>
> <phase>package</phase>
> <goals>
> <goal>cobertura</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </project>
> {code}
> if you type
> {code}mvn clean package{code}
> you will see
> {code}
> Running ru.alexlumpov.coberturatest.MyServiceTest
> Adding module definition for class org.apache.tapestry5.ioc.services.TapestryIOCModule
> Adding module definition for class ru.alexlumpov.coberturatest.MyModule
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.421 sec <<< FAILURE!
> Cobertura: Loaded information on 3 classes.
> Cobertura: Saved information on 3 classes.
> Results :
> Tests in error:
> testGetHello(ru.alexlumpov.coberturatest.MyServiceTest): Module class ru.alexlumpov.coberturatest.MyModule contains unrecognized public methods: public static int[] ru.alexlumpov.coberturatest.MyModule.__cobertura_get_and_reset_counters(), public static void ru.alexlumpov.coberturatest.MyModule.__cobertura_classmap(net.sourceforge.cobertura.coveragedata.LightClassmapListener), public static void ru.alexlumpov.coberturatest.MyModule.__cobertura_classmap_0(net.sourceforge.cobertura.coveragedata.LightClassmapListener), public static void ru.alexlumpov.coberturatest.MyModule.__cobertura_init().
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
> There are test failures.
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)