Hi Borut,
 
> thanks VERY much for the explanations.
> I refactored my code to almost match your recomendation (I did not put 
stuff
> from src/main/resources into src/main/java).

Putting the resources in the java tree was the most controversial 
suggestion :-) Definitely a personal preference. But useful for people to 
know that they do have that choice.


> When running mvn clean test I get:
> 
> FAILED: testElementIsOnPage
> java.lang.RuntimeException: Request was not handled:
> 'demo/DayMonthYearDateInputDemo' may not be a valid page name.
>     at 
org.apache.tapestry5.test.PageTester.renderPage(PageTester.java:177)
>     at
> test.si.najdi.tapestry.library.demo.components.
> DayMonthYearDateInputDemo.
> testElementIsOnPage(DayMonthYearDateInputDemo.java:14)
>     at
> 
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74)

What's interesting about this stack trace (reading from the bottom up) is 
that TestNG is calling:
 
test.si.najdi.tapestry.library.demo.components.DayMonthYearDateInputDemo.testElementIsOnPage
 


So TestNG is calling the demo page and the demo page contains the test... 
That's not right.

You need the demo page to just be a simple page providing enough 
infrastructure to exercise the component that you want to test.

The test method needs to move into:
 test.si.najdi.tapestry.library.components.DayMonthYearDateInputTest.java


So something like this:

DayMonthYearDateInputTest.java
==========================================================
package test.si.najdi.tapestry.library.components;

import org.apache.tapestry5.dom.Document;
import org.testng.Assert;
import org.testng.annotations.Test;

import 
test.si.najdi.tapestry.library.base.AbstractT5ComponentsLibraryTest;

public class DayMonthYearDateInputTest extends
AbstractT5ComponentsLibraryTest {

    @Test
    public void testElementIsOnPage() {
        Document page = 
tester.renderPage("demo/DayMonthYearDateInputDemo");
        Assert.assertNotNull(page.getElementById("h1"));
    }
}


DayMonthYearDateInputDemo.java
==========================================================
package test.si.najdi.tapestry.library.demo.components;

public class DayMonthYearDateInputDemo {
}


And you need to make TestNG run that test class (it was trying to run the 
page :-) ):

testng.xml
====================
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd";>
<suite name="Najdi.si Tapestry Components Suite" parallel="false"
thread-count="10" annotations="1.5" verbose="2">
    <parameter name="tapestry.integration-webapp" 
value="src/main/webapp"/>
    <test name="DayMonthYearDateInput">
        <classes>
            <class
name="test.si.najdi.tapestry.library.components.DayMonthYearDateInputTest"/>
        </classes>
    </test>
</suite>


Hopefully that will do the trick.. but let me know if not.


------------------------------------
Other things:

> Just prior to this error message a list of available components is also
> printed out on the console:
> ......
>     demo/DayMonthYearDateInput:
> test.si.najdi.tapestry.library.demo.components.DayMonthYearDateInputDemo
> demo/DayMonthYearDateInputDemo:
> test.si.najdi.tapestry.library.demo.components.DayMonthYearDateInputDemo
> 
> Why there are 2 demo components?

I'm guessing here but I think it because of Tapestry's clever naming 
system. The name of the page ends in "Demo" and the page is in a "demo" 
directory and Tapestry allows an abbreviated URL where the "Demo" can be 
ommitted (i.e. /demo/DayMonthYearDateInput). So my guess is that you are 
seeing Tapestry register the same page under two URLs: the long one and 
the abbreviated one.


>     private static final TapestryTester SHARED_TESTER = new
> TapestryTester("demo", DemoModule.class);
 
> I tried instantiating TapestryTester with all kind of appPackage names I
> could think off.

You actually need to be a bit careful with the appPackage name. If you 
give it a name like "app", Tapestry will look for "AppModule" in the 
modules package - now this might be OK for you, but also might build a 
complex IOC that you don't want just for unit testing. So personally, I 
prefer to use a nonsense name (like "xxxxxxx"), because the testing 
infrastructure will ignore that, and then I control exactly the set of 
modules that I want using the TapestryTester constructor. 

- Paul



---

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional 
EU corporate and regulatory disclosures.

Reply via email to