mnuessler / cakupan

Automatically exported from code.google.com/p/cakupan
1 stars 0 forks source link

CoverageTemplate, CoverageFile, and CoverageLine need default constructors #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Here's a JUnit Test

package com.cakupan.xslt.ant;

import java.io.File;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class ReportTaskTest {

    @Test
    public void destDir() {
        Assert.assertNotNull(this.destDir);
        Assert.assertTrue(this.destDir.exists());
        Assert.assertTrue(this.destDir.isDirectory());
    }

    @Test
    public void execute() {
        FileSet fileSet = new FileSet();
        fileSet.setDir(new File("C:\\svn\\prime\\code\\trunk\\xslt\\src\\main\\resources\\xsl"));
        fileSet.setIncludes("**/*.xsl");
        Project project = new Project();
        this.task.setProject(project);
        try {
            this.task.execute();
            Assert.assertTrue(true);
        }
        catch (BuildException ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Before
    public void createDestDir() throws Exception {
        this.destDir = new File("C:\\svn\\prime\\code\\trunk\\xslt\\cakupan-instrument");
        this.task = new ReportTask();
        this.task.setDestDir(this.destDir);
    }

    private File destDir;
    private ReportTask task;

}

2.

Execute with CoverageTemplate, CoverageFile and CoverageLine as in 1.5, with no 
default constructors.

3.

Then add default constructors.

What is the expected output? What do you see instead?

EXPECTED:
Start reporttask
End reporttask

ACTUAL:
Start reporttask
com.thoughtworks.xstream.converters.ConversionException: Cannot construct 
com.cakupan.xslt.data.CoverageTemplate as it does not have a no-args constructor
---- Debugging information ----
message             : Cannot construct com.cakupan.xslt.data.CoverageTemplate 
as it does not have a no-args constructor
cause-exception     : 
com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message       : Cannot construct com.cakupan.xslt.data.CoverageTemplate 
as it does not have a no-args constructor
class               : java.util.TreeMap
required-type       : com.cakupan.xslt.data.CoverageTemplate
path                : 
/tree-map/entry/com.cakupan.xslt.data.CoverageFile/templates/com.cakupan.xslt.da
ta.CoverageTemplate
line number         : 102
-------------------------------
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:63)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
    at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:66)
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:57)
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
    at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
    at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:66)
    at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:67)
    at com.thoughtworks.xstream.converters.collections.TreeMapConverter.unmarshal(TreeMapConverter.java:57)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
    at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:833)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:781)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:773)
    at com.cakupan.xslt.util.XStreamUtil.fromXML(XStreamUtil.java:19)
    at com.cakupan.xslt.util.XSLTCakupanUtil.loadCoverageStats(XSLTCakupanUtil.java:165)
    at com.cakupan.xslt.util.XSLTCakupanUtil.generateCoverageReport(XSLTCakupanUtil.java:231)
    at com.cakupan.xslt.ant.ReportTask.execute(ReportTask.java:27)
    at com.cakupan.xslt.ant.ReportTaskTest.execute(ReportTaskTest.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: 
com.thoughtworks.xstream.converters.reflection.ObjectAccessException: Cannot 
construct com.cakupan.xslt.data.CoverageTemplate as it does not have a no-args 
constructor
    at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.newInstance(PureJavaReflectionProvider.java:59)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.instantiateNewInstance(AbstractReflectionConverter.java:257)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:124)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
    ... 55 more
End reporttask

What version of the product are you using? On what operating system?
Using cakupan-1.5, executing in Eclipse/JBoss Developer Studio on Windows VM.

Please provide any additional information below.

Original issue reported on code.google.com by schubert...@gmail.com on 5 Jan 2015 at 8:33

GoogleCodeExporter commented 9 years ago
Here's my slightly modified pom...

<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>com.cakupan</groupId>
        <artifactId>cakupan</artifactId>
        <version>1.5.1</version>
        <packaging>jar</packaging>

        <name>Cakupan</name>
        <description>Cakupan XSLT test coverage tool</description>
        <url>http://code.google.com/p/cakupan/</url>
        <licenses>
                <license>
                        <name>GNU GPL v2</name>
                        <url>http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt</url>
                        <distribution>repo</distribution>
                </license>
        </licenses>

        <scm>
                <connection>scm:svn:http://cakupan.googlecode.com/svn/trunk/</connection>
                <developerConnection>scm:svn:https://cakupan.googlecode.com/svn/trunk/</developerConnection>
                <url>http://code.google.com/p/cakupan/source/browse/</url>
        </scm>

        <issueManagement>
                <system>Google Code Issues</system>
                <url>http://code.google.com/p/cakupan/issues/list</url>
        </issueManagement>

    <developers>
        <developer>
            <id>patrick.oosterveld</id>
            <name>Patrick Oosterveld</name>
            <roles>
                <role>owner</role>
                <role>developer</role>
            </roles>
        </developer>
    </developers>

        <dependencies>
                <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-junit</artifactId>
                        <version>1.6.5</version>
                </dependency>
                <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-launcher</artifactId>
                        <version>1.6.5</version>
                </dependency>
                <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant</artifactId>
                        <version>1.6.5</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant-testutil</artifactId>
                        <version>1.8.0</version>
                </dependency>
                <dependency>
                        <groupId>net.sourceforge.saxon</groupId>
                        <artifactId>saxon</artifactId>
                        <version>9.1.0.8</version>
                </dependency>
                <dependency>
                        <groupId>xalan</groupId>
                        <artifactId>xalan</artifactId>
                        <version>2.6.0</version>
                </dependency>
                <dependency>
                        <groupId>xpp3</groupId>
                        <artifactId>xpp3</artifactId>
                        <version>1.1.4c</version>
                </dependency>
                <dependency>
                        <groupId>xstream</groupId>
                        <artifactId>xstream</artifactId>
                        <version>1.2.2</version>
                </dependency>

                <dependency>
                        <groupId>commons-lang</groupId>
                        <artifactId>commons-lang</artifactId>
                        <version>2.1</version>
                </dependency>

                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>4.11</version>
                </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        </dependencies>

    <build>
        <defaultGoal>install</defaultGoal>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <outputDirectory>target/test/classes</outputDirectory>
        <testOutputDirectory>target/test/classes</testOutputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-source-plugin</artifactId>
  <executions>
    <execution>
      <id>attach-sources</id>
      <goals>
        <goal>jar</goal>
      </goals>
    </execution>
  </executions>
            </plugin>
        </plugins>
    </build>
</project>

Original comment by schubert...@gmail.com on 5 Jan 2015 at 8:37

GoogleCodeExporter commented 9 years ago
I had a similar problem when I tried to use XStream 1.3.1, which was fixed with 
an upgrade to 1.4.5.  The version shipped with Cakupan is 1.4.3, are you using 
that version, or some other version?

Original comment by sgiff...@suspectclass.com on 6 Jan 2015 at 6:36