karurkarthi / xdocreport

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

XdocReport throw exception when velocity.properties file is in classpath #237

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. prepare everything to generate report using velocity template engine
2. create in classpath file velocity.properties
3. run report generation

What is the expected output? What do you see instead?
Expect a generated report, but get following exception:
java.lang.AssertionError: Unable to find resource 
'fr.opensagres.xdocreport.document.docx.DocxReport@174fa0ef!word/document.xml'
    at org.junit.Assert.fail(Assert.java:91)
    at test.com.jet.dsetl.service.proofDod.TestGeneratinProofDod.testClient(TestGeneratinProofDod.java:159)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    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)

What version of the product are you using? On what operating system?
1.0.0

Please provide any additional information below.
When I remove the velocity.properties file from classpath, the report is 
generated.

Original issue reported on code.google.com by ruslancu...@gmail.com on 21 Mar 2013 at 8:02

GoogleCodeExporter commented 9 years ago
Hi ruslancusnir,

As you override the velocity.properties, it doesn't contains the XDocReport 
resource loader (load a XML entry (ex : word/document.xml) from a zip 
(XDocArchive)), and throw your error : 

See 
https://code.google.com/p/xdocreport/source/browse/template/fr.opensagres.xdocre
port.template.velocity/src/main/java/fr/opensagres/xdocreport/template/velocity/
discovery/VelocityTemplateEngineDiscovery.java

--------------------------------------------------------------------------------
velocityEngineProperties.setProperty( "report.resource.loader.class",           

XDocReportEntryResourceLoader.class.getName() );
--------------------------------------------------------------------------------

To resolve your problem, you must add in the velocity.properties the line :

--------------------------------------------------------------------------------
fr.opensagres.xdocreport.template.velocity.cache.XDocReportEntryResourceLoader
--------------------------------------------------------------------------------

But perhaps it's a bad idea to test :

--------------------------------------------------
if(velocityDefaultProperties != null){
   velocityEngineProperties.putAll(velocityDefaultProperties);
}else{
...
//Only if default velocity properties are not reads at velocity.properties
--------------------------------------------------

and do every time the code after the else.

Is it possible to test that?

If it works, I could commit that.

Regards Angelo

Original comment by angelo.z...@gmail.com on 21 Mar 2013 at 8:48

GoogleCodeExporter commented 9 years ago
Hi Angelo,

I tested and I configured velocity.properties to use report loader. Bottom is 
the part from velocity.properties which will configure velocity template engine 
to load resources from xdoc resource loader:
--------------------------------------
#velocity other properties
....
#resource loader config
resource.loader=report
report.resource.loader.class=fr.opensagres.xdocreport.template.velocity.cache.XD
ocReportEntryResourceLoader
report.resource.loader.cache=true
report.resource.loader.modificationCheckInterval=1
....
#other velocity properties
-----------------------------

If it is possible, please add this somewhere to wiki with note that in this 
case templates will be loaded ONLY and ONLY from xdocreport template.

Original comment by ruslancu...@gmail.com on 21 Mar 2013 at 9:37

GoogleCodeExporter commented 9 years ago
As I said you, I tell me it's perhaps a bad idea to test :

--------------------------------------------------
if(velocityDefaultProperties != null){
   velocityEngineProperties.putAll(velocityDefaultProperties);
}else{
...
//Only if default velocity properties are not reads at velocity.properties
--------------------------------------------------

If else is removed, perhaps you could add velocity.properties without crashing 
XDocReport. Could you test that please.

Original comment by angelo.z...@gmail.com on 21 Mar 2013 at 9:42

GoogleCodeExporter commented 9 years ago
I get you... 
In this case, it is need to add XDocReport specific properties to velocity 
properties.

Unfortunately I use version 1.0.0 for development, and I have no posibility to 
test with version 1.0.1 because it is missing in maven, and I have no time to 
reconfigure the project to use xdocreport from local repository.

A question, there are some unit test which test this?
I can create a patch which will add xdoc report specific properties and just 
run test.

Original comment by ruslancu...@gmail.com on 21 Mar 2013 at 9:46

GoogleCodeExporter commented 9 years ago
I don't remember if we have JUnit about that.

I will try to see my idea when I will find time.

Original comment by angelo.z...@gmail.com on 21 Mar 2013 at 10:55

GoogleCodeExporter commented 9 years ago

Original comment by angelo.z...@gmail.com on 18 Feb 2014 at 2:16