I don't have an answer, but I have some comments that may help you find a solution...

jdwyah wrote:
My tests need to access the templates in WEB-INF/freemarker

If I configure my directory with the standard

src/main/java
src/main/webapp/WEB-INF/freemarker/myTemplate.ftl
src/main/resources/applicationContext.xml
test/main/resouces/--nothing here--


My tests that require applicationContext.xml work fine, but the ones that
require myTemplate.ftl do not. Super, I just need to add a resource
location, right? I tried the additions below, but it didn't seem to do
anything. Is mvn -X -Dtest=mytest  the best way to get debug output/sort
these things out?

<build>
        <resources>
                <resource>
                        <directory>
                                src/main/resources
                        </directory>
                </resource>
                <resource>
                        <directory>
                                ${warSourceDirectory}
                        </directory>
                </resource>
        </resources>
</build>
So I'd like a solution like the above, but if that fails, My 2nd attempt was
making a:
src/main/resources/WEB-INF/freemarker/myTemplate.ftl

This wasn't found either and my app (well actually the freemarkerViewLoader)
looks like it's only checking:  test-classes/

Lastly I tried:
test/main/resources/WEB-INF/freemarker/myTemplate.ftl

and the template is found.

What I'd really like is some variation on the first option I tried. Is this
incorrect?

In general, there are two ways to load a file/resource:

1. from a file path, that might be relative to the current working directory, or relative to the root of your webapp

2. from the classpath

Defining maven resources essentially gets more stuff into your classpath (in support of way 2). But if the application is trying to load them from a specific file path (way 1), it won't help. I think this is a disconnect that you are experiencing.


2ndly I'm confused as to why the tests find:

src/main/resources/applicationContext.xml
but not src/main/resources/WEB-INF/freemarker/myTemplate.ftl

An issue in the way the Spring/Freemarker template loading is happening?

applicationContext.xml is (most likely) loaded from the classpath, not from src/main/resources/. Stuff that is in src/main/resources gets copied to target/classes. target/classes is in the classpath.

I don't know anything about freemarker. Is there any way to get it to load your .ftl files from the classpath (rather than from the file path /WEB-INF/freemarker)? Looking at the freemarker source code might be the best way to understand how it loads the files.

-Max


Any ideas? Thanks,
-j
--
View this message in context: 
http://www.nabble.com/WEB-INF+resources+in+test-t1677440.html#a4548550
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to