tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Lumpov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TAP5-2468) Tapestry & Cobertura
Date Wed, 18 Mar 2015 15:58:38 GMT

    [ https://issues.apache.org/jira/browse/TAP5-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14367355#comment-14367355
] 

Alex Lumpov commented on TAP5-2468:
-----------------------------------

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
>
> 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)

Mime
View raw message